3 my $population_detail_page = CXGN
::Phenome
::PopulationDetailPage
->new();
5 package CXGN
::Phenome
::PopulationDetailPage
;
9 use CXGN
::Page
::FormattingHelpers qw
/info_section_html
18 use CXGN
::Phenome
::Population
;
19 use CXGN
::Phenome
::PopulationDbxref
;
20 use CXGN
::People
::PageComment
;
21 use CXGN
::People
::Person
;
22 use CXGN
::Chado
::Publication
;
23 use CXGN
::Chado
::Pubauthor
;
29 use base qw
/ CXGN::Page::Form::SimpleFormPage CXGN::Phenome::Main/;
33 my $self = $class->SUPER::new
(@_);
34 $self->set_script_name("population.pl");
43 # call set_object_id, set_object and set_primary_key here
44 # with the appropriate parameters.
46 $self->set_dbh(CXGN
::DB
::Connection
->new('phenome'));
47 my %args = $self->get_args();
48 my $population_id= $args{population_id
};
49 unless (!$population_id || $population_id =~m
/^\d+$/) { $self->get_page->message_page("No population exists for identifier $population_id"); }
50 $self->set_object_id($population_id);
51 $self->set_object(CXGN
::Phenome
::Population
->new($self->get_dbh(),$self->get_object_id()));
52 $self->set_primary_key("population_id");
53 $self->set_owners($self->get_object()->get_owners());
64 my %args = $self->get_args();
66 my $population = $self->get_object();
67 my $population_id = $self->get_object_id();
68 my $type_id = $args{type_id
};
71 my ($submitter, $submitter_link) = $self->submitter();
73 my $login_user= $self->get_user();
74 my $login_user_id= $login_user->get_sp_person_id();
77 if ($self->get_action()=~/edit|store/ && ($login_user_id = $submitter || $self->get_user()->get_user_type() eq 'curator') ) {
78 print STDERR
"Generating EditableForm..\n";
79 $form = CXGN
::Page
::Form
::Editable
->new();
82 print STDERR
"Generating static Form...\n";
83 $form = CXGN
::Page
::Form
::Static
->new();
87 display_name
=>"Name:",
96 display_name
=>"Description: ",
97 field_name
=>"description",
99 getter
=>"get_description", setter
=>"set_description",
105 $form->add_label( display_name
=>"Uploaded by: ",
106 field_name
=>"submitter",
107 contents
=>$submitter_link,
109 $form->add_hidden( field_name
=>"population_id", contents
=>$args{population_id
});
112 field_name
=> "sp_person_id",
113 contents
=>$self->get_user()->get_sp_person_id(),
114 object
=> $population,
115 setter
=>"set_sp_person_id",
118 $form->add_hidden( field_name
=>"action", contents
=>"store" );
124 $self->set_form($form);
126 if ($self->get_action=~ /view|edit/) {
127 $self->get_form->from_database();
130 }elsif ($self->get_action=~ /store/) {
131 $self->get_form->from_request($self->get_args());
142 $self->get_page->add_style( text
=> <<EOS);
144 a.abstract_optional_show {
149 div.abstract_optional_show {
151 border: 1px solid #9F9FC7;
152 margin: 0.2em 1em 0.2em 1em;
153 padding: 0.2em 0.5em 0.2em 1em;
159 my %args = $self->get_args();
161 my $population = $self->get_object();
162 my $population_id = $self->get_object_id();
163 my $population_name = $population->get_name();
165 my $action = $args{action
};
166 if (!$population_id && $action ne 'new' && $action ne 'store')
167 { $self->get_page->message_page("No population exists for this identifier"); }
169 #used to show certain elements to only the proper users
170 my $login_user= $self->get_user();
171 my $login_user_id= $login_user->get_sp_person_id();
172 my $login_user_type= $login_user->get_user_type();
173 my $page="../phenome/population.pl?population_id=$population_id";
175 $self->get_page()->header("SGN Population name: $population_name");
177 print page_title_html
("Population: $population_name \n");
179 my $page="../phenome/population.pl?population_id=$population_id";
180 $args{calling_page
} = $page;
182 my $population_html = $self->get_edit_link_html(). "\t[<a href=/phenome/qtl_form.pl>New QTL Population</a>] <br />";
184 #print all editable form fields
185 $population_html .= $self->get_form()->as_table_string();
190 my $graph_icon = qq |<img src
="../documents/img/pop_graph.png"/> |;
192 if ($population->get_web_uploaded()) {
193 my @traits = $population->get_cvterms();
195 foreach my $trait (@traits) {
196 my $trait_id = $trait->get_user_trait_id();
197 my $trait_name = $trait->get_name();
198 my $definition = $trait->get_definition();
199 my ($min, $max, $avg, $std, $count)= $population->get_pop_data_summary($trait_id);
201 my $cvterm_obj = CXGN
::Chado
::Cvterm
::get_cvterm_by_name
( $self->get_dbh(), $trait_name);
203 my $cvterm_id = $cvterm_obj->get_cvterm_id();
207 print STDERR
"cvterm_id: $cvterm_id\n";
208 $trait_link = qq |<a href
="/chado/cvterm.pl?cvterm_id=$cvterm_id">$trait_name</a
>|;
212 print STDERR
"trait_id: $trait_id\n";
213 $trait_link = qq |<a href
="/phenome/trait.pl?trait_id=$trait_id">$trait_name</a
>|;
218 push @phenotype, [map {$_} ( (tooltipped_text
($trait_link, $definition)),
220 qq | <a href
="/phenome/population_indls.pl?population_id=$population_id&cvterm_id=$trait_id">
223 qq | <a href
="/phenome/population_indls.pl?population_id=$population_id&cvterm_id=$trait_id">
226 } else { push @phenotype, [map {$_} ($trait_name, $min, $max, $avg,
227 qq | <a href
="/phenome/population_indls.pl?population_id=$population_id&cvterm_id=$trait_id">
230 qq | <a href
="/phenome/population_indls.pl?population_id=$population_id&cvterm_id=$trait_id">
237 my @cvterms = $population->get_cvterms();
238 foreach my $cvterm(@cvterms) {
239 my ($min, $max, $avg, $std, $count)= $population->get_pop_data_summary($cvterm->get_cvterm_id());
240 my $cvterm_id = $cvterm->get_cvterm_id();
241 my $cvterm_name = $cvterm->get_cvterm_name();
242 if ($cvterm->get_definition()) {
243 push @phenotype, [map {$_} ( (tooltipped_text
( qq|<a href
="/chado/cvterm.pl?cvterm_id=$cvterm_id">
246 $cvterm->get_definition())), $min, $max, $avg,
247 qq | <a href
="/phenome/population_indls.pl?population_id=$population_id&cvterm_id=$cvterm_id">
250 qq | <a href
="/phenome/population_indls.pl?population_id=$population_id&cvterm_id=$cvterm_id">
253 } else { push @phenotype, [map {$_} (qq | <a href
="/chado/cvterm.pl?cvterm_id=$cvterm_id">$cvterm_name</a
>|,
255 qq | <a href
="/phenome/population_indls.pl?population_id=$population_id&cvterm_id=$cvterm_id">
258 qq | <a href
="/phenome/population_indls.pl?population_id=$population_id&cvterm_id=$cvterm_id">
265 my $accessions_link = qq |<a href
="../search/phenotype_search.pl?wee9_population_id=$population_id">
266 See all accessions
...</a
>
269 my ($phenotype_data, $data_view, $data_download);
272 $phenotype_data = columnar_table_html
(headings
=> [
287 # $data_view = html_optional_show("phenotype",
288 # 'View/hide phenotype data summary',
289 # qq|$phenotype_data</b>|,
290 # 1, #< show data by default
293 $data_download .= qq { <span
><br
/><br/>Download
:<a href
="pop_download.pl?population_id=$population_id"><b
>\
294 [Phenotype raw data
]</b></a><a href
="genotype_download.pl?population_id=$population_id">\
295 <b
>[Genotype raw data\
]</b></a></span
>
301 if ($population_name && ($login_user_type eq 'curator' || $login_user_type eq 'submitter')) {
302 $pub_subtitle .= qq|<a href
="../chado/add_publication.pl?type=population&type_id=$population_id&refering_page=$page&action=new">[Associate publication
]</a
>|;
306 else { $pub_subtitle= qq|<span
class=\"ghosted
\">[Associate publication
]</span
>|;
312 my $url_pubmed = qq | http
://www
.ncbi
.nlm
.nih
.gov
/pubmed/|;
314 my @publications = $population->get_population_publications();
316 my $abstract_count = 0;
320 foreach my $pub (@publications) {
321 my ($title, $abstract, $authors, $journal, $pyear,
322 $volume, $issue, $pages, $obsolete, $pub_id, $accession
326 my @dbxref_objs = $pub->get_dbxrefs();
327 my $dbxref_obj = shift(@dbxref_objs);
329 $obsolete = $population->get_population_dbxref($dbxref_obj)->get_obsolete();
331 if ($obsolete eq 'f') {
332 $pub_id = $pub->get_pub_id();
333 $title = $pub->get_title();
334 $abstract = $pub->get_abstract();
335 $pyear = $pub->get_pyear();
336 $volume = $pub->get_volume();
337 $journal = $pub->get_series_name();
338 $pages = $pub->get_pages();
339 $issue = $pub->get_issue();
341 $accession = $dbxref_obj->get_accession();
342 my $pub_info = qq|<a href
="/chado/publication.pl?pub_id=$pub_id" >PMID
:$accession</a
>|;
348 my @pubauthors_ids = $pub->get_pubauthors_ids($pub_id);
350 foreach my $pubauthor_id (@pubauthors_ids) {
351 my $pubauthor_obj = CXGN
::Chado
::Pubauthor
->new($self->get_dbh, $pubauthor_id);
352 my $last_name = $pubauthor_obj->get_surname();
353 my $first_names = $pubauthor_obj->get_givennames();
354 my @first_names = split (/,/, $first_names);
355 $first_names = shift (@first_names);
356 push @authors, ("$first_names" ." ". "$last_name");
357 $authors = join (", ", @authors);
364 $abstract_view = html_optional_show
("abstracts$abstract_count",
365 'Show/hide abstract',
366 qq|$abstract <b
> <i
>$authors.</i> $journal. $pyear. $volume($issue). $pages.</b
>|,
367 0, #< do not show by default
368 'abstract_optional_show', #< don't use the default button-like style
372 $pubmed .= qq| <div
><a href
="$url_pubmed$accession" target
="blank">$pub_info</a> $title $abstract_view</div
> |;
376 my $is_public = $population->get_privacy_status();
377 my ($submitter_obj, $submitter_link) = $self->submitter();
378 my $map_link = $self->genetic_map();
379 print info_section_html
(title
=> 'Population Details',
380 contents
=> $population_html,
384 $login_user_type eq 'curator' ||
386 $population->get_sp_person_id()
388 if ($phenotype_data) {
389 print info_section_html
(title
=> 'Phenotype Data and QTLs',
390 contents
=> $phenotype_data ." ".$data_download
393 print info_section_html
(title
=> 'Phenotype Data',
394 contents
=> $accessions_link
398 unless (!$map_link) {
399 print info_section_html
( title
=> 'Genetic Map',
400 contents
=> $map_link
405 my $message = "The QTL data for this population is not public yet.
406 If you would like to know more about this data,
407 please contact the owner of the data: <b>$submitter_link</b>
409 <a href=mailto:sgn-feedback\@sgn.cornell.edu>
410 sgn-feedback\@sgn.cornell.edu</a>.\n";
412 print info_section_html
(title
=> 'Phenotype Data and QTLs',
417 print info_section_html
(title
=> 'Literature Annotation',
418 #subtitle => $pub_subtitle,
422 if ($population_name) {
423 # change sgn_people.forum_topic.page_type and the CHECK constraint!!
424 my $page_comment_obj = CXGN
::People
::PageComment
->new($self->get_dbh(), "population", $population_id);
425 print $page_comment_obj->get_html();
428 $self->get_page()->footer();
439 # override store to check if a locus with the submitted symbol/name already exists in the database
443 my $population = $self->get_object();
444 my $population_id = $self->get_object_id();
445 my %args = $self->get_args();
447 $self->SUPER::store
(0);
455 my $population = $self->get_object();
456 my $sp_person_id= $population->get_sp_person_id();
457 my $submitter = CXGN
::People
::Person
->new($self->get_dbh(), $population->get_sp_person_id());
458 my $submitter_name = $submitter->get_first_name()." ".$submitter->get_last_name();
459 my $submitter_link = qq |<a href
="/solpeople/personal-info.pl?sp_person_id=$sp_person_id">$submitter_name</a
> |;
461 return $submitter, $submitter_link;
467 my $mapv_id = $self->get_object()->mapversion_id();
470 my $map = CXGN
::Map
->new( $self->get_dbh(), { map_version_id
=> $mapv_id } );
471 my $map_name = $map->get_long_name();
473 qq | <a href
=/cview/map.pl?map_version_id
=$mapv_id>$map_name</a
>|;