[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.5, Wed Sep 22 20:41:39 2004 UTC revision 1.6, Fri Sep 24 18:34:32 2004 UTC
# Line 90  Line 90 
90              #              #
91              # Peg id is directly usable.              # Peg id is directly usable.
92              #              #
93                $peg_mapping{$peg} = $peg;
94          }          }
95          elsif ($key eq 'peg_info')          elsif ($key eq 'peg_info')
96          {          {
# Line 127  Line 128 
128      #      #
129      # finished first pass. Now go over the per-genome mappings that need to be made.      # finished first pass. Now go over the per-genome mappings that need to be made.
130      #      #
131        # $genome_map{$genome_id} is a list of pegs that reside on that genome.
132        # the pegs and genome id are both target-based identifiers.
133        #
134    
135        my @finalize_req = ();
136    
137      for my $genome_info (@$genome_list)      for my $genome_info (@$genome_list)
138      {      {
# Line 134  Line 140 
140    
141          next unless defined($genome_map{$genome});          next unless defined($genome_map{$genome});
142    
143            #
144            # Determine if we have a local genome installed that matches precisely the
145            # genome on the target side.
146            #
147          my $my_genome = $fig->find_genome_by_content($genome, $n_contigs, $n_nucs, $cksum);          my $my_genome = $fig->find_genome_by_content($genome, $n_contigs, $n_nucs, $cksum);
148    
149            my $pegs = $genome_map{$genome};
150    
151          if ($my_genome)          if ($my_genome)
152          {          {
153              #              #
154              # Found a match.              # We do have such a local genome. Generate a peg_genome request to
155                # get the location information from the target side.
156              #              #
157              print "Genome $genome maps to $my_genome locally\n";              print "$genome mapped to $my_genome\n";
158                push(@finalize_req, map { ['peg_genome', $_] } @$pegs);
159    
160          }          }
161          else          else
162          {          {
163              print "No mapping for $genome\n";              #
164                # We don't have such a genome. We need to retrieve the
165                # sequence data in order to finish mapping.
166                #
167                push(@finalize_req, map { ['peg_unknown', $_] } @$pegs);
168            }
169        }
170    
171        #
172        # If we need to finalize, make the call.
173        if (@finalize_req)
174        {
175            print Dumper(\@finalize_req);
176            $ret = $peer->finalize_pegs($session, \@finalize_req);
177    
178            if (!$ret or ref($ret) ne "ARRAY")
179            {
180                die "perform_update: finalize_pegs failed\n";
181          }          }
182    
183            #
184            # The return is a list of either location entries or
185            # sequence data.
186            #
187    
188            print Dumper($ret);
189      }      }
190  }  }
191    
# Line 369  Line 407 
407      return $self->call("get_pegs", $session_id, $start, $length);      return $self->call("get_pegs", $session_id, $start, $length);
408  }  }
409    
410    sub finalize_pegs
411    {
412        my($self, $session_id, $request) = @_;
413    
414        return $self->call("finalize_pegs", $session_id, $request);
415    }
416    
417  sub call  sub call
418  {  {
419      my($self, $func, @args) = @_;      my($self, $func, @args) = @_;
# Line 674  Line 719 
719    
720      return [$peg_output, $genome_output];      return [$peg_output, $genome_output];
721  }  }
722    
723    sub finalize_pegs
724    {
725        my($self, $session, $request) = @_;
726        my($out);
727    
728        my $fig = new FIG;
729    
730        #
731        # Walk the request handling appropriately. This is fairly easy, as it
732        # is just a matter of pulling either sequence or location/contig data.
733        #
734    
735        for my $item (@$request)
736        {
737            my($what, $peg) = @$item;
738    
739            if ($what eq "peg_genome")
740            {
741                #
742                # Return the location and contig checksum for this peg.
743                #
744    
745                my $loc = $fig->feature_location($peg);
746                my $contig = $fig->contig_of($loc);
747                my $cksum = $fig->contig_checksum($contig);
748    
749                push(@$out, ['peg_loc', $peg,
750                            $fig->strand_of($loc),
751                            $fig->beg_of($loc), $fig->end_of($loc),
752                            $cksum]);
753    
754            }
755            elsif ($what eq "peg_seq")
756            {
757                my $seq = $fig->get_translation($peg);
758                push(@$out, ['peg_seq', $peg, $seq]);
759            }
760        }
761        return $out;
762    }
763    

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3