Class SingleCompoundSequenceReader<C extends Compound>
java.lang.Object
org.biojava.nbio.core.sequence.storage.SingleCompoundSequenceReader<C>
- All Implemented Interfaces:
Iterable<C>,Accessioned,ProxySequenceReader<C>,Sequence<C>,SequenceReader<C>
public class SingleCompoundSequenceReader<C extends Compound>
extends Object
implements ProxySequenceReader<C>
An implementation of the SequenceReader interface which for every
call will return only 1 compound (given to it during construction; a String
is also valid but will require a CompoundSet). The idea is to represent
large runs of a single compound without the memory footprint of storing these
compounds e.g. a run of 10KB of Ns in a DNASequence.
- Author:
- ayates
-
Constructor Summary
ConstructorsConstructorDescriptionSingleCompoundSequenceReader(C compound, CompoundSet<C> compoundSet, int length) Build the object with a compound rather than a StringSingleCompoundSequenceReader(String compound, CompoundSet<C> compoundSet, int length) Public constructor to be used with String based constructor -
Method Summary
Modifier and TypeMethodDescriptionintcountCompounds(C... compounds) booleanbooleanUnsupoortedgetCompoundAt(int position) Always returns the compound given at constructionReturns the compound set given at constructionintgetIndexOf(C compound) Returns 1 if the given compound is equal to the one given during construction; otherwise will return -1.Does the right thing to get the inverse of the current Sequence.intgetLastIndexOf(C compound) Returns the length of the Sequence if the given compound was equal to the one given during construction.intReturns the length given during constructiongetSubSequence(Integer start, Integer end) Creates aSequenceProxyViewfor the given coordinatesinthashCode()iterator()Returns an instance ofSequenceMixin.SequenceIteratorvoidsetCompoundSet(CompoundSet<C> compoundSet) UnsupportedvoidsetContents(String sequence) UnsupportedMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
SingleCompoundSequenceReader
Public constructor to be used with String based constructor -
SingleCompoundSequenceReader
Build the object with a compound rather than a String
-
-
Method Details
-
setCompoundSet
Unsupported- Specified by:
setCompoundSetin interfaceSequenceReader<C extends Compound>
-
setContents
Unsupported- Specified by:
setContentsin interfaceSequenceReader<C extends Compound>- Throws:
CompoundNotFoundException
-
getLength
Returns the length given during construction -
getCompoundAt
Always returns the compound given at construction- Specified by:
getCompoundAtin interfaceSequence<C extends Compound>- Parameters:
position- Biological index (1 to n)- Returns:
- Compound at the specified position
-
getIndexOf
Returns 1 if the given compound is equal to the one given during construction; otherwise will return -1.- Specified by:
getIndexOfin interfaceSequence<C extends Compound>- Parameters:
compound- Compounds to look for- Returns:
- Index of the first position of the compound in the sequence (1 to n)
-
getLastIndexOf
Returns the length of the Sequence if the given compound was equal to the one given during construction. Otherwise returns -1- Specified by:
getLastIndexOfin interfaceSequence<C extends Compound>- Parameters:
compound- Compounds to look for- Returns:
- Index of the last position of the compound in the sequence (1 to n)
-
getSequenceAsString
- Specified by:
getSequenceAsStringin interfaceSequence<C extends Compound>
-
getAsList
-
getSubSequence
Creates aSequenceProxyViewfor the given coordinates- Specified by:
getSubSequencein interfaceSequence<C extends Compound>- Parameters:
start- Biological index start; must be greater than 0end- Biological end; must be less than length + 1- Returns:
- A SequenceView of the offset
-
getCompoundSet
Returns the compound set given at construction- Specified by:
getCompoundSetin interfaceSequence<C extends Compound>
-
getAccession
Unsupoorted- Specified by:
getAccessionin interfaceAccessioned
-
countCompounds
Delegates toSequenceMixin.countCompounds(org.biojava.nbio.core.sequence.template.Sequence<C>, C...)- Specified by:
countCompoundsin interfaceSequence<C extends Compound>- Parameters:
compounds- Vargs of the compounds to count- Returns:
- Number of times a compound was found
-
iterator
Returns an instance ofSequenceMixin.SequenceIterator -
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>
-
hashCode
-
equals
-
equals
-