Class Coder

  • All Implemented Interfaces:
    java.io.Serializable
    Direct Known Subclasses:
    DnaCoder

    public abstract class Coder
    extends java.lang.Object
    implements java.io.Serializable
    Class used to encode & decode sequences into binary and vice-versa They are usually stored in 'long' words
    Author:
    pcingola
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      Coder()  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      abstract int basesPerWord()
      How many bases can we pack in a word
      abstract int baseToBits​(char c)
      Encode a base using a binary representation
      abstract int bitsPerBase()
      How many bits do we need for each base
      abstract int decodeWord​(long word, int pos)
      Decode bits from a given position in a word
      abstract int lastBaseinWord()
      Index of the last base coded in a word
      abstract long mask​(int baseIndexInWord)
      Bitmask for a base in a word
      int qualityToBits​(int q)
      Encode a quality using a binary representation
      abstract char toBase​(int code)
      Decode a base using a binary representation
      abstract char toBase​(long word, int pos)
      Decode a base from a given position in a word
      int toQuality​(int code)
      Decode a quality
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Coder

        public Coder()
    • Method Detail

      • basesPerWord

        public abstract int basesPerWord()
        How many bases can we pack in a word
        Returns:
      • baseToBits

        public abstract int baseToBits​(char c)
        Encode a base using a binary representation
        Parameters:
        c -
        Returns:
      • bitsPerBase

        public abstract int bitsPerBase()
        How many bits do we need for each base
        Returns:
      • decodeWord

        public abstract int decodeWord​(long word,
                                       int pos)
        Decode bits from a given position in a word
        Parameters:
        word -
        pos -
        Returns:
      • lastBaseinWord

        public abstract int lastBaseinWord()
        Index of the last base coded in a word
        Returns:
      • mask

        public abstract long mask​(int baseIndexInWord)
        Bitmask for a base in a word
        Returns:
      • qualityToBits

        public int qualityToBits​(int q)
        Encode a quality using a binary representation
        Parameters:
        c -
        Returns:
      • toBase

        public abstract char toBase​(int code)
        Decode a base using a binary representation
        Parameters:
        c -
        Returns:
      • toBase

        public abstract char toBase​(long word,
                                    int pos)
        Decode a base from a given position in a word
        Parameters:
        word -
        pos -
        Returns:
      • toQuality

        public int toQuality​(int code)
        Decode a quality
        Parameters:
        c -
        Returns: