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

Diff of /FigKernelPackages/FC.pm

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

revision 1.4, Mon Mar 9 14:42:27 2009 UTC revision 1.5, Tue Mar 10 03:35:23 2009 UTC
# Line 174  Line 174 
174      my($db,$peg1,$peg2) = @_;      my($db,$peg1,$peg2) = @_;
175    
176      my($key,$inv,$set);      my($key,$inv,$set);
177      my $key = ($peg1 lt $peg2) ? "$peg1:$peg2" : "$peg2:$peg1";      $key = ($peg1 lt $peg2) ? "$peg1:$peg2" : "$peg2:$peg1";
178    
179      my $query = $db->Get("Pairing Determines",      my $query = $db->Get("Pairing Determines",
180                           "Pairing(id) = ?",[$key]);                           "Pairing(id) = ?",[$key]);
# Line 197  Line 197 
197  # This routine inserts a Pairing for $peg1 and $peg2  # This routine inserts a Pairing for $peg1 and $peg2
198  sub insert_pair {  sub insert_pair {
199      my($db,$peg1,$peg2,$set) = @_;      my($db,$peg1,$peg2,$set) = @_;
200        # Compute the key and the inversion flag.
201      my $key = ($peg1 lt $peg2) ? "$peg1:$peg2" : "$peg2:$peg1";      my ($invertFlag, $key);
202        if ($peg1 lt $peg2) {
203            $key = "$peg1:$peg2";
204            $invertFlag = 0;
205        } else {
206            $key = "$peg2:$peg1";
207            $invertFlag = 1;
208        }
209        # Create the pairing.
210        $db->InsertObject('Pairing', id => $key);
211        # Connect it to its constituent features.
212        $db->InsertObject('IsInPair', from_link => $peg1, to_link => $key);
213        $db->InsertObject('IsInPair', from_link => $peg2, to_link => $key);
214        # Insert it into the pair set.
215        $db->InsertObject('IsDeterminedBy', from_link => $set, to_link => $key,
216                          inverted => $invertFlag);
217      print STDERR "inserted $peg1:$peg2 into $set\n";      print STDERR "inserted $peg1:$peg2 into $set\n";
218  }  }
219    
220  # This routine creates a new PairSet, returning the ID  # This routine creates a new PairSet, returning the ID
221  sub new_set {  sub new_set {
222      my($db) = @_;      my($db) = @_;
223      my $next_id = 0;      # Create the new pair set.
224        my $retVal = $db->InsertNew('PairSet', score => 0);
225      return $next_id;      # Return its ID.
226        return $retVal;
227  }  }
228    
229    
# Line 217  Line 232 
232    
233  sub delete_PairSet {  sub delete_PairSet {
234      my($db,$pair_set) = @_;      my($db,$pair_set) = @_;
235        # Disconnect the pair set from all of its pairings.
236        $db->Disconnect('IsDeterminedBy', PairSet => $pair_set);
237        # Delete the pair set. Because we've already disconnected, the pairings
238        # are safe.
239        $db->Delete(PairSet => $pair_set);
240      print STDERR "deleted PairSet $pair_set\n";      print STDERR "deleted PairSet $pair_set\n";
241  }  }
242    
# Line 226  Line 245 
245    
246  sub delete_pair_from_PairSet {  sub delete_pair_from_PairSet {
247      my($db,$pair,$PairSet) = @_;      my($db,$pair,$PairSet) = @_;
248        # Delete the relationship connecting this set to this pair.
249        $db->DeleteRow('IsDeterminedBy', $PairSet, $pair);
250  }  }
251    
252  # This routine updates the "score" field in a PairSet  # This routine updates the "score" field in a PairSet
253  sub set_pair_set_sc {  sub set_pair_set_sc {
254      my($db,$pair_set,$sc) = @_;      my($db,$pair_set,$sc) = @_;
255        # Update the score in place.
256        $db->UpdateEntity(PairSet => $pair_set, score => $sc);
257      print STDERR "reset score of PairSet to $sc\n";      print STDERR "reset score of PairSet to $sc\n";
258  }  }
259    

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3