Package htsjdk.beta.plugin.reads
Class ReadsBundle<T extends IOPath>
java.lang.Object
htsjdk.beta.io.bundle.Bundle
htsjdk.beta.plugin.reads.ReadsBundle<T>
- Type Parameters:
T- The type to use when creating aReadsBundlenew IOPathResources for aReadsBundle. Note that resources that are put into aReadsBundleusing the {ReadsBundle(Collection)} constructor may have tIOPathResources that do not conform to this type.
- All Implemented Interfaces:
Serializable,Iterable<BundleResource>
A
Bundle specifically for reads and reads-related resources. A ReadsBundle has a
primary resource with content type BundleResourceType.ALIGNED_READS; and an optional index
resource. ReadsBundles can also contain other resources.
ReadsBundle is primarily a convenience layer for the common case where a Bundle
contains reads and related resources backed by IOPathResources. It provides convenient
constructors, and validation for JSON interconversions. For reads sources that are backed by streams or
other BundleResource types, the Bundle and BundleBuilder classes can be used
directly.- See Also:
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedReadsBundle(Collection<BundleResource> resources) Create aReadsBundleusing the resources in an existing bundle.ReadsBundle(T reads) Create aReadsBundlecontaining only a reads resource.ReadsBundle(T reads, T index) Create aReadsBundlecontaining only reads and an index. -
Method Summary
Modifier and TypeMethodDescriptiongetIndex()Get the optionalBundleResourceType.READS_INDEXresource for thisReadsBundle.getReads()static ReadsBundle<IOPath>getReadsBundleFromPath(IOPath jsonPath) Create aReadsBundlefrom a JSON string contained in jsonPath.static ReadsBundle<IOPath>getReadsBundleFromString(String jsonString) Create aReadsBundlefrom a JSON string.static <T extends IOPath>
ReadsBundle<T>getReadsBundleFromString(String jsonString, Function<String, T> ioPathConstructor) Create aReadsBundlefrom a JSON string with all IOPathResources using an IOPath-derived class of typeT.static booleanlooksLikeAReadsBundle(IOPath rawReadPath) static ReadsBundle<IOPath>resolveIndex(IOPath reads) Find the companion index for a reads source, and create a newReadsBundlecontaining the reads and the companion index, if one can be found.static <T extends IOPath>
ReadsBundle<T>resolveIndex(T reads, Function<String, T> ioPathConstructor) Find the companion index for a reads source, and create a newReadsBundlecontaining the reads and the companion index, if one can be found.Methods inherited from class htsjdk.beta.io.bundle.Bundle
equals, get, getOrThrow, getPrimaryContentType, getPrimaryResource, getResources, hashCode, iterator, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
ReadsBundle
Create aReadsBundlecontaining only a reads resource.- Parameters:
reads- AnIOPath-derived object that represents a source of reads.
-
ReadsBundle
Create aReadsBundlecontaining only reads and an index.- Parameters:
reads- AnIOPath-derived object that represents a source of reads.
-
ReadsBundle
Create aReadsBundleusing the resources in an existing bundle. A resource with content typeBundleResourceType.ALIGNED_READSmust be present in the resources, or this constructor will throw. Note that this constructor allows existingIOPathResources that do not conform to the typeReadsBundleto be included in the resultingReadsBundle.- Parameters:
resources- collection ofBundleResource. the collection must include a resource with content typeBundleResourceType.ALIGNED_READS.- Throws:
IllegalArgumentException- if no resource with content typeBundleResourceType.ALIGNED_READSis included in the inputBundleResourcecollection
-
-
Method Details
-
getReads
- Returns:
- the
BundleResourceType.ALIGNED_READSBundleResourcefor thisReadsBundle
-
getIndex
Get the optionalBundleResourceType.READS_INDEXresource for thisReadsBundle.- Returns:
- the optional
BundleResourceType.READS_INDEXresrouce for thisReadsBundle, or Optional.empty if no index resource is present in the bundle.
-
getReadsBundleFromPath
Create aReadsBundlefrom a JSON string contained in jsonPath.- Parameters:
jsonPath- the path to a file that containsBundleserialized to JSON. The bundle must contain a resource with content type READS.- Returns:
- a
ReadsBundlecreated from jsonPath
-
getReadsBundleFromString
Create aReadsBundlefrom a JSON string.- Parameters:
jsonString- the jsonString to use to create theReadsBundle- Returns:
- a
ReadsBundle
-
getReadsBundleFromString
public static <T extends IOPath> ReadsBundle<T> getReadsBundleFromString(String jsonString, Function<String, T> ioPathConstructor) Create aReadsBundlefrom a JSON string with all IOPathResources using an IOPath-derived class of typeT.- Type Parameters:
T- the type of- Parameters:
jsonString- the string to use to create theReadsBundleioPathConstructor- a function that takes a string and returns an IOPath-derived class of typeT- Returns:
- a newly created
ReadsBundle
-
resolveIndex
Find the companion index for a reads source, and create a newReadsBundlecontaining the reads and the companion index, if one can be found.- Parameters:
reads- the reads source to use- Returns:
- a
ReadsBundlecontaining reads and companion index, if it can be found
-
resolveIndex
public static <T extends IOPath> ReadsBundle<T> resolveIndex(T reads, Function<String, T> ioPathConstructor) Find the companion index for a reads source, and create a newReadsBundlecontaining the reads and the companion index, if one can be found. An index can only be resolved for an IOPath that represents on a file system for which an NIO provider is installed. Remote paths that use a protocol scheme for which no NIO file system is available will (silently) not be resolved.- Type Parameters:
T- the IOPath-derived type of the IOPathResources in the new bundle- Parameters:
reads- the reads source to useioPathConstructor- a function that takes a string and returns an IOPath-derived class of type- Returns:
- a
ReadsBundlecontaining reads and companion index, if it can be found
-
looksLikeAReadsBundle
-