Class SequenceFileProxyLoader<C extends Compound>
java.lang.Object
org.biojava3.core.sequence.loader.SequenceFileProxyLoader<C>
- Type Parameters:
C
-
- All Implemented Interfaces:
Iterable<C>
,Accessioned
,ProxySequenceReader<C>
,Sequence<C>
,SequenceReader<C>
public class SequenceFileProxyLoader<C extends Compound>
extends 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
ConstructorDescriptionSequenceFileProxyLoader
(File file, SequenceParserInterface sequenceParser, long sequenceStartIndex, int sequenceLength, CompoundSet<C> compoundSet) -
Method Summary
Modifier and TypeMethodDescriptionint
countCompounds
(C... compounds) Returns the number of times we found a compound in the SequenceReturns the AccessionID this location is currently bound withReturns the Sequence as a List of compoundsgetCompoundAt
(int position) Returns the Compound at the given biological indexGets the compound set used to back this Sequenceint
getIndexOf
(C compound) Scans through the Sequence looking for the first occurrence of the given compoundDoes 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 compoundint
Returns the length of the SequenceReturns the String representation of the SequencegetSequenceAsString
(Integer bioBegin, Integer bioEnd, Strand strand) getSubSequence
(Integer bioBegin, Integer bioEnd) Returns a portion of the sequence from the different positions.boolean
iterator()
void
setCompoundSet
(CompoundSet<C> compoundSet) void
setContents
(String sequence) void
setInitialized
(boolean initialized) toString()
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
SequenceFileProxyLoader
public SequenceFileProxyLoader(File file, SequenceParserInterface sequenceParser, long sequenceStartIndex, int sequenceLength, CompoundSet<C> compoundSet) - 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
-
-
-
Method Details
-
setCompoundSet
- Specified by:
setCompoundSet
in interfaceSequenceReader<C extends Compound>
- Parameters:
compoundSet
-
-
setContents
- Specified by:
setContents
in interfaceSequenceReader<C extends Compound>
- Parameters:
sequence
-
-
getLength
public int getLength()Description copied from interface:Sequence
Returns the length of the Sequence -
getCompoundAt
Description copied from interface:Sequence
Returns the Compound at the given biological index- Specified by:
getCompoundAt
in interfaceSequence<C extends Compound>
- Parameters:
position
-- Returns:
-
getIndexOf
Description copied from interface:Sequence
Scans through the Sequence looking for the first occurrence of the given compound- Specified by:
getIndexOf
in interfaceSequence<C extends Compound>
- Parameters:
compound
-- Returns:
-
getLastIndexOf
Description copied from interface:Sequence
Scans through the Sequence looking for the last occurrence of the given compound- Specified by:
getLastIndexOf
in interfaceSequence<C extends Compound>
- Parameters:
compound
-- Returns:
-
toString
-
getSequenceAsString
Description copied from interface:Sequence
Returns the String representation of the Sequence- Specified by:
getSequenceAsString
in interfaceSequence<C extends Compound>
- Returns:
-
getSequenceAsString
- Parameters:
bioBegin
-bioEnd
-strand
-- Returns:
-
getAsList
Description copied from interface:Sequence
Returns the Sequence as a List of compounds -
getSubSequence
Description copied from interface:Sequence
Returns a portion of the sequence from the different positions. This is indexed from 1- Specified by:
getSubSequence
in interfaceSequence<C extends Compound>
- Parameters:
bioBegin
-bioEnd
-- Returns:
-
iterator
-
getCompoundSet
Description copied from interface:Sequence
Gets the compound set used to back this Sequence- Specified by:
getCompoundSet
in interfaceSequence<C extends Compound>
- Returns:
-
isInitialized
public boolean isInitialized()- Returns:
- the initialized
-
setInitialized
public void setInitialized(boolean initialized) - Parameters:
initialized
- the initialized to set
-
getAccession
Description copied from interface:Accessioned
Returns the AccessionID this location is currently bound with- Specified by:
getAccession
in interfaceAccessioned
- Returns:
-
countCompounds
Description copied from interface:Sequence
Returns the number of times we found a compound in the Sequence- Specified by:
countCompounds
in interfaceSequence<C extends Compound>
- Parameters:
compounds
-- Returns:
-
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 interfaceSequence<C extends Compound>
- Returns:
-