| 1 |
|
| 2 |
use strict; |
| 3 |
use warnings; |
| 4 |
use diagnostics; |
| 5 |
|
| 6 |
|
| 7 |
# swissprot_extract_go.pl - Extract SwissProt->GO data from uniprot_sprot.dat |
| 8 |
# Usage: |
| 9 |
# $ swissprot_extract_go.pl < uniprot_sprot.dat > sprot_go.lst |
| 10 |
|
| 11 |
while(my $line = <STDIN>) { |
| 12 |
chomp $line; |
| 13 |
my $type = substr($line, 0, 2); |
| 14 |
my $content = length($line) >= 4 ? substr($line, 5) : ""; |
| 15 |
|
| 16 |
if($type eq "ID") { |
| 17 |
if($content =~ m/^([0-9A-Z]+_[0-9A-Z]+)/g) { |
| 18 |
print $1; |
| 19 |
} else { |
| 20 |
die("Unknown identifier line:\n$line"); |
| 21 |
} |
| 22 |
} elsif($type eq "DR") { |
| 23 |
|
| 24 |
if($content =~ m/^GO;\s*(GO:[0-9]{7});/g) { |
| 25 |
print "\t$1"; |
| 26 |
} |
| 27 |
} elsif($type eq "//") { |
| 28 |
print "\n"; |
| 29 |
} |
| 30 |
} |