package coalescent.dna;
import java.util.*;

/**
 *  Basic class representing sequence 
 */ 
public class Nucleotide{
	private  static final String Code="agctAGCTnN-mMrRwWsSyYkK";
	private  static final char[][] Bases={ 
	{'a','a'}, {'g','g'}, {'c','c'}, {'t','t'},
	{'a','a'}, {'g','g'}, {'c','c'}, {'t','t'},
	{'n','n'}, {'n','n'}, {'-','-'},
	{'a','c'}, {'c','a'}, // m and M 
	{'a','g'}, {'g','a'}, // r and R 
	{'a','t'}, {'t','a'}, // w and W 
	{'c','g'}, {'g','c'}, // s and S
	{'c','t'}, {'t','c'}, // y and Y
	{'g','t'}, {'t','g'}  // k and K
	};

	/**
	* retrun the two nucleotide represented by a letter
	*/
	public static char[] unpack(char a)
	{
		return Bases[Code.indexOf(a)];
	}
	/**
	* retrun the letter representing a ordered pair (a,b)
	*/
	public static char pack(char a, char b)
	{
		for(int i=0; i<Bases.length; i++){
			if( a == Bases[i][0] && b == Bases[i][1]) 
				return Code.charAt(i);
		}
		return 'n';
	}
	/**
	*
	*/
	public static boolean isAmbiguous(char a)
	{
		return (Code.indexOf(a)>10)?true:false;
	}
}
