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
Bundle for variants and variants-related resources that are backed by on disk files. A VariantsBundle has a primary resource with content type BundleResourceType.CT_VARIANT_CONTEXTS; 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 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 aVariantsBundlecontaining only a variants resource.VariantsBundle(IOPath vcfPath, IOPath indexPath) Create aVariantsBundlecontaining only variants and an index.VariantsBundle(Collection<BundleResource> resources) Create aVariantsBundleusing the resources in an existing bundle. -
Method Summary
Modifier and TypeMethodDescriptiongetIndex()Get the optionalBundleResourceType.CT_VARIANTS_INDEXresource for thisVariantsBundle.static VariantsBundlegetVariantsBundleFromPath(IOPath jsonPath) Create aVariantsBundlefrom a JSON string contained in jsonPath.static <T extends IOPath>
VariantsBundlegetVariantsBundleFromPath(IOPath jsonPath, Function<String, T> ioPathConstructor) Create aVariantsBundlefrom a JSON string contained in jsonPath.static VariantsBundlegetVariantsBundleFromString(String jsonString) Create aVariantsBundlefrom a JSON string.static <T extends IOPath>
VariantsBundlegetVariantsBundleFromString(String jsonString, Function<String, T> ioPathConstructor) Create aVariantsBundlefrom 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 newVariantsBundlecontaining 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 newVariantsBundlecontaining 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, 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
-
VariantsBundle
Create aVariantsBundlecontaining only a variants resource.- Parameters:
vcfPath- AnIOPath-derived object that represents a source of variants.
-
VariantsBundle
Create aVariantsBundlecontaining only variants and an index. -
VariantsBundle
Create aVariantsBundleusing the resources in an existing bundle. A resource with content typeBundleResourceType.CT_VARIANT_CONTEXTSmust 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_CONTEXTSis included in the inputBundleResourcecollection.
-
-
Method Details
-
getVariants
- Returns:
- the
BundleResourceType.CT_VARIANT_CONTEXTSBundleResourcefor thisVariantsBundle
-
getIndex
Get the optionalBundleResourceType.CT_VARIANTS_INDEXresource for thisVariantsBundle.- Returns:
- the optional
BundleResourceType.CT_VARIANTS_INDEXresource for thisVariantsBundle, or Optional.empty() if no index resource is present in the bundle.
-
getVariantsBundleFromPath
Create aVariantsBundlefrom a JSON string contained in jsonPath.- Parameters:
jsonPath- the path to a file that contains aBundleserialized to JSON. The bundle must contain a resource with content type VARIANT_CONTEXTS.- Returns:
- a
VariantsBundlecreated from jsonPath
-
getVariantsBundleFromPath
public static <T extends IOPath> VariantsBundle getVariantsBundleFromPath(IOPath jsonPath, Function<String, T> ioPathConstructor) Create aVariantsBundlefrom 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 aBundleserialized 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
VariantsBundlecreated from jsonPath
-
getVariantsBundleFromString
Create aVariantsBundlefrom 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 aVariantsBundlefrom 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 theVariantsBundleioPathConstructor- 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 newVariantsBundlecontaining the variants and the companion index, if one can be found.- Parameters:
variants- the variants source to use- Returns:
- a
VariantsBundlecontaining 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 newVariantsBundlecontaining 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
-