集册 Java实例教程 返回已配置遗传代码的所有停止密码子的数组

返回已配置遗传代码的所有停止密码子的数组

欢马劈雪     最近更新时间:2020-01-02 10:19:05

400
返回已配置遗传代码的所有停止密码子的数组-停止密码子为3个字母的核苷酸字母,例如“TGA”

/*

 **  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;

/**
 * N o w  J a v a  . c o m 提 供 
**/

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);/** from N o w  J a v a  . c o m**/

        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) {
展开阅读全文