Debian Codegraph @

wtools/homol2match

raw
1 #!/usr/local/bin/perl
2 #
3 # $Id: homol2match,v 1.1 1996/12/02 00:50:50 rd Exp $
4 #
5
6 $prog = "homol2match" ;
7 $usage = "Usage: $prog <acefile>\n" ;
8
9 %homolType = ( "DNA" => "Sequence",
10 "Pep" => "Protein",
11 "Motif" => "Motif",
12 "Align" => "Alignment"
13 ) ;
14
15 ($in = shift) || die $usage ;
16
17 open (IN, "<$in") || die "$prog: failed to open file $in: $!\n" ;
18
19 if ($in =~ s/\.ace$//) {
20 $out1 = $in . ".bs.ace" ;
21 $out2 = $in . ".match.ace" ;
22 }
23 else {
24 $out1 = $in . ".1" ;
25 $out2 = $in . ".2" ;
26 }
27
28 open (OUT1, ">$out1") && open (OUT2, ">$out2") ||
29 die "$prog: failed to open output files $out1, $out2: $!\n" ;
30
31 while (<IN>) {
32 if ( /^(\S+)\s+(:\s+)?(\S+)/ ) {
33 $class = $1 ;
34 $name = $3 ;
35 print OUT1 "\n" . $_ ;
36 $matches = 0 ;
37 while (<IN>) {
38 last if /^\s*$/ ;
39 if ( /^(\S+)_homol/ ) {
40 if ($matches == 0) {
41 $name =~ s/"//g ;
42 print OUT2 "\nMatchTable $class-$name\n" ;
43 $matches = 1 ;
44 }
45 $x = $homolType{$1} ;
46 if (!defined ($x)) { die "unknown homol type $1\n" ; }
47 @f = split ;
48 if ($#f == 7) {
49 s/$1_homol/$x/ ;
50 s/\"//g ;
51 print OUT2 $_ ;
52 }
53 }
54 else {
55 print OUT1 $_ ;
56 }
57 }
58 }
59 }
60
61 1 ;
62
63 ########### end of file ##################
64