5 /stock/index.mas - a page for displaying stock details (e.g. accession, population, etc.)
15 a hashref with all the parameters needed for printing the stock page!
20 $stockref->{uniquename}
21 $stockref->{curator} (boolean)
22 $stockref->{submitter} (boolean)
23 $stockref->{is_owner} (boolean)
24 $stockref->{props} (hash of arrayrefs of stockprops. Keys = prop name, value = prop value)
25 $stockref->{has_pedigree} (boolean)
26 $stockref->{has_descendants} (boolean)
28 locus_autocomplete_uri => '/ajax/locus/autocomplete/'
30 cvterm_autocomplete_uri => '/ajax/cvterm/autocomplete/'
33 organism_autocomplete_uri => '/ajax/organism/autocomplete/'
39 Naama Menda <nm249@cornell.edu>
49 $locus_autocomplete_uri => undef
51 $cvterm_autocomplete_uri => undef
52 $barcode_tempdir => undef
53 $barcode_tempuri => undef
54 $identifier_prefix => 'SGN'
55 $organism_autocomplete_uri => '/ajax/organism/autocomplete/'
62 use Bio::Chado::Schema;
63 use CXGN::Chado::Stock;
64 use CXGN::Page::FormattingHelpers qw / html_optional_show info_table_html /;
65 use CXGN::People::Person;
66 use CXGN::Chado::Publication;
67 use CXGN::Cview::Map::SGN::Genotype;
68 use CXGN::Cview::MapOverviews;
70 my $stock = $stockref->{stock};
71 my $stock_id = $stockref->{stock_id};
72 my $action = $stockref->{action} || 'view';
73 my $person_id = $stockref->{person_id};
74 my $curator = $stockref->{curator};
75 my $submitter = $stockref->{submitter};
76 my $sequencer = $stockref->{sequencer};
77 my $pubs = $stockref->{pubs};
78 my $has_pedigree = $stockref->{has_pedigree};
79 my $has_descendants = $stockref->{has_descendants};
80 my $trait_ontology_db_name = $stockref->{trait_ontology_db_name};
82 my $schema = $stockref->{schema};
83 my $dbh = $stockref->{dbh};
85 my $stockprop_cv = $schema->resultset("Cv::Cv")->search( {
86 'me.name' => 'stock_property'} );
89 my ($type_name, $uniquename);
90 my $type = $stock_row ? $stock_row->type : undef;
91 $type_name = $type->name() if $type;
92 $uniquename = $stock->get_uniquename if $type;
94 my $is_owner = $stockref->{is_owner};
96 my $this_page = "/stock/$stock_id/view";
98 my $add_image_link = qq|<a href="/image/add?type_id=$stock_id&action=new&type=stock&refering_page=$this_page">[Add new image]</a>|;
99 my $image_ids = $stockref->{image_ids} || [] ;
100 my $stockprops = $stockref->{props};
102 my $metadata = ['variety', 'donor', 'donor institute', 'country', 'state' , 'adaptation' , 'notes'];
104 #my $pedigree= ['pedigree', 'male parent', 'female parent'];
105 # get pedigree of stock
106 #my $stock_pedigree = $stockref->{stock_pedigree};
107 #my $stock_descendants = $stockref->{stock_descendants};
110 my $experiment = ['year', 'location', 'replicate']; # these values should be in nd_experimentprop ?
112 my $resources = [ 'synonym', 'solcap number'];
114 my $allele_div = "stock_alleles";
115 my $new_locus_link = !$person_id ? qq|<a href="/solpeople/login.pl">[log-in to associate new locus]</a> | : '' ;
118 my $owners = $stockref->{owners};
120 foreach my $o_id (@$owners) {
121 my $person = CXGN::People::Person->new($dbh, $o_id);
122 my $first_name = $person->get_first_name;
123 my $last_name = $person->get_last_name;
124 $editor_link .= qq|<a href="/solpeople/personal-info.pl?sp_person_id=$o_id">$first_name $last_name</a> |;
127 #phenotypes measured directly on this stock
128 my $direct_phenotypes = $stockref->{direct_phenotypes} || undef;
130 # get all phenotypes of subjects
131 my $members_phenotypes = $stockref->{members_phenotypes};
132 my $p_download_link = qq|<a href = "/stock/$stock_id/phenotypes">[Download phenotypes]</a>| if ( (keys %$direct_phenotypes) || ( keys %$members_phenotypes) );
133 my $direct_genotypes = $stockref->{direct_genotypes};
134 my $g_download_link = qq|<a href = "/stock/$stock_id/genotypes">Download genotypes</a>| if (keys %$direct_genotypes) ;
135 ############################
136 my $map_html = $stockref->{map_html};
139 $map = CXGN::Cview::Map::SGN::Genotype->new($dbh, $stock_id);
140 if ($map->get_chromosome_count > 1 ) {
141 my $overview = CXGN::Cview::MapOverviews::Generic->new($map,
144 basepath => $stockref->{cview_basepath},
145 tempfiles_subdir => $stockref->{cview_tmp_dir } });
147 $overview->render_map();
148 $map_html .= $overview->get_image_html();
152 #########################################
153 my $has_qtl_data = $stockref->{has_qtl_data};
156 my $new_pub_link = $curator || $submitter || $sequencer ? qq|<a href="/chado/add_publication.pl?type=stock&type_id=$stock_id&refering_page=$this_page&action=new"> [Associate publication] </a>| : qq|<span class=\"ghosted\">[Associate publication]</span>| ;
158 my $pub_count = scalar( keys %$pubs );
160 ## EUSOL, tgrc (stock_dbxref)
161 my $dbxrefs = $stockref->{dbxrefs};
163 foreach my $db_name ( keys %$dbxrefs ) {
164 foreach my $dbxref ( @{ $dbxrefs->{$db_name} } ) {
165 my $url = $dbxref->db->urlprefix . $dbxref->db->url;
166 $url .= $dbxref->accession if $url =~ m/\?$|\=$/ ;
167 $source_dbs{$url} = $db_name . ": " . $dbxref->accession if $url;
171 my $ontology_subtitle = $curator || $submitter || $sequencer ?
172 qq|<a href="javascript:Tools.toggleContent('associate_cvterm_form', 'stock_ontology')">[Add ontology annotations]</a> | :
173 qq |<span class = "ghosted"> [Add ontology annotations]</span> |;
175 my $add_phenotype_link = $curator || $submitter || $sequencer ? qq| <a href="javascript:Tools.toggleContent('add_phenotype_form', 'stock_phenotype')" >[Add phenotype]</a> | : qq |<span class = "ghosted"> [Add phenotype]</span> |;
177 my $edit_privs = $curator || $submitter || $sequencer;
179 <& /util/import_javascript.mas, classes => ["jquery", "jqueryui", "thickbox", "CXGN.Phenome.Tools", "CXGN.Page.FormattingHelpers", "jquery.cookie"] &>
182 <script language="javascript">
183 function jqueryStuff() {
185 jQuery("#species_name").autocomplete({
186 source: '/organism/autocomplete'
191 <& /page/page_title.mas, title=> join( ': ', grep $_, ucfirst($type_name), $uniquename ) || 'Create a new stock' &>
194 <&| /page/info_section.mas, title=>"Stock details" , subtitle => "<a href=/phenome/qtl_form.pl>New QTL population</a> | <a href=/stock/search/>Back to stock search</a>" &>
196 <table><tr><td width="400">
198 object_type=>'stock',
199 object_id=>"$stock_id",
200 form_name=> 'stock_form',
201 server_side_script => '/phenome/stock/stock_ajax_form.pl',
202 form_div_name=>'stock_details',
203 js_object_name=> 'stockForm',
204 page_url => "/stock/$stock_id/view/" ,
205 alternate_new_button => '<a href ="/stock/0/new">[New]</a>'
209 <& /util/barcode.mas, identifier => "$identifier_prefix"."$stock_id", text=> "$identifier_prefix stock $stock_id ($uniquename)", format=>"code128" &><br /><br />
210 % #<& /util/barcode.mas, identifier => "http://solgenomics.net/stock/$stock_id/view", text=>"SGN stock $stock_id ($uniquename)", format=>"qrcode" &>
215 <div><b>Stock editors: </b> <% $editor_link %></div>
217 % foreach my $db_url (keys %source_dbs) {
218 <div><a href=<% $db_url %>><% $source_dbs{$db_url} %></a> </div>
221 % my $div_name = join("_", @$resources);
222 % my $subtitle = $edit_privs ? "[<a href=\"javascript:synonyms_addPropDialog()\">Add...</a>]" : "[Add]";
223 <&| /page/info_section.mas, title => "Synonyms" , is_subsection => 1 , subtitle=>$subtitle &>
224 <& /stock/stockprops.mas, stock_id=> $stock_id, props=> $stockprops , div_name=>'synonyms', subset=>$resources, editable=> [ 'synonym' ], edit_privs => $edit_privs &>
226 % $div_name = join("_", @$metadata);
227 <&| /page/info_section.mas, title => "Additional information" , collapsible=> 1, is_subsection => 1 &>
228 <& /stock/stockprops.mas, stock_id=>$stock_id, props=> $stockprops, subset=> $metadata &>
235 <&| /page/info_section.mas, title => "Associated loci (" . $stockref->{allele_count} . ")" , subtitle => $new_locus_link, collapsible=> 1 , collapsed => 1 &>
237 <& /phenome/associate_locus.mas, object_id => $stock_id , object_name => "stock", locus_add_uri=> $locus_add_uri, allele_div => $allele_div , show_form => $is_owner &>
242 <&| /page/info_section.mas, title => "Experimental data" , collapsible=> 1, is_subsection => 0 &>
243 <& /stock/stockprops.mas, stock_id=>$stock_id, props=> $stockprops, subset=> $experiment &>
247 <&| /page/info_section.mas, title=>"Stock history", collapsible=>1, collapsed=>1 &>
254 % my $collapsible = 0;
255 % if ($has_pedigree==1) {
258 % my $add_parent_link = "Add parent";
259 % if ($person_id && $submitter) { $add_parent_link = qq | <a id="add_parent_link" >Add parent</a> |; }
261 <&| /page/info_section.mas, title=>"Pedigree" , collapsible=> $collapsible, collapsed=>0, subtitle=>"[$add_parent_link]" &>
262 <& /pedigree/stock_pedigree.mas, stock_id => $stock_id, has_pedigree => $has_pedigree &>
269 % if ($has_descendants==1) {
271 <&| /page/info_section.mas, title=>"Descendants" , collapsible=>1, collapsed=>0 &>
272 <& /pedigree/stock_descendants.mas, stock_id => $stock_id &>
277 <&| /page/info_section.mas, title=>"Descendants" , collapsible=>1, collapsed=>1 &>
284 <&| /page/info_section.mas, title=>"Related stocks" , collapsible=>1, collapsed=>0 &>
285 <& /stock/related_stocks.mas, stock => $stock_row &>
292 <&| /page/info_section.mas, title=>"Images (" . scalar(@$image_ids) . ")", subtitle => "$add_image_link", collapsible=>1, collapsed=>1 &>
293 <& /image/print_images.mas , images=>$image_ids , dbh=>$dbh &>
298 <&| /page/info_section.mas, title=>"Literature annotation ($pub_count)" , subtitle=>$new_pub_link, id=>"publications" , collapsible=>1, collapsed=>1 &>
301 % foreach my $full_accession ( keys %$pubs ) {
302 % my $pub = CXGN::Chado::Publication->new($dbh, $pubs->{$full_accession}->pub_id );
303 % my ($pub_db_name, $accession) = split ':' , $full_accession;
304 <& /chado/publication.mas, pub=>$pub, count=>$pub_count++, db=>$pub_db_name, accession=>$accession &>
310 <&| /page/info_section.mas,
311 id => 'stock_ontology',
312 title=>"Ontology annotation (" . $stockref->{ontology_count} . ")",
315 subtitle=>$ontology_subtitle &>
316 <& /ontology/associate_ontology.mas,
317 trait_db_name => $trait_ontology_db_name,
318 object_id => $stock_id ,
319 object_name => "stock",
320 cvterm_add_uri=> $cvterm_add_uri,
321 ontology_url => "/stock/$stock_id/ontologies/",
322 reference_uri => "/stock/$stock_id/references/",
323 evidence_with_uri => "/stock/$stock_id/evidences/",
324 show_form => $is_owner &>
327 <&| /page/info_section.mas, title=>"Phenotype data " , subtitle=>$p_download_link , collapsible => 1, collapsed => 1 &>
328 % foreach my $project (keys %$direct_phenotypes) {
329 % my $rs = $direct_phenotypes->{$project} ;
331 <&| /page/info_section.mas,
332 id => "stock_phenotype",
333 title =>"Experiment: $project",
334 subtitle => $add_phenotype_link,
338 <& /stock/add_phenotype.mas,
339 stock_id => $stock_id ,
340 trait_ontology_db_name => $trait_ontology_db_name,
343 <& /phenotypes/phenotype_data.mas ,
349 % foreach my $key (keys %$members_phenotypes) {
350 % my $m_rs = $members_phenotypes->{$key};
351 <&| /page/info_section.mas,
352 title => "Member phenotypes",
357 <& /phenotypes/phenotype_data.mas,
359 object_id => $stock_id,
360 has_qtl => $has_qtl_data,
366 <&| /page/info_section.mas, title=>"Genotype data ", subtitle=> $g_download_link, collapsible => 1 , collapsed => 1 &>
368 % foreach my $project (keys %$direct_genotypes) {
369 % my $genotypes = $direct_genotypes->{$project} ;
370 <&| /page/info_section.mas, title=>"Experiment: $project", is_subsection => 1, collapsible => 1 &>
371 % foreach my $genotype (@$genotypes) {
372 % print $genotype->description . "\n";
379 <& /page/comments.mas, object_type=>'stock', object_id=>$stock_id, referer=>$this_page &>