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`

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} 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:
  - Serialized Form

## Constructor Summary

Constructors
Constructor
Description
`DnaSequence(int length, long[] codes)`
`DnaSequence(String seqStr)`
`DnaSequence(String seqStr, boolean ignoreErrors)`

## Method Summary

Modifier and Type
Method
Description
`DnaSequence`
`clone()`
`int`
`compareTo(BinarySequence o)`
`static DnaSequence`
`empty()`
Empty sequence singleton
`protected DnaSequence`
`factory()`
Create a new sequence
`char`
`getBase(int index)`
Return the base at position 'index'
`String`
`getBases(int index, int len)`
Get a few bases from this sequence
`int`
`getCode(int index)`
Return the base at position 'index'
`Coder`
`getCoder()`
Get sequence encoder invalid input: '&' decoder
`long[]`
`getCodes()`
`String`
`getSequence()`
Get the sequence as a String
`int`
`hashCode()`
`boolean`
`isEmpty()`
Is this sequence empty?
`int`
`length()`
Sequence lenth
`BinarySequence`
`overlap(BinarySequence sequence, int start)`
Creates a new sequence by overlapping 'this' and 'sequence' E.g.
`BinarySequence`
`read(DataInputStream dataInStream)`
Read data in binary format
`protected void`
`readDataStream(DataInputStream dataInStream)`
Read data in binary format
`BinarySequence`
`reverseWc()`
Reverse Watson-Cricks complement
`void`
`set(String seqStr)`
Set sequence
`void`
`set(String seqStr, boolean ignoreErrors)`
`void`
`setBase(int index, char base)`
Replace a base in the sequence
`void`
`setCodes(long[] codes)`
`String`
`toString()`
`void`
`write(DataOutputStream dataOutStream)`
Write data in binary format

### Methods inherited from class org.snpeff.binseq.BinarySequence

`setQuality`

### Methods inherited from class java.lang.Object

`equals, finalize, getClass, notify, notifyAll, wait, wait, wait`

## Constructor Details

### DnaSequence

public DnaSequence(int length, long[] codes)

### DnaSequence

public DnaSequence(String seqStr)

### DnaSequence

public DnaSequence(String seqStr, boolean ignoreErrors)

## Method Details

### empty

public static DnaSequence empty()
Empty sequence singleton

### clone

public DnaSequence clone()

Overrides:
  `clone` in class `BinarySequence`

### 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 class `BinarySequence`

### getBases

public 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 class `BinarySequence`

### getCoder

public Coder getCoder()
Description copied from class: `BinarySequence`
Get sequence encoder invalid input: '&' decoder

Specified by:
  `getCoder` in class `BinarySequence`

### getCodes

public long[] getCodes()

### getSequence

public String getSequence()
Description copied from class: `BinarySequence`
Get the sequence as a String

Specified by:
  `getSequence` in class `BinarySequence`

### hashCode

public int hashCode()

Specified by:
  `hashCode` in class `BinarySequence`

### isEmpty

public boolean isEmpty()
Is this sequence empty?

Returns:

### length

public int length()
Sequence lenth

Specified by:
  `length` in class `BinarySequence`
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 class `BinarySequence`
Parameters:
  `start` -
Returns:
  A new sequence

### read

public BinarySequence read(DataInputStream dataInStream) throws IOException
Read data in binary format

Specified by:
  `read` in class `BinarySequence`
Throws:
  `IOException`

### readDataStream

protected void readDataStream(DataInputStream dataInStream) throws IOException
Read data in binary format

Specified by:
  `readDataStream` in class `BinarySequence`
Throws:
  `IOException`

### reverseWc

public BinarySequence reverseWc()
Description copied from class: `BinarySequence`
Reverse Watson-Cricks complement

Specified by:
  `reverseWc` in class `BinarySequence`

### set

public void set(String seqStr)
Set sequence

Specified by:
  `set` in class `BinarySequence`
Parameters:
  `seqStr` -

### set

public void set(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 String toString()

Overrides:
  `toString` in class `Object`

### write

public void write(DataOutputStream dataOutStream) throws IOException
Write data in binary format

Specified by:
  `write` in class `BinarySequence`
Throws:
  `IOException`