Class 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 Detail

      • DnaSequence

        public DnaSequence​(int length,
                           long[] codes)
      • DnaSequence

        public DnaSequence​(java.lang.String seqStr)
      • DnaSequence

        public DnaSequence​(java.lang.String seqStr,
                           boolean ignoreErrors)
    • Method Detail

      • empty

        public static DnaSequence empty()
        Empty sequence singleton
      • factory

        protected DnaSequence factory()
        Create a new sequence
      • 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 class BinarySequence
      • getCodes

        public long[] getCodes()
      • 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​(java.io.DataInputStream dataInStream)
                            throws java.io.IOException
        Read data in binary format
        Specified by:
        read in class BinarySequence
        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 class BinarySequence
        Throws:
        java.io.IOException
      • set

        public void set​(java.lang.String seqStr)
        Set sequence
        Specified by:
        set in class BinarySequence
      • 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 class java.lang.Object
      • write

        public void write​(java.io.DataOutputStream dataOutStream)
                   throws java.io.IOException
        Write data in binary format
        Specified by:
        write in class BinarySequence
        Throws:
        java.io.IOException