bioinformatics - how to get all dna encoding for peptide in c# -



bioinformatics - how to get all dna encoding for peptide in c# -

hi head boiling 3 days! want deoxyribonucleic acid encodings peptide: peptide sequence of amino acids i.e. amino acid m , amino acid q can form peptide mq or qm

dna encoding means there deoxyribonucleic acid code (called codon) each amino acid (for there more 1 code i.e. amino acid t has 4 different codes / codons)

the lastly function in next code not working want 1 create work me , please no query integrated language (i forgot acronym!)`

private string[] codons ={ "ttt", "ttc", "tta", "ttg", "tct", "tcc", "tca", "tcg", "tat", "tac", "tgt", "tgc", "tgg", "ctt", "ctc", "cta", "ctg", "cct", "ccc", "cca", "ccg", "cat", "cac", "caa", "cag", "cgt", "cgc", "cga", "cgg", "att", "atc", "ata", "atg", "act", "acc", "aca", "acg", "aat", "aac", "aaa", "aag", "agt", "agc", "aga", "agg", "gtt", "gtc", "gta", "gtg", "gct", "gcc", "gca", "gcg", "gat", "gac", "gaa", "gag", "ggt", "ggc", "gga", "ggg", }; private string[] aminos_per_codon = { "f", "f", "l", "l", "s", "s", "s", "s", "y", "y", "c", "c", "w", "l", "l", "l", "l", "p", "p", "p", "p", "h", "h", "q", "q", "r", "r", "r", "r", "i", "i", "i", "m", "t", "t", "t", "t", "n", "n", "k", "k", "s", "s", "r", "r", "v", "v", "v", "v", "a", "a", "a", "a", "d", "d", "e", "e", "g", "g", "g", "g", }; public string codontoaminoacid(string codon) { (int k = 0; k < codons.length; k++) { if (codons[k].equals(codon)) { homecoming aminos_per_codon[k]; } } // never reach here valid codon homecoming "x"; } public string aminoacidtocodon(string aminoacid) { (int k = 0; k < aminos_per_codon .length; k++) { if (aminos_per_codon [k].equals(aminoacid )) { homecoming codons[k]; } } // never reach here valid codon homecoming "x"; } public string getcodonsforpeptide(string pep) { string result = ""; (int = 0; <pep.length ; i++) { result = aminoacidtocodon(pep.substring (i,1) ); (int q = 0; q < pep.length; q++) { result += aminoacidtocodon(pep.substring(q, 1)); } } homecoming result; }

try using next 2 methods:

public ienumerable<string> aminoacidtocodon(char aminoacid) { (int k = 0; k < aminos_per_codon.length; k++) { if (aminos_per_codon[k] == aminoacid) { yield homecoming codons[k]; } } } public ienumerable<string> getcodonsforpeptide(string pep) { if (string.isnullorempty(pep)) { yield homecoming string.empty; yield break; } foreach (var codon in aminoacidtocodon(pep[0])) foreach (var codonofrest in getcodonsforpeptide(pep.substring(1))) yield homecoming codon + codonofrest; }

notes:

since each amino acid have multiple matching codons, method returns when finds first ever match each amino acid once. instead created enumerator method yield return each matching codon. the lastly method finds matching codons first character of peptide, , combines each such codon codons made of rest of peptide after first character. i made aminos_per_codon array utilize char type instead. can alter code utilize string array if want. a improve approach without 2 separate arrays create dictionary mapping each single amino acid character list of codon strings.

example output when passing in "ma":

atggct atggcc atggca atggcg

this because m maps these:

atg

and a maps these:

gct gcc gca gcg

the dictionary suggest utilize this:

var codonsbyaminoacid = new dictionary<char, string[]> { { 'm', new[] { "atg" } }, { 'a', new[] { "gct", "gcc", "gca", "gcg" } } };

this replace aminoacidtocodon method.

you can build dictionary 2 arrays:

var lookup = codons .zip(aminos_per_codon, (codon, amino) => new { codon, amino }) .groupby(entry => entry.amino) .todictionary( g => g.key, g => g.select(ge => ge.codon).toarray());

the getcodonsforpeptide method this:

public ienumerable<string> getcodonsforpeptide(string pep) { if (string.isnullorempty(pep)) { yield homecoming string.empty; yield break; } foreach (var codon in lookup(pep[0])) foreach (var codonofrest in getcodonsforpeptide(pep.substring(1))) yield homecoming codon + codonofrest; }

ie. replace phone call other method lookup table.

c# bioinformatics

Comments

Popular posts from this blog

assembly - What is the addressing mode for ld, add, and rjmp instructions? -

vowpalwabbit - Interpreting Vowpal Wabbit results: Why are some lines appended by "h"? -

Is there a way to convert an HTML page styled with Bootstrap CSS into email-compatible html? -