Class VariantsBundle

java.lang.Object
htsjdk.beta.io.bundle.Bundle
htsjdk.beta.plugin.variants.VariantsBundle
All Implemented Interfaces:
Serializable, Iterable<BundleResource>

public class VariantsBundle extends Bundle implements Serializable
A 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
; 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 Details

  • Method Details

    • getVariants

      public BundleResource getVariants()
      Returns:
      the BundleResourceType.CT_VARIANT_CONTEXTS BundleResource for this VariantsBundle
    • getIndex

      public Optional<BundleResource> getIndex()
      Get the optional BundleResourceType.CT_VARIANTS_INDEX resource for this VariantsBundle.
      Returns:
      the optional BundleResourceType.CT_VARIANTS_INDEX resource for this VariantsBundle, or Optional.empty() if no index resource is present in the bundle.
    • getVariantsBundleFromPath

      public static VariantsBundle getVariantsBundleFromPath(IOPath jsonPath)
      Create a VariantsBundle from a JSON string contained in jsonPath.
      Parameters:
      jsonPath - the path to a file that contains a Bundle 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 a VariantsBundle 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 a Bundle 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 type T
      Returns:
      a VariantsBundle created from jsonPath
    • getVariantsBundleFromString

      public static VariantsBundle getVariantsBundleFromString(String jsonString)
      Create a VariantsBundle from a JSON string.
      Parameters:
      jsonString - the jsonString to use to create the VariantsBundle
      Returns:
      a VariantsBundle
    • getVariantsBundleFromString

      public static <T extends IOPath> VariantsBundle getVariantsBundleFromString(String jsonString, Function<String,T> ioPathConstructor)
      Create a VariantsBundle from a JSON string with all IOPathResources using an IOPath-derived class of type T.
      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 the VariantsBundle
      ioPathConstructor - a function that takes a string and returns an IOPath-derived class of type T
      Returns:
      a newly created VariantsBundle
    • resolveIndex

      public static Optional<IOPath> resolveIndex(IOPath variants)
      Find the companion index for a variants source, and create a new VariantsBundle 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 new VariantsBundle 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 use
      ioPathConstructor - 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 for variantsPath, if it can be found