[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.5 - (view) (download) (as text)

1 : efrank 1.1
2 : efrank 1.2 $usage = "usage: merge_translation_rules Existing Proposed From > Good ";
3 : efrank 1.1
4 :     (($existing = shift @ARGV) &&
5 : efrank 1.2 ($proposed = shift @ARGV) &&
6 :     ($who_from = shift @ARGV)
7 : efrank 1.1 )
8 :     || die $usage;
9 :    
10 :     $trans = {};
11 :    
12 : efrank 1.2 open(LOG,">>$FIG_Config::global/translation.update.results.log")
13 :     || die "could not open $FIG_Config::global/translation.update.results.log";
14 :    
15 :     &load($existing,$trans,"mine",\*LOG);
16 :     &load($proposed,$trans,$who_from,\*LOG);
17 :     close(LOG);
18 : efrank 1.1
19 :     foreach $from (sort keys(%$trans))
20 :     {
21 : overbeek 1.5 $to = $trans->{$from};
22 :     while ($trans->{$to})
23 :     {
24 :     $to = $trans->{$to};
25 :     }
26 :     print "$from\t$to\n";
27 : efrank 1.1 }
28 :    
29 :     sub load {
30 : efrank 1.2 my($file,$trans,$who_from,$fh_log) = @_;
31 : efrank 1.1
32 : efrank 1.4 open(TMP,"<$file") || return;
33 : efrank 1.1 while (defined($_ = <TMP>))
34 :     {
35 :     chop;
36 :     ($from,$to) = split(/\t/,$_);
37 :     if ($trans->{$from} && ($trans->{$from} eq $to))
38 :     {
39 :     # print STDERR "exists: $from => $to\n\n";
40 :     }
41 :     elsif ($trans->{$from} && ($trans->{$from} ne $to))
42 :     {
43 : efrank 1.2 print $fh_log "conflict\t$who_from\n$from\t$to\n$from\t$trans->{$from}\n\n";
44 : efrank 1.1 }
45 : efrank 1.3 elsif ($new = $trans->{$to})
46 : efrank 1.1 {
47 : efrank 1.2 print $fh_log "target_gets_rewritten\t$who_from\n$from\t$to\n$to\t$new\n\n";
48 : efrank 1.1 }
49 :     else
50 :     {
51 :     $trans->{$from} = $to;
52 :     }
53 :     }
54 :     }
55 :    

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3