diff fa_gc_content/gc_content.pl @ 0:8ed4fe2456f0 draft default tip

Uploaded
author qtrinh
date Fri, 09 Nov 2012 12:00:28 -0500
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/fa_gc_content/gc_content.pl	Fri Nov 09 12:00:28 2012 -0500
@@ -0,0 +1,23 @@
+#!/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 );