package org.broadinstitute.sting.utils.analysis; import java.util.HashMap; /* * Copyright (c) 2010 The Broad Institute * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation * files (the "Software"), to deal in the Software without * restriction, including without limitation the rights to use, * copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following * conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. */ /** * @author chartl * @since June 28, 2010 */ public class AminoAcidTable { public HashMap tableByCodon = new HashMap(21); public HashMap tableByCode = new HashMap(21); public AminoAcidTable() { for ( AminoAcid acid : AminoAcid.values() ) { tableByCode.put(acid.getCode(),acid); for ( String codon : acid.codons ) { tableByCodon.put(codon,acid); } } } // todo -- these functions are for the genomic annotator and are named too generally -- they are // todo -- actually accessors by codon; thus should be more specific. public AminoAcid getEukaryoticAA(String codon) { return tableByCodon.get(codon.toUpperCase()); } public AminoAcid getMitochondrialAA(String codon, boolean isFirst) { String upperCodon = codon.toUpperCase(); if ( isFirst && upperCodon.equals("ATT") || upperCodon.equals("ATA") ) { return AminoAcid.Methionine; } else if ( upperCodon.equals("AGA") || upperCodon.equals("AGG") ) { return AminoAcid.Stop_codon; } else if ( upperCodon.equals("TGA") ) { return AminoAcid.Tryptophan; } else { return tableByCodon.get(upperCodon); } } public AminoAcid getAminoAcidByCode(String code) { return tableByCode.get(code); } }