AppleFritter seems to have given you a good solution to the specific question you asked. However, I would suggest you become familiar with the string manipulation facilities of Perl.
Specifically for this problem, the tr operator would seem very useful. Please see its discussion via the tr link and in the Quote-Like Operators section of perlop.
c:\@Work\Perl>perl -wMstrict -le "my $sequence = 'xxxGCxxCxxxxCGxGxxxGxxxxxCxx'; ;; my $sequencelength = length $sequence; print qq{sequence length: $sequencelength}; ;; my $GCcount = $sequence =~ tr/GC//; print qq{total Gs and Cs: $GCcount}; ;; my $GCcontent = ($GCcount / $sequencelength) * 100; print qq{GCcontent: $GCcontent percent} " sequence length: 28 total Gs and Cs: 8 GCcontent: 28.5714285714286 percent
In reply to Re: Problem computing GC content
by AnomalousMonk
in thread Problem computing GC content
by zuepinhel
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |