Mercurial > repos > matthias > testtool
annotate gccontent.pl @ 0:878ec9a5f8c0 draft default tip
planemo upload
| author | matthias |
|---|---|
| date | Tue, 08 Jan 2019 09:43:35 -0500 |
| parents | |
| children |
| rev | line source |
|---|---|
| 0 | 1 #!/usr/bin/perl -w |
| 2 | |
| 3 # usage : perl toolExample.pl <FASTA file> <output file> | |
| 4 | |
| 5 open (IN, "<$ARGV[0]"); | |
| 6 open (OUT, ">$ARGV[1]"); | |
| 7 while (<IN>) { | |
| 8 chop; | |
| 9 if (m/^>/) { | |
| 10 s/^>//; | |
| 11 if ($. > 1) { | |
| 12 print OUT sprintf("%.3f", $gc/$length) . "\n"; | |
| 13 } | |
| 14 $gc = 0; | |
| 15 $length = 0; | |
| 16 } else { | |
| 17 ++$gc while m/[gc]/ig; | |
| 18 $length += length $_; | |
| 19 } | |
| 20 } | |
| 21 print OUT sprintf("%.3f", $gc/$length) . "\n"; | |
| 22 close( IN ); | |
| 23 close( OUT ); |
