Merge pull request #5134 from solgenomics/topic/fix_seedlot_search
[sgn.git] / cgi-bin / search / locus_search.pl
blob4485ea473c12cb6de40d30d522cf6c76b467f54a
1 ######################################################################
3 # Search the phenome database and displays the results.
5 ######################################################################
9 use strict;
11 use CXGN::Phenome;
12 use CXGN::Page;
13 use CXGN::Page::FormattingHelpers qw/blue_section_html
14 info_section_html
15 page_title_html
16 columnar_table_html
18 use CXGN::Search::CannedForms;
19 #################################################
21 # Start a new SGN page.
23 my $page=CXGN::Page->new("SGN gene search results","Naama");
24 $page->header();
26 print page_title_html('Gene search results');
29 #create the search and query objects
30 my $search = CXGN::Phenome->new;
31 my $query = $search->new_query;
33 $search->page_size(10); #set 10 loci per page
37 #get the parameters
38 my %params = $page->get_all_encoded_arguments;
39 my $any_name = $page->get_encoded_arguments("any_name");
42 $query->from_request(\%params);
46 if(%params) {
47 $query->order_by( locus_symbol=> 'UPPER(&t)');
48 my $result = $search->do_search($query); #execute the search
50 my @results;
53 while(my $r = $result->next_result) {
54 # push @results,$r;
55 my ($allele_name, $allele_symbol, $phenotype) = ($r->[3], $r->[4], $r->[6]);
56 my $allele_obsolete = $r->[8];
58 my $phenotype= substr($r->[6],0,20);
59 if (defined$r->[6]) {
60 $phenotype .= '....';
61 }else {
62 $phenotype = '--';
64 #if (!$allele_obsolete) { #don't display obsolete alleles! #alleles shouldn't be obsolete now..
66 push @results, [map {$_} ($r->[14],
67 '<a href="/phenome/locus_display.pl?locus_id='.$r->[0].'">'.$r->[1].'</a>',
68 $r->[2],
69 $allele_name,
70 $allele_symbol,
71 $phenotype,
79 #build the HTML to output
80 my $pagination_html = $search->pagination_buttons_html( $query, $result );
83 my $results_html = <<EOH;
84 <div id="searchresults">
85 EOH
87 $results_html .= columnar_table_html(headings => ['Organism',
88 'Locus name',
89 'Locus symbol',
90 'Allele name',
91 'Allele symbol',
92 'Allele phenotype'],
93 data => \@results,
94 # __alt_freq => 2,
95 # __alt_width => 2,
99 $results_html .= <<EOH;
100 </div>
101 $pagination_html
105 if (@results) {
107 print blue_section_html('Gene search results', ,sprintf('<span class="paginate_summary">%s matches </span>', $result->total_results,$result->time),$results_html);
108 }else {
109 print '<h4><span class="">No matches found</span></h4>';
112 print info_section_html(title => 'Search again',
113 contents =>CXGN::Search::CannedForms::gene_search_form($page,$query)
119 $page->footer();
121 #############