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 aReadsBundle
new IOPathResources for aReadsBundle
. Note that resources that are put into aReadsBundle
using the {ReadsBundle(Collection)
} constructor may have tIOPathResources that do not conform to this type.
- All Implemented Interfaces:
Serializable
,Iterable<BundleResource>
A class for creating a
Bundle
for reads and reads-related resources. A ReadsBundle
has a
primary resource with content type BundleResourceType.CT_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 IOPathResource
s. 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
ConstructorsModifierConstructorDescriptionprotected
ReadsBundle
(Collection<BundleResource> resources) Create aReadsBundle
using the resources in an existing bundle.ReadsBundle
(T reads) Create aReadsBundle
containing only a reads resource.ReadsBundle
(T reads, T index) Create aReadsBundle
containing only reads and an index. -
Method Summary
Modifier and TypeMethodDescriptiongetIndex()
Get the optionalBundleResourceType.CT_READS_INDEX
resource for thisReadsBundle
.getReads()
static ReadsBundle
<IOPath> getReadsBundleFromPath
(IOPath jsonPath) Create aReadsBundle
from a JSON string contained in jsonPath.static ReadsBundle
<IOPath> getReadsBundleFromString
(String jsonString) Create aReadsBundle
from a JSON string.static <T extends IOPath>
ReadsBundle<T> getReadsBundleFromString
(String jsonString, Function<String, T> ioPathConstructor) Create aReadsBundle
from a JSON string with all IOPathResources using an IOPath-derived class of typeT
.static ReadsBundle
<IOPath> resolveIndex
(IOPath reads) Find the companion index for a reads source, and create a newReadsBundle
containing 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 newReadsBundle
containing the reads and the companion index, if one can be found.Methods inherited from class htsjdk.beta.io.bundle.Bundle
equals, equalsIgnoreOrder, get, getOrThrow, getPrimaryContentType, getPrimaryResource, getResources, hashCode, iterator, toString
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
ReadsBundle
Create aReadsBundle
containing only a reads resource.- Parameters:
reads
- AnIOPath
-derived object that represents a source of reads.
-
ReadsBundle
Create aReadsBundle
containing only reads and an index.- Parameters:
reads
- AnIOPath
-derived object that represents a source of reads.
-
ReadsBundle
Create aReadsBundle
using the resources in an existing bundle. A resource with content typeBundleResourceType.CT_ALIGNED_READS
must be present in the resources, or this constructor will throw. Note that this constructor allows existingIOPathResource
s that do not conform to the typeReadsBundle
to be included in the resultingReadsBundle
.- Parameters:
resources
- collection ofBundleResource
. the collection must include a resource with content typeBundleResourceType.CT_ALIGNED_READS
.- Throws:
IllegalArgumentException
- if no resource with content typeBundleResourceType.CT_ALIGNED_READS
is included in the inputBundleResource
collection
-
-
Method Details
-
getReads
- Returns:
- the
BundleResourceType.CT_ALIGNED_READS
BundleResource
for thisReadsBundle
-
getIndex
Get the optionalBundleResourceType.CT_READS_INDEX
resource for thisReadsBundle
.- Returns:
- the optional
BundleResourceType.CT_READS_INDEX
resrouce for thisReadsBundle
, or Optional.empty if no index resource is present in the bundle.
-
getReadsBundleFromPath
Create aReadsBundle
from a JSON string contained in jsonPath.- Parameters:
jsonPath
- the path to a file that containsBundle
serialized to JSON. The bundle must contain a resource with content type READS.- Returns:
- a
ReadsBundle
created from jsonPath
-
getReadsBundleFromString
Create aReadsBundle
from 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 aReadsBundle
from 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 theReadsBundle
ioPathConstructor
- 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 newReadsBundle
containing the reads and the companion index, if one can be found.- Parameters:
reads
- the reads source to use- Returns:
- a
ReadsBundle
containing 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 newReadsBundle
containing 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
ReadsBundle
containing reads and companion index, if it can be found
-