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 DnaSequenceclone()intcompareTo(BinarySequence o)static DnaSequenceempty()Empty sequence singletonprotected DnaSequencefactory()Create a new sequencechargetBase(int index)Return the base at position 'index'java.lang.StringgetBases(int index, int len)Get a few bases from this sequenceintgetCode(int index)Return the base at position 'index'CodergetCoder()Get sequence encoder & decoderlong[]getCodes()java.lang.StringgetSequence()Get the sequence as a StringinthashCode()booleanisEmpty()Is this sequence empty?intlength()Sequence lenthBinarySequenceoverlap(BinarySequence sequence, int start)Creates a new sequence by overlapping 'this' and 'sequence' E.g.BinarySequenceread(java.io.DataInputStream dataInStream)Read data in binary formatprotected voidreadDataStream(java.io.DataInputStream dataInStream)Read data in binary formatBinarySequencereverseWc()Reverse Watson-Cricks complementvoidset(java.lang.String seqStr)Set sequencevoidset(java.lang.String seqStr, boolean ignoreErrors)voidsetBase(int index, char base)Replace a base in the sequencevoidsetCodes(long[] codes)java.lang.StringtoString()voidwrite(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:
clonein 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:BinarySequenceReturn the base at position 'index'- Overrides:
getBasein 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:
getCodein classBinarySequence
-
getCoder
public Coder getCoder()
Description copied from class:BinarySequenceGet sequence encoder & decoder- Specified by:
getCoderin classBinarySequence
-
getCodes
public long[] getCodes()
-
getSequence
public java.lang.String getSequence()
Description copied from class:BinarySequenceGet the sequence as a String- Specified by:
getSequencein classBinarySequence
-
hashCode
public int hashCode()
- Specified by:
hashCodein classBinarySequence
-
isEmpty
public boolean isEmpty()
Is this sequence empty?- Returns:
-
length
public int length()
Sequence lenth- Specified by:
lengthin 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:
overlapin 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:
readin classBinarySequence- Throws:
java.io.IOException
-
readDataStream
protected void readDataStream(java.io.DataInputStream dataInStream) throws java.io.IOExceptionRead data in binary format- Specified by:
readDataStreamin classBinarySequence- Throws:
java.io.IOException
-
reverseWc
public BinarySequence reverseWc()
Description copied from class:BinarySequenceReverse Watson-Cricks complement- Specified by:
reverseWcin classBinarySequence
-
set
public void set(java.lang.String seqStr)
Set sequence- Specified by:
setin 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:
toStringin classjava.lang.Object
-
write
public void write(java.io.DataOutputStream dataOutStream) throws java.io.IOExceptionWrite data in binary format- Specified by:
writein classBinarySequence- Throws:
java.io.IOException
-
-