Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

Hi PerlMonks,

I have a string like "ATCGGCGCCTAT" consisting of four 3-letter words (ATC,GGC,GCC,TAT). I am interested to count the number and the kinds of letters (A,T,G,C) at 1st, 2nd and 3rd positions of these four words. I am a beginner in perl programming. I shall be glad if any perl monk can help me by providing the syntax/perl code that can count letters and their kinds in 1st, 2nd and 3rd position of 3-letter words. Separate scalar variable may be used for each position and letter. For instance, for the 1st position the scalar variables may be $A1, $T1, $G1 and $C1. Similarly, for 2nd the scalar variables may be $A2,$T2,$G2,$C2 and for 3rd position $A3,$T3,$G3 and $C3.

#!usr/bin/perl-w $a="ATCGGCGCCTAT"; code?? print" Letters at 1st position:\n A1=$A1; T1=$T1; G1=$G1; C1=$C1; \n Letters at 2nd position:\n A2=$A2; T2=$T2; G2=$G2; C2=$C2; \n Letters at 3rd position:\n A3=$A3; T3=$T3; G3=$G3; C3=$C3; \n"; exit;

Expected results are:

The result of counting from the string should look like: Letters at 1st position: A1=1; T1=1; G1=2; C1=0; Letters at 2nd position: A2=1; T2=1; G2=1; C2=1; Letters at 3rd position: A3=0; T3=1; G3=0; C3=3;

In reply to How can I count the number and kinds of letters at 1st, 2nd and 3rd positions of 3-letter words in a string? by supriyoch_2008

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others scrutinizing the Monastery: (4)
    As of 2014-12-27 13:54 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      Is guessing a good strategy for surviving in the IT business?





      Results (177 votes), past polls