Class JoiningSequenceReader<C extends Compound>
java.lang.Object
org.biojava.nbio.core.sequence.storage.JoiningSequenceReader<C>
- Type Parameters:
C- Tyoe of compound to hold
- All Implemented Interfaces:
Iterable<C>,Accessioned,ProxySequenceReader<C>,Sequence<C>,SequenceReader<C>
public class JoiningSequenceReader<C extends Compound>
extends Object
implements ProxySequenceReader<C>
This reader actually proxies onto multiple types of sequence in order
to allow a number of sequence objects to act as if they are one sequence.
The code takes in any number of sequences, records the minimum and maximum
bounds each sequence covers with respect to 1 position indexing and then
binary searches these when a position is requested. Because of this
0 length Sequences are excluded during construction.
Performance is not as good as if you are using a flat sequence however the
speed of lookup is more than adaquate for most situations. Using the iterator
gives the best performance as this does not rely on the binary search
mechanism instead iterating through each sequence in turn.
- Author:
- ayates
-
Constructor Summary
ConstructorsConstructorDescriptionJoiningSequenceReader(List<Sequence<C>> sequences) JoiningSequenceReader(CompoundSet<C> compoundSet, List<Sequence<C>> sequences) JoiningSequenceReader(CompoundSet<C> compoundSet, Sequence<C>... sequences) JoiningSequenceReader(Sequence<C>... sequences) -
Method Summary
Modifier and TypeMethodDescriptionintcountCompounds(C... compounds) Returns the number of times we found a compound in the SequencebooleanReturns 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 SequenceintgetIndexOf(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.intgetLastIndexOf(C compound) Scans through the Sequence looking for the last occurrence of the given compoundintReturns the length of the SequenceReturns the String representation of the SequencegetSubSequence(Integer start, Integer end) Returns a portion of the sequence from the different positions.inthashCode()iterator()Iterator implementation which attempts to move through the 2D structure attempting to skip onto the next sequence as & when it is asked tovoidsetCompoundSet(CompoundSet<C> compoundSet) voidsetContents(String sequence) Methods 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
-
JoiningSequenceReader
-
JoiningSequenceReader
-
JoiningSequenceReader
-
JoiningSequenceReader
-
-
Method Details
-
getCompoundAt
Description copied from interface:SequenceReturns the Compound at the given biological index- Specified by:
getCompoundAtin interfaceSequence<C extends Compound>- Parameters:
position- Biological index (1 to n)- Returns:
- Compound at the specified position
-
getCompoundSet
Description copied from interface:SequenceGets the compound set used to back this Sequence- Specified by:
getCompoundSetin interfaceSequence<C extends Compound>
-
getLength
Description copied from interface:SequenceReturns the length of the Sequence -
iterator
Iterator implementation which attempts to move through the 2D structure attempting to skip onto the next sequence as & when it is asked to -
setCompoundSet
- Specified by:
setCompoundSetin interfaceSequenceReader<C extends Compound>
-
setContents
- Specified by:
setContentsin interfaceSequenceReader<C extends Compound>- Throws:
CompoundNotFoundException
-
countCompounds
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- Vargs of the compounds to count- Returns:
- Number of times a compound was found
-
getAccession
Description copied from interface:AccessionedReturns the AccessionID this location is currently bound with- Specified by:
getAccessionin interfaceAccessioned
-
getAsList
Description copied from interface:SequenceReturns the Sequence as a List of compounds -
equals
-
hashCode
-
getIndexOf
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- Compounds to look for- Returns:
- Index of the first position of the compound in the sequence (1 to n)
-
getLastIndexOf
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- Compounds to look for- Returns:
- Index of the last position of the compound in the sequence (1 to n)
-
getSequenceAsString
Description copied from interface:SequenceReturns the String representation of the Sequence- Specified by:
getSequenceAsStringin interfaceSequence<C extends Compound>
-
getSubSequence
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:
start- Biological index start; must be greater than 0end- Biological end; must be less than length + 1- Returns:
- A SequenceView of the offset
-
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>
-