bug fix. Now it tests correctly if either of the tests evaluate to false or not
[sgn.git] / cgi-bin / phenome / qtl_traits.pl
blob30a378a595881954881194e2e4e45c59c5f16140
2 =head1 DESCRIPTION
4 A tiny mini script to display a group of traits/cvterms
5 that start with a given letter
7 =head1 AUTHOR
9 Isaak Y Tecle (iyt2@cornell.edu)
11 =cut
13 use strict;
15 use List::MoreUtils qw /uniq/;
17 use HTML::Entities;
19 use CXGN::Page;
20 use CXGN::Page::FormattingHelpers qw(
21 info_section_html
22 page_title_html
23 columnar_table_html
24 info_table_html
27 use CXGN::DB::Connection;
28 use CXGN::Chado::Cvterm;
29 use CXGN::Search::CannedForms;
31 my $page = CXGN::Page->new( "SGN QTL/Traits", "Isaak" );
32 $page->header();
34 my $index = $page->get_arguments("index");
36 my $dbh = CXGN::DB::Connection->new();
37 my $qtl_tools = CXGN::Phenome::Qtl::Tools->new();
38 my ( $all_traits, $all_trait_d ) = $qtl_tools->all_traits_with_qtl_data();
39 my @all_traits = @{$all_traits};
40 @all_traits = uniq(@all_traits);
41 @all_traits =
42 sort { $a <=> $b } @all_traits;
44 my @index_traits;
45 foreach my $trait (@all_traits)
47 if ( $trait =~ /^$index/i )
49 push @index_traits, $trait;
54 my @traits_list;
56 if (@index_traits)
58 foreach my $trait (@index_traits)
60 my $cvterm = CXGN::Chado::Cvterm::get_cvterm_by_name( $dbh, $trait );
61 my $cvterm_id = $cvterm->get_cvterm_id();
62 if ($cvterm_id)
64 push @traits_list,
66 map { $_ } (
67 qq |<a href=/chado/cvterm.pl?cvterm_id=$cvterm_id>$trait</a> |
71 else
73 my $t = CXGN::Phenome::UserTrait->new_with_name( $dbh, $trait );
74 my $trait_id = $t->get_user_trait_id();
75 push @traits_list,
77 map { $_ } (
78 qq |<a href=/phenome/trait.pl?trait_id=$trait_id>$trait</a> |
88 print page_title_html('List Traits with QTLs');
90 print info_section_html (
91 title => encode_entities( qq|Traits beginning with "$index"| ),
92 contents => columnar_table_html (
93 data => \@traits_list,
94 __align => 'l',
95 __alt_freq => 2,
96 __alt_width => 1,
97 __cellpadding => 20,
101 my $search = CXGN::Search::CannedForms::qtl_search_form();
103 print info_section_html (
104 title => 'Search QTLs by trait names',
105 contents => $search,
106 collapsible => 1,
107 collapsed => 0,
109 $page->footer();
111 #############