[Bio] / FigKernelPackages / P2P.pm Repository:
ViewVC logotype

Diff of /FigKernelPackages/P2P.pm

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

revision 1.21, Fri Jan 7 18:54:45 2005 UTC revision 1.22, Fri Jan 7 19:24:39 2005 UTC
# Line 40  Line 40 
40  my $anno_batch_size = 1000;  my $anno_batch_size = 1000;
41  my $assign_batch_size = 1000;  my $assign_batch_size = 1000;
42    
43    my $log_fh;
44    
45  =pod  =pod
46    
47  =head1 perform_update($peer)  =head1 perform_update($peer)
# Line 56  Line 58 
58    
59  sub perform_update  sub perform_update
60  {  {
61      my($fig, $peer, $last_update, $skip_tough_search, $update_thru) = @_;      my($fig, $peer, $last_update, $skip_tough_search, $update_thru, $log_file) = @_;
62    
63        $log_file = "/dev/null" unless $log_file ne "";
64        open($log_fh, ">>$log_file") or die "Cannot open logfile $log_file: $!\n";
65        $log_fh->autoflush(1);
66    
67        print $log_fh "Beginning P2P update at " . localtime() . "\n";
68        print $log_fh "  Peer URL: $peer->{url}\n";
69        print $log_fh "  Update from: " . localtime($last_update) . "\n";
70        print $log_fh "\n";
71    
72      my $ret = $peer->request_update($last_update, $update_thru);      my $ret = $peer->request_update($last_update, $update_thru);
73    
# Line 71  Line 82 
82      print "perform_update: session=$session target=@$target_release num_annos=$num_annos\n";      print "perform_update: session=$session target=@$target_release num_annos=$num_annos\n";
83      print "                num_pegs=$num_pegs num_genomes=$num_genomes target_time=$target_time compat=$compatible\n";      print "                num_pegs=$num_pegs num_genomes=$num_genomes target_time=$target_time compat=$compatible\n";
84    
85        my @my_release = $fig->get_release_info();
86    
87        print $log_fh "Session id = $session\n";
88        print $log_fh "Target release information: \n\t", join("\n\t", @$target_release), "\n";
89        print $log_fh "My release information: \n\t", join("\n\t", @my_release), "\n";
90        print $log_fh "$num_annos annotations\n";
91        print $log_fh "$num_assignments assignments\n";
92        print $log_fh "$num_pegs pegs\n";
93    
94      #      #
95      # We now know the data release for our peer.      # We now know the data release for our peer.
96      #      #
# Line 126  Line 146 
146      #      #
147      my %genome_assignments;      my %genome_assignments;
148    
   
   
149      #      #
150      # Retrieve the annotations, and generate a list of mapped annotations.      # Retrieve the annotations, and generate a list of mapped annotations.
151      #      #
# Line 138  Line 156 
156          $anno_req_len = $anno_batch_size if $anno_req_len > $anno_batch_size;          $anno_req_len = $anno_batch_size if $anno_req_len > $anno_batch_size;
157    
158          print "Retrieve $anno_req_len annos at $anno_start\n";          print "Retrieve $anno_req_len annos at $anno_start\n";
159            print $log_fh "Retrieve $anno_req_len annos at $anno_start\n";
160    
161          my $annos = $peer->get_annotations($session, $anno_start, $anno_req_len);          my $annos = $peer->get_annotations($session, $anno_start, $anno_req_len);
162    
# Line 167  Line 186 
186          $assign_req_len = $assign_batch_size if $assign_req_len > $assign_batch_size;          $assign_req_len = $assign_batch_size if $assign_req_len > $assign_batch_size;
187    
188          print "Retrieve $assign_req_len assigns at $assign_start\n";          print "Retrieve $assign_req_len assigns at $assign_start\n";
189            print $log_fh "Retrieve $assign_req_len assigns at $assign_start\n";
190    
191          my $assignments = $peer->get_assignments($session, $assign_start, $assign_req_len);          my $assignments = $peer->get_assignments($session, $assign_start, $assign_req_len);
192    
# Line 189  Line 209 
209      # Now install annotations.      # Now install annotations.
210      #      #
211    
     open(my $old_assignments, ">old_assignments");  
   
212      for my $genome (keys(%genome_annos))      for my $genome (keys(%genome_annos))
213      {      {
214          #          #
# Line 228  Line 246 
246          if (-f $anno_file)          if (-f $anno_file)
247          {          {
248              rename($anno_file, $anno_bak) or die "Cannot rename $anno_file to $anno_bak: $!";              rename($anno_file, $anno_bak) or die "Cannot rename $anno_file to $anno_bak: $!";
249                print $log_fh "Moved annotations file $anno_file to backup $anno_bak\n";
250          }          }
251    
252          if (open(my $fh, "<$anno_bak"))          if (open(my $fh, "<$anno_bak"))
# Line 313  Line 332 
332                  #                  #
333    
334                  warn "Skipping assignment for $peg $func due to more recent assignment $cand[0]->[3]\n";                  warn "Skipping assignment for $peg $func due to more recent assignment $cand[0]->[3]\n";
335                    print $log_fh "Skipping assignment for $peg $func due to more recent assignment $cand[0]->[3]\n";
336              }              }
337              else              else
338              {              {
# Line 321  Line 341 
341                  #                  #
342    
343                  my $old = $fig->function_of($peg, 'master');                  my $old = $fig->function_of($peg, 'master');
                 print $old_assignments "$peg\t$old\n";  
344    
345                  if ($old ne $func)                  if ($old ne $func)
346                  {                  {
347                      print "Assign $peg $func\n";                      print "Assign $peg $func\n";
348                        print $log_fh "Assign $peg $func\n";
349                        print $log_fh "   was $old\n";
350                      $fig->assign_function($peg, 'master', $func);                      $fig->assign_function($peg, 'master', $func);
351                  }                  }
352              }              }
# Line 361  Line 382 
382          close($outfh);          close($outfh);
383          chmod(0666, $anno_file) or warn "Cannot chmod 0666 $anno_file: $!\n";          chmod(0666, $anno_file) or warn "Cannot chmod 0666 $anno_file: $!\n";
384          print "Wrote $anno_file. $new_count new annos, $inst installed, $dup duplicates\n";          print "Wrote $anno_file. $new_count new annos, $inst installed, $dup duplicates\n";
385            print $log_fh "Wrote $anno_file. $new_count new annos, $inst installed, $dup duplicates\n";
         #  
         # _install_genome_annos($fig, $genome, $genome_annos{$genome});  
386      }      }
     close($old_assignments);  
387  }  }
388    
389  #  #
# Line 412  Line 430 
430          $peg_req_len = $peg_batch_size if $peg_req_len > $peg_batch_size;          $peg_req_len = $peg_batch_size if $peg_req_len > $peg_batch_size;
431    
432          print "Getting $peg_req_len pegs at $peg_start\n";          print "Getting $peg_req_len pegs at $peg_start\n";
433            print $log_fh "Getting $peg_req_len pegs at $peg_start\n";
434          my $ret = $peer->get_pegs($session, $peg_start, $peg_req_len);          my $ret = $peer->get_pegs($session, $peg_start, $peg_req_len);
435    
436          if (!$ret or ref($ret) ne "ARRAY")          if (!$ret or ref($ret) ne "ARRAY")
# Line 483  Line 502 
502              #              #
503    
504              print "$genome mapped to $my_genome\n";              print "$genome mapped to $my_genome\n";
505                print $log_fh "$genome mapped to $my_genome\n";
506              for my $peg (@$pegs)              for my $peg (@$pegs)
507              {              {
508                  push(@finalize_req, ['peg_genome', $peg]);                  push(@finalize_req, ['peg_genome', $peg]);
# Line 572  Line 592 
592                  if ($mapped)                  if ($mapped)
593                  {                  {
594                      print "$peg maps to $mapped via $alias\n";                      print "$peg maps to $mapped via $alias\n";
595                        print $log_fh "$peg maps to $mapped via $alias\n";
596                      $peg_mapping->{$peg}= $mapped;                      $peg_mapping->{$peg}= $mapped;
597                      $peg_cache->{$peg} = $mapped;                      $peg_cache->{$peg} = $mapped;
598                      last;                      last;
# Line 588  Line 609 
609              {              {
610                  push(@{$genome_map->{$genome_id}}, $peg);                  push(@{$genome_map->{$genome_id}}, $peg);
611                  print "$peg did not map on first pass\n";                  print "$peg did not map on first pass\n";
612                    print $log_fh "$peg did not map on first pass\n";
613              }              }
614          }          }
615      }      }
# Line 616  Line 638 
638          my @req = splice(@$finalize_req, 0, $fin_batch_size);          my @req = splice(@$finalize_req, 0, $fin_batch_size);
639    
640          print "Invoking finalize_pegs on ", int(@req), " pegs\n";          print "Invoking finalize_pegs on ", int(@req), " pegs\n";
641            print $log_fh "Invoking finalize_pegs on ", int(@req), " pegs\n";
642          my $ret = $peer->finalize_pegs($session, \@req);          my $ret = $peer->finalize_pegs($session, \@req);
643    
644          if (!$ret or ref($ret) ne "ARRAY")          if (!$ret or ref($ret) ne "ARRAY")
# Line 671  Line 694 
694                          if (@$res > 1)                          if (@$res > 1)
695                          {                          {
696                              warn "Multiple mappings found for $peg: @ids\n";                              warn "Multiple mappings found for $peg: @ids\n";
697                                print $log_fh "Multiple mappings found for $peg: @ids\n";
698                          }                          }
699                      }                      }
700                      else                      else
701                      {                      {
702                          print "failed: $peg  $my_genome and contig $local_contig start=$start end=$end strand=$strand\n";                          print "failed: $peg  $my_genome and contig $local_contig start=$start end=$end strand=$strand\n";
703                            print $log_fh "failed: $peg  $my_genome and contig $local_contig start=$start end=$end strand=$strand\n";
704                          $sought{$peg}++;                          $sought{$peg}++;
705                          $sought_seq{$peg} = $seq;                          $sought_seq{$peg} = $seq;
706                      }                      }
# Line 683  Line 708 
708                  else                  else
709                  {                  {
710                      print "Mapping failed for $my_genome checksum $cksum\n";                      print "Mapping failed for $my_genome checksum $cksum\n";
711                        print $log_fh "Mapping failed for $my_genome checksum $cksum\n";
712                      $sought{$peg}++;                      $sought{$peg}++;
713                      $sought_seq{$peg} = $seq;                      $sought_seq{$peg} = $seq;
714                  }                  }
# Line 705  Line 731 
731              my %trans;              my %trans;
732    
733              print "Starting tough search\n";              print "Starting tough search\n";
734                print $log_fh "Starting tough search\n";
735    
736              $fig->tough_search(undef, \%sought_seq, \%trans, \%sought);              $fig->tough_search(undef, \%sought_seq, \%trans, \%sought);
737              print "Tough search translated: \n";              print "Tough search translated: \n";
738                print $log_fh "Tough search translated: \n";
739              while (my($tpeg, $ttrans) = each(%trans))              while (my($tpeg, $ttrans) = each(%trans))
740              {              {
741                  print "  $tpeg -> $ttrans\n";                  print "  $tpeg -> $ttrans\n";
742                    print $log_fh "  $tpeg -> $ttrans\n";
743                  $peg_mapping->{$tpeg} = $ttrans;                  $peg_mapping->{$tpeg} = $ttrans;
744                  $peg_cache->{$tpeg} = $ttrans;                  $peg_cache->{$tpeg} = $ttrans;
745              }              }
# Line 1032  Line 1061 
1061      #      #
1062    
1063      &FIG::verify_dir("$FIG_Config::temp/p2p_spool");      &FIG::verify_dir("$FIG_Config::temp/p2p_spool");
1064      #my $spool_dir = tempdir(DIR  => "$FIG_Config::temp/p2p_spool");      my $spool_dir = tempdir(DIR  => "$FIG_Config::temp/p2p_spool");
1065    
1066      my $spool_dir = "$FIG_Config::temp/p2p_spool/test";      #my $spool_dir = "$FIG_Config::temp/p2p_spool/test";
1067      &FIG::verify_dir($spool_dir);      &FIG::verify_dir($spool_dir);
1068    
1069      my $session_id = basename($spool_dir);      my $session_id = basename($spool_dir);
# Line 1557  Line 1586 
1586      return $assign_output;      return $assign_output;
1587  }  }
1588    
1589    1;

Legend:
Removed from v.1.21  
changed lines
  Added in v.1.22

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3