Class SequenceFileProxyLoader<C extends Compound>

  • Type Parameters:
    C -
    All Implemented Interfaces:
    java.lang.Iterable<C>, Accessioned, ProxySequenceReader<C>, Sequence<C>, SequenceReader<C>

    public class SequenceFileProxyLoader<C extends Compound>
    extends java.lang.Object
    implements ProxySequenceReader<C>
    This class represents the storage container of a sequence stored in a fasta file where the initial parsing of the file we store the offset and length of the sequence. When a call is made to any method that needs sequence data then the file will be opened and the sequence loaded. This class could be improved by using the hints or a some algorithm that indicates the sequence data once loaded should stay loaded. Could keep track of the last time sequence data was loaded and then after X amount of time clear the contents to free up memory.
    Author:
    Scooter Willis
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int countCompounds​(C... compounds)
      Returns the number of times we found a compound in the Sequence
      AccessionID getAccession()
      Returns the AccessionID this location is currently bound with
      java.util.List<C> getAsList()
      Returns the Sequence as a List of compounds
      C getCompoundAt​(int position)
      Returns the Compound at the given biological index
      CompoundSet<C> getCompoundSet()
      Gets the compound set used to back this Sequence
      int getIndexOf​(C compound)
      Scans through the Sequence looking for the first occurrence of the given compound
      SequenceView<C> getInverse()
      Does the right thing to get the inverse of the current Sequence.
      int getLastIndexOf​(C compound)
      Scans through the Sequence looking for the last occurrence of the given compound
      int getLength()
      Returns the length of the Sequence
      java.lang.String getSequenceAsString()
      Returns the String representation of the Sequence
      java.lang.String getSequenceAsString​(java.lang.Integer bioBegin, java.lang.Integer bioEnd, Strand strand)  
      SequenceView<C> getSubSequence​(java.lang.Integer bioBegin, java.lang.Integer bioEnd)
      Returns a portion of the sequence from the different positions.
      java.util.Iterator<C> iterator()  
      void setCompoundSet​(CompoundSet<C> compoundSet)  
      void setContents​(java.lang.String sequence)  
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.lang.Iterable

        forEach, spliterator
    • Constructor Detail

      • SequenceFileProxyLoader

        public SequenceFileProxyLoader​(java.io.File file,
                                       SequenceParserInterface sequenceParser,
                                       long sequenceStartIndex,
                                       int sequenceLength,
                                       CompoundSet<C> compoundSet)
                                throws java.io.IOException,
                                       CompoundNotFoundException
        Parameters:
        file - The file where the sequence will be found
        sequenceParser - The parser to use to load the sequence
        sequenceStartIndex - The file offset to the start of the sequence
        sequenceLength - The length of the sequence
        compoundSet -
        Throws:
        java.io.IOException - if problems occur while reading the file
        CompoundNotFoundException - if a compound in the sequence can't be found in the given compoundSet
    • Method Detail

      • getLength

        public int getLength()
        Description copied from interface: Sequence
        Returns the length of the Sequence
        Specified by:
        getLength in interface Sequence<C extends Compound>
        Returns:
      • getCompoundAt

        public C getCompoundAt​(int position)
        Description copied from interface: Sequence
        Returns the Compound at the given biological index
        Specified by:
        getCompoundAt in interface Sequence<C extends Compound>
        Parameters:
        position -
        Returns:
      • getIndexOf

        public int getIndexOf​(C compound)
        Description copied from interface: Sequence
        Scans through the Sequence looking for the first occurrence of the given compound
        Specified by:
        getIndexOf in interface Sequence<C extends Compound>
        Parameters:
        compound -
        Returns:
      • getLastIndexOf

        public int getLastIndexOf​(C compound)
        Description copied from interface: Sequence
        Scans through the Sequence looking for the last occurrence of the given compound
        Specified by:
        getLastIndexOf in interface Sequence<C extends Compound>
        Parameters:
        compound -
        Returns:
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
        Returns:
      • getSequenceAsString

        public java.lang.String getSequenceAsString()
        Description copied from interface: Sequence
        Returns the String representation of the Sequence
        Specified by:
        getSequenceAsString in interface Sequence<C extends Compound>
        Returns:
      • getSequenceAsString

        public java.lang.String getSequenceAsString​(java.lang.Integer bioBegin,
                                                    java.lang.Integer bioEnd,
                                                    Strand strand)
        Parameters:
        bioBegin -
        bioEnd -
        strand -
        Returns:
      • getAsList

        public java.util.List<C> getAsList()
        Description copied from interface: Sequence
        Returns the Sequence as a List of compounds
        Specified by:
        getAsList in interface Sequence<C extends Compound>
        Returns:
      • getSubSequence

        public SequenceView<C> getSubSequence​(java.lang.Integer bioBegin,
                                              java.lang.Integer bioEnd)
        Description copied from interface: Sequence
        Returns a portion of the sequence from the different positions. This is indexed from 1
        Specified by:
        getSubSequence in interface Sequence<C extends Compound>
        Parameters:
        bioBegin -
        bioEnd -
        Returns:
      • iterator

        public java.util.Iterator<C> iterator()
        Specified by:
        iterator in interface java.lang.Iterable<C extends Compound>
        Returns:
      • countCompounds

        public int countCompounds​(C... compounds)
        Description copied from interface: Sequence
        Returns the number of times we found a compound in the Sequence
        Specified by:
        countCompounds in interface Sequence<C extends Compound>
        Parameters:
        compounds -
        Returns:
      • getInverse

        public SequenceView<C> getInverse()
        Description copied from interface: Sequence
        Does the right thing to get the inverse of the current Sequence. This means either reversing the Sequence and optionally complementing the Sequence.
        Specified by:
        getInverse in interface Sequence<C extends Compound>
        Returns: