Class IndexFactory

java.lang.Object
htsjdk.tribble.index.IndexFactory

public class IndexFactory extends Object
Factory class for creating indexes. It is the responsibility of this class to determine and create the correct index type from the input file or stream. LinearIndex, IntervalTreeIndex, and TabixIndex are supported by this factory.
  • Constructor Details

    • IndexFactory

      public IndexFactory()
  • Method Details

    • loadIndex

      public static Index loadIndex(String indexFile)
      Load in index from the specified file. The type of index (LinearIndex or IntervalTreeIndex) is determined at run time by reading the type flag in the file.
      Parameters:
      indexFile - from which to load the index
    • loadIndex

      public static Index loadIndex(String indexFile, Function<SeekableByteChannel,SeekableByteChannel> indexWrapper)
      Load in index from the specified file. The type of index (LinearIndex or IntervalTreeIndex) is determined at run time by reading the type flag in the file.
      Parameters:
      indexFile - from which to load the index
      indexWrapper - a wrapper to apply to the raw byte stream of the index file, only applied to uri's loaded as Path
    • loadIndex

      public static Index loadIndex(String source, InputStream inputStream)
      Load in index from the specified stream. Note that the caller is responsible for decompressing the stream if necessary.
      Parameters:
      source - the stream source (typically the file name)
      inputStream - the raw byte stream of the index
    • createLinearIndex

      public static <FEATURE_TYPE extends Feature, SOURCE_TYPE> LinearIndex createLinearIndex(File inputFile, FeatureCodec<FEATURE_TYPE,SOURCE_TYPE> codec)
      a helper method for creating a linear binned index with default bin size
      Parameters:
      inputFile - the input file to load features from
      codec - the codec to use for decoding records
    • createLinearIndex

      public static <FEATURE_TYPE extends Feature, SOURCE_TYPE> LinearIndex createLinearIndex(Path inputPath, FeatureCodec<FEATURE_TYPE,SOURCE_TYPE> codec)
      a helper method for creating a linear binned index with default bin size
      Parameters:
      inputPath - the input file to load features from
      codec - the codec to use for decoding records
    • createLinearIndex

      public static <FEATURE_TYPE extends Feature, SOURCE_TYPE> LinearIndex createLinearIndex(File inputFile, FeatureCodec<FEATURE_TYPE,SOURCE_TYPE> codec, int binSize)
      a helper method for creating a linear binned index
      Parameters:
      inputFile - the input file to load features from
      codec - the codec to use for decoding records
      binSize - the bin size
    • createLinearIndex

      public static <FEATURE_TYPE extends Feature, SOURCE_TYPE> LinearIndex createLinearIndex(Path inputPath, FeatureCodec<FEATURE_TYPE,SOURCE_TYPE> codec, int binSize)
      a helper method for creating a linear binned index
      Parameters:
      inputPath - the input path to load features from
      codec - the codec to use for decoding records
      binSize - the bin size
    • createIntervalIndex

      public static <FEATURE_TYPE extends Feature, SOURCE_TYPE> IntervalTreeIndex createIntervalIndex(File inputFile, FeatureCodec<FEATURE_TYPE,SOURCE_TYPE> codec)
      create an interval-tree index with the default features per bin count
      Parameters:
      inputFile - the file containing the features
      codec - to decode the features
    • createIntervalIndex

      public static <FEATURE_TYPE extends Feature, SOURCE_TYPE> IntervalTreeIndex createIntervalIndex(Path inputPath, FeatureCodec<FEATURE_TYPE,SOURCE_TYPE> codec)
      create an interval-tree index with the default features per bin count
      Parameters:
      inputPath - the file containing the features
      codec - to decode the features
    • createIntervalIndex

      public static <FEATURE_TYPE extends Feature, SOURCE_TYPE> IntervalTreeIndex createIntervalIndex(File inputFile, FeatureCodec<FEATURE_TYPE,SOURCE_TYPE> codec, int featuresPerInterval)
      a helper method for creating an interval-tree index
      Parameters:
      inputFile - the input file to load features from
      codec - the codec to use for decoding records
      featuresPerInterval -
    • createIntervalIndex

      public static <FEATURE_TYPE extends Feature, SOURCE_TYPE> IntervalTreeIndex createIntervalIndex(Path inputPath, FeatureCodec<FEATURE_TYPE,SOURCE_TYPE> codec, int featuresPerInterval)
      a helper method for creating an interval-tree index
      Parameters:
      inputPath - the input path to load features from
      codec - the codec to use for decoding records
      featuresPerInterval -
    • createDynamicIndex

      public static <FEATURE_TYPE extends Feature, SOURCE_TYPE> Index createDynamicIndex(File inputFile, FeatureCodec<FEATURE_TYPE,SOURCE_TYPE> codec)
      Create a dynamic index with the default balancing approach
      Parameters:
      inputFile - the input file to load features from
      codec - the codec to use for decoding records
    • createDynamicIndex

      public static <FEATURE_TYPE extends Feature, SOURCE_TYPE> Index createDynamicIndex(Path inputPath, FeatureCodec<FEATURE_TYPE,SOURCE_TYPE> codec)
      Create a dynamic index with the default balancing approach
      Parameters:
      inputPath - the input path to load features from
      codec - the codec to use for decoding records
    • createIndex

      public static <FEATURE_TYPE extends Feature, SOURCE_TYPE> Index createIndex(File inputFile, FeatureCodec<FEATURE_TYPE,SOURCE_TYPE> codec, IndexFactory.IndexType type)
      Create a index of the specified type with default binning parameters
      Parameters:
      inputFile - the input file to load features from
      codec - the codec to use for decoding records
      type - the type of index to create
    • createIndex

      public static <FEATURE_TYPE extends Feature, SOURCE_TYPE> Index createIndex(Path inputhPath, FeatureCodec<FEATURE_TYPE,SOURCE_TYPE> codec, IndexFactory.IndexType type)
      Create a index of the specified type with default binning parameters
      Parameters:
      inputhPath - the input file to load features from
      codec - the codec to use for decoding records
      type - the type of index to create
    • createIndex

      public static <FEATURE_TYPE extends Feature, SOURCE_TYPE> Index createIndex(File inputFile, FeatureCodec<FEATURE_TYPE,SOURCE_TYPE> codec, IndexFactory.IndexType type, SAMSequenceDictionary sequenceDictionary)
      Create an index of the specified type with default binning parameters
      Parameters:
      inputFile - the input File to load features from
      codec - the codec to use for decoding records
      type - the type of index to create
      sequenceDictionary - May be null, but if present may reduce memory footprint for tabix index creation
    • createIndex

      public static <FEATURE_TYPE extends Feature, SOURCE_TYPE> Index createIndex(Path inputPath, FeatureCodec<FEATURE_TYPE,SOURCE_TYPE> codec, IndexFactory.IndexType type, SAMSequenceDictionary sequenceDictionary)
      Create an index of the specified type with default binning parameters
      Parameters:
      inputPath - the input path to load features from
      codec - the codec to use for decoding records
      type - the type of index to create
      sequenceDictionary - May be null, but if present may reduce memory footprint for tabix index creation
    • writeIndex

      @Deprecated public static void writeIndex(Index idx, File idxFile) throws IOException
      Deprecated.
      use Index.write(File) instead
      Write the index to a file; little endian.
      Parameters:
      idx -
      idxFile -
      Throws:
      IOException
    • createDynamicIndex

      public static <FEATURE_TYPE extends Feature, SOURCE_TYPE> Index createDynamicIndex(File inputFile, FeatureCodec<FEATURE_TYPE,SOURCE_TYPE> codec, IndexFactory.IndexBalanceApproach iba)
      create a dynamic index, given an input file, codec, and balance approach
      Parameters:
      inputFile - the input file to load features from
      codec - the codec to use for decoding records
      iba - the index balancing approach
    • createDynamicIndex

      public static <FEATURE_TYPE extends Feature, SOURCE_TYPE> Index createDynamicIndex(Path inputPath, FeatureCodec<FEATURE_TYPE,SOURCE_TYPE> codec, IndexFactory.IndexBalanceApproach iba)
      create a dynamic index, given an input path, codec, and balance approach
      Parameters:
      inputPath - the input path to load features from
      codec - the codec to use for decoding records
      iba - the index balancing approach
    • createTabixIndex

      public static <FEATURE_TYPE extends Feature, SOURCE_TYPE> TabixIndex createTabixIndex(File inputFile, FeatureCodec<FEATURE_TYPE,SOURCE_TYPE> codec, TabixFormat tabixFormat, SAMSequenceDictionary sequenceDictionary)
      Parameters:
      inputFile - The file to be indexed.
      codec - Mechanism for reading inputFile.
      tabixFormat - Header fields for TabixIndex to be produced.
      sequenceDictionary - May be null, but if present may reduce memory footprint for index creation. Features in inputFile must be in the order defined by sequenceDictionary, if it is present.
    • createTabixIndex

      public static <FEATURE_TYPE extends Feature, SOURCE_TYPE> TabixIndex createTabixIndex(Path inputPath, FeatureCodec<FEATURE_TYPE,SOURCE_TYPE> codec, TabixFormat tabixFormat, SAMSequenceDictionary sequenceDictionary)
      Parameters:
      inputPath - The path to be indexed.
      codec - Mechanism for reading inputFile.
      tabixFormat - Header fields for TabixIndex to be produced.
      sequenceDictionary - May be null, but if present may reduce memory footprint for index creation. Features in inputFile must be in the order defined by sequenceDictionary, if it is present.
    • createTabixIndex

      public static <FEATURE_TYPE extends Feature, SOURCE_TYPE> TabixIndex createTabixIndex(File inputFile, FeatureCodec<FEATURE_TYPE,SOURCE_TYPE> codec, SAMSequenceDictionary sequenceDictionary)
      Parameters:
      inputFile - The file to be indexed.
      codec - the codec to use for decoding records
      sequenceDictionary - May be null, but if present may reduce memory footprint for index creation. Features in inputFile must be in the order defined by sequenceDictionary, if it is present.
    • createTabixIndex

      public static <FEATURE_TYPE extends Feature, SOURCE_TYPE> TabixIndex createTabixIndex(Path inputPath, FeatureCodec<FEATURE_TYPE,SOURCE_TYPE> codec, SAMSequenceDictionary sequenceDictionary)
      Parameters:
      inputPath - The path to be indexed.
      codec - the codec to use for decoding records
      sequenceDictionary - May be null, but if present may reduce memory footprint for index creation. Features in inputFile must be in the order defined by sequenceDictionary, if it is present.