5 generates a page with the list of individual
6 plant accessions (and their corresponding trait values)
7 falling within a phenotypic range in a population.
11 Isaak Y Tecle (iyt2@cornell.edu)
19 my $individuals_range_detail_page = CXGN
::Phenome
::IndividualsRangeDetailPage
->new();
21 package CXGN
::Phenome
::IndividualsRangeDetailPage
;
25 use CXGN
::Page
::FormattingHelpers qw
/info_section_html
34 use CXGN
::Phenome
::Population
;
35 use CXGN
::Phenome
::PopulationDbxref
;
36 use CXGN
::Tools
::WebImageCache
;
38 use CXGN
::People
::PageComment
;
39 use CXGN
::People
::Person
;
40 use CXGN
::Chado
::Publication
;
41 use CXGN
::Chado
::Pubauthor
;
46 use Statistics
::Descriptive
;
47 use CXGN
::Scrap
::AjaxPage
;
52 use base qw
/ CXGN::Page::Form::SimpleFormPage CXGN::Phenome::Main/;
56 my $self = $class->SUPER::new
(@_);
57 $self->set_script_name("indls_range_cvterm.pl");
66 $self->set_dbh(CXGN
::DB
::Connection
->new('phenome'));
67 my %args = $self->get_args();
68 my $population_id= $args{population_id
};
69 unless (!$population_id || $population_id =~m
/^\d+$/) { $self->get_page->message_page("No population exists for identifier $population_id"); }
70 $self->set_object_id($population_id);
71 $self->set_object(CXGN
::Phenome
::Population
->new($self->get_dbh(),$self->get_object_id()));
72 $self->set_primary_key("population_id");
73 $self->set_owners($self->get_object()->get_owners());
84 my %args = $self->get_args();
86 my $population = $self->get_object();
87 my $population_id = $self->get_object_id();
88 my $type_id = $args{type_id
};
90 my $pop_name = $population->get_name();
91 my $pop_link = qq |<a href
="/phenome/population.pl?population_id=$population_id">$pop_name</a
> |;
93 my $sp_person_id= $population->get_sp_person_id();
94 my $submitter = CXGN
::People
::Person
->new($self->get_dbh(), $population->get_sp_person_id());
95 my $submitter_name = $submitter->get_first_name()." ".$submitter->get_last_name();
96 my $submitter_link = qq |<a href
="/solpeople/personal-info.pl?sp_person_id=$sp_person_id">$submitter_name </a
> |;
99 my $login_user= $self->get_user();
100 my $login_user_id= $login_user->get_sp_person_id();
102 if ($self->get_action()=~/edit|store/ && ($login_user_id = $submitter || $self->get_user()->get_user_type() eq 'curator') ) {
103 print STDERR
"Generating EditableForm..\n";
104 $form = CXGN
::Page
::Form
::Editable
->new();
107 print STDERR
"Generating static Form...\n";
108 $form = CXGN
::Page
::Form
::Static
->new();
112 display_name
=>"Name:",
114 contents
=> $pop_link,
118 display_name
=>"Description: ",
119 field_name
=>"description",
121 getter
=>"get_description", setter
=>"set_description",
127 $form->add_label( display_name
=>"Uploaded by: ",
128 field_name
=>"submitter",
129 contents
=>$submitter_link,
131 $form->add_hidden( field_name
=>"population_id", contents
=>$args{population_id
});
134 field_name
=> "sp_person_id",
135 contents
=>$self->get_user()->get_sp_person_id(),
136 object
=> $population,
137 setter
=>"set_sp_person_id",
140 $form->add_hidden( field_name
=>"action", contents
=>"store" );
146 $self->set_form($form);
148 if ($self->get_action=~ /view|edit/) {
149 $self->get_form->from_database();
152 }elsif ($self->get_action=~ /store/) {
153 $self->get_form->from_request($self->get_args());
164 $self->get_page->add_style( text
=> <<EOS);
165 a.abstract_optional_show {
170 div.abstract_optional_show {
172 border: 1px solid #9F9FC7;
173 margin: 0.2em 1em 0.2em 1em;
174 padding: 0.2em 0.5em 0.2em 1em;
180 my %args = $self->get_args();
181 my $population = $self->get_object();
182 my $population_id = $self->get_object_id();
183 my $population_name = $population->get_name();
184 my $login_user= $self->get_user();
185 my $login_user_id= $login_user->get_sp_person_id();
186 my $login_user_type= $login_user->get_user_type();
189 $self->get_page()->header("SGN Population name: $population_name");
191 print page_title_html
("SGN population: $population_name \n");
193 my $population_html .= $self->get_form()->as_table_string();
200 my $cvterm_id = $args{cvterm_id
};
201 my $lower = $args{lower
};
202 my $upper = $args{upper
};
204 my ($indl_id, $indl_name, $value)= $population->indls_range_cvterm($cvterm_id, $lower, $upper);
205 my @indls_id = @
$indl_id;
206 my $indls_count = scalar @indls_id;
209 my $cvterm = CXGN
::Chado
::Cvterm
->new($self->get_dbh(), $args{cvterm_id
});
210 my $cvterm_name = $cvterm->get_cvterm_name();
211 my $cvterm_id = $args{cvterm_id
};
212 my ($min, $max, $avg, $count)= $population->get_pop_data_summary($cvterm_id);
214 for (my $i=0; $i<@
$indl_name; $i++) {
216 push @phenotype, [map {$_} ( qq | <a href
="/phenome/individual.pl?individual_id=$indl_id->[$i]">$indl_name->[$i]</a
>|, $value->[$i]) ];
220 my ($phenotype_data, $data_view, $data_download);
222 my $cvterm_note = " <br><b>$indls_count plant accessions had
223 $cvterm_name values >$lower but <= $upper.
224 The population average, minimum, and maximum
225 values for the trait were $avg, $min, and $max,
226 respectively.</b> <br />";
229 $phenotype_data = columnar_table_html
(headings
=> [
241 $data_view = html_optional_show
("phenotype",
242 'View/hide phenotype data summary',
243 qq|$phenotype_data</b
>|,
244 1, #< show data by default
246 $data_download .= qq { <span
><a href
="pop_download.pl?population_id=$population_id"><b
>\
[download population raw data\
]</b></a></span
> };
249 my $page="../phenome/indls_range_cvterm.pl?cvterm_id=$cvterm_id&lower=$lower&upper=$upper&population_id=$population_id ";
250 $args{calling_page
} = $page;
254 my $url_pubmed = qq | http
://www
.ncbi
.nlm
.nih
.gov
/pubmed/|;
256 my @publications = $population->get_population_publications();
258 my $abstract_count = 0;
262 foreach my $pub (@publications) {
263 my ($title, $abstract, $authors, $journal, $pyear, $volume, $issue, $pages, $obsolete, $pub_id, $accession);
266 my @dbxref_objs = $pub->get_dbxrefs();
267 my $dbxref_obj = shift(@dbxref_objs);
269 $obsolete = $population->get_population_dbxref($dbxref_obj)->get_obsolete();
271 if ($obsolete eq 'f') {
272 $pub_id = $pub->get_pub_id();
273 $accession = $pub->get_accession();
274 $title = $pub->get_title();
275 $abstract = $pub->get_abstract();
276 $pyear = $pub->get_pyear();
277 $volume = $pub->get_volume();
278 $journal = $pub->get_series_name();
279 $pages = $pub->get_pages();
280 $issue = $pub->get_issue();
281 $accession = $dbxref_obj->get_accession();
282 my $pub_info = qq|<a href
="/chado/publication.pl?pub_id=$pub_id" >PMID
:$accession</a
> |;
287 my @pubauthors_ids = $pub->get_pubauthors_ids($pub_id);
289 foreach my $pubauthor_id (@pubauthors_ids) {
290 my $pubauthor_obj = CXGN
::Chado
::Pubauthor
->new($self->get_dbh, $pubauthor_id);
291 my $last_name = $pubauthor_obj->get_surname();
292 my $first_names = $pubauthor_obj->get_givennames();
293 my @first_names = split (/,/, $first_names);
294 $first_names = shift (@first_names);
295 push @authors, ("$first_names" ." ". "$last_name");
296 $authors = join (", ", @authors);
303 $abstract_view = html_optional_show
("abstracts$abstract_count",
304 'Show/hide abstract',
305 qq|$abstract <b
> <i
>$authors.</i> $journal. $pyear. $volume($issue). $pages.</b
>|,
306 0, #< do not show by default
307 'abstract_optional_show', #< don't use the default button-like style
311 $pubmed .= qq|<div
><a href
="$url_pubmed$accession" target
="blank">$pub_info</a> $title $abstract_view </div
> |;
315 print info_section_html
(title
=> 'Population details',
316 contents
=> $population_html,
319 print info_section_html
(title
=> 'Phenotype Data',
320 contents
=>$cvterm_note . $data_view ." ".$data_download,
325 print info_section_html
(title
=> 'Literature annotation',
326 #subtitle => $pub_subtitle,
331 if ($population_name) {
332 my $page_comment_obj = CXGN
::People
::PageComment
->new($self->get_dbh(), "population", $population_id);
333 print $page_comment_obj->get_html();
338 $self->get_page()->footer();