How do I get a DNA, RNA or Protein Alphabet? - Cookbook - BioSharp
In BioSharp, Alphabets are collections of Symbols, represented by the IAlphabet and ISymbol interfaces. Common biological alphabets (DNA, RNA, protein, etc) are registered with the BioSharp 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.
- using BioSharp.Core.Bio.Seq;
- using BioSharp.Core.Bio.Symbol;
- namespace Cookbook.Alphabets
- {
- class GetAlphabet
- {
- public static void Main(string[] args)
- {
- IAlphabet dna, rna, prot;
- // 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
- prot = AlphabetManager.AlphabetForName("PROTEIN-TERM");
- // Get those same Alphabets from the Tools classes
- dna = DNATools.DNA;
- rna = RNATools.RNA;
- prot = ProteinTools.Alphabet;
- // or the one with the * symbol
- prot = ProteinTools.TAlphabet;
- }
- }
- }