Package htsjdk.tribble.index.tabix
Class TabixIndex
- java.lang.Object
-
- htsjdk.tribble.index.tabix.TabixIndex
-
-
Field Summary
Fields Modifier and Type Field Description static int
MAGIC_NUMBER
-
Constructor Summary
Constructors Constructor Description TabixIndex(TabixFormat formatSpec, List<String> sequenceNames, BinningIndexContent[] indices)
TabixIndex(File tabixFile)
Convenient ctor that opens the file, wraps with with BGZF reader, and closes after reading index.TabixIndex(InputStream inputStream)
TabixIndex(Path tabixPath)
Convenient ctor that opens the path, wraps with with BGZF reader, and closes after reading index.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
containsChromosome(String chr)
boolean
equals(Object o)
boolean
equalsIgnoreProperties(Object o)
Returns true if this and obj are 'effectively' equivalent indices.List<Block>
getBlocks(String chr, int start, int end)
Query the index.TabixFormat
getFormatSpec()
Map<String,String>
getProperties()
No arbitrary properties in TabixList<String>
getSequenceNames()
int
hashCode()
boolean
isCurrentVersion()
void
write(LittleEndianOutputStream los)
all indexes are writable to diskvoid
write(Path tabixPath)
Writes the index with BGZF.void
writeBasedOnFeaturePath(Path featurePath)
Writes to a path with appropriate name and directory based on feature path.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface htsjdk.tribble.index.Index
write, writeBasedOnFeatureFile
-
-
-
-
Constructor Detail
-
TabixIndex
public TabixIndex(TabixFormat formatSpec, List<String> sequenceNames, BinningIndexContent[] indices)
- Parameters:
formatSpec
- Information about how to interpret the file being indexed. Unused by this class other than written to an output file.sequenceNames
- Sequences in the file being indexed, in the order they appear in the file.indices
- One for each element of sequenceNames
-
TabixIndex
public TabixIndex(InputStream inputStream) throws IOException
- Parameters:
inputStream
- This is expected to be buffered and be gzip-decompressing as appropriate. Caller should close input stream after ctor returns.- Throws:
IOException
-
TabixIndex
public TabixIndex(File tabixFile) throws IOException
Convenient ctor that opens the file, wraps with with BGZF reader, and closes after reading index.- Throws:
IOException
-
TabixIndex
public TabixIndex(Path tabixPath) throws IOException
Convenient ctor that opens the path, wraps with with BGZF reader, and closes after reading index.- Throws:
IOException
-
-
Method Detail
-
getBlocks
public List<Block> getBlocks(String chr, int start, int end)
Description copied from interface:Index
Query the index.- Specified by:
getBlocks
in interfaceIndex
- Parameters:
chr
- the chromosomestart
- the start position, one-based, inclusive.end
- the end position, one-based, inclusive.- Returns:
- List of regions of file that are candidates for the given query. TODO: This method has not yet been tested, since the primary task is index writing.
-
isCurrentVersion
public boolean isCurrentVersion()
- Specified by:
isCurrentVersion
in interfaceIndex
- Returns:
- true if the index is up to date, false otherwise
-
getSequenceNames
public List<String> getSequenceNames()
- Specified by:
getSequenceNames
in interfaceIndex
- Returns:
- a list of the sequence names we've seen during indexing, in order
-
containsChromosome
public boolean containsChromosome(String chr)
- Specified by:
containsChromosome
in interfaceIndex
- Parameters:
chr
- the chromosome (or contig) name- Returns:
- true if we have an entry; false otherwise
-
getProperties
public Map<String,String> getProperties()
No arbitrary properties in Tabix- Specified by:
getProperties
in interfaceIndex
- Returns:
- get the list of properties for this index. Returns null if no properties.
-
equalsIgnoreProperties
public boolean equalsIgnoreProperties(Object o)
Description copied from interface:Index
Returns true if this and obj are 'effectively' equivalent indices. Ignores the time stamp on the file, as this may not be the same for even identical indices- Specified by:
equalsIgnoreProperties
in interfaceIndex
- Returns:
-
getFormatSpec
public TabixFormat getFormatSpec()
-
write
public void write(Path tabixPath) throws IOException
Writes the index with BGZF.- Specified by:
write
in interfaceIndex
- Parameters:
tabixPath
- Where to write the index.- Throws:
IOException
- if the index is unable to write to the specified path.
-
writeBasedOnFeaturePath
public void writeBasedOnFeaturePath(Path featurePath) throws IOException
Writes to a path with appropriate name and directory based on feature path.- Specified by:
writeBasedOnFeaturePath
in interfaceIndex
- Parameters:
featurePath
- Path being indexed.- Throws:
IOException
- if featureFile is not a normal file.
-
write
public void write(LittleEndianOutputStream los) throws IOException
Description copied from interface:Index
all indexes are writable to disk- Specified by:
write
in interfaceIndex
- Parameters:
los
- It is assumes that caller has done appropriate buffering and BlockCompressedOutputStream wrapping. Caller should close output stream after invoking this method.- Throws:
IOException
-
-