001package com.hfg.bio.seq.translation;
002
003//------------------------------------------------------------------------------
004/**
005 Standard translation table for mapping codons to amino acids.
006 <div>
007  @author J. Alex Taylor, hairyfatguy.com
008 </div>
009 */
010//------------------------------------------------------------------------------
011// com.hfg Library
012//
013// This library is free software; you can redistribute it and/or
014// modify it under the terms of the GNU Lesser General Public
015// License as published by the Free Software Foundation; either
016// version 2.1 of the License, or (at your option) any later version.
017//
018// This library is distributed in the hope that it will be useful,
019// but WITHOUT ANY WARRANTY; without even the implied warranty of
020// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
021// Lesser General Public License for more details.
022//
023// You should have received a copy of the GNU Lesser General Public
024// License along with this library; if not, write to the Free Software
025// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
026//
027// J. Alex Taylor, President, Founder, CEO, COO, CFO, OOPS hairyfatguy.com
028// jataylor@hairyfatguy.com
029//------------------------------------------------------------------------------
030
031public class StandardTranslationTable implements TranslationTable
032{
033   private CodonTable mCodonTable;
034
035   private static StandardTranslationTable sInstance;
036
037   //###########################################################################
038   // CONSTRUCTORS
039   //###########################################################################
040
041   //---------------------------------------------------------------------------
042   private StandardTranslationTable()
043   {
044      String rsrc = "codondata/standard.cod.xml.gz";
045
046      mCodonTable = new CodonTable(rsrc);
047   }
048
049   //###########################################################################
050   // PUBLIC METHODS
051   //###########################################################################
052
053   //---------------------------------------------------------------------------
054   public static synchronized StandardTranslationTable getInstance()
055   {
056      if (null == sInstance)
057      {
058         sInstance = new StandardTranslationTable();
059      }
060
061      return sInstance;
062   }
063
064   //---------------------------------------------------------------------------
065   /**
066    Converts the specified codon (3 nucleotides) into a character representing
067    the corresponding amino acid.
068    @param inCodon 3-letter nucleotide (DNA or RNA) string to be translated
069    @return single letter amino acid
070    */
071   public char translateCodon(String inCodon)
072   {
073      return mCodonTable.translateCodon(inCodon);
074   }
075}