in reply to Problem computing GC content
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Problem computing GC content
by zuepinhel (Initiate) on Jul 13, 2014 at 21:18 UTC | |
by AnomalousMonk (Archbishop) on Jul 13, 2014 at 23:30 UTC | |
by ww (Archbishop) on Jul 13, 2014 at 22:51 UTC |