# Class BinarySequence

java.lang.Object
org.snpeff.binseq.BinarySequence

All Implemented Interfaces:
  `Serializable, Cloneable, Comparable<BinarySequence>`

Direct Known Subclasses:
  `DnaAndQualitySequence, DnaSequence, DnaSequencePe`

public abstract class BinarySequence extends Object implements Comparable<BinarySequence>, Serializable, Cloneable
Base class for a binary 'read'. I.e. a binary representation of a sequencer's read A read is a short DNA fragment (short now means anywhere from 36 bases to 10K).

Author:
  pcingola
See Also:
  - Serialized Form

## Constructor Summary

Constructors
Constructor
Description
`BinarySequence()`

## Method Summary

Modifier and Type
Method
Description
`BinarySequence`
`clone()`
`char`
`getBase(int index)`
Return the base at position 'index'
`abstract int`
`getCode(int index)`
Return the code at position 'index'
`abstract Coder`
`getCoder()`
Get sequence encoder invalid input: '&' decoder
`abstract String`
`getSequence()`
Get the sequence as a String
`abstract int`
`hashCode()`
`abstract int`
`length()`
Get sequence length
`BinarySequence`
`overlap(BinarySequence sequence, int start)`
Creates a new sequence by overlapping 'this' and 'sequence' E.g.
`abstract BinarySequence`
`read(DataInputStream dataInStream)`
Read a sequence from a data stream
`protected abstract void`
`readDataStream(DataInputStream dataInStream)`
`abstract BinarySequence`
`reverseWc()`
Reverse Watson-Cricks complement
`abstract void`
`set(String seqStr)`
Set sequence from a string
`void`
`setQuality(int index, int quality)`
Set the quality at position 'index'
`abstract void`
`write(DataOutputStream dataOutStream)`
Write to a binary stream

### Methods inherited from class Object

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

### Methods inherited from interface Comparable

`compareTo`

## Constructor Details

### BinarySequence

public BinarySequence()

## Method Details

### getBase

public char getBase(int index)
Return the base at position 'index'

### clone

public BinarySequence clone()

Overrides:
  `clone` in class `Object`

### getCode

public abstract int getCode(int index)
Return the code at position 'index'

### getCoder

public abstract Coder getCoder()
Get sequence encoder invalid input: '&' decoder

### getSequence

public abstract String getSequence()
Get the sequence as a String

### hashCode

public abstract int hashCode()

Overrides:
  `hashCode` in class `Object`

### length

public abstract int length()
Get sequence length

### 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 : |xxxxxxxxxxxxxxxxxxxxOOOOOOOOOOOOOOOOOOOOOOOO| other.sequence : | OOOOOOOOOOOOOOO | | |start=20 | result : |xxxxxxxxxxxxxxxxxxxxOOOOOOOOOOOOOOOOOOOOOOOO| this.sequence : | OOOOOOOOOOO | other.sequence : |yyyyyyyyyyyyyyyyyyyyyyyyOOOOOOOOOOOOOOOOOOOOOOOO| |start=-20 | result : |yyyyyyyyyyyyyyyyyyyyyyyyOOOOOOOOOOOOOOOOOOOOOOOO|

### read

public abstract BinarySequence read(DataInputStream dataInStream) throws IOException
Read a sequence from a data stream

Throws:
  `IOException`

### readDataStream

protected abstract void readDataStream(DataInputStream dataInStream) throws IOException

Throws:
  `IOException`

### reverseWc

public abstract BinarySequence reverseWc()
Reverse Watson-Cricks complement

### set

public abstract void set(String seqStr)
Set sequence from a string

Parameters:
  `seqStr` -

### setQuality

public void setQuality(int index, int quality)
Set the quality at position 'index'

### write

public abstract void write(DataOutputStream dataOutStream) throws IOException
Write to a binary stream

Throws:
  `IOException`