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

Diff of /FigKernelScripts/generate_partitions_worker.pl

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

revision 1.1, Thu Jan 31 20:36:12 2008 UTC revision 1.2, Mon Dec 22 07:13:27 2008 UTC
# Line 1  Line 1 
1  use FIG;  use FIG;
2  my $fig = new FIG;  my $fig = new FIG;
3    my $dbf = $fig->db_handle;
4  use FIGO;  use FIGO;
5  my $figO = new FIGO;  my $figO = new FIGO;
6    
7  use strict;  use strict;
8    
9  my $sim_thresh = 1.0e-10;  my $sim_thresh = 1.0e-10;
10  my($usage,$fams,$outD,$doneF,$proc);  my($usage,$fams,$outD,$proc,$log_file);
11  $usage = "usage: generate_partition_worker Families OutDir DoneF Process < FIGfams > Partitions";  $usage = "usage: generate_partition_worker Families OutDir Process < FIGfams > Partitions";
12    
13    while ( $ARGV[0] =~ /^-/ )
14    {
15        $_ = shift @ARGV;
16        if ($_ =~ s/^-log//)     { $log_file      = ($_ || shift @ARGV) }
17        else                  { print STDERR  "Bad flag: '$_'\n$usage"; exit 1 }
18    }
19    
20  (  (
21   ($fams = shift @ARGV) && open(FAMS,"<$fams") &&   ($fams = shift @ARGV) && open(FAMS,"<$fams") &&
22   ($outD = shift @ARGV) &&   ($outD = shift @ARGV) &&
  ($doneF = shift @ARGV) &&  
23   ($proc = shift @ARGV)   ($proc = shift @ARGV)
24  )  )
25      || die $usage;      || die $usage;
26    
27  open(OUT,">>$outD/$proc") || die "could not open $outD/$proc";  open(OUT,">>$outD/$proc") || die "could not open $outD/$proc";
28  my $ofh = select OUT; $| = 1; select $ofh;  my $ofh = select OUT; $| = 1; select $ofh;
   
29  my %done_fam;  my %done_fam;
 foreach $_ (`cat $doneF`)  
 {  
     chop;  
     $done_fam{$_} = 1;  
 }  
30    
31  my(%fam_to_pegs,%peg_to_fams);  my(%fam_to_pegs,%peg_to_fams);
32  while (defined($_ = <FAMS>))  while (defined($_ = <FAMS>))
# Line 46  Line 47 
47  my $peg;  my $peg;
48  while (defined($_ = <STDIN>))  while (defined($_ = <STDIN>))
49  {  {
50      if (($_ =~ /(FIG\d{6})/) && (! $done_fam{$1}))      if (!$fig){
51            $fig = new FIG;
52            $dbf = $fig->db_handle;
53        }
54    
55        my $cond = "fam = '".$_."'";
56        my $x = $dbf->SQL("select fam from tmp_sync_partitions where $cond");
57    
58    #    if (($_ =~ /(FIG\d{6})/) && (! $done_fam{$1}))
59        if (($_ =~ /(FIG\d{6})/) && (! $done_fam{$1}) && (! scalar @$x > 0))
60      {      {
         print STDERR "$proc processing $1\n";  
61          my $ff = $1;          my $ff = $1;
62            print STDERR "$proc processing $ff\n";
63    
64          my $todo = { $ff => 1 };          my $todo = { $ff => 1 };
65          my $loaded_fams = {};          my $loaded_fams = {};
# Line 176  Line 186 
186      {      {
187          if ($todo->{$famD}) { delete $todo->{$famD} }          if ($todo->{$famD}) { delete $todo->{$famD} }
188          $done_fam->{$famD} = 1;          $done_fam->{$famD} = 1;
189    
190            # add to db_handle to show that figfam is done for all other processes
191            if (!$fig){
192                $fig = new FIG;
193                $dbf = $fig->db_handle;
194            }
195            $dbf->SQL("insert into tmp_sync_partitions (fam) values ('$famD')");
196      }      }
197    
198      foreach my $famO (@not_contained_in)      foreach my $famO (@not_contained_in)
199      {      {
200          if (! $done_fam->{$famO})          if (!$fig){
201                $fig = new FIG;
202                $dbf = $fig->db_handle;
203            }
204    
205            my $cond = "fam = '".$famO."'";
206            my $x = $dbf->SQL("select fam from tmp_sync_partitions where $cond");
207    
208    #       if (! $done_fam->{$famO})
209            if ( (! $done_fam->{$famO}) && (! scalar @$x > 0) )
210          {          {
211              $todo->{$famO} = 1;              $todo->{$famO} = 1;
212          }          }

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3