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

Annotation of /FigKernelScripts/order_figfams.pl

Parent Directory Parent Directory | Revision Log Revision Log


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

1 : overbeek 1.1
2 :     my $tmp1 = "$FIG_Config::temp/figfams.$$";
3 :     my $tmp2 = "$FIG_Config::temp/figfams.$$.S";
4 :     open(FIGFAMS,">$tmp1") || die "could not open $tmp1";
5 :     while (defined($_ = <STDIN>))
6 :     {
7 :     if ($_ =~ /^(\S+)/)
8 :     {
9 :     $fam{$1}++;
10 :     print FIGFAMS $_;
11 :     }
12 :     }
13 :     close(FIGFAMS);
14 :    
15 :     @fams = sort { $fam{$b} <=> $fam{$a} } keys(%fam);
16 :    
17 :    
18 :     for ($i=1; ($fam = shift @fams); $i++)
19 :     {
20 :     $n{$fam} = $i;
21 :     }
22 :    
23 :     open(FIGFAMS,"<$tmp1") || die "could not open $tmp1";
24 :     open(SORTED,"| sort > $tmp2") || die "could not open $tmp2";
25 :     while (defined($_ = <FIGFAMS>))
26 :     {
27 :     if ($_ =~ /^(\S+)\t(\S.*\S)/)
28 :     {
29 :     $fam = $1;
30 :     $rest = $2;
31 :     $n = $n{$fam};
32 :     print SORTED join("\t",("FIG" . ("0" x (6 - length($n))) . $n,$rest)),"\n";
33 :     }
34 :     }
35 :     close(FIGFAMS);
36 :     close(SORTED);
37 :     open(SORTED,"<$tmp2") || die "could not open $tmp2";
38 :     while (defined($_ = <SORTED>))
39 :     {
40 :     print $_;
41 :     }
42 :     close(SORTED);
43 :     unlink($tmp1,$tmp2);
44 :    
45 :    

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3