[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.5, Tue Nov 3 21:20:07 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 65  Line 65 
65    
66  =head2 Primary Methods  =head2 Primary Methods
67    
68    =head3 methods
69    
70        my $document = $coObject->methods();
71    
72    Return a list of the methods allowed on this object.
73    
74    =cut
75    
76    use constant METHODS => [qw(conserved_in_neighborhood
77                                pairsets
78                                clusters_containing
79                                related_clusters
80                                co_occurrence_evidence
81                                related_figfams
82                            )];
83    
84    sub methods {
85        # Get the parameters.
86        my ($self) = @_;
87        # Return the result.
88        return METHODS;
89    }
90    
91  =head3 conserved_in_neighborhood  =head3 conserved_in_neighborhood
92    
93      my $document = $coObject->conserved_in_neighborhood($args);      my $document = $coObject->conserved_in_neighborhood($args);
# Line 78  Line 101 
101  =item args  =item args
102    
103  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
104  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),
105    the additional parameter C<-hash> can be provided. If it has a value of
106    TRUE, then the output will be a hash of lists instead of a list of lists.
107    
108  =item RETURN  =item RETURN
109    
110  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
111  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
112  one per feature functionally coupled to the input feature. Each tuple  feature functionally coupled to the input feature. Each tuple contains the
113  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
114  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.
115  set to which the coupling belongs.  If the output is a hash, it maps each incoming feature ID to that feature's
116    sub-list.
117    
118  =back  =back
119    
# Line 98  Line 124 
124      my ($self, $args) = @_;      my ($self, $args) = @_;
125      # Get the sapling database.      # Get the sapling database.
126      my $sapling = $self->{db};      my $sapling = $self->{db};
127        # Determine the output format.
128        my $hashFormat = $args->{-hash} || 0;
129      # Declare the return variable.      # Declare the return variable.
130      my $retVal = [];      my $retVal = ($hashFormat ? {} : []);
131      # Convert a list to a hash.      # Convert a list to a hash.
132      if (ref $args ne 'HASH') {      if (ref $args ne 'HASH') {
133          $args = { -ids => $args };          $args = { -ids => $args };
# Line 119  Line 147 
147              # Add it to the group of tuples for this feature's couplings.              # Add it to the group of tuples for this feature's couplings.
148              push(@$group, [$sc, $fid, $sapling->Assignment($fid), $pairset]);              push(@$group, [$sc, $fid, $sapling->Assignment($fid), $pairset]);
149          }          }
150          # Add this feature's couplings to the return list.          # Add this feature's couplings to the return value.
151            if ($hashFormat) {
152                $retVal->{$id} = $group;
153            } else {
154          push(@$retVal, $group);          push(@$retVal, $group);
155      }      }
156        }
157      # Return the result.      # Return the result.
158      return $retVal;      return $retVal;
159  }  }
# Line 232  Line 264 
264    
265      my $document = $coObject->related_clusters($args);      my $document = $coObject->related_clusters($args);
266    
267  This method returns the functional-coupling clusters for features related  This method returns the functional-coupling clusters related to the specified
268  to the specified input features.  input features. Each cluster contains features on a single genome that are
269    related by functional coupling.
270    
271  =over 4  =over 4
272    
# Line 288  Line 321 
321      return $retVal;      return $retVal;
322  }  }
323    
324    =head3 co_occurrence_evidence
325    
326        my $document = $coObject->co_occurrence_evidence($args);
327    
328    For each specified pair of genes, this method returns the evidence that
329    the genes are functionally coupled (if any); that is, it returns a list
330    of the physically close homologs for the pair.
331    
332    =over 4
333    
334    =item args
335    
336    Reference to a hash containing the parameters.
337    
338    =item RETURN
339    
340    Returns a hash mapping each incoming gene pair to a list of 2-tuples. Each 2-tuple
341    contains a pair of physically close genes, the first of which is similar to the first
342    gene in the input pair, and the second of which is similar to the second gene in the
343    input pair. The hash keys will consist of the two gene IDs separated by a colon (e.g.
344    C<fig|273035.4.peg.1016:fig|273035.4.peg.1018>).
345    
346    =back
347    
348    =head4 Parameter Hash Fields
349    
350    =over 4
351    
352    =item -pairs
353    
354    Reference to a list of functionally-coupled pairs. Each pair is represented by two
355    FIG gene IDs, either in the form of a 2-tuple or as a string with the two gene IDs
356    separated by a colon.
357    
358    =back
359    
360    =cut
361    
362    sub co_occurrence_evidence {
363        # Get the parameters.
364        my ($self, $args) = @_;
365        # Declare the return variable.
366        my $retVal = {};
367        # Get the Sapling database.
368        my $sap = $self->{db};
369        # Get the list of pairs.
370        my $pairs = ServerThing::GetIdList(-pairs => $args);
371        # Loop through the pairs.
372        for my $pair (@$pairs) {
373            # Determine the IDs in this pair.
374            my ($peg1, $peg2);
375            if (ref $pair) {
376                ($peg1, $peg2) = @$pair;
377            } else {
378                ($peg1, $peg2) = split /:/, $pair;
379            }
380            # Get the evidence and store it in the return hash.
381            $retVal->{"$peg1:$peg2"} = FC::co_occurrence_evidence($sap, $peg1, $peg2);
382        }
383        # Return the result.
384        return $retVal;
385    }
386    
387    
388    
389  =head3 related_figfams  =head3 related_figfams
390    

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3