Class GFFTools


  • public class GFFTools
    extends java.lang.Object
    Since:
    1.2
    Author:
    Mark Schreiber, Matthew Pocock
    • Field Detail

      • NO_SCORE

        public static double NO_SCORE
        Flag to indicate that there is no score info.
      • NO_FRAME

        public static int NO_FRAME
        Flag to indicate that there is no frame info.
    • Constructor Detail

      • GFFTools

        public GFFTools()
    • Method Detail

      • readGFF

        public static GFFEntrySet readGFF​(java.lang.String fileName)
                                   throws java.io.FileNotFoundException,
                                          ParserException,
                                          BioException,
                                          java.io.IOException
        Deprecated.
        use: readGff(File)
        Reads a GFFEntrySet from a file with no filtering.
        Parameters:
        fileName - the file containing the GFF
        Returns:
        a GFFEntrySet encapsulating the records read from the file
        Throws:
        java.io.FileNotFoundException - if file is not found
        ParserException - if format is wrong
        BioException - if format is wrong
        java.io.IOException - if file reading error occurs
      • readGFF

        public static GFFEntrySet readGFF​(java.lang.String fileName,
                                          GFFRecordFilter recFilt)
                                   throws java.io.FileNotFoundException,
                                          ParserException,
                                          BioException,
                                          java.io.IOException
        Deprecated.
        use: readGff(File,GFFRecordFilter)
        Reads a GFFEntrySet from a file with the specified filter.
        Parameters:
        fileName - the file containing the GFF
        recFilt - the filter to use
        Returns:
        a GFFEntrySet encapsulating the records read from the file
        Throws:
        java.io.FileNotFoundException - if file is not found
        ParserException - if format is wrong
        BioException - if format is wrong
        java.io.IOException - if file reading error occurs
      • readGFF

        public static GFFEntrySet readGFF​(java.io.File inFile)
                                   throws java.io.FileNotFoundException,
                                          ParserException,
                                          BioException,
                                          java.io.IOException
        Reads a GFFEntrySet from a file with no filtering.
        Parameters:
        inFile - the File containing the GFF
        Returns:
        a GFFEntrySet encapsulating the records read from the file
        Throws:
        java.io.FileNotFoundException - if file is not found
        ParserException - if format is wrong
        BioException - if format is wrong
        java.io.IOException - if file reading error occurs
      • readGFF

        public static GFFEntrySet readGFF​(java.io.File inFile,
                                          GFFRecordFilter recFilt)
                                   throws java.io.FileNotFoundException,
                                          ParserException,
                                          BioException,
                                          java.io.IOException
        Reads a GFFEntrySet from a file with the specified filter.
        Parameters:
        inFile - the File containing the GFF
        recFilt - the filter to use
        Returns:
        a GFFEntrySet encapsulating the records read from the file
        Throws:
        java.io.FileNotFoundException - if file is not found
        ParserException - if format is wrong
        BioException - if format is wrong
        java.io.IOException - if file reading error occurs
      • readGFF

        public static GFFEntrySet readGFF​(java.io.BufferedReader gffIn)
                                   throws ParserException,
                                          BioException,
                                          java.io.IOException
        Read all GFF entries from a buffered reader. This will read up untill the end of the reader.
        Parameters:
        gffIn - the BufferedReader to read text from
        Returns:
        a GFFEntrySet containing all of the GFF that could be read
        Throws:
        parserException - if the text could not be parsed as GFF
        BioException - if there was some error reading the GFF
        java.io.IOException - if there was an error with the reader
        ParserException
      • readGFF

        public static GFFEntrySet readGFF​(java.io.BufferedReader gffIn,
                                          GFFRecordFilter recFilt)
                                   throws ParserException,
                                          BioException,
                                          java.io.IOException
        Read all GFF entries matching a filter from a buffered reader. This will read up untill the end of the reader.
        Parameters:
        gffIn - the BufferedReader to read text from
        Returns:
        a GFFEntrySet containing all of the GFF that could be read
        Throws:
        parserException - if the text could not be parsed as GFF
        BioException - if there was some error reading the GFF
        java.io.IOException - if there was an error with the reader
        ParserException
      • writeGFF

        public static void writeGFF​(java.lang.String fileName,
                                    GFFEntrySet ents)
                             throws java.io.IOException
        Writes a GFFEntrySet to a file.
        Parameters:
        fileName - the file to write to
        ents - the entries to write
        Throws:
        java.io.IOException - if file writing fails
      • writeGFF

        public static void writeGFF​(java.io.File outFile,
                                    GFFEntrySet ents)
                             throws java.io.IOException
        Writes a GFFEntrySet to a file.
        Parameters:
        outFile - the file to write to
        ents - the entry set to write
        Throws:
        java.io.IOException - if writing to the file fails
      • writeGFF

        public static void writeGFF​(java.io.PrintWriter pw,
                                    GFFEntrySet ents)
                             throws java.io.IOException
        Writes a GFFEntrySet to a PrintWriter.
        Parameters:
        pw - the PrintWriter to write to
        ents - the entries to write
        Throws:
        java.io.IOException - if file writing fails
      • annotateSequence

        public static Sequence annotateSequence​(Sequence seq,
                                                GFFEntrySet ents)
        Annotates a sequence with the features from a GFF entry set with sequence name matching this sequence.
        Parameters:
        seq - the Sequence to annotate.
        ents - the the GFF features to annotate it with.
        Returns:
        a reference to a newly annotated sequence.
      • annotateSequence

        public static Sequence annotateSequence​(Sequence seq,
                                                GFFEntrySet ents,
                                                boolean checkSeqName)
        Annotates a sequence with the features from a GFF entry set.
        Parameters:
        seq - the Sequence to annotate.
        ents - the the GFF features to annotate it with.
        checkSeqName - boolean flat, if true only annotate sequence with features that have matching sequence names, otherwise annotate all features
        Returns:
        a reference to a newly annotated sequence.
      • gffFromSequence

        public static GFFEntrySet gffFromSequence​(Sequence seq)
                                           throws BioException
        Creates a GFFEntrySet containing one entry for each feature on a sequence.
        Parameters:
        seq - the Sequence to create features for
        Returns:
        a new GFFEntrySet with gff records for each featre on the sequence
        Throws:
        BioException - if something went wrong GFF-ifying the sequences features
      • gffFromSeqDB

        public static GFFEntrySet gffFromSeqDB​(SequenceDB seqDB)
                                        throws BioException
        Creates a GFFEntrySet containing one entry for each feature on each sequence of a SequenceDB.

        Note: This converts all features in the whole database to in-memorey GFFRecord instances. This will take up considerable memory for large databases.

        Parameters:
        seqDB - the SequenceDB to create features for
        Returns:
        a new GFFEntrySet with gff records for each feature on the database
        Throws:
        BioException - if something went wrong GFF-ifying the sequences features