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

Diff of /FigKernelPackages/CO.pm

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

revision 1.1, Thu Aug 27 19:42:21 2009 UTC revision 1.3, Tue Oct 20 20:37:30 2009 UTC
# Line 29  Line 29 
29  =head1 Co-Occurrence Server Function Object  =head1 Co-Occurrence Server Function Object
30    
31  This file contains the functions and utilities used by the Co-Occurrence Server  This file contains the functions and utilities used by the Co-Occurrence Server
32  (B<co_occurs_server_.cgi>). The L</Primary Methods> represent function  (B<co_occurs_server.cgi>). The L</Primary Methods> represent function
33  calls direct to the server. These all have a signature similar to the following.  calls direct to the server. These all have a signature similar to the following.
34    
35      my $document = $coObject->function_name($args);      my $document = $coObject->function_name($args);
36    
37  where C<$coObject> is an object created by this module,  where C<$coObject> is an object created by this module, C<$args> is a parameter
38  C<$args> is a parameter structure, and C<function_name> is the Co-Occurrence  structure, and C<function_name> is the Co-Occurrence Server function name. The
39  Server function name. The output is a structure, generally a hash reference, but  output is a structure, generally a hash reference, but sometimes a string or a
40  sometimes a string or a list reference.  list reference.
41    
42  =head2 Special Methods  =head2 Special Methods
43    
# Line 46  Line 46 
46      my $coObject = CO->new();      my $coObject = CO->new();
47    
48  Create a new co-occurrence server function object. The server function object  Create a new co-occurrence server function object. The server function object
49  contains a pointer to a [[SaplingPm]] object, and is used to invoke the  contains a pointer to a L<Sapling> object, and is used to invoke the
50  server functions.  server functions.
51    
52  =cut  =cut
# Line 78  Line 78 
78  =item args  =item args
79    
80  Either (1) a reference to a hash mapping the key C<-ids> to a list of FIG  Either (1) a reference to a hash mapping the key C<-ids> to a list of FIG
81  feature IDs, or (2) a reference to a list of FIG feature IDs.  feature IDs, or (2) a reference to a list of FIG feature IDs. In case (1),
82    the additional parameter C<-hash> can be provided. If it has a value of
83    TRUE, then the output will be a hash of lists instead of a list of lists.
84    
85  =item RETURN  =item RETURN
86    
87  Returns a reference to a list of sub-lists. Each sub-list corresponds to  Returns a reference to a hash or list of sub-lists. Each sub-list corresponds to
88  a feature in the input list. The sub-list itself is a list of 4-tuples,  a feature in the input list. The sub-list itself is consists 4-tuples, one per
89  one per feature functionally coupled to the input feature. Each tuple  feature functionally coupled to the input feature. Each tuple contains the
90  contains the coupling score, the FIG ID of the coupled feature, the  coupling score, the FIG ID of the coupled feature, the coupled feature's current
91  coupled feature's current functinal assignment, and the ID of the pair  functional assignment, and the ID of the pair set to which the coupling belongs.
92  set to which the coupling belongs.  If the output is a hash, it maps each incoming feature ID to that feature's
93    sub-list.
94    
95  =back  =back
96    
# Line 98  Line 101 
101      my ($self, $args) = @_;      my ($self, $args) = @_;
102      # Get the sapling database.      # Get the sapling database.
103      my $sapling = $self->{db};      my $sapling = $self->{db};
104        # Determine the output format.
105        my $hashFormat = $args->{-hash} || 0;
106      # Declare the return variable.      # Declare the return variable.
107      my $retVal = [];      my $retVal = ($hashFormat ? {} : []);
108      # Convert a list to a hash.      # Convert a list to a hash.
109      if (ref $args ne 'HASH') {      if (ref $args ne 'HASH') {
110          $args = { -ids => $args };          $args = { -ids => $args };
# Line 119  Line 124 
124              # Add it to the group of tuples for this feature's couplings.              # Add it to the group of tuples for this feature's couplings.
125              push(@$group, [$sc, $fid, $sapling->Assignment($fid), $pairset]);              push(@$group, [$sc, $fid, $sapling->Assignment($fid), $pairset]);
126          }          }
127          # Add this feature's couplings to the return list.          # Add this feature's couplings to the return value.
128            if ($hashFormat) {
129                $retVal->{$id} = $group;
130            } else {
131          push(@$retVal, $group);          push(@$retVal, $group);
132      }      }
133        }
134      # Return the result.      # Return the result.
135      return $retVal;      return $retVal;
136  }  }

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3