Merge pull request #3869 from solgenomics/genotype-protocol-fix-tissue
[sgn.git] / cgi-bin / phenome / trait.pl
blob28f4a07fab9fe7aa1139f859cf7a1e8df2803361
1 ######################################################################
3 # Displays a static user submitted trait detail page.
5 ######################################################################
7 my $trait_detail_page=CXGN::Phenome::TraitDetailPage->new();
9 package CXGN::Phenome::TraitDetailPage;
11 use base qw/CXGN::Page::Form::SimpleFormPage/;
13 use strict;
15 use CXGN::Page;
16 use CXGN::Page::FormattingHelpers qw/info_section_html
17 page_title_html
18 columnar_table_html
19 info_table_html
20 html_optional_show
23 use CXGN::Phenome::UserTrait;
24 use CXGN::People::PageComment;
27 sub new {
28 my $class=shift;
29 my $schema='phenome';
30 my $self= $class->SUPER::new(@_);
31 return $self;
34 sub define_object {
35 my $self=shift;
36 $self->set_dbh(CXGN::DB::Connection->new('phenome'));
37 my %args= $self->get_args();
39 my $user_trait_id="";
40 if (exists($args{trait}) && defined($args{trait})) {
41 my $ut = CXGN::Phenome::UserTrait::->new_with_name($self->get_dbh(), $args{trait});
42 $user_trait_id = $ut->get_user_trait_id();
44 else {
45 $user_trait_id= $args{trait_id};
47 unless (!$user_trait_id || $user_trait_id =~m /^\d+$/) { $self->get_page->message_page("No term exists for identifier $user_trait_id"); }
48 $self->set_object_id($user_trait_id);
49 $self->set_object(CXGN::Phenome::UserTrait->new($self->get_dbh, $self->get_object_id));
51 $self->set_primary_key("user_trait_id");
57 sub display_page {
58 my $self=shift;
59 my %args = $self->get_args();
62 my $ut=$self->get_object();
63 my $ut_id=$self->get_object_id();
64 my $ut_name=$ut->get_name();
66 my $definition = $ut->get_definition() ;
67 my $page="/phenome/trait.pl?trait_id=$ut_id";
68 my $action= $args{action} || "";
69 if (!$ut_id) { $self->get_page->message_page("No term exists for this identifier") } ;
71 $self->get_page->header("SGN: $ut_name " );
72 print page_title_html("$ut_name\n");
74 my $trait_html= "<br />" .$self->get_form()->as_table_string()."<br />";
78 print info_section_html(title => 'Trait details',
79 contents => $trait_html,
82 my @pops = $ut->get_all_populations_trait();
83 my $pop_list;
85 foreach my $pop (@pops) {
86 my $pop_id = $pop->get_population_id();
87 my $pop_name = $pop->get_name();
89 $pop_list .= qq |<a href="../phenome/population_indls.pl?population_id=$pop_id&amp;cvterm_id=$ut_id">$pop_name</a> <br />|;
92 my $pop_count = scalar(@pops);
93 if ($pop_count > 0) {
94 $pop_count .= " " . 'populations';
97 print info_section_html(title => "Phenotype data/QTLs ($pop_count)",
98 contents => $pop_list,
99 collapsible=>1,
100 collapsed=>0,
104 ####add page comments
105 if ($ut_name) {
106 my $page_comment_obj = CXGN::People::PageComment->new($self->get_dbh(), "trait", $ut_id, $self->get_page()->{request}->uri()."?".$self->get_page()->{request}->args());
107 print $page_comment_obj->get_html();
111 $self->get_page()->footer();
115 sub generate_form {
116 my $self=shift;
117 $self->init_form();
118 my $ut=$self->get_object();
120 my %args=$self->get_args();
122 my $ut_name=$ut->get_name();
124 my $definition = $ut->get_definition() ;
126 $self->get_form()->add_label(
127 display_name =>"Term name",
128 field_name =>"term_name",
129 contents => $ut_name,
131 $self->get_form()->add_label(
132 display_name =>"Definition",
133 field_name =>"definition",
134 contents => $definition,
138 if ($self->get_action=~ /view/) {
140 $self->get_form->from_database();
145 #########################################################