Package htsjdk.tribble.index
Class IndexFactory
java.lang.Object
htsjdk.tribble.index.IndexFactory
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.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
We can optimize index-file-creation for different factors.static enum
an enum that contains all of the information about the index types, and how to create them -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptioncreateDynamicIndex
(File inputFile, FeatureCodec<FEATURE_TYPE, SOURCE_TYPE> codec) Create a dynamic index with the default balancing approachcreateDynamicIndex
(File inputFile, FeatureCodec<FEATURE_TYPE, SOURCE_TYPE> codec, IndexFactory.IndexBalanceApproach iba) create a dynamic index, given an input file, codec, and balance approachcreateDynamicIndex
(Path inputPath, FeatureCodec<FEATURE_TYPE, SOURCE_TYPE> codec) Create a dynamic index with the default balancing approachcreateDynamicIndex
(Path inputPath, FeatureCodec<FEATURE_TYPE, SOURCE_TYPE> codec, IndexFactory.IndexBalanceApproach iba) create a dynamic index, given an input path, codec, and balance approachcreateIndex
(File inputFile, FeatureCodec<FEATURE_TYPE, SOURCE_TYPE> codec, IndexFactory.IndexType type) Create a index of the specified type with default binning parameterscreateIndex
(File inputFile, FeatureCodec<FEATURE_TYPE, SOURCE_TYPE> codec, IndexFactory.IndexType type, SAMSequenceDictionary sequenceDictionary) Create an index of the specified type with default binning parameterscreateIndex
(Path inputhPath, FeatureCodec<FEATURE_TYPE, SOURCE_TYPE> codec, IndexFactory.IndexType type) Create a index of the specified type with default binning parameterscreateIndex
(Path inputPath, FeatureCodec<FEATURE_TYPE, SOURCE_TYPE> codec, IndexFactory.IndexType type, SAMSequenceDictionary sequenceDictionary) Create an index of the specified type with default binning parametersstatic <FEATURE_TYPE extends Feature,
SOURCE_TYPE>
IntervalTreeIndexcreateIntervalIndex
(File inputFile, FeatureCodec<FEATURE_TYPE, SOURCE_TYPE> codec) create an interval-tree index with the default features per bin countstatic <FEATURE_TYPE extends Feature,
SOURCE_TYPE>
IntervalTreeIndexcreateIntervalIndex
(File inputFile, FeatureCodec<FEATURE_TYPE, SOURCE_TYPE> codec, int featuresPerInterval) a helper method for creating an interval-tree indexstatic <FEATURE_TYPE extends Feature,
SOURCE_TYPE>
IntervalTreeIndexcreateIntervalIndex
(Path inputPath, FeatureCodec<FEATURE_TYPE, SOURCE_TYPE> codec) create an interval-tree index with the default features per bin countstatic <FEATURE_TYPE extends Feature,
SOURCE_TYPE>
IntervalTreeIndexcreateIntervalIndex
(Path inputPath, FeatureCodec<FEATURE_TYPE, SOURCE_TYPE> codec, int featuresPerInterval) a helper method for creating an interval-tree indexstatic <FEATURE_TYPE extends Feature,
SOURCE_TYPE>
LinearIndexcreateLinearIndex
(File inputFile, FeatureCodec<FEATURE_TYPE, SOURCE_TYPE> codec) a helper method for creating a linear binned index with default bin sizestatic <FEATURE_TYPE extends Feature,
SOURCE_TYPE>
LinearIndexcreateLinearIndex
(File inputFile, FeatureCodec<FEATURE_TYPE, SOURCE_TYPE> codec, int binSize) a helper method for creating a linear binned indexstatic <FEATURE_TYPE extends Feature,
SOURCE_TYPE>
LinearIndexcreateLinearIndex
(Path inputPath, FeatureCodec<FEATURE_TYPE, SOURCE_TYPE> codec) a helper method for creating a linear binned index with default bin sizestatic <FEATURE_TYPE extends Feature,
SOURCE_TYPE>
LinearIndexcreateLinearIndex
(Path inputPath, FeatureCodec<FEATURE_TYPE, SOURCE_TYPE> codec, int binSize) a helper method for creating a linear binned indexstatic <FEATURE_TYPE extends Feature,
SOURCE_TYPE>
TabixIndexcreateTabixIndex
(File inputFile, FeatureCodec<FEATURE_TYPE, SOURCE_TYPE> codec, SAMSequenceDictionary sequenceDictionary) static <FEATURE_TYPE extends Feature,
SOURCE_TYPE>
TabixIndexcreateTabixIndex
(File inputFile, FeatureCodec<FEATURE_TYPE, SOURCE_TYPE> codec, TabixFormat tabixFormat, SAMSequenceDictionary sequenceDictionary) static <FEATURE_TYPE extends Feature,
SOURCE_TYPE>
TabixIndexcreateTabixIndex
(Path inputPath, FeatureCodec<FEATURE_TYPE, SOURCE_TYPE> codec, SAMSequenceDictionary sequenceDictionary) static <FEATURE_TYPE extends Feature,
SOURCE_TYPE>
TabixIndexcreateTabixIndex
(Path inputPath, FeatureCodec<FEATURE_TYPE, SOURCE_TYPE> codec, TabixFormat tabixFormat, SAMSequenceDictionary sequenceDictionary) static Index
Load in index from the specified file.static Index
loadIndex
(String source, InputStream inputStream) Load in index from the specified stream.static Index
loadIndex
(String indexFile, Function<SeekableByteChannel, SeekableByteChannel> indexWrapper) Load in index from the specified file.static void
writeIndex
(Index idx, File idxFile) Deprecated.
-
Constructor Details
-
IndexFactory
public IndexFactory()
-
-
Method Details
-
loadIndex
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 indexindexWrapper
- a wrapper to apply to the raw byte stream of the index file, only applied to uri's loaded asPath
-
loadIndex
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 fromcodec
- 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 fromcodec
- 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 fromcodec
- the codec to use for decoding recordsbinSize
- 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 fromcodec
- the codec to use for decoding recordsbinSize
- 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 featurescodec
- 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 featurescodec
- 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 fromcodec
- the codec to use for decoding recordsfeaturesPerInterval
-
-
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 fromcodec
- the codec to use for decoding recordsfeaturesPerInterval
-
-
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 fromcodec
- 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 fromcodec
- 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 fromcodec
- the codec to use for decoding recordstype
- 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 fromcodec
- the codec to use for decoding recordstype
- 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 fromcodec
- the codec to use for decoding recordstype
- the type of index to createsequenceDictionary
- 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 fromcodec
- the codec to use for decoding recordstype
- the type of index to createsequenceDictionary
- May be null, but if present may reduce memory footprint for tabix index creation
-
writeIndex
Deprecated.useIndex.write(File)
insteadWrite 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 fromcodec
- the codec to use for decoding recordsiba
- 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 fromcodec
- the codec to use for decoding recordsiba
- 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 recordssequenceDictionary
- 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 recordssequenceDictionary
- 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.
-
Index.write(File)
instead