Main Links
Documentation
Source Code

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.

  1. using BioSharp.Core.Bio.Seq;
  2. using BioSharp.Core.Bio.Symbol;
  3. namespace Cookbook.Alphabets
  4. {
  5. class GetAlphabet
  6. {
  7. public static void Main(string[] args)
  8. {
  9. IAlphabet dna, rna, prot;
  10. // Get the DNA alphabet by name
  11. dna = AlphabetManager.AlphabetForName("DNA");
  12. // Get the RNA alphabet by name
  13. rna = AlphabetManager.AlphabetForName("RNA");
  14. // Get the Protein alphabet by name
  15. prot = AlphabetManager.AlphabetForName("PROTEIN");
  16. // Get the protein alphabet that includes the * termination Symbol
  17. prot = AlphabetManager.AlphabetForName("PROTEIN-TERM");
  18. // Get those same Alphabets from the Tools classes
  19. dna = DNATools.DNA;
  20. rna = RNATools.RNA;
  21. prot = ProteinTools.Alphabet;
  22. // or the one with the * symbol
  23. prot = ProteinTools.TAlphabet;
  24. }
  25. }
  26. }