http://www.perlmonks.org?node_id=1018596

suchetana has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.
  • Comment on Urgent help required. Need a code to translate a given nucleotide sequence into proteins using codon table.
  • Download Code

Replies are listed 'Best First'.
Re: Urgent help required. Need a code to translate a given nucleotide sequence into proteins using codon table.
by roboticus (Chancellor) on Feb 13, 2013 at 18:59 UTC

    suchetana:

    If it does what you want, then it's fine!

    Since you really didn't tell what's wrong or right, I'll leave it to you to decide how fine it is.

    I suggest urgently fixing your code tags, then urgently describing the symptoms to your urgent problem. Otherwise, many monks will urgently ignore it.

    ...roboticus

    When your only tool is a hammer, all problems look like your thumb.

      See what I have is suppose TATGCATGGCATATATATACGTACGTATGCATATATATGCTAA. I want to find the substring that has ATG......TAA while reading from the first T Then I want it to start reading from the second alphabet and find the substring having ATG...TAA and again then the same thing from T to get ATG....TAA. Also, I then need to store these three substrings in three different scalars/arrays. Then I need to translate them, like if the first three are ATG it should return say M, then it reads the next 3 characters of that substring and say it is CAT. Then it will return X say. Likewise. How do I go about? Please please help
Re: Urgent help required. Need a code to translate a given nucleotide sequence into proteins using codon table.
by thundergnat (Deacon) on Feb 13, 2013 at 19:44 UTC

    Umm. Is this the same urgent problem from Nov 11, 2011 (11/11/11 :-) ) on stackoverflow?

    If it is, why didn't any of those answers help? If not, why would you copy code that is explicitly stated to be broken?

    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: Urgent help required. Need a code to translate a given nucleotide sequence into proteins using codon table.
by kennethk (Abbot) on Feb 13, 2013 at 19:11 UTC
    So a scan your post suggests you would be well served by using strict in your coding -- see Basic debugging checklist and Use strict warnings and diagnostics or die. If I'm reading it correctly, most of your return statements return barewords rather than strings. For example, I expect return K; should actually be return 'K'; -- you don't actually have a subroutine named K, right?

    Of course, all this is guesses because your posted code is mangled because of lack of <code> tags and you don't provide input or expected output. See How do I post a question effectively?


    #11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

Re: Urgent help required. Need a code to translate a given nucleotide sequence into proteins using codon table.
by dasgar (Priest) on Feb 13, 2013 at 19:35 UTC

    To be nice, here's the OP's code in a more readable format (i.e. added in line breaks and is inside proper code tags).

    In the process of reformatting, I suspect that there are some issues with curly brackets. It looks like the while loop's open curly bracket isn't closed off until after the subroutines. I suspect that might be an issue and definitely agree with kennethk's suggestion about using strict and warnings.

      For future reference, perlmonks linkifies anything between [ and ], so locations in the posted code that display as links should actually be array indices or character classes. For example
      if ( $_ 0 =~ / GGAGCU /i ) { return G;} # Glycine;
      is printed above as

      if ( $_ 0 =~ / GGAGCU /i ) { return G;} # Glycine;

      and should therefore actually probably be translated as

      if ( $_[0] =~ /GG[AGCU]/i ) { return G;} # Glycine;
      barring ambiguities with regard to whitespace counts. Not that I've done this before....

      #11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

      i do have -w given, so it should read the bugs and warn, right?

        warnings and strict cover different issues. Without strict, you get some very regressive behaviors that you almost assuredly don't intend, e.g. my point about barewords. Did you try addressing that issue yet?


        #11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

Re: Urgent help required. Need a code to translate a given nucleotide sequence into proteins using codon table.
by necroshine (Acolyte) on Feb 14, 2013 at 15:46 UTC
Re: Urgent help required. Need a code to translate a given nucleotide sequence into proteins using codon table.
by runrig (Abbot) on Mar 11, 2013 at 20:50 UTC
    I need the total program URGENTLY.
    I'll get right on it!!! What's your deadline ?!?!?!?
    Please let me know if it is fine or not.
    That code is NOT fine!!! The problems should be fixed (URGENTLY)!!!!

      I'll get right on it!!! What's your deadline ?!?!?!?

      Last month sometime? Like when OP last visited?