1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
|
#!/usr/bin/perl -w
sub idsort{
$cat{$a} cmp $cat{$b}
or
$a cmp $b
}
$isdata = 0;
$line=0;
$id = $cat = $name = $ref = $link = $server = $dburl = $note = "";
while (<>) {
chomp;
s/\s+$//;
$line++;
if($isdata){
if(/^--------/) {$isdata = 0}
}
if(!$isdata){
if(/^Abbrev: /) {$isdata = 1}
}
if(!$isdata) {next}
# "$abbrev\|\| \|\| \|\| Swiss-Prot \|\| Name \|\| Citation \|\| "
# "\|\|
if(/^$/) {
$cat{$id} = $cat;
$name{$id} = $name;
$ref{$id} = $ref;
$link{$id} = $link;
$server{$id} = $server;
$dburl{$id} = $dburl;
$note{$id} = $note;
$id = $cat = $name = $ref = $link = $server = $dburl = $note = "";
}
elsif(/^Abbrev: (.*)/) {$last="abbrev";$id=$1}
elsif(/^Name : (.*)/) {$last="name";$name=$1}
elsif(/^Ref : (.*)/) {
$last="ref";
$txt = $1;
$txt =~ s/<\/A>//g;
$txt =~ s/<A HREF[^>]+>//g;
$ref=$txt;
}
elsif(/^LinkTp: (.*)/) {
$last="link";
$txt = $1;
if($txt =~ /Explicit/) {
$txt =~ s/<A HREF=\"([^\"]+)\">Explicit<\/A>/$1/;
}
$link=$txt;
}
elsif(/^Server: (.*)/) {
$last="server";
$txt = $1;
$txt =~ s/<\/A>//g;
$txt =~ s/<A HREF[^>]+>//g;
$server=$txt;
}
elsif(/^Db_URL: (.*)/) {
$last="dburl";
$txt = $1;
$txt =~ s/<\/A>//g;
$txt =~ s/<A HREF[^>]+>//g;
if($txt =~ /^http:/){$dburl="$txt";}
else {$dburl = "http://$txt"}
}
elsif(/^Note : (.*)/) {$last="note";$note=$1}
elsif(/^Cat : (.*)/) {$last="cat";$cat=$1}
elsif(/^(\S+) *:/) {print STDERR "$line: Unexpected tag '$1\n"}
elsif(/^\s*(.+)/) {
if($last eq "abbrev") {$id .= " $1"}
if($last eq "name") {$name .= " $1"}
if($last eq "ref") {$ref .= " $1"}
if($last eq "link") {$link .= " $1"}
if($last eq "server") {
$txt = $1;
$txt =~ s/<\/A>//g;
$txt =~ s/<A HREF[^>]+>//g;
$server .= " $txt";
}
if($last eq "dburl") {$dburl .= " $1"}
if($last eq "cat") {$cat .= " $1"}
if($last eq "note") {$note .= " $1"}
}
}
$lastcat = "";
foreach $d (sort idsort (keys(%cat))) {
if($cat{$d} ne $lastcat) {
if($lastcat ne "") {print "|}\n";}
$lastcat = $cat{$d};
print "\n====Swiss-Prot $lastcat====\n\n";
print "{| class=\"wikitable\" border=\"1\"\n";
print "\|-\n";
print "!DbName\n";
print "!Primary\n";
print "!Secondary\n";
print "!UsedIn\n";
print "!Name\n";
print "!Citation\n";
print "!Link\n";
print "!Server\n";
print "!URL\n";
}
print "\|-\n";
print "|$d \|\| \|\| \|\| Swiss-Prot\n";
print "\|$name{$d} \|\| $ref{$d}\n";
print "\|$link{$d} \|\| $server{$d}\n";
print "\|$dburl{$d} \|\| $note{$d}\n";
}
print "|}\n";
print "\n\n";
$lastcat = "";
$n = 0;
foreach $c (sort (values(%cat))) {
if($c eq $lastcat) {$n++;next}
$lastcat = $c;
if($n) {print " ($n)\n"}
print "$c";
$n = 1;
}
print " ($n)\n";
|