public abstract class AbstractIndex extends Object implements MutableIndex
Modifier and Type | Class and Description |
---|---|
protected static class |
AbstractIndex.BlockStats |
static class |
AbstractIndex.IndexType |
Modifier and Type | Field and Description |
---|---|
protected LinkedHashMap<String,ChrIndex> |
chrIndices
the map of our chromosome bins
|
protected int |
flags |
protected File |
indexedFile |
protected String |
indexedFileMD5 |
protected long |
indexedFileSize |
protected long |
indexedFileTS |
static int |
MAGIC_NUMBER |
protected int |
version |
static int |
VERSION |
Constructor and Description |
---|
AbstractIndex()
create an abstract index, with defaults for the version value, and empty properties and chromosome lists
|
AbstractIndex(AbstractIndex parent) |
AbstractIndex(File featureFile) |
AbstractIndex(String featureFile)
create an index file from the target feature file
|
Modifier and Type | Method and Description |
---|---|
void |
addProperties(Map<String,String> properties) |
void |
addProperty(String key,
String value) |
boolean |
containsChromosome(String chr) |
boolean |
equalsIgnoreProperties(Object obj)
Returns true if this and obj are 'effectively' equivalent indices.
|
void |
finalizeIndex() |
List<Block> |
getBlocks(String chr) |
List<Block> |
getBlocks(String chr,
int start,
int end)
Query the index.
|
protected AbstractIndex.BlockStats |
getBlockStats(boolean logDetails) |
abstract Class |
getChrIndexClass()
returns the class for the index type
|
int |
getFlags() |
File |
getIndexedFile() |
String |
getIndexedFileMD5() |
long |
getIndexedFileSize() |
long |
getIndexedFileTS() |
Map<String,String> |
getProperties()
return a mapping of name to property value
|
List<String> |
getSequenceNames() |
protected abstract int |
getType()
get the index type
|
int |
getVersion() |
boolean |
hasFileSize() |
boolean |
hasMD5() |
boolean |
hasTimestamp() |
boolean |
isCurrentVersion()
check the current version against the version we read in
|
protected void |
printIndexInfo() |
void |
read(LittleEndianInputStream dis) |
void |
setMD5(String md5) |
protected String |
statsSummary() |
protected void |
validateIndexHeader(int indexType,
LittleEndianInputStream dis) |
void |
write(File idxFile)
Writes the index into a file.
|
void |
write(LittleEndianOutputStream stream)
all indexes are writable to disk
|
void |
writeBasedOnFeatureFile(File featureFile)
Write an appropriately named and located Index file based on the name and location of the featureFile.
|
public static final int VERSION
public static final int MAGIC_NUMBER
protected int version
protected File indexedFile
protected long indexedFileSize
protected long indexedFileTS
protected String indexedFileMD5
protected int flags
protected LinkedHashMap<String,ChrIndex> chrIndices
public AbstractIndex()
public AbstractIndex(String featureFile)
featureFile
- the feature file to create an index frompublic AbstractIndex(File featureFile)
public AbstractIndex(AbstractIndex parent)
public boolean hasFileSize()
public boolean hasTimestamp()
public boolean hasMD5()
public boolean equalsIgnoreProperties(Object obj)
Index
equalsIgnoreProperties
in interface Index
obj
- protected void validateIndexHeader(int indexType, LittleEndianInputStream dis) throws IOException
IOException
public boolean isCurrentVersion()
isCurrentVersion
in interface Index
public File getIndexedFile()
public long getIndexedFileSize()
public long getIndexedFileTS()
public String getIndexedFileMD5()
public int getFlags()
public int getVersion()
public void setMD5(String md5)
public boolean containsChromosome(String chr)
containsChromosome
in interface Index
chr
- the chromosome (or contig) namepublic void finalizeIndex()
public List<String> getSequenceNames()
getSequenceNames
in interface Index
public List<Block> getBlocks(String chr, int start, int end)
Index
public void write(LittleEndianOutputStream stream) throws IOException
Index
write
in interface Index
stream
- the stream to write the index to. Caller must close after invocation.IOException
- if the index is unable to write to the specified locationpublic void write(File idxFile) throws IOException
Index
write
in interface Index
idxFile
- Where to write the index.IOException
- if the index is unable to write to the specified filepublic void writeBasedOnFeatureFile(File featureFile) throws IOException
Index
writeBasedOnFeatureFile
in interface Index
IOException
public void read(LittleEndianInputStream dis) throws IOException
IOException
protected void printIndexInfo()
protected AbstractIndex.BlockStats getBlockStats(boolean logDetails)
protected String statsSummary()
public void addProperty(String key, String value)
addProperty
in interface MutableIndex
public void addProperties(Map<String,String> properties)
addProperties
in interface MutableIndex
public Map<String,String> getProperties()
getProperties
in interface Index
protected abstract int getType()
public abstract Class getChrIndexClass()