Package htsjdk.tribble.index
Class AbstractIndex
java.lang.Object
htsjdk.tribble.index.AbstractIndex
- All Implemented Interfaces:
Index
,MutableIndex
- Direct Known Subclasses:
IntervalTreeIndex
,LinearIndex
An abstract implementation of the index class. This class takes care of the basics that are common
to all of the current indexing classes; including the version information, common header properties,
and reading and writing the header to disk.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static class
static enum
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptioncreate an abstract index, with defaults for the version value, and empty properties and chromosome listsAbstractIndex
(AbstractIndex parent) AbstractIndex
(File featureFile) AbstractIndex
(String featureFile) create an index file from the target feature fileAbstractIndex
(Path featurePath) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addProperties
(Map<String, String> properties) void
addProperty
(String key, String value) boolean
containsChromosome
(String chr) boolean
Returns true if this and obj are 'effectively' equivalent indices.void
Query the index.protected AbstractIndex.BlockStats
getBlockStats
(boolean logDetails) abstract Class
returns the class for the index typeint
getFlags()
Deprecated.on 03/2017.long
long
return a mapping of name to property valueprotected abstract int
getType()
get the index typeint
boolean
boolean
hasMD5()
boolean
boolean
check the current version against the version we read inprotected void
void
void
protected String
protected void
validateIndexHeader
(int indexType, LittleEndianInputStream dis) void
write
(LittleEndianOutputStream stream) all indexes are writable to diskvoid
Writes the index into a path.void
writeBasedOnFeaturePath
(Path featurePath) Write an appropriately named and located Index file based on the name and location of the featureFile.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface htsjdk.tribble.index.Index
write, writeBasedOnFeatureFile
-
Field Details
-
VERSION
public static final int VERSION- See Also:
-
MAGIC_NUMBER
public static final int MAGIC_NUMBER- See Also:
-
version
protected int version -
indexedPath
-
indexedFileSize
protected long indexedFileSize -
indexedFileTS
protected long indexedFileTS -
indexedFileMD5
-
flags
protected int flags -
logger
-
chrIndices
the map of our chromosome bins
-
-
Constructor Details
-
AbstractIndex
public AbstractIndex()create an abstract index, with defaults for the version value, and empty properties and chromosome lists -
AbstractIndex
create an index file from the target feature file- Parameters:
featureFile
- the feature file to create an index from
-
AbstractIndex
-
AbstractIndex
-
AbstractIndex
-
-
Method Details
-
hasFileSize
public boolean hasFileSize() -
hasTimestamp
public boolean hasTimestamp() -
hasMD5
public boolean hasMD5() -
equalsIgnoreProperties
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
- Parameters:
obj
-- Returns:
- true if this and obj are 'effectively' equivalent data structures.
-
validateIndexHeader
- Throws:
IOException
-
isCurrentVersion
public boolean isCurrentVersion()check the current version against the version we read in- Specified by:
isCurrentVersion
in interfaceIndex
- Returns:
- true if we're up to date, false otherwise
-
getIndexedFile
Deprecated.on 03/2017. UsegetIndexedPath()
instead.Gets the indexed file.- Throws:
UnsupportedOperationException
- if the path cannot be represented as a file.
-
getIndexedPath
-
getIndexedFileSize
public long getIndexedFileSize() -
getIndexedFileTS
public long getIndexedFileTS() -
getIndexedFileMD5
-
getFlags
public int getFlags() -
getVersion
public int getVersion() -
setMD5
-
containsChromosome
- Specified by:
containsChromosome
in interfaceIndex
- Parameters:
chr
- the chromosome (or contig) name- Returns:
- true if we have an entry; false otherwise
-
finalizeIndex
public void finalizeIndex() -
getSequenceNames
- Specified by:
getSequenceNames
in interfaceIndex
- Returns:
- a list of the sequence names we've seen during indexing, in order
-
getBlocks
Description copied from interface:Index
Query the index. -
getBlocks
-
write
Description copied from interface:Index
all indexes are writable to disk- Specified by:
write
in interfaceIndex
- Parameters:
stream
- the stream to write the index to. Caller must close after invocation.- Throws:
IOException
- if the index is unable to write to the specified location
-
write
Description copied from interface:Index
Writes the index into a path.- Specified by:
write
in interfaceIndex
- Parameters:
idxPath
- Where to write the index.- Throws:
IOException
- if the index is unable to write to the specified path.
-
writeBasedOnFeaturePath
Description copied from interface:Index
Write an appropriately named and located Index file based on the name and location of the featureFile. If featureFile is not a normal file, the index will silently not be written.- Specified by:
writeBasedOnFeaturePath
in interfaceIndex
- Parameters:
featurePath
-- Throws:
IOException
- if featureFile is not a normal file.
-
read
- Throws:
IOException
-
printIndexInfo
protected void printIndexInfo() -
getBlockStats
-
statsSummary
-
addProperty
- Specified by:
addProperty
in interfaceMutableIndex
-
addProperties
- Specified by:
addProperties
in interfaceMutableIndex
-
getProperties
return a mapping of name to property value- Specified by:
getProperties
in interfaceIndex
- Returns:
- the mapping of values as an unmodifiable map
-
getType
protected abstract int getType()get the index type- Returns:
- The index type
-
getChrIndexClass
returns the class for the index type- Returns:
- a Class, from which a new instance can be created
-