# Class Coder

java.lang.Object
org.snpeff.binseq.coder.Coder

All Implemented Interfaces:
  `Serializable`

Direct Known Subclasses:
  `DnaCoder`

public abstract class Coder extends Object implements Serializable
Class used to encode invalid input: '&' decode sequences into binary and vice-versa They are usually stored in 'long' words

Author:
  pcingola
See Also:
  - Serialized Form

## Field Summary

Fields
Modifier and Type
Field
Description
`static final int`
`BITS_PER_LONGWORD`
`static final int`
`BYTES_PER_LONGWORD`

## Constructor Summary

Constructors
Constructor
Description
`Coder()`

## Method Summary

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 Object

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

## Field Details

### BITS_PER_LONGWORD

public static final int BITS_PER_LONGWORD

See Also:
  - Constant Field Values

### BYTES_PER_LONGWORD

public static final int BYTES_PER_LONGWORD

See Also:
  - Constant Field Values

## Constructor Details

### Coder

public Coder()

## Method Details

### 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: