Difference between revisions of "Design Specs: Evidence Handling"
From WormBaseWiki
Jump to navigationJump to search (→API) |
(→API) |
||
Line 1: | Line 1: | ||
=API= | =API= | ||
+ | |||
+ | ==the base function== | ||
by calling the _get_evidence($node,$type) subroutine in lib/API/Object.pm | by calling the _get_evidence($node,$type) subroutine in lib/API/Object.pm | ||
− | + | argument $type is optional. If specified, only this type of evidence is retrieved. | |
returns a hash reference containing all the types of evidences to the right of the node | returns a hash reference containing all the types of evidences to the right of the node | ||
− | + | code snippet: | |
− | + | $data{$type}{$evidence}{id} = "$evidence"; | |
+ | $data{$type}{$evidence}{label} = "$label"; | ||
+ | $data{$type}{$evidence}{class} = lc($class) if(defined $class); | ||
+ | ... | ||
+ | return %data ? \%data :undef; | ||
+ | |||
+ | ==use it in object model module== | ||
+ | |||
e.g. in lib/API/Object/Gene.pm | e.g. in lib/API/Object/Gene.pm | ||
+ | sub gene_ontology { | ||
+ | |||
+ | push @{ $data{$facet} }, { | ||
+ | method => $1, | ||
+ | evidence_code => {text=>"$evidence_code",evidence=>$self->_get_evidence($evidence_code)}, | ||
+ | term => $self->_pack_obj($go_term), | ||
+ | }; | ||
+ | } | ||
=Template= | =Template= |
Revision as of 20:41, 3 January 2012
API
the base function
by calling the _get_evidence($node,$type) subroutine in lib/API/Object.pm argument $type is optional. If specified, only this type of evidence is retrieved. returns a hash reference containing all the types of evidences to the right of the node
code snippet: $data{$type}{$evidence}{id} = "$evidence";
$data{$type}{$evidence}{label} = "$label"; $data{$type}{$evidence}{class} = lc($class) if(defined $class);
... return %data ? \%data :undef;
use it in object model module
e.g. in lib/API/Object/Gene.pm sub gene_ontology {
push @{ $data{$facet} }, { method => $1, evidence_code => {text=>"$evidence_code",evidence=>$self->_get_evidence($evidence_code)}, term => $self->_pack_obj($go_term), }; }