Class RNATools

java.lang.Object
org.biojava.bio.seq.RNATools

public final class RNATools extends Object
Useful functionality for processing DNA and RNA sequences.
Author:
Matthew Pocock, Keith James (docs), Thomas Down, Greg Cox, Mark Schreiber, David Huen (refactoring), gwaldon (update genetic code translation tables)
  • Method Details

    • a

      public static AtomicSymbol a()
    • g

      public static AtomicSymbol g()
    • c

      public static AtomicSymbol c()
    • u

      public static AtomicSymbol u()
    • n

      public static Symbol n()
    • getRNA

      public static FiniteAlphabet getRNA()
      Return the RNA alphabet.
      Returns:
      a flyweight version of the RNA alphabet
    • getCodonAlphabet

      Gets the (RNA x RNA x RNA) Alphabet
      Returns:
      a flyweight version of the (RNA x RNA x RNA) alphabet
    • createRNA

      public static SymbolList createRNA(String rna) throws IllegalSymbolException
      Return a new RNA SymbolList for rna.
      Parameters:
      rna - a String to parse into RNA
      Returns:
      a SymbolList created form rna
      Throws:
      IllegalSymbolException - if rna contains any non-RNA characters
    • createRNASequence

      public static Sequence createRNASequence(String rna, String name) throws IllegalSymbolException
      Return a new RNA Sequence for rna.
      Parameters:
      rna - a String to parse into RNA
      name - a String to use as the name
      Returns:
      a Sequence created form dna
      Throws:
      IllegalSymbolException - if rna contains any non-DNA characters
    • index

      public static int index(Symbol sym) throws IllegalSymbolException
      Return an integer index for a symbol - compatible with forIndex.

      The index for a symbol is stable across virtual machines invalid input: '&' invocations.

      Parameters:
      sym - the Symbol to index
      Returns:
      the index for that symbol
      Throws:
      IllegalSymbolException - if sym is not a member of the DNA alphabet
    • forIndex

      public static Symbol forIndex(int index) throws IndexOutOfBoundsException
      Return the symbol for an index - compatible with index.

      The index for a symbol is stable accross virtual machines invalid input: '&' invocations.

      Parameters:
      index - the index to look up
      Returns:
      the symbol at that index
      Throws:
      IndexOutOfBoundsException - if index is not between 0 and 3
    • complement

      public static Symbol complement(Symbol sym) throws IllegalSymbolException
      Complement the symbol.
      Parameters:
      sym - the symbol to complement
      Returns:
      a Symbol that is the complement of sym
      Throws:
      IllegalSymbolException - if sym is not a member of the RNA alphabet
    • forSymbol

      public static Symbol forSymbol(char token) throws IllegalSymbolException
      Retrieve the symbol for a symbol.
      Parameters:
      token - the char to look up
      Returns:
      the symbol for that char
      Throws:
      IllegalSymbolException - if the char is not a valid IUB code.
    • complement

      Retrieve a complement view of list.
      Parameters:
      list - the SymbolList to complement
      Returns:
      a SymbolList that is the complement
      Throws:
      IllegalAlphabetException - if list is not a complementable alphabet
    • reverseComplement

      Retrieve a reverse-complement view of list.
      Parameters:
      list - the SymbolList to complement
      Returns:
      a SymbolList that is the complement
      Throws:
      IllegalAlphabetException - if list is not a complementable alphabet
    • transcribe

      Deprecated.
      The naming of this method is confusing and inconsistent use either DNATools.toRNA(SymbolList list) or DNATools.transcribeToRNA(SymbolList list) depending on the desired behaivour.
      Transcribe DNA into RNA.
      Parameters:
      list - the SymbolList to transcribe
      Returns:
      a SymbolList that is the transcribed view
      Throws:
      IllegalAlphabetException - if the list is not DNA
    • complementTable

      Get a translation table for complementing DNA symbols.
      Since:
      1.1
    • transcriptionTable

      Get a translation table for converting DNA to RNA.
      Since:
      1.1
    • getGeneticCode

      Retrieve a TranslationTable by name. The valid names are:
      • "UNIVERSAL"
      • "VERTEBRATE_MITOCHONDRIAL"
      • "YEAST_MITOCHONDRIAL"
      • "MOLD_MITOCHONDRIAL"
      • "INVERTEBRATE_MITOCHONDRIAL"
      • "CILIATE_NUCLEAR"
      • "ECHINODERM_MITOCHONDRIAL"
      • "EUPLOTID_NUCLEAR"
      • "BACTERIAL"
      • "ALTERNATIVE_YEAST_NUCLEAR"
      • "ASCIDIAN_MITOCHONDRIAL"
      • "FLATWORM_MITOCHONDRIAL"
      • "BLEPHARISMA_MACRONUCLEAR"
      • "CHLOROPHYCEAN_MITOCHONDRIAL"
      • "TREMATODE_MITOCHONDRIAL"
      • "SCENEDESMUS_MITOCHONDRIAL"
      There are public static final fields in the TranslationTable interface which contain these values. One of these should be used as the argument for this method.

      You can now get the reverse translation of the residue back to its (usually several) codons too.

      Since:
      1.1
    • getGeneticCode

      public static ManyToOneTranslationTable getGeneticCode(int table_num)
      Retrieve a TranslationTable by number. These numbers correspond to the transl_table qualifier in the DDBJ/EMBL/GenBank Feature Table (Version 6.5 Apr 2006): transl_table defines the genetic code table used if other than the universal genetic code table. Tables are described in appendix V, section 7.5.5:
      • " 1 - UNIVERSAL"
      • " 2 - VERTEBRATE_MITOCHONDRIAL"
      • " 3 - YEAST_MITOCHONDRIAL"
      • " 4 - MOLD_MITOCHONDRIAL"
      • " 5 - INVERTEBRATE_MITOCHONDRIAL"
      • " 6 - CILIATE_NUCLEAR"
      • " 9 - ECHINODERM_MITOCHONDRIAL"
      • "10 - EUPLOTID_NUCLEAR"
      • "11 - BACTERIAL"
      • "12 - ALTERNATIVE_YEAST_NUCLEAR"
      • "13 - ASCIDIAN_MITOCHONDRIAL"
      • "14 - FLATWORM_MITOCHONDRIAL"
      • "15 - BLEPHARISMA_MACRONUCLEAR"
      • "16 - 2CHLOROPHYCEAN_MITOCHONDRIAL"
      • "21 - TREMATODE_MITOCHONDRIAL"
      • "23 - SCENEDESMUS_MITOCHONDRIAL"
      Throws:
      IllegalArgumentException - if there is no table with that number.
      Since:
      1.5
    • getGeneticCodeNames

      public static Set getGeneticCodeNames()
      Retrieve a Set containing the name of each genetic code.
      Since:
      1.1
    • translate

      Translate RNA into protein (with termination symbols). For compatibility with BioJava 1.1, this will also handle sequences which are already expressed in the (RNA x RNA x RNA) (codon) alphabet.
      Throws:
      IllegalAlphabetException
      Since:
      1.1