001/*
002 *                    BioJava development code
003 *
004 * This code may be freely distributed and modified under the
005 * terms of the GNU Lesser General Public Licence.  This should
006 * be distributed with the code.  If you do not have a copy,
007 * see:
008 *
009 *      http://www.gnu.org/copyleft/lesser.html
010 *
011 * Copyright for this code is held jointly by the individual
012 * authors.  These should be listed in @author doc comments.
013 *
014 * For more information on the BioJava project and its aims,
015 * or to join the biojava-l mailing list, visit the home page
016 * at:
017 *
018 *      http://www.biojava.org/
019 *
020 */
021
022package org.biojava.bio.seq;
023
024import org.biojava.bio.symbol.IllegalAlphabetException;
025import org.biojava.bio.symbol.SymbolList;
026
027/**
028 * Collects the references to translation methods in one place.  Right now this
029 * is just a wrapper on RNATools
030 *
031 * @author Greg Cox
032 */
033public class GeneticCodes
034{
035// Static variables
036
037// Member variables
038
039// Constructors and initialization
040
041    private GeneticCodes() {
042    }
043
044// Interface implementations
045
046// Public methods
047        /**
048         * Transcribe DNA into RNA.
049         *
050         * @param theList the SymbolList of DNA symbols to transcribe
051         * @return a SymbolList that is the transcribed view
052         * @throws IllegalAlphabetException if the list is not DNA
053         */
054        public static SymbolList transcribe(SymbolList theList)
055                throws IllegalAlphabetException
056        {
057                return RNATools.transcribe(theList);
058        }
059
060        /**
061         * Translate RNA into protein (with termination symbols).
062         *
063         * @param theList the SymbolList of RNA symbols to translate
064         * @return a SymbolList that is the translated view
065         * @throws IllegalAlphabetException if the list is not RNA
066         * @since 1.1
067         */
068        public static SymbolList translate(SymbolList theList)
069                throws IllegalAlphabetException
070        {
071                SymbolList returnList = null;
072                try
073                {
074                        // Assume it's a RNA list
075                        returnList = RNATools.translate(theList);
076                }
077                catch(IllegalAlphabetException iae)
078                {
079                        // Since it isn't, lets try DNA.  If this fails, the method fails,
080                        // so we won't catch the exception
081                        SymbolList tempList = GeneticCodes.transcribe(theList);
082                        returnList = RNATools.translate(tempList);
083                }
084                return returnList;
085        }
086
087// Protected methods
088
089// Private methods
090}