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} <=> {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 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 & 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
    • 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