annotate toolExample.pl @ 0:25f1eb15e37e draft

Uploaded
author k3v1n
date Mon, 17 Aug 2020 23:20:05 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
25f1eb15e37e Uploaded
k3v1n
parents:
diff changeset
1 #!/usr/bin/perl -w
25f1eb15e37e Uploaded
k3v1n
parents:
diff changeset
2
25f1eb15e37e Uploaded
k3v1n
parents:
diff changeset
3 # usage : perl toolExample.pl <FASTA file> <output file>
25f1eb15e37e Uploaded
k3v1n
parents:
diff changeset
4
25f1eb15e37e Uploaded
k3v1n
parents:
diff changeset
5 open (IN, "<$ARGV[0]");
25f1eb15e37e Uploaded
k3v1n
parents:
diff changeset
6 open (OUT, ">$ARGV[1]");
25f1eb15e37e Uploaded
k3v1n
parents:
diff changeset
7 while (<IN>) {
25f1eb15e37e Uploaded
k3v1n
parents:
diff changeset
8 chop;
25f1eb15e37e Uploaded
k3v1n
parents:
diff changeset
9 if (m/^>/) {
25f1eb15e37e Uploaded
k3v1n
parents:
diff changeset
10 s/^>//;
25f1eb15e37e Uploaded
k3v1n
parents:
diff changeset
11 if ($. > 1) {
25f1eb15e37e Uploaded
k3v1n
parents:
diff changeset
12 print OUT sprintf("%.3f", $gc/$length) . "\n";
25f1eb15e37e Uploaded
k3v1n
parents:
diff changeset
13 }
25f1eb15e37e Uploaded
k3v1n
parents:
diff changeset
14 $gc = 0;
25f1eb15e37e Uploaded
k3v1n
parents:
diff changeset
15 $length = 0;
25f1eb15e37e Uploaded
k3v1n
parents:
diff changeset
16 } else {
25f1eb15e37e Uploaded
k3v1n
parents:
diff changeset
17 ++$gc while m/[gc]/ig;
25f1eb15e37e Uploaded
k3v1n
parents:
diff changeset
18 $length += length $_;
25f1eb15e37e Uploaded
k3v1n
parents:
diff changeset
19 }
25f1eb15e37e Uploaded
k3v1n
parents:
diff changeset
20 }
25f1eb15e37e Uploaded
k3v1n
parents:
diff changeset
21 print OUT sprintf("%.3f", $gc/$length) . "\n";
25f1eb15e37e Uploaded
k3v1n
parents:
diff changeset
22 close( IN );
25f1eb15e37e Uploaded
k3v1n
parents:
diff changeset
23 close( OUT );