Difference between revisions of "Design Specs: Evidence Handling"

From WormBaseWiki
Jump to navigationJump to search
(Created page with 'API: by calling the _get_evidence($node,$type) subroutine in lib/API/Object.pm returns a hash reference containing all the types of evidences to the right of the node argu…')
 
 
(21 intermediate revisions by the same user not shown)
Line 1: Line 1:
API:
+
=API=
  by calling the _get_evidence($node,$type) subroutine in lib/API/Object.pm
+
 
  returns a hash reference containing all the types of evidences to the right of the node
+
==the base function==
   argument $type is optional, if specified, only this type of evidence is retrieved.
+
 
 +
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:
 +
  sub _get_evidence {
 +
  ...
 +
  ...
 +
  $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 each class 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),
 +
            };
 +
  ...
 +
  }
 +
 
 +
=Template=
 +
 
 +
==generic evidence macro==
 +
 
 +
in root/templates/shared/page_elements.tt2 we defined the evidence macro
 +
 
 +
  [% MACRO evidence(data, id) BLOCK %]
 +
 
 +
data is the returned hash reference and id sets the div id number/label in case there are multiple evidence display on same page
 +
*e.g. root/templates/classes/gene/overview.tt2
 +
 
 +
  <pre> 
 +
    FOREACH sd IN fields.structured_description.data.keys;
 +
          WRAPPER $field_block title=String.capital;
 +
              FOREACH obj IN fields.structured_description.data.$sd;
 +
                  '<div class="text-width" style="margin:0.5em">';
 +
                      markup(obj.text);
 +
                      evidence(obj.evidence,sd);
 +
                  '</div>';
 +
              END;
 +
          END;
 +
    END;
 +
  </pre>
 +
 
 +
==DataTable==
 +
 
 +
in the jquery_data_table_html macro we also added evidence handling
 +
 
 +
if a cell in the table contains evidence information, it will be shown up automatically.
 +
 
 +
*the data structure returned from API for the cell element should be like:
 
   
 
   
   e.g. in lib/API/Object/Gene.pm
+
   { text=>...,
 +
    evidence=>...
 +
  }
  
 +
*eg. gene ontology widget on the gene page
  
Template:
+
[[File:Evidence display.png]]

Latest revision as of 21:11, 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: 
 sub _get_evidence {
 ...
 ...
 $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 each class 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),
           };
  ...
 }

Template

generic evidence macro

in root/templates/shared/page_elements.tt2 we defined the evidence macro

  [% MACRO evidence(data, id) BLOCK %]

data is the returned hash reference and id sets the div id number/label in case there are multiple evidence display on same page

  • e.g. root/templates/classes/gene/overview.tt2
  
    FOREACH sd IN fields.structured_description.data.keys;
          WRAPPER $field_block title=String.capital;
               FOREACH obj IN fields.structured_description.data.$sd;
                   '<div class="text-width" style="margin:0.5em">';
                      markup(obj.text);
                      evidence(obj.evidence,sd);
                   '</div>';
               END;
           END;
    END;
   

DataTable

in the jquery_data_table_html macro we also added evidence handling

if a cell in the table contains evidence information, it will be shown up automatically.

  • the data structure returned from API for the cell element should be like:
 { text=>...,
   evidence=>...
 }
  • eg. gene ontology widget on the gene page

Evidence display.png