+
+
+
+
+
+
+
+
+
+
+ Permalink
+
+
+
+
+
+
+
+
+
+
+
+
+ Join GitHub today
+GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.
+ Sign up +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Find file
+
+
+ Copy path
+
+
+
+
+
+ + fasta-tool/fasta-tool.pl +
+ +
+
+ Find file
+
+
+ Copy path
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + | #!/usr/bin/perl -w | +
+ | + | +
+ | # usage : perl toolExample.pl <FASTA file> <output file> | +
+ | + | +
+ | open (IN, "<$ARGV[0]"); | +
+ | open (OUT, ">$ARGV[1]"); | +
+ | while (<IN>) { | +
+ | chop; | +
+ | if (m/^>/) { | +
+ | s/^>//; | +
+ | if ($. > 1) { | +
+ | print OUT sprintf("%.3f", $gc/$length) . "\n"; | +
+ | } | +
+ | $gc = 0; | +
+ | $length = 0; | +
+ | } else { | +
+ | ++$gc while m/[gc]/ig; | +
+ | $length += length $_; | +
+ | } | +
+ | } | +
+ | print OUT sprintf("%.3f", $gc/$length) . "\n"; | +
+ | close( IN ); | +
+ | close( OUT ); | +