if a variable is displayed, show trait properties section, otherwise do not.
[sgn.git] / mason / chado / cvterm.mas
blobd4f2a6e0300e994eca7edb2e471cab7d2c2ec0a7
1 <%doc>
3 =head1 NAME
5 /chado/cvterm.mas - a component for printing the cvterm page
7 =head1 DESCRIPTION
9 Parameters:
11 =over 1
13 =item cvterm
15 CXGN::Chado::Cvterm object
19 =back
21 =head1 AUTHOR
23 Naama Menda <nm249@cornell.edu>
25 =cut
27 </%doc>
29 <%args>
30   $cvterm
31   $cvtermref
32 </%args>
34 <%once>
35 use CXGN::Page::FormattingHelpers qw/
36  info_section_html
37  page_title_html
38  columnar_table_html
40 use CXGN::Phenome::Qtl::Tools;
41 </%once>
43 <%perl>
45 my $cvterm_id   = $cvterm->cvterm_id;
46 my $db_name     = $cvterm->db->name;
47 my $accession   = $cvterm->accession;
48 my $cvterm_name = $cvterm->name;
49 my $definition  = $cvterm->definition;
50 my $is_variable = $cvterm->is_variable;
51 my $comment     = '' ;#$cvterm->comment;
52 #$stockref->{props} (hash of arrayrefs of cvtermprops. Keys = prop name, value = prop value)
53 my $editable_cvterm_props_string = $cvtermref->{editable_cvterm_props};
54 my @editable_cvterm_props = split "," , $editable_cvterm_props_string;
57 my $is_obsolete = $cvterm->is_obsolete();
58 my @synonyms    = $cvterm->synonyms();
59 my @def_dbxrefs = $cvterm->def_dbxrefs();
60 my @secondary_dbxrefs = $cvterm->secondary_dbxrefs();
61 my @image_ids = $cvterm->get_image_ids;
63 my $curator   = $cvtermref->{curator};
64 my $submitter = $cvtermref->{submitter};
65 my $sequencer = $cvtermref->{sequencer};
66 my $cvtermprops = $cvtermref->{props};
69 my @def_accessions;
70 if ( scalar (@def_dbxrefs ) > 0 ) {
71   # @def_accessions = map( $_->db->name . ":" . $_->accession , @def_dbxrefs);
74 my @secondary_accessions = ();
75 foreach ( @secondary_dbxrefs) {
76   my $db_name =       $_->db->name;
77   my $acc =           $_->accession;
78   my $urlprefix=      $_->db->urlprefix;
79   my $url =           $_->db->url;
80   my $full_acc =      $db_name . ":" . $acc;
81   my $link = $full_acc;
82   if ( $url ) {
83     my $xref_link = $urlprefix . $url . $acc;
84     $link = qq | <a href="$xref_link">$full_acc</a> |
85   }
86   push @secondary_accessions , $link ;
89 my @qtl_pops = CXGN::Phenome::Qtl::Tools->new()->is_from_qtl( $cvterm_id );
90 my @qtl_data;
92 if ( @qtl_pops )
93  {
94     foreach my $pop (@qtl_pops)
95     {
96       my $pop_id   = $pop->get_population_id();
97       my $name     = $pop->get_name();
98       my $desc     = $pop->get_description();
99       my $qtl_link = qq | <a href="/phenome/qtl_analysis.pl?population_id=$pop_id&amp;cvterm_id=$cvterm_id" onClick="Qtl.waitPage()">$name</a> |;
100       push @qtl_data, [ $qtl_link, $desc ];
101     }
104 my $this_page = "/cvterm/$cvterm_id/view/";
105 my $image_subtitle =
106    " <a href=\"/image/add?type_id=$cvterm_id&type=cvterm&refering_page=$this_page\">[Add image]</a>" ;
109 my $edit_privs = $curator ;
111 </%perl>
114 <& /util/import_javascript.mas, classes => [qw [CXGN.AJAX.Ontology  CXGN.Phenome.Qtl thickbox jquery  jquery.dataTables] ] &>
117 <script language="javascript">
118   function recursiveAnnotations( a ) {
119       jQuery.ajax( { url:      a.url+"?cvterm_id=<% $cvterm_id %>" ,
120                      dataType: "json",
121                      success: function(response) {
122                               //jQuery("#"+a.content_id).html(response.html);
123                               jQuery("#"+a.count_id).html( response.count + ' ' + a.inflect[ response.count == 1 ? 0 : 1 ]);
124                        if( response.error )  {
125                              alert(response.error);
126                       }
127                      }
128                   });
129   }
130 </script>
133 <& /page/page_title.mas, title=> "$accession '$cvterm_name' " &>
136 <&| /page/info_section.mas, title=>"Cvterm details" &>
137 <table>
138 <tr><td>Term id</td><td><b><% $accession %></b></td></tr>
139 <tr><td>Term name</td><td><b><% $cvterm_name %></b></td></tr>
140 <tr><td>Term definition</td><td><b><% $definition %></b></td></tr>
141 <tr><td>Comment</td><td><b><% $comment %></b></td></tr>
142 </table>
144 % if ($is_obsolete) {
145 <b>Obsolete:</b> TRUE <br />
146 % }
148 <br /><b>Synoyms</b><br />
149 % foreach my $synonym (@synonyms) {
150 <% $synonym %> <br />
151 % }
153 <br /><b> Definition dbxrefs</b><br />
154 % foreach my $da (@def_accessions) {
155 <% $da %><br />
156 % }
158 <br /><b> Related dbxrefs</b><br />
159 % foreach my $sa (@secondary_accessions) {
160 <% $sa %><br />
161 %  }
163 </&>
164 <br />
167 % my $props_subtitle = $edit_privs ? "[<a id=\"cvterm_add_props\" href=\"javascript:cvtermprops_addPropDialog()\">Add...</a>]" : "[Add]";
169 % if ($is_variable) { 
170 <&| /page/info_section.mas, title => "Trait Properties" , collapsible=> 1, is_subsection => 1, subtitle=>$props_subtitle &>
171       <& /chado/cvtermprops.mas,
172        cv_name    => 'trait_property',
173        cvterm_id  =>$cvterm_id,
174        props      => $cvtermprops,
175         div_name   => 'cvtermprops',
176         edit_privs => $edit_privs,
177         subset     => \@editable_cvterm_props,
178         editable   => \@editable_cvterm_props  &>
179 </&>
181 % }
182 % else {
183     <&| /page/info_section.mas, title => "Trait Properties" , collapsible=> 1, is_collapsed => 1, is_subsection => 1, &>
184     No properties for traits. Trait properties can be set for variables only.
185     </&>
189 <div id="cvterm_id" style="display:none" ><% $cvterm_name %>|<% $accession %></div>
191 <&| /page/info_section.mas, title=>"Add this term to a list", collapsible=>1, collapsed=>1 &>
192 <div id="paste_to_list">
193 LOAD...
194 </div>
196 </&>
197 <script>
199   if (isLoggedIn()) { 
200     addToListMenu('paste_to_list', 'cvterm_id', { listType: 'traits' } );
201   }
202   else { 
203     jQuery('#paste_to_list').html("&nbsp;Please log in to use lists.");
204   }
205   
206 </script>
208 <br />
211 <& /ontology/embedded_browser.mas, cvterm => $cvterm &>
215 <&| /page/info_section.mas,
216     title=> "Annotated loci",
217     subtitle => '',
218     collapsible => 1,
219     collapsed   => 1,
222 <table id="loci_data" class="display">
223 <thead>
224   <tr>
225     <th>Organism</th>
226     <th>Locus symbol</th>
227     <th>Locus name</th>
228   </tr>
229 </thead>
231 </table>
233 <script>
235   jQuery(document).ready(function () {
236   
237     jQuery('#loci_data').DataTable( { 
238       'ajax': '/cvterm/'+ <% $cvterm_id %> + '/datatables/annotated_loci',
239      });
240   });
242 </script>
245 </&>
249 <&| /page/info_section.mas,
250        title=> "Annotated stocks",
251        collapsible => 1,
252        collapsed=>1,
253        subtitle => '',
254        hide_if_empty => 1,
255  &>
257 <table id="annotated_stocks_data" class="display">
258 <thead>
259   <tr>
260      <th>Type</th>
261     <th>Stock name</th>
262     <th>Description</th>
263   </tr>
264 </thead>
266 </table>
268 <script>
270   jQuery(document).ready(function () {
271   
272     jQuery('#annotated_stocks_data').DataTable( { 
273       'ajax': '/cvterm/'+ <% $cvterm_id %> + '/datatables/annotated_stocks',
274      });
275   });
277 </script>
280 </&>
284 % if ( @qtl_pops )
285 % {
286     <&| /page/info_section.mas,
287         title       => "QTL analysis",
288         collapsible => 1,
289    &>
290      <& /page/columnar_table.mas,
291         headings     => ["Analyze QTL in population", "Population description"], 
292         data         => \@qtl_data,
293         __alt_freq   => 2,
294         __align      =>'l',
295      &>
296   </&>
297 % }
301 <&| /page/info_section.mas,
302       title       => "Phenotyped accessions",
303       collapsible => 1,
304       collapsed=>1,
305       subtitle    => '' ,
309 <table id="phen_stocks_data" class="display">
310 <thead>
311   <tr>
312      <th>Type</th>
313     <th>Stock name</th>
314     <th>Description</th>
315   </tr>
316 </thead>
318 </table>
320 <script>
322   jQuery(document).ready(function () {
323   
324     jQuery('#phen_stocks_data').DataTable( { 
325       'ajax': '/cvterm/'+ <% $cvterm_id %> + '/datatables/phenotyped_stocks',
326      });
327   });
329 </script>
332 </&>
336 <&| /page/info_section.mas,
337       title       => "Phenotyping trials",
338       collapsible => 1,
339       collapsed=>1,
340       subtitle    => '<span id="trial_count"></span>',
343 <script language="javascript">
344     recursiveAnnotations({
345                          url:        "/cvterm/"+<% $cvterm_id %>+"/datatables/direct_trials",
346                          content_id: "trial_div",
347                          count_id:   "trial_count",
348                          inflect:    [ 'trial', 'trials' ],
349                        });
350 </script>
354 <table id="trial_data" class="display">
355 <thead>
356   <tr>
357      <th>Trial name</th>
358      <th>Description</th>
359   </tr>
360 </thead>
362 </table>
364 <script>
366   jQuery(document).ready(function () {
367   
368     jQuery('#trial_data').DataTable( { 
369       'ajax': '/cvterm/'+ <% $cvterm_id %> + '/datatables/direct_trials',
370        }
371      );
372   });
374 </script>
376 </&>
378 <&| /page/info_section.mas, 
379     title => "Images and figures",
380     subtitle      => $image_subtitle,
381     collapsible   => 1,
382     collapsed     => 0,
383     hide_if_empty => 1,
386 <& /image/print_images.mas, images => \@image_ids &>
388 </&>
390 <& /qtl/waitmessage.mas &>