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

Diff of /FigKernelScripts/partition_prots.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1, Fri Jul 4 15:28:08 2008 UTC revision 1.2, Fri Sep 12 01:47:15 2008 UTC
# Line 1  Line 1 
 ########################################################################  
   
1  use DB_File;  use DB_File;
2  use strict;  use strict;
3    
# Line 7  Line 5 
5  my $fig = new FIG;  my $fig = new FIG;
6    
7  my $max_sz;  my $max_sz;
8  my $usage = "usage: partition_prots Dir MaxPartSz";  my $usage = "usage: partition_prots MaxPartSz";
9  (  (
10   ($max_sz = shift @ARGV)   ($max_sz = shift @ARGV)
11  )  )
# Line 27  Line 25 
25  {  {
26      if (! $seen_hash{$all[$i]})      if (! $seen_hash{$all[$i]})
27      {      {
28            print STDERR "processing $all[$i], $i of $#all\n";
29          &process($fig,$all[$i],\%seen_hash,\%prot_hash,$max_sz,\$n);          &process($fig,$all[$i],\%seen_hash,\%prot_hash,$max_sz,\$n);
30      }      }
31  }  }
32    
33  sub process {  sub process {
34      my($fig,$prot,$seen,$prot_hash,$max_sz,$nP,$file) = @_;      my($fig,$prot,$seen,$prot_hash,$max_sz,$nP) = @_;
35    
36      my %in;      my %in;
37      $in{$prot} = 1;      $in{$prot} = 1;
# Line 65  Line 64 
64          }          }
65          $seen->{$peg} = 1;          $seen->{$peg} = 1;
66          print "IN\t$prot\t$peg\n";          print "IN\t$prot\t$peg\n";
67          $peg = &the_closest(\%closest);          $peg = &the_closest(\%closest,$seen);
68      }      }
69      print STDERR "$$nP left\n";      print STDERR "$$nP left\n";
70      foreach $_ (sort keys(%in))      foreach $_ (sort keys(%in))
# Line 74  Line 73 
73      }      }
74  }  }
75    
76  sub the closest {  sub the_closest {
77      my($closest) = @_;      my($closest,$seen) = @_;
78    
79      my($peg,$x,$peg1,$x1);      my($peg,$x,$peg1,$x1);
80      while (($peg1,$x1) = each %$closest)      while (($peg1,$x1) = each %$closest)
81      {      {
82          if ((! defined($peg)) || ($x1 > $x))          if ((! $seen->{$peg}) && ((! defined($peg)) || ($x1 > $x)))
83          {          {
84              $peg = $peg1;              $peg = $peg1;
85              $x = $x1;              $x = $x1;
# Line 93  Line 92 
92      my($prot_hash,$seen_hash) = @_;      my($prot_hash,$seen_hash) = @_;
93    
94      my($prot_hash_tie,$seen_hash_tie);      my($prot_hash_tie,$seen_hash_tie);
95      $prot_hash_tie = tie %$prot_hash, 'DB_File','prot_hash.db',O_RDWR,0666,$DB_BTREE;  #    $prot_hash_tie = tie %$prot_hash, 'DB_File','prot_hash.db',O_RDWR,0666,$DB_BTREE;
96      $seen_hash_tie = tie %$seen_hash, 'DB_File','seen_hash.db',O_RDWR,0666,$DB_BTREE;  #    $seen_hash_tie = tie %$seen_hash, 'DB_File','seen_hash.db',O_RDWR,0666,$DB_BTREE;
97      return;  #    return;
98    
99      $prot_hash_tie = tie %$prot_hash, 'DB_File','prot_hash.db',O_CREAT,0666,$DB_BTREE;      $prot_hash_tie = tie %$prot_hash, 'DB_File','prot_hash.db',O_CREAT,0666,$DB_BTREE;
100      $prot_hash_tie || die "tie failed";      $prot_hash_tie || die "tie failed";

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3