Note that there are some explanatory texts on larger screens.

plurals
  1. POconversion of DNA to Protein - c structure issue
    text
    copied!<p>I am working on conversion of DNA sequence to Protein sequence.<br> I had completed all program only one error I found there is of structure.<br> dna_codon is a structure and I am iterating over it.In first iteration it shows proper values of structure but from next iteration, it dont show the proper value stored in structure. </p> <p>Its a small error so do not think that I havnt done anything and downvote. I am stucked here because I am new in c for structures. </p> <p>CODE : </p> <pre><code>#include &lt;stdio.h&gt; #include&lt;string.h&gt; void main() { int i, len; char short_codons[20]; char short_slc[1000]; char sequence[1000]; struct codons { char amino_acid[20], slc[20], dna_codon[40]; }; struct codons c1 [20]= { {"Isoleucine", "I", "ATT, ATC, ATA"}, {"Leucine", "L", "CTT, CTC, CTA, CTG, TTA, TTG"}, {"Valine", "V", "GTT, GTC, GTA, GTG"}, {"Phenylalanine", "F", "TTT, TTC"}, {"Methionine", "M", "ATG"}, {"Cysteine", "C", "TGT, TGC"}, {"Alanine", "A", "GCT, GCC, GCA, GCG"}, {"Proline", "P", "CCT, CCC, CCA,CCG "}, {"Threonine", "T", "ACT, ACC, ACA, ACG"}, {"Serine", "S", "TCT, TCC, TCA, TCG, AGT, AGC"}, {"Tyrosine", "Y", "TAT, TAC"}, {"Tryptophan", "W", "TGG"}, {"Glutamine", "Q", "CAA, CAG"}, {"Aspargine","N" "AAT, AAC"}, {"Histidine", "H", "CAT, CAC"}, {"Glutamic acid", "E", "GAA, GAG"}, {"Aspartic acid", "D", "GAT, GAC"}, {"Lysine", "K", "AAA, AAG"}, {"Arginine", "R", "CGT, CGC, CGA, CGG, AGA, AGG"}, {"Stop codons", "Stop", "AA, TAG, TGA"} }; int count = 0; printf("Enter the sequence: "); gets(sequence); char *input_string = sequence; char *tmp_str = input_string; int k; char *pch; while (*input_string != '\0') { char string_3l[4] = {'\0'}; strncpy(string_3l, input_string, 3); printf("\n-----------%s &amp; %s----------", string_3l, tmp_str ); for(k=0;k&lt;20;k++) { //printf("@REAL - %s", c1[0].dna_codon); printf("@ %s", c1[k].dna_codon); int x; x = c1[k].dna_codon; pch = strtok(x, ","); while (pch != NULL) { printf("\n%d : %s with %s", k, string_3l, pch); count=strcmp(string_3l, pch); if(count==0) { strcat(short_slc, c1[k].slc); printf("\n==&gt;%s", short_slc); } pch = strtok (NULL, " ,.-"); } } input_string = input_string+3; } printf("\nProtien sequence is : %s\n", short_slc); } </code></pre> <p>INPUT : </p> <pre><code>TAGTAG </code></pre> <p>OUTPUT :<br> If you see output of </p> <pre><code>printf("\n-----------%s &amp; %s----------", string_3l, tmp_str ); </code></pre> <p>in both iterations, we found that values defined in structure are reduced.</p> <p>I want to know why structure reduces it or its my mistake? because I am stucked here</p> <p>OUTPUT REQUIRED : </p> <pre><code>StopStop </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload