Package htsjdk.tribble.index
Class AbstractIndex
- java.lang.Object
-
- htsjdk.tribble.index.AbstractIndex
-
- All Implemented Interfaces:
Index,MutableIndex
- Direct Known Subclasses:
IntervalTreeIndex,LinearIndex
public abstract class AbstractIndex extends Object implements MutableIndex
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 Classes Modifier and Type Class Description protected static classAbstractIndex.BlockStatsstatic classAbstractIndex.IndexType
-
Field Summary
Fields Modifier and Type Field Description protected LinkedHashMap<String,ChrIndex>chrIndicesthe map of our chromosome binsprotected intflagsprotected StringindexedFileMD5protected longindexedFileSizeprotected longindexedFileTSprotected PathindexedPathprotected Logloggerstatic intMAGIC_NUMBERprotected intversionstatic intVERSION
-
Constructor Summary
Constructors Constructor Description AbstractIndex()create 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
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddProperties(Map<String,String> properties)voidaddProperty(String key, String value)booleancontainsChromosome(String chr)booleanequalsIgnoreProperties(Object obj)Returns true if this and obj are 'effectively' equivalent indices.voidfinalizeIndex()List<Block>getBlocks(String chr)List<Block>getBlocks(String chr, int start, int end)Query the index.protected AbstractIndex.BlockStatsgetBlockStats(boolean logDetails)abstract ClassgetChrIndexClass()returns the class for the index typeintgetFlags()FilegetIndexedFile()Deprecated.on 03/2017.StringgetIndexedFileMD5()longgetIndexedFileSize()longgetIndexedFileTS()PathgetIndexedPath()Map<String,String>getProperties()return a mapping of name to property valueList<String>getSequenceNames()protected abstract intgetType()get the index typeintgetVersion()booleanhasFileSize()booleanhasMD5()booleanhasTimestamp()booleanisCurrentVersion()check the current version against the version we read inprotected voidprintIndexInfo()voidread(LittleEndianInputStream dis)voidsetMD5(String md5)protected StringstatsSummary()protected voidvalidateIndexHeader(int indexType, LittleEndianInputStream dis)voidwrite(LittleEndianOutputStream stream)all indexes are writable to diskvoidwrite(Path idxPath)Writes the index into a path.voidwriteBasedOnFeaturePath(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 Detail
-
VERSION
public static final int VERSION
- See Also:
- Constant Field Values
-
MAGIC_NUMBER
public static final int MAGIC_NUMBER
- See Also:
- Constant Field Values
-
version
protected int version
-
indexedPath
protected Path indexedPath
-
indexedFileSize
protected long indexedFileSize
-
indexedFileTS
protected long indexedFileTS
-
indexedFileMD5
protected String indexedFileMD5
-
flags
protected int flags
-
logger
protected final Log logger
-
chrIndices
protected LinkedHashMap<String,ChrIndex> chrIndices
the map of our chromosome bins
-
-
Constructor Detail
-
AbstractIndex
public AbstractIndex()
create an abstract index, with defaults for the version value, and empty properties and chromosome lists
-
AbstractIndex
public AbstractIndex(String featureFile)
create an index file from the target feature file- Parameters:
featureFile- the feature file to create an index from
-
AbstractIndex
public AbstractIndex(File featureFile)
-
AbstractIndex
public AbstractIndex(Path featurePath)
-
AbstractIndex
public AbstractIndex(AbstractIndex parent)
-
-
Method Detail
-
hasFileSize
public boolean hasFileSize()
-
hasTimestamp
public boolean hasTimestamp()
-
hasMD5
public boolean hasMD5()
-
equalsIgnoreProperties
public boolean equalsIgnoreProperties(Object obj)
Description copied from interface:IndexReturns 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:
equalsIgnorePropertiesin interfaceIndex- Parameters:
obj-- Returns:
- true if this and obj are 'effectively' equivalent data structures.
-
validateIndexHeader
protected void validateIndexHeader(int indexType, LittleEndianInputStream dis) throws IOException- Throws:
IOException
-
isCurrentVersion
public boolean isCurrentVersion()
check the current version against the version we read in- Specified by:
isCurrentVersionin interfaceIndex- Returns:
- true if we're up to date, false otherwise
-
getIndexedFile
@Deprecated public File getIndexedFile()
Deprecated.on 03/2017. UsegetIndexedPath()instead.Gets the indexed file.- Throws:
UnsupportedOperationException- if the path cannot be represented as a file.
-
getIndexedPath
public Path getIndexedPath()
-
getIndexedFileSize
public long getIndexedFileSize()
-
getIndexedFileTS
public long getIndexedFileTS()
-
getIndexedFileMD5
public String getIndexedFileMD5()
-
getFlags
public int getFlags()
-
getVersion
public int getVersion()
-
setMD5
public void setMD5(String md5)
-
containsChromosome
public boolean containsChromosome(String chr)
- Specified by:
containsChromosomein interfaceIndex- Parameters:
chr- the chromosome (or contig) name- Returns:
- true if we have an entry; false otherwise
-
finalizeIndex
public void finalizeIndex()
-
getSequenceNames
public List<String> getSequenceNames()
- Specified by:
getSequenceNamesin interfaceIndex- Returns:
- a list of the sequence names we've seen during indexing, in order
-
getBlocks
public List<Block> getBlocks(String chr, int start, int end)
Description copied from interface:IndexQuery the index.
-
write
public void write(LittleEndianOutputStream stream) throws IOException
Description copied from interface:Indexall indexes are writable to disk- Specified by:
writein 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
public void write(Path idxPath) throws IOException
Description copied from interface:IndexWrites the index into a path.- Specified by:
writein interfaceIndex- Parameters:
idxPath- 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
Description copied from interface:IndexWrite 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:
writeBasedOnFeaturePathin interfaceIndex- Throws:
IOException- if featureFile is not a normal file.
-
read
public void read(LittleEndianInputStream dis) throws IOException
- Throws:
IOException
-
printIndexInfo
protected void printIndexInfo()
-
getBlockStats
protected AbstractIndex.BlockStats getBlockStats(boolean logDetails)
-
statsSummary
protected String statsSummary()
-
addProperty
public void addProperty(String key, String value)
- Specified by:
addPropertyin interfaceMutableIndex
-
addProperties
public void addProperties(Map<String,String> properties)
- Specified by:
addPropertiesin interfaceMutableIndex
-
getProperties
public Map<String,String> getProperties()
return a mapping of name to property value- Specified by:
getPropertiesin interfaceIndex- Returns:
- the mapping of values as an unmodifiable map
-
getType
protected abstract int getType()
get the index type- Returns:
- The index type
-
getChrIndexClass
public abstract Class getChrIndexClass()
returns the class for the index type- Returns:
- a Class, from which a new instance can be created
-
-