Class BitSequenceReader<C extends Compound>
java.lang.Object
org.biojava.nbio.core.sequence.storage.BitSequenceReader<C>
- Type Parameters:
- C- Type of compound; must extend- NucleotideCompound
- All Implemented Interfaces:
- Iterable<C>,- Accessioned,- ProxySequenceReader<C>,- Sequence<C>,- SequenceReader<C>
- Direct Known Subclasses:
- FourBitSequenceReader,- TwoBitSequenceReader
An implementation of the popular bit encodings. This class provides the
 Sequence view over what is actually carried out in the 
BitSequenceReader.BitArrayWorker
 instances. These are the objects that carry out array storage as well as
 indexing into those arrays. New bit encodings can be written by extending
 this class and a worker class. There are a number of issues with this
 type of storage engine:
 - We can only support a finite number of Compounds; 2 bit allows no N compounds
- For real savings you must read the sequence in using your own
 Reader and a BitSequenceReader.BitArrayWorkerinstance
- Author:
- ayates
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic classBitSequenceReader.BitArrayWorker<C extends Compound>The logic of working with a bit has been separated out into this class to help developers create the bit data structures without having to put the code into an intermediate format and to also use the format without the need to copy this code.
- 
Constructor SummaryConstructorsConstructorDescriptionBitSequenceReader(BitSequenceReader.BitArrayWorker<C> worker, AccessionID accession) Instance which allows you to supply a different @{BitArrayWorker} object.
- 
Method SummaryModifier and TypeMethodDescriptionintcountCompounds(C... compounds) Counts the number of times a compound appears in this sequence storebooleanReturns the AccessionID this location is currently bound withReturns this Sequence store as a ListgetCompoundAt(int position) Returns the compound at the specified biological indexReturns the compound set backing this storeintgetIndexOf(C compound) Returns the first occurrence of the given compound in this store; performs a linear searchDoes the right thing to get the inverse of the current Sequence.intgetLastIndexOf(C compound) Returns the last occurrence of the given compound in this store; performs a linear searchintReturns the length of the sequenceReturns the sequence as a StringgetSubSequence(int start, int end) Returns a sub sequence viewgetSubSequence(Integer start, Integer end) Returns a portion of the sequence from the different positions.inthashCode()iterator()Provides basic iterable access to this classvoidsetCompoundSet(CompoundSet<C> compoundSet) Class is immutable, so this is unsupportedvoidsetContents(String sequence) Class is immutable, so this is unsupportedMethods inherited from class java.lang.Objectclone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.IterableforEach, spliterator
- 
Constructor Details- 
BitSequenceReaderInstance which allows you to supply a different @{BitArrayWorker} object.
 
- 
- 
Method Details- 
setCompoundSetClass is immutable, so this is unsupported- Specified by:
- setCompoundSetin interface- SequenceReader<C extends Compound>
 
- 
setContentsClass is immutable, so this is unsupported- Specified by:
- setContentsin interface- SequenceReader<C extends Compound>
- Throws:
- CompoundNotFoundException
 
- 
countCompoundsCounts the number of times a compound appears in this sequence store- Specified by:
- countCompoundsin interface- Sequence<C extends Compound>
- Parameters:
- compounds- Vargs of the compounds to count
- Returns:
- Number of times a compound was found
 
- 
getAccessionDescription copied from interface:AccessionedReturns the AccessionID this location is currently bound with- Specified by:
- getAccessionin interface- Accessioned
 
- 
getAsListReturns this Sequence store as a List
- 
getCompoundAtReturns the compound at the specified biological index- Specified by:
- getCompoundAtin interface- Sequence<C extends Compound>
- Parameters:
- position- Biological index (1 to n)
- Returns:
- Compound at the specified position
 
- 
getCompoundSetReturns the compound set backing this store- Specified by:
- getCompoundSetin interface- Sequence<C extends Compound>
 
- 
getIndexOfReturns the first occurrence of the given compound in this store; performs a linear search- Specified by:
- getIndexOfin interface- Sequence<C extends Compound>
- Parameters:
- compound- Compounds to look for
- Returns:
- Index of the first position of the compound in the sequence (1 to n)
 
- 
getLastIndexOfReturns the last occurrence of the given compound in this store; performs a linear search- Specified by:
- getLastIndexOfin interface- Sequence<C extends Compound>
- Parameters:
- compound- Compounds to look for
- Returns:
- Index of the last position of the compound in the sequence (1 to n)
 
- 
getLengthReturns the length of the sequence
- 
getSequenceAsStringReturns the sequence as a String- Specified by:
- getSequenceAsStringin interface- Sequence<C extends Compound>
 
- 
getSubSequenceReturns a sub sequence view
- 
iteratorProvides basic iterable access to this class
- 
getSubSequenceDescription copied from interface:SequenceReturns a portion of the sequence from the different positions. This is indexed from 1- Specified by:
- getSubSequencein interface- Sequence<C extends Compound>
- Parameters:
- start- Biological index start; must be greater than 0
- end- Biological end; must be less than length + 1
- Returns:
- A SequenceView of the offset
 
- 
getInverseDescription 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 interface- Sequence<C extends Compound>
 
- 
hashCode
- 
equals
 
-