BioJava:Cookbook:Alphabets
From BioJava
How do I get a DNA, RNA or Protein Alphabet?
In BioJava Alphabets are collections of Symbols. Common biological alphabets (DNA, RNA, protein, etc) are registered with the BioJava AlphabetManager at startup and can be accessed by name. The DNA, RNA and protein alphabets can also be accessed using convenient static methods from DNATools, RNATools and ProteinTools respectively.
Both of these approaches are shown in the example below
package biojava_in_anger; import org.biojava.bio.symbol.*; import java.util.*; import org.biojava.bio.seq.*; public class AlphabetExample { public static void main(String[] args) { Alphabet dna, rna, prot, proteinterm; //get the DNA alphabet by name dna = AlphabetManager.alphabetForName("DNA"); //get the RNA alphabet by name rna = AlphabetManager.alphabetForName("RNA"); //get the Protein alphabet by name prot = AlphabetManager.alphabetForName("PROTEIN"); //get the protein alphabet that includes the * termination Symbol proteinterm = AlphabetManager.alphabetForName("PROTEIN-TERM"); //get those same Alphabets from the Tools classes dna = DNATools.getDNA(); rna = RNATools.getRNA(); prot = ProteinTools.getAlphabet(); //or the one with the * symbol proteinterm = ProteinTools.getTAlphabet(); } }

