comparison toolExample.pl @ 0:25f1eb15e37e draft

Uploaded
author k3v1n
date Mon, 17 Aug 2020 23:20:05 -0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:25f1eb15e37e
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 );