package org.biojava.bio.symbol;

import java.util.*;

import org.biojava.bio.seq.*;

/**
 * @author Matthew Pocock
 */  
public class DNANoAmbPack
  implements
    Packing
{
  Symbol placeHolder;
  public DNANoAmbPack(Symbol placeHolder) {
    this.placeHolder = placeHolder;
  }
  
  public FiniteAlphabet getAlphabet() {
    return DNATools.getDNA();
  }
  
  public byte pack(Symbol sym) {
    if(false) {
    } else if(sym == DNATools.a()) {
      return 0;
    } else if(sym == DNATools.g()) {
      return 1;
    } else if(sym == DNATools.c()) {
      return 2;
    } else if(sym == DNATools.t()) {
      return 3;
    }
    
    return pack(placeHolder);
  }
  
  public Symbol unpack(byte b)
  throws IllegalSymbolException {
    if(false) {
    } else if(b == 0) {
      return DNATools.a();
    } else if(b == 1) {
      return DNATools.g();
    } else if(b == 2) {
      return DNATools.c();
    } else if(b == 3) {
      return DNATools.t();
    }
    
    throw new IllegalSymbolException("Can't unpack: " + b);
  }
  
  public byte wordSize() {
    return 2;
  }
  
  public boolean handlesAmbiguity() {
    return false;
  }
}


@@ -108,16 +108,39 @@
  Pocock%0A
+ * @author Thomas Down%0A
  */  %0Apu
@@ -192,22 +192,109 @@
 ing%0A%7B%0A  
-Symbol
+final byte placeHolder;%0A    %0A%0A    public DNANoAmbPack(byte placeHolder) %7B%0A%09this.placeHolder =
  placeHo
@@ -299,16 +299,27 @@
 Holder;%0A
+    %7D%0A  %0A  
   public
@@ -350,24 +350,27 @@
 ceHolder
-) %7B%0A    
+Symbol) %7B%0A%09
 this.pla
@@ -372,32 +372,37 @@
 s.placeHolder = 
+pack(
 placeHolder;%0A  %7D
@@ -396,25 +396,34 @@
 ceHolder
+Symbol)
 ;%0A  
+ 
-%7D
+ %7D%0A
 %0A  
-%0A
   public
@@ -450,28 +450,25 @@
 lphabet() %7B%0A
-    
+%09
 return DNATo
@@ -481,16 +481,18 @@
 tDNA();%0A
+  
   %7D%0A  %0A 
@@ -773,21 +773,16 @@
  return 
-pack(
 placeHol
@@ -784,17 +784,16 @@
 ceHolder
-)
 ;%0A  %7D%0A  

Allow proper differentiation of unknown (e.g. ambiguity) symbols.