Package org.snpeff.binseq
Class DnaSequence
java.lang.Object
org.snpeff.binseq.BinarySequence
org.snpeff.binseq.DnaSequence
- All Implemented Interfaces:
Serializable
,Cloneable
,Comparable<BinarySequence>
- Direct Known Subclasses:
DnaNSequence
,DnaSequenceId
Binary packed DNA sequence
Notes:
- This is designed for short sequences (such as "short reads")
- Every base is encoded in 2 bits {a, c, g, t} invalid input: '<'=> {0, 1, 2, 3}
- All bits are stored in an array of 'words' (integers)
- Most significant bits are the first bases in the sequence (makes comparison easier)
- Author:
- pcingola
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionDnaSequence
(int length, long[] codes) DnaSequence
(String seqStr) DnaSequence
(String seqStr, boolean ignoreErrors) -
Method Summary
Modifier and TypeMethodDescriptionclone()
int
static DnaSequence
empty()
Empty sequence singletonprotected DnaSequence
factory()
Create a new sequencechar
getBase
(int index) Return the base at position 'index'getBases
(int index, int len) Get a few bases from this sequenceint
getCode
(int index) Return the base at position 'index'getCoder()
Get sequence encoder invalid input: '&' decoderlong[]
getCodes()
Get the sequence as a Stringint
hashCode()
boolean
isEmpty()
Is this sequence empty?int
length()
Sequence lenthoverlap
(BinarySequence sequence, int start) Creates a new sequence by overlapping 'this' and 'sequence' E.g.read
(DataInputStream dataInStream) Read data in binary formatprotected void
readDataStream
(DataInputStream dataInStream) Read data in binary formatReverse Watson-Cricks complementvoid
Set sequencevoid
void
setBase
(int index, char base) Replace a base in the sequencevoid
setCodes
(long[] codes) toString()
void
write
(DataOutputStream dataOutStream) Write data in binary formatMethods inherited from class org.snpeff.binseq.BinarySequence
setQuality
-
Constructor Details
-
DnaSequence
public DnaSequence(int length, long[] codes) -
DnaSequence
-
DnaSequence
-
-
Method Details
-
empty
Empty sequence singleton -
clone
- Overrides:
clone
in classBinarySequence
-
compareTo
-
factory
Create a new sequence -
getBase
public char getBase(int index) Description copied from class:BinarySequence
Return the base at position 'index'- Overrides:
getBase
in classBinarySequence
-
getBases
Get a few bases from this sequence -
getCode
public int getCode(int index) Return the base at position 'index'- Specified by:
getCode
in classBinarySequence
-
getCoder
Description copied from class:BinarySequence
Get sequence encoder invalid input: '&' decoder- Specified by:
getCoder
in classBinarySequence
-
getCodes
public long[] getCodes() -
getSequence
Description copied from class:BinarySequence
Get the sequence as a String- Specified by:
getSequence
in classBinarySequence
-
hashCode
public int hashCode()- Specified by:
hashCode
in classBinarySequence
-
isEmpty
public boolean isEmpty()Is this sequence empty?- Returns:
-
length
public int length()Sequence lenth- Specified by:
length
in classBinarySequence
- Returns:
-
overlap
Creates a new sequence by overlapping 'this' and 'sequence' E.g. this.sequence : |xxxxxxxxxxxxxxxxxxxxOOOOOOOOOOOOOOOOOOOOOOOO | other.sequence : | OOOOOOOOOOOOOOOOOOOOOOOOyyyyyyyyyyyyyyyyy| | |start=20 | result : |xxxxxxxxxxxxxxxxxxxxOOOOOOOOOOOOOOOOOOOOOOOOyyyyyyyyyyyyyyyyy| this.sequence : | OOOOOOOOOOOOOOOOOOOOOOOOxxxxxxxxxxxxxxxxxxxx| other.sequence : |yyyyyyyyyyyyyyyyyyyyyyyyOOOOOOOOOOOOOOOOOOOOOOOO | |start=-20 | result : |yyyyyyyyyyyyyyyyyyyyyyyyOOOOOOOOOOOOOOOOOOOOOOOOxxxxxxxxxxxxxxxxxxxx| Another case is when a sequence is fully included in the other sequence. In this case the result is just a copy of the longest sequence (with the quality updated) E.g. this.sequence : |xxxxxxxxxxxxxxxxxxxxOOOOOOOOOOOOOOOzzzzzzzzz| other.sequence : | OOOOOOOOOOOOOOO | | |start=20 | result : |xxxxxxxxxxxxxxxxxxxxOOOOOOOOOOOOOOOzzzzzzzzz| this.sequence : | OOOOOOOOOOO | other.sequence : |yyyyyyyyyyyyyyyyyyyyyyyyOOOOOOOOOOOzzzzzzzzzzzzz| |start=-20 | result : |yyyyyyyyyyyyyyyyyyyyyyyyOOOOOOOOOOOzzzzzzzzzzzzz|- Overrides:
overlap
in classBinarySequence
- Parameters:
start
-- Returns:
- A new sequence
-
read
Read data in binary format- Specified by:
read
in classBinarySequence
- Throws:
IOException
-
readDataStream
Read data in binary format- Specified by:
readDataStream
in classBinarySequence
- Throws:
IOException
-
reverseWc
Description copied from class:BinarySequence
Reverse Watson-Cricks complement- Specified by:
reverseWc
in classBinarySequence
-
set
Set sequence- Specified by:
set
in classBinarySequence
- Parameters:
seqStr
-
-
set
-
setBase
public void setBase(int index, char base) Replace a base in the sequence -
setCodes
public void setCodes(long[] codes) -
toString
-
write
Write data in binary format- Specified by:
write
in classBinarySequence
- Throws:
IOException
-