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

Annotation of /FigKernelScripts/merge_translation_rules.pl

Parent Directory Parent Directory | Revision Log Revision Log


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

1 : olson 1.7 #
2 :     # Copyright (c) 2003-2006 University of Chicago and Fellowship
3 :     # for Interpretations of Genomes. All Rights Reserved.
4 :     #
5 :     # This file is part of the SEED Toolkit.
6 :     #
7 :     # The SEED Toolkit is free software. You can redistribute
8 :     # it and/or modify it under the terms of the SEED Toolkit
9 :     # Public License.
10 :     #
11 :     # You should have received a copy of the SEED Toolkit Public License
12 :     # along with this program; if not write to the University of Chicago
13 :     # at info@ci.uchicago.edu or the Fellowship for Interpretation of
14 :     # Genomes at veronika@thefig.info or download a copy from
15 :     # http://www.theseed.org/LICENSE.TXT.
16 :     #
17 :    
18 : efrank 1.1
19 : efrank 1.2 $usage = "usage: merge_translation_rules Existing Proposed From > Good ";
20 : efrank 1.1
21 :     (($existing = shift @ARGV) &&
22 : efrank 1.2 ($proposed = shift @ARGV) &&
23 :     ($who_from = shift @ARGV)
24 : efrank 1.1 )
25 :     || die $usage;
26 :    
27 :     $trans = {};
28 :    
29 : efrank 1.2 open(LOG,">>$FIG_Config::global/translation.update.results.log")
30 :     || die "could not open $FIG_Config::global/translation.update.results.log";
31 :    
32 :     &load($existing,$trans,"mine",\*LOG);
33 :     &load($proposed,$trans,$who_from,\*LOG);
34 :     close(LOG);
35 : efrank 1.1
36 :     foreach $from (sort keys(%$trans))
37 :     {
38 : overbeek 1.5 $to = $trans->{$from};
39 :     while ($trans->{$to})
40 :     {
41 : overbeek 1.6 print STDERR "$to => $trans->{$to}\n";
42 : overbeek 1.5 $to = $trans->{$to};
43 :     }
44 : overbeek 1.6 if ($from ne $to)
45 :     {
46 :     print "$from\t$to\n";
47 :     }
48 : efrank 1.1 }
49 :    
50 :     sub load {
51 : efrank 1.2 my($file,$trans,$who_from,$fh_log) = @_;
52 : efrank 1.1
53 : efrank 1.4 open(TMP,"<$file") || return;
54 : efrank 1.1 while (defined($_ = <TMP>))
55 :     {
56 :     chop;
57 :     ($from,$to) = split(/\t/,$_);
58 :     if ($trans->{$from} && ($trans->{$from} eq $to))
59 :     {
60 :     # print STDERR "exists: $from => $to\n\n";
61 :     }
62 :     elsif ($trans->{$from} && ($trans->{$from} ne $to))
63 :     {
64 : efrank 1.2 print $fh_log "conflict\t$who_from\n$from\t$to\n$from\t$trans->{$from}\n\n";
65 : efrank 1.1 }
66 : efrank 1.3 elsif ($new = $trans->{$to})
67 : efrank 1.1 {
68 : efrank 1.2 print $fh_log "target_gets_rewritten\t$who_from\n$from\t$to\n$to\t$new\n\n";
69 : efrank 1.1 }
70 : overbeek 1.6 elsif ($from ne $to)
71 : efrank 1.1 {
72 :     $trans->{$from} = $to;
73 :     }
74 :     }
75 :     }
76 :    

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3