Mercurial > repos > jeltje > jtest1
annotate myTools/toolExample.pl @ 1:a5f711786a86 draft default tip
Uploaded
| author | jeltje |
|---|---|
| date | Wed, 07 Jan 2015 22:03:51 -0500 |
| parents | 65489579eace |
| children |
| rev | line source |
|---|---|
| 0 | 1 #!/usr/local/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 ); |
