Package org.snpeff.binseq
Class DnaSequence
- java.lang.Object
-
- org.snpeff.binseq.BinarySequence
-
- org.snpeff.binseq.DnaSequence
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
,java.lang.Comparable<BinarySequence>
- Direct Known Subclasses:
DnaNSequence
,DnaSequenceId
public class DnaSequence extends BinarySequence
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} <=> {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:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description DnaSequence(int length, long[] codes)
DnaSequence(java.lang.String seqStr)
DnaSequence(java.lang.String seqStr, boolean ignoreErrors)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description DnaSequence
clone()
int
compareTo(BinarySequence o)
static DnaSequence
empty()
Empty sequence singletonprotected DnaSequence
factory()
Create a new sequencechar
getBase(int index)
Return the base at position 'index'java.lang.String
getBases(int index, int len)
Get a few bases from this sequenceint
getCode(int index)
Return the base at position 'index'Coder
getCoder()
Get sequence encoder & decoderlong[]
getCodes()
java.lang.String
getSequence()
Get the sequence as a Stringint
hashCode()
boolean
isEmpty()
Is this sequence empty?int
length()
Sequence lenthBinarySequence
overlap(BinarySequence sequence, int start)
Creates a new sequence by overlapping 'this' and 'sequence' E.g.BinarySequence
read(java.io.DataInputStream dataInStream)
Read data in binary formatprotected void
readDataStream(java.io.DataInputStream dataInStream)
Read data in binary formatBinarySequence
reverseWc()
Reverse Watson-Cricks complementvoid
set(java.lang.String seqStr)
Set sequencevoid
set(java.lang.String seqStr, boolean ignoreErrors)
void
setBase(int index, char base)
Replace a base in the sequencevoid
setCodes(long[] codes)
java.lang.String
toString()
void
write(java.io.DataOutputStream dataOutStream)
Write data in binary format-
Methods inherited from class org.snpeff.binseq.BinarySequence
setQuality
-
-
-
-
Method Detail
-
empty
public static DnaSequence empty()
Empty sequence singleton
-
clone
public DnaSequence clone()
- Overrides:
clone
in classBinarySequence
-
compareTo
public int compareTo(BinarySequence o)
-
factory
protected DnaSequence 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
public java.lang.String getBases(int index, int len)
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
public Coder getCoder()
Description copied from class:BinarySequence
Get sequence encoder & decoder- Specified by:
getCoder
in classBinarySequence
-
getCodes
public long[] getCodes()
-
getSequence
public java.lang.String 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
public BinarySequence overlap(BinarySequence sequence, int start)
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
public BinarySequence read(java.io.DataInputStream dataInStream) throws java.io.IOException
Read data in binary format- Specified by:
read
in classBinarySequence
- Throws:
java.io.IOException
-
readDataStream
protected void readDataStream(java.io.DataInputStream dataInStream) throws java.io.IOException
Read data in binary format- Specified by:
readDataStream
in classBinarySequence
- Throws:
java.io.IOException
-
reverseWc
public BinarySequence reverseWc()
Description copied from class:BinarySequence
Reverse Watson-Cricks complement- Specified by:
reverseWc
in classBinarySequence
-
set
public void set(java.lang.String seqStr)
Set sequence- Specified by:
set
in classBinarySequence
-
set
public void set(java.lang.String seqStr, boolean ignoreErrors)
-
setBase
public void setBase(int index, char base)
Replace a base in the sequence
-
setCodes
public void setCodes(long[] codes)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
write
public void write(java.io.DataOutputStream dataOutStream) throws java.io.IOException
Write data in binary format- Specified by:
write
in classBinarySequence
- Throws:
java.io.IOException
-
-