Class SequenceFileProxyLoader<C extends Compound>
- java.lang.Object
-
- org.biojava.nbio.core.sequence.loader.SequenceFileProxyLoader<C>
-
- 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
-
-
Constructor Summary
Constructors Constructor Description SequenceFileProxyLoader(java.io.File file, SequenceParserInterface sequenceParser, long sequenceStartIndex, int sequenceLength, CompoundSet<C> compoundSet)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcountCompounds(C... compounds)Returns the number of times we found a compound in the Sequencebooleanequals(java.lang.Object o)AccessionIDgetAccession()Returns the AccessionID this location is currently bound withjava.util.List<C>getAsList()Returns the Sequence as a List of compoundsCgetCompoundAt(int position)Returns the Compound at the given biological indexCompoundSet<C>getCompoundSet()Gets the compound set used to back this SequenceintgetIndexOf(C compound)Scans through the Sequence looking for the first occurrence of the given compoundSequenceView<C>getInverse()Does the right thing to get the inverse of the current Sequence.intgetLastIndexOf(C compound)Scans through the Sequence looking for the last occurrence of the given compoundintgetLength()Returns the length of the Sequencejava.lang.StringgetSequenceAsString()Returns the String representation of the Sequencejava.lang.StringgetSequenceAsString(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.inthashCode()java.util.Iterator<C>iterator()voidsetCompoundSet(CompoundSet<C> compoundSet)voidsetContents(java.lang.String sequence)java.lang.StringtoString()
-
-
-
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 foundsequenceParser- The parser to use to load the sequencesequenceStartIndex- The file offset to the start of the sequencesequenceLength- The length of the sequencecompoundSet-- Throws:
java.io.IOException- if problems occur while reading the fileCompoundNotFoundException- if a compound in the sequence can't be found in the given compoundSet
-
-
Method Detail
-
setCompoundSet
public void setCompoundSet(CompoundSet<C> compoundSet)
- Specified by:
setCompoundSetin interfaceSequenceReader<C extends Compound>- Parameters:
compoundSet-
-
setContents
public void setContents(java.lang.String sequence) throws CompoundNotFoundException- Specified by:
setContentsin interfaceSequenceReader<C extends Compound>- Parameters:
sequence-- Throws:
CompoundNotFoundException
-
getLength
public int getLength()
Description copied from interface:SequenceReturns the length of the Sequence
-
getCompoundAt
public C getCompoundAt(int position)
Description copied from interface:SequenceReturns the Compound at the given biological index- Specified by:
getCompoundAtin interfaceSequence<C extends Compound>- Parameters:
position-- Returns:
-
getIndexOf
public int getIndexOf(C compound)
Description copied from interface:SequenceScans through the Sequence looking for the first occurrence of the given compound- Specified by:
getIndexOfin interfaceSequence<C extends Compound>- Parameters:
compound-- Returns:
-
getLastIndexOf
public int getLastIndexOf(C compound)
Description copied from interface:SequenceScans through the Sequence looking for the last occurrence of the given compound- Specified by:
getLastIndexOfin interfaceSequence<C extends Compound>- Parameters:
compound-- Returns:
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object- Returns:
-
getSequenceAsString
public java.lang.String getSequenceAsString()
Description copied from interface:SequenceReturns the String representation of the Sequence- Specified by:
getSequenceAsStringin interfaceSequence<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:SequenceReturns the Sequence as a List of compounds
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
getSubSequence
public SequenceView<C> getSubSequence(java.lang.Integer bioBegin, java.lang.Integer bioEnd)
Description copied from interface:SequenceReturns a portion of the sequence from the different positions. This is indexed from 1- Specified by:
getSubSequencein interfaceSequence<C extends Compound>- Parameters:
bioBegin-bioEnd-- Returns:
-
iterator
public java.util.Iterator<C> iterator()
-
getCompoundSet
public CompoundSet<C> getCompoundSet()
Description copied from interface:SequenceGets the compound set used to back this Sequence- Specified by:
getCompoundSetin interfaceSequence<C extends Compound>- Returns:
-
getAccession
public AccessionID getAccession()
Description copied from interface:AccessionedReturns the AccessionID this location is currently bound with- Specified by:
getAccessionin interfaceAccessioned- Returns:
-
countCompounds
public int countCompounds(C... compounds)
Description copied from interface:SequenceReturns the number of times we found a compound in the Sequence- Specified by:
countCompoundsin interfaceSequence<C extends Compound>- Parameters:
compounds-- Returns:
-
getInverse
public SequenceView<C> getInverse()
Description copied from interface:SequenceDoes the right thing to get the inverse of the current Sequence. This means either reversing the Sequence and optionally complementing the Sequence.- Specified by:
getInversein interfaceSequence<C extends Compound>- Returns:
-
-