Class GenbankReader<S extends AbstractSequence<C>,​C extends Compound>


  • public class GenbankReader<S extends AbstractSequence<C>,​C extends Compound>
    extends java.lang.Object
    Use GenbankReaderHelper as an example of how to use this class where GenbankReaderHelper should be the primary class used to read Genbank files
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()  
      static void main​(java.lang.String[] args)  
      java.util.LinkedHashMap<java.lang.String,​S> process()
      The parsing is done in this method.
      This method tries to process all the available Genbank records in the File or InputStream, closes the underlying resource, and return the results in LinkedHashMap.
      You don't need to call close() after calling this method.
      java.util.LinkedHashMap<java.lang.String,​S> process​(int max)
      This method tries to parse maximum max records from the open File or InputStream, and leaves the underlying resource open.
      Subsequent calls to the same method continue parsing the rest of the file.
      This is particularly useful when dealing with very big data files, (e.g.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • GenbankReader

        public GenbankReader​(java.io.InputStream is,
                             SequenceHeaderParserInterface<S,​C> headerParser,
                             SequenceCreatorInterface<C> sequenceCreator)
        If you are going to use FileProxyProteinSequenceCreator then do not use this constructor because we need details about local file offsets for quick reads. InputStreams does not give you the name of the stream to access quickly via file seek. A seek in an inputstream is forced to read all the data so you don't gain anything.
        Parameters:
        br -
        headerParser -
        sequenceCreator -
      • GenbankReader

        public GenbankReader​(java.io.File file,
                             SequenceHeaderParserInterface<S,​C> headerParser,
                             SequenceCreatorInterface<C> sequenceCreator)
                      throws java.io.FileNotFoundException
        If you are going to use the FileProxyProteinSequenceCreator then you need to use this constructor because we need details about the location of the file.
        Parameters:
        file -
        headerParser -
        sequenceCreator -
        Throws:
        java.io.FileNotFoundException - if the file does not exist, is a directory rather than a regular file, or for some other reason cannot be opened for reading.
        java.lang.SecurityException - if a security manager exists and its checkRead method denies read access to the file.
    • Method Detail

      • process

        public java.util.LinkedHashMap<java.lang.String,​S> process()
                                                                  throws java.io.IOException,
                                                                         CompoundNotFoundException
        The parsing is done in this method.
        This method tries to process all the available Genbank records in the File or InputStream, closes the underlying resource, and return the results in LinkedHashMap.
        You don't need to call close() after calling this method.
        Returns:
        HashMap containing all the parsed Genbank records present, starting current fileIndex onwards.
        Throws:
        java.io.IOException
        CompoundNotFoundException
        See Also:
        process(int)
      • process

        public java.util.LinkedHashMap<java.lang.String,​S> process​(int max)
                                                                  throws java.io.IOException,
                                                                         CompoundNotFoundException
        This method tries to parse maximum max records from the open File or InputStream, and leaves the underlying resource open.
        Subsequent calls to the same method continue parsing the rest of the file.
        This is particularly useful when dealing with very big data files, (e.g. NCBI nr database), which can't fit into memory and will take long time before the first result is available.
        N.B.
        • This method ca't be called after calling its NO-ARGUMENT twin.
        • remember to close the underlying resource when you are done.
        Parameters:
        max - maximum number of records to return, -1 for infinity.
        Returns:
        HashMap containing maximum max parsed Genbank records present, starting current fileIndex onwards.
        Throws:
        java.io.IOException
        CompoundNotFoundException
        Since:
        3.0.6
        See Also:
        process()
      • close

        public void close()
                   throws java.io.IOException
        Throws:
        java.io.IOException
      • main

        public static void main​(java.lang.String[] args)
                         throws java.lang.Exception
        Throws:
        java.lang.Exception