Class TribbleIndexedFeatureReader<T extends Feature,​SOURCE>

  • All Implemented Interfaces:
    FeatureReader<T>, Closeable, AutoCloseable

    public class TribbleIndexedFeatureReader<T extends Feature,​SOURCE>
    extends AbstractFeatureReader<T,​SOURCE>
    A reader for text feature files (i.e. not tabix files). This includes tribble-indexed and non-indexed files. If index both iterate() and query() methods are supported.

    Note: Non-indexed files can be gzipped, but not bgzipped.

    Since:
    2/11/12
    • Constructor Detail

      • TribbleIndexedFeatureReader

        public TribbleIndexedFeatureReader​(String featurePath,
                                           FeatureCodec<T,​SOURCE> codec,
                                           boolean requireIndex)
                                    throws IOException
        Parameters:
        featurePath - - path to the feature file, can be a local file path, http url, or ftp url
        codec - - codec to decode the features
        requireIndex - - true if the reader will be queries for specific ranges. An index (idx) file must exist
        Throws:
        IOException
      • TribbleIndexedFeatureReader

        public TribbleIndexedFeatureReader​(String featureFile,
                                           String indexFile,
                                           FeatureCodec<T,​SOURCE> codec,
                                           boolean requireIndex)
                                    throws IOException
        Parameters:
        featureFile - - path to the feature file, can be a local file path, http url, or ftp url
        indexFile - - path to the index file
        codec - - codec to decode the features
        requireIndex - - true if the reader will be queries for specific ranges. An index (idx) file must exist
        Throws:
        IOException
      • TribbleIndexedFeatureReader

        public TribbleIndexedFeatureReader​(String featureFile,
                                           FeatureCodec<T,​SOURCE> codec,
                                           Index index)
                                    throws IOException
        Parameters:
        featureFile - - path to the feature file, can be a local file path, http url, or ftp url
        codec - - codec to decode the features
        index - - a tribble Index object
        Throws:
        IOException
    • Method Detail

      • getSequenceNames

        public List<String> getSequenceNames()
        Return the sequence (chromosome/contig) names in this file, if known.
        Returns:
        list of strings of the contig names
      • query

        public CloseableTribbleIterator<T> query​(String chr,
                                                 int start,
                                                 int end)
                                          throws IOException
        Return an iterator to iterate over features overlapping the specified interval

        Note that TribbleIndexedFeatureReader only supports issuing and manipulating a single query for each reader. That is, the behavior of the following code is undefined:

        reader = new TribbleIndexedFeatureReader() Iterator it1 = reader.query("x", 10, 20) Iterator it2 = reader.query("x", 1000, 1010)

        As a consequence of this, the TribbleIndexedFeatureReader are also not thread-safe.

        Parameters:
        chr - contig
        start - start position
        end - end position
        Returns:
        an iterator of records in this interval
        Throws:
        IOException