[Bio] / FigKernelScripts / salvage_annotations.pl Repository:
ViewVC logotype

Annotation of /FigKernelScripts/salvage_annotations.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.6 - (view) (download) (as text)

1 : overbeek 1.5 ########################################################################
2 : olson 1.4 #
3 :     # Copyright (c) 2003-2006 University of Chicago and Fellowship
4 :     # for Interpretations of Genomes. All Rights Reserved.
5 :     #
6 :     # This file is part of the SEED Toolkit.
7 :     #
8 :     # The SEED Toolkit is free software. You can redistribute
9 :     # it and/or modify it under the terms of the SEED Toolkit
10 :     # Public License.
11 :     #
12 :     # You should have received a copy of the SEED Toolkit Public License
13 :     # along with this program; if not write to the University of Chicago
14 :     # at info@ci.uchicago.edu or the Fellowship for Interpretation of
15 :     # Genomes at veronika@thefig.info or download a copy from
16 :     # http://www.theseed.org/LICENSE.TXT.
17 :     #
18 :    
19 : overbeek 1.1 use FIG;
20 :     my $fig = new FIG;
21 :    
22 : overbeek 1.3 my $usage = "usage: salvage_annotations From To Map";
23 : overbeek 1.1
24 :     (
25 :     ($from = shift @ARGV) &&
26 : overbeek 1.3 ($to = shift @ARGV) &&
27 :     ($map = shift @ARGV)
28 : overbeek 1.1 )
29 :     || die $usage;
30 :    
31 :     ($from =~ /(\d+\.\d+)$/) || die "$from does not end in the organism ID";
32 :     my $fromO = $1;
33 :    
34 :     ($to =~ /(\d+\.\d+)$/) || die "$to does not end in the organism ID";
35 :     my $toO = $1;
36 :    
37 : overbeek 1.3 %mapping = map { $_ =~ /^(\S+)\t(\S+)/; $1 => $2 } `cat $map`;
38 : overbeek 1.1
39 :     &salvage_assignments("$from/assigned_functions","$to/assigned_functions",\%mapping);
40 : overbeek 1.5 &salvage_annotations("$from/annotations","$to/annotations",\%mapping);
41 : overbeek 1.1
42 :     sub salvage_assignments {
43 :     my($in,$out,$mapping) = @_;
44 :     my($rep);
45 :    
46 :     open(IN,"<$in") || die "could not open $in";
47 :     open(OUT,">$out") || die "could not open $out";
48 :     while (defined($_ = <IN>))
49 :     {
50 :     if (($_ =~ /^(\S+)\t(\S.*\S)/) && ($rep = $mapping->{$1}))
51 :     {
52 :     print OUT "$rep\t$2\n";
53 :     }
54 :     }
55 :     close(IN);
56 :     close(OUT);
57 :     }
58 :    
59 :     sub salvage_annotations {
60 :     my($in,$out,$mapping) = @_;
61 :     my($rep);
62 : overbeek 1.5
63 : overbeek 1.1 open(IN,"<$in") || die "could not open $in";
64 :     open(OUT,">$out") || die "could not open $out";
65 :     $/ = "\n//\n";
66 :     while (defined($_ = <IN>))
67 :     {
68 : overbeek 1.5 if (($_ =~ /^(\S+)\n(\S.*\S)/s) && ($rep = $mapping->{$1}))
69 : overbeek 1.1 {
70 : olson 1.6 print OUT "$rep\n$2\n";
71 : overbeek 1.1 }
72 :     }
73 :     $/ = "\n";;
74 :     close(IN);
75 :     close(OUT);
76 :     }

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3