Class Gff3Codec

  • All Implemented Interfaces:
    FeatureCodec<Gff3Feature,​LineIterator>

    public class Gff3Codec
    extends AbstractFeatureCodec<Gff3Feature,​LineIterator>
    Codec for parsing Gff3 files, as defined in https://github.com/The-Sequence-Ontology/Specifications/blob/31f62ad469b31769b43af42e0903448db1826925/gff3.md Note that while spec states that all feature types must be defined in sequence ontology, this implementation makes no check on feature types, and allows any string as feature type Each feature line in the Gff3 file will be emitted as a separate feature. Features linked together through the "Parent" attribute will be linked through Gff3Feature.getParents(), Gff3Feature.getChildren(), Gff3Feature.getAncestors(), Gff3Feature.getDescendents(), amd Gff3Feature.flatten(). This linking is not guaranteed to be comprehensive when the file is read for only features overlapping a particular region, using a tribble index. In this case, a particular feature will only be linked to the subgroup of features it is linked to in the input file which overlap the given region.
    • Constructor Detail

      • Gff3Codec

        public Gff3Codec()
    • Method Detail

      • decode

        public Gff3Feature decode​(LineIterator lineIterator)
                           throws IOException
        Description copied from interface: FeatureCodec
        Decode a single Feature from the FeatureCodec, reading no further in the underlying source than beyond that feature.
        Parameters:
        lineIterator - the input stream from which to decode the next record
        Returns:
        Return the Feature encoded by the line, or null if the line does not represent a feature (e.g. is a comment)
        Throws:
        IOException
      • canDecode

        public boolean canDecode​(String inputFilePath)
        Description copied from interface: FeatureCodec

        This function returns true iff the File potentialInput can be parsed by this codec. Note that checking the file's extension is a perfectly acceptable implementation of this method and file contents only rarely need to be checked.

        There is an assumption that there's never a situation where two different Codecs return true for the same file. If this occurs, the recommendation would be to error out.

        Note this function must never throw an error. All errors should be trapped and false returned.
        Parameters:
        inputFilePath - the file to test for parsability with this codec
        Returns:
        true if potentialInput can be parsed, false otherwise
      • readHeader

        public FeatureCodecHeader readHeader​(LineIterator lineIterator)
        Description copied from interface: FeatureCodec
        Read and return the header, or null if there is no header. Note: Implementers of this method must be careful to read exactly as much from FeatureCodec as needed to parse the header, and no more. Otherwise, data that might otherwise be fed into parsing a Feature may be lost.
        Parameters:
        lineIterator - the source from which to decode the header
        Returns:
        header object
      • makeSourceFromStream

        public LineIterator makeSourceFromStream​(InputStream bufferedInputStream)
        Description copied from interface: FeatureCodec
        Generates a reader of type FeatureCodec appropriate for use by this codec from the generic input stream. Implementers should assume the stream is buffered.
      • isDone

        public boolean isDone​(LineIterator lineIterator)
        Description copied from interface: FeatureCodec
        Adapter method that assesses whether the provided FeatureCodec has more data. True if it does, false otherwise.