Java examples for Data Structure:DNA
Return array of all stop codons for the configured genetic code - stop codons as 3 letter nucleotide letters eg "TGA"
/*// w w w . j a va 2 s . c o m ** DNAUtils ** (c) Copyright 1997, Neomorphic Sofware, Inc. ** All Rights Reserved ** ** CONFIDENTIAL ** DO NOT DISTRIBUTE ** ** File: DNAUtils.java ** */ import java.util.List; import java.util.ArrayList; public class Main{ private static List stopCodonCharArrayList; /** Genetic Code in 1-character amino acid codes. by default set to default genetic code 1 */ protected static String aa1[][][] = aa1Default; /** ascii character codes for each nucleotide (or set of nucleotides). */ protected static char[] id_to_letter = new char[LETTERS]; /** Return array of all stop codons for the configured genetic code - stop codons as 3 letter nucleotide letters eg "TGA" */ public static String[] get3NucleotideStopCodons() { //synchGeneticCodeWithConfig(); if (threeNucleotideStopCodons == null) { createStopCodons(); } return threeNucleotideStopCodons; } private static void createStopCodons() { List stopList = new ArrayList(5); stopCodonCharArrayList = new ArrayList(5); for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { for (int k = 0; k < 4; k++) { if (aa1[i][j][k].equals("*")) { String codon = get3LetterCodeFromInts(i, j, k); stopList.add(codon); char[] charCodon = getCharArrayCodonFromInts(i, j, k); stopCodonCharArrayList.add(charCodon); } } } } String[] threeNucleotideStopCodons = new String[stopList.size()]; for (int i = 0; i < stopList.size(); i++) threeNucleotideStopCodons[i] = (String) stopList.get(i); } private static String get3LetterCodeFromInts(int i, int j, int k) { return "" + getResidueChar(i) + getResidueChar(j) + getResidueChar(k); } private static char[] getCharArrayCodonFromInts(int i, int j, int k) { return new char[] { getResidueChar(i), getResidueChar(j), getResidueChar(k) }; } /** * gets a nucleotide code. * * @param residue_id ordinal of nucleotide letter code. * @return letter representation of a nucleotide. * @see #getResidueChar */ public static char getResidueChar(int residue_id) { return id_to_letter[residue_id]; } }