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

Diff of /FigKernelPackages/ACH.pm

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

revision 1.1, Wed Sep 30 19:41:44 2009 UTC revision 1.4, Tue Nov 3 21:20:07 2009 UTC
# Line 70  Line 70 
70    
71  =head2 Primary Methods  =head2 Primary Methods
72    
73    =head3 methods
74    
75        my $document = $achObject->methods();
76    
77    Return a list of the methods allowed on this object.
78    
79    =cut
80    
81    use constant METHODS => [qw(equiv_sequence
82                                equiv_precise
83                            )];
84    
85    sub methods {
86        # Get the parameters.
87        my ($self) = @_;
88        # Return the result.
89        return METHODS;
90    }
91    
92  =head3 equiv_sequence  =head3 equiv_sequence
93    
94      my $document = $achObject->equiv_sequence($args);      my $document = $achObject->equiv_sequence($args);
# Line 91  Line 110 
110    
111  =item RETURN  =item RETURN
112    
113  Normally, returns a reference to a list of 4-tuples. Each 4-tuple contains an  Normally, returns a reference to a list of 5-tuples. Each 5-tuple contains an
114  identifier that is sequence-equivalent to at least one of the input identifiers,  identifier that is sequence-equivalent to at least one of the input identifiers,
115  the asserted function of that identifier, the source of the assertion, and a  the asserted function of that identifier, the source of the assertion, a
116  flag that is TRUE if the assertion is by an expert. If the C<-hash> flag  flag that is TRUE if the assertion is by an expert, and the name of the genome
117  is specified in the parameter list, then the return value will be a hash  relevant to the identifier (if any). If the C<-hash> flag is specified in the
118  of lists, keyed by incoming protein identifier, mapping each protein  parameter list, then the return value will be a hash of lists, keyed by incoming
119  identifier to a list of the relevant 4-tuples.  protein identifier, mapping each protein identifier to a list of the relevant
120    5-tuples.
121    
122  =back  =back
123    
# Line 108  Line 128 
128      my ($self, $args) = @_;      my ($self, $args) = @_;
129      # Get the Sapling database.      # Get the Sapling database.
130      my $sap = $self->{db};      my $sap = $self->{db};
     # Find out if we're returning a hash.  
     my $hashFlag = $args->{-hash} || 0;  
     # Declare the return variable.  
     my $retVal = ($hashFlag ? {} : []);  
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 };
134      }      }
135        # Find out if we're returning a hash.
136        my $hashFlag = $args->{-hash} || 0;
137        # Declare the return variable.
138        my $retVal = ($hashFlag ? {} : []);
139      # Get the list of IDs.      # Get the list of IDs.
140      my $ids = ServerThing::GetIdList(-ids => $args);      my $ids = ServerThing::GetIdList(-ids => $args);
     # These object name sequences are the base of every query. The first finds  
     # every identifier associated with a gene that produces the protein sequence.  
     # The second finds every identifier associated with the protein sequence  
     # itself.  
     my @objects = ("ProteinSequence IsProteinFor Feature IsIdentifiedBy Identifier HasAssertionFrom Source",  
                    "ProteinSequence IsNamedBy Identifier HasAssertionFrom Source");  
     # This is the list of fields we want back.  
     my $fields = [qw(Identifier(id) HasAssertionFrom(function) Source(id)  
                   HasAssertionFrom(expert))];  
     # Finally, this is the filter clause.  
     my $filter = "ProteinSequence(id) = ?";  
141      # Loop through the IDs in the list.      # Loop through the IDs in the list.
142      for my $id (@$ids) {      for my $id (@$ids) {
143          # This hash will contain a list of the relevant protein sequence IDs.          # This hash will contain a list of the relevant protein sequence IDs.
         # We apply the above two queries to each protein sequence of interest.  
144          my %prots;          my %prots;
145          # We'll put our assertions found in here.          # We'll put our assertions found in here.
146          my @results;          my @results;
# Line 157  Line 165 
165              }              }
166          }          }
167          # Loop through the protein sequences, finding assertions. For each          # Loop through the protein sequences, finding assertions. For each
168          # protein, we make two queries.          # protein, we make two queries. Note that we expect the number of
169            # protein sequences to be small, despite the large amount of work
170            # performed above.
171          for my $prot (sort keys %prots) {          for my $prot (sort keys %prots) {
172              for my $objects (@objects) {              # Get the assertions on the protein's identifiers.
173                  push @results, $sap->GetAll($objects, $filter, $prot, $fields);              @results = $sap->GetAll("ProteinSequence IsNamedBy Identifier HasAssertionFrom Source",
174              }                                      "ProteinSequence(id) = ?", [$prot],
175                                        [qw(Identifier(id) HasAssertionFrom(function)
176                                            Source(id) HasAssertionFrom(expert))]);
177                # Add the assertions on the identifiers for the protein's features.
178                push @results, $sap->GetAll("ProteinSequence IsProteinFor Feature IsIdentifiedBy Identifier HasAssertionFrom Source AND Feature IsOwnedBy Genome",
179                                            "ProteinSequence(id) = ?", [$prot],
180                                            [qw(Identifier(id) HasAssertionFrom(function)
181                                               Source(id) HasAssertionFrom(expert)
182                                               Genome(scientific-name))]);
183          }          }
184          # If we found results, put them in the return object.          # If we found results, put them in the return object.
185            Trace(scalar(@results) . " results found for $id.") if T(3);
186          if (@results) {          if (@results) {
187              if ($hashFlag) {              if ($hashFlag) {
188                  $retVal->{$id} = \@results;                  $retVal->{$id} = \@results;

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3