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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |