Class 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.

    • Field Detail

      • 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
    • 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)
    • Method Detail

      • hasFileSize

        public boolean hasFileSize()
      • hasTimestamp

        public boolean hasTimestamp()
      • hasMD5

        public boolean hasMD5()
      • equalsIgnoreProperties

        public boolean equalsIgnoreProperties​(Object obj)
        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 interface Index
        Parameters:
        obj -
        Returns:
        true if this and obj are 'effectively' equivalent data structures.
      • isCurrentVersion

        public boolean isCurrentVersion()
        check the current version against the version we read in
        Specified by:
        isCurrentVersion in interface Index
        Returns:
        true if we're up to date, false otherwise
      • 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:
        containsChromosome in interface Index
        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:
        getSequenceNames in interface Index
        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: Index
        Query the index.
        Specified by:
        getBlocks in interface Index
        Parameters:
        chr - the chromosome
        start - the start position
        end - the end position
        Returns:
        a list of blocks that contain the specified interval. Can never return null
      • write

        public void write​(LittleEndianOutputStream stream)
                   throws IOException
        Description copied from interface: Index
        all indexes are writable to disk
        Specified by:
        write in interface Index
        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: Index
        Writes the index into a path.
        Specified by:
        write in interface Index
        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: 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 interface Index
        Throws:
        IOException - if featureFile is not a normal file.
      • printIndexInfo

        protected void printIndexInfo()
      • statsSummary

        protected String statsSummary()
      • getProperties

        public Map<String,​String> getProperties()
        return a mapping of name to property value
        Specified by:
        getProperties in interface Index
        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