Package htsjdk.beta.plugin.variants
Class VariantsBundle
java.lang.Object
htsjdk.beta.io.bundle.Bundle
htsjdk.beta.plugin.variants.VariantsBundle
- All Implemented Interfaces:
Serializable
,Iterable<BundleResource>
A
; and an optional index resource. A VariantsBundle can also
contain additional resources.
Note that this class is merely a convenience class for the case where the variants are backed by files on disk.
A bundle that contains variants and related resources can be created manually using the
Bundle
for variants and variants-related resources that are backed by on disk files. A VariantsBundle
has a primary resource with content type
invalid reference
BundleResourceType#PRIMARY_CT_VARIANT_CONTEXTS
Bundle
class.
This class provides convenient constructors, and validation for JSON interconversions. To create a VariantsBundle
for variants sources that are backed by streams or other BundleResource
types, the Bundle
and
BundleBuilder
classes can be used to construct such bundles directly.- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionVariantsBundle
(IOPath vcfPath) Create aVariantsBundle
containing only a variants resource.VariantsBundle
(IOPath vcfPath, IOPath indexPath) Create aVariantsBundle
containing only variants and an index.VariantsBundle
(Collection<BundleResource> resources) Create aVariantsBundle
using the resources in an existing bundle. -
Method Summary
Modifier and TypeMethodDescriptiongetIndex()
Get the optionalBundleResourceType.CT_VARIANTS_INDEX
resource for thisVariantsBundle
.static VariantsBundle
getVariantsBundleFromPath
(IOPath jsonPath) Create aVariantsBundle
from a JSON string contained in jsonPath.static <T extends IOPath>
VariantsBundlegetVariantsBundleFromPath
(IOPath jsonPath, Function<String, T> ioPathConstructor) Create aVariantsBundle
from a JSON string contained in jsonPath.static VariantsBundle
getVariantsBundleFromString
(String jsonString) Create aVariantsBundle
from a JSON string.static <T extends IOPath>
VariantsBundlegetVariantsBundleFromString
(String jsonString, Function<String, T> ioPathConstructor) Create aVariantsBundle
from a JSON string with all IOPathResources using an IOPath-derived class of typeT
.resolveIndex
(IOPath variants) Find the companion index for a variants source, and create a newVariantsBundle
containing the variants and the companion index, if one can be found.resolveIndex
(T variantsHtsPath, Function<String, T> ioPathConstructor) Attempts to find the companion index for a variants source based on commonly used file extensions, and create a newVariantsBundle
containing the variants 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
-
VariantsBundle
Create aVariantsBundle
containing only a variants resource.- Parameters:
vcfPath
- AnIOPath
-derived object that represents a source of variants.
-
VariantsBundle
Create aVariantsBundle
containing only variants and an index. -
VariantsBundle
Create aVariantsBundle
using the resources in an existing bundle. A resource with content typeBundleResourceType.CT_VARIANT_CONTEXTS
must be present in the resources, or this constructor will throw.- Parameters:
resources
- collection ofBundleResource
. the collection must include a resource with content typeBundleResourceType.CT_VARIANT_CONTEXTS
.- Throws:
IllegalArgumentException
- if no resource with content typeBundleResourceType.CT_VARIANT_CONTEXTS
is included in the inputBundleResource
collection.
-
-
Method Details
-
getVariants
- Returns:
- the
BundleResourceType.CT_VARIANT_CONTEXTS
BundleResource
for thisVariantsBundle
-
getIndex
Get the optionalBundleResourceType.CT_VARIANTS_INDEX
resource for thisVariantsBundle
.- Returns:
- the optional
BundleResourceType.CT_VARIANTS_INDEX
resource for thisVariantsBundle
, or Optional.empty() if no index resource is present in the bundle.
-
getVariantsBundleFromPath
Create aVariantsBundle
from a JSON string contained in jsonPath.- Parameters:
jsonPath
- the path to a file that contains aBundle
serialized to JSON. The bundle must contain a resource with content type VARIANT_CONTEXTS.- Returns:
- a
VariantsBundle
created from jsonPath
-
getVariantsBundleFromPath
public static <T extends IOPath> VariantsBundle getVariantsBundleFromPath(IOPath jsonPath, Function<String, T> ioPathConstructor) Create aVariantsBundle
from a JSON string contained in jsonPath.- Type Parameters:
T
- the IOPath-derived type of the IOPathResources to be used in the new bundle- Parameters:
jsonPath
- the path to a file that contains aBundle
serialized to JSON. The bundle must contain a resource with content type VARIANT_CONTEXTS.ioPathConstructor
- a function that takes a string and returns an IOPath-derived class of typeT
- Returns:
- a
VariantsBundle
created from jsonPath
-
getVariantsBundleFromString
Create aVariantsBundle
from a JSON string.- Parameters:
jsonString
- the jsonString to use to create theVariantsBundle
- Returns:
- a
VariantsBundle
-
getVariantsBundleFromString
public static <T extends IOPath> VariantsBundle getVariantsBundleFromString(String jsonString, Function<String, T> ioPathConstructor) Create aVariantsBundle
from a JSON string with all IOPathResources using an IOPath-derived class of typeT
.- Type Parameters:
T
- the IOPath-derived type of the IOPathResources to be used in the new bundle- Parameters:
jsonString
- the string to use to create theVariantsBundle
ioPathConstructor
- a function that takes a string and returns an IOPath-derived class of typeT
- Returns:
- a newly created
VariantsBundle
-
resolveIndex
Find the companion index for a variants source, and create a newVariantsBundle
containing the variants and the companion index, if one can be found.- Parameters:
variants
- the variants source to use- Returns:
- a
VariantsBundle
containing variants and companion index, if it can be found.
-
resolveIndex
public static <T extends IOPath> Optional<T> resolveIndex(T variantsHtsPath, Function<String, T> ioPathConstructor) Attempts to find the companion index for a variants source based on commonly used file extensions, and create a newVariantsBundle
containing the variants and the companion index, if one can be found. An index can only be resolved for an IOPath that represents a file 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 IOPath to be returned- Parameters:
variantsHtsPath
- the IOPath-derived object representing the variants source to useioPathConstructor
- a function that takes a string and returns an IOPath-derived class of type- Returns:
- a
IOPath
-derived object of type T containing the companion index forvariantsPath
, if it can be found
-