changeset 0:25f1eb15e37e draft

Uploaded
author k3v1n
date Mon, 17 Aug 2020 23:20:05 -0400
parents
children be850bbbf835
files toolExample.pl
diffstat 1 files changed, 23 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/toolExample.pl	Mon Aug 17 23:20:05 2020 -0400
@@ -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 );
\ No newline at end of file