Merge pull request #5134 from solgenomics/topic/fix_seedlot_search
[sgn.git] / cgi-bin / search / ug-ad2.pl
blob0714033da23ecd3a9cea2ac629f93dab250c6e53
1 ######################################################################
3 # This conducts and displays the results of a BAC search.
5 ######################################################################
7 use strict;
8 use warnings;
10 use English;
11 use CXGN::Page;
12 use CXGN::Search::CannedForms;
13 use CXGN::Page::FormattingHelpers qw/ blue_section_html
14 page_title_html
15 commify_number
16 columnar_table_html
18 use CXGN::Tools::Text;
19 use CXGN::DB::Connection;
20 use CXGN::Unigene::Search;
21 use CatalystX::GlobalContext '$c';
24 #################################
25 # Start a new SGN page.
26 our $page = CXGN::Page->new( 'Unigene Advanced Search', 'Rob Buels');
27 $page->header('Unigene Search Results'); #print out header immediately so users get 'in progress' message
29 #create the search and query objects
30 my $search = CXGN::Unigene::Search->new;
31 $search->page_size(15); #set 15 unigenes per page
32 my $query = $search->new_query;
34 #get the parameters
35 my %params = $page->get_all_encoded_arguments;
37 eval { #initialize the query object from the page parameters
38 $query->from_request(\%params);
39 }; if( $EVAL_ERROR ) {
40 if($c->config->{'production_server'}) {
41 print "<b>Invalid search parameters.</b>\n";
42 } else {
43 die $EVAL_ERROR; #die it on
45 $page->footer;
46 exit;
49 #execute the search
50 # use Data::Dumper;
51 # print "<pre>".Dumper($query)."</pre>";
52 # exit;
54 my $result = $search->do_search($query);
56 my $sql = $query->to_query_string();
58 #build the HTML to output
59 my $pagination_html = $search->pagination_buttons_html( $query, $result );
62 my @tableheadings = ('Unigene','Build','Length (bp)','# Members');
63 my @tabledata;
64 my $querystring = $query->to_query_string;
65 while(my $ug = $result->next_result) {
66 push @tabledata,[ map {$_ || '-'} ('<a href="'.$ug->info_page_href.';'.$querystring.'">'.$ug->external_identifier.'</a>',
67 $ug->build_object->organism_group_name.' #'.$ug->build_object->build_nr,
68 commify_number(length($ug->seq)),
69 $ug->nr_members,
74 my $results_html = <<EOH
75 <div id="searchresults">
76 EOH
77 . columnar_table_html(headings => \@tableheadings, data => \@tabledata)
78 . <<EOH;
79 </div>
80 $pagination_html
81 EOH
83 print page_title_html('Unigene Search Results');
85 print blue_section_html('Unigene Search Results',sprintf('<span class="paginate_summary">%s matches (%0.1f seconds)</span>',commify_number($result->total_results),$result->time),$results_html);
87 print blue_section_html('Search Again',CXGN::Search::CannedForms::unigene_search_form($page,$query));
89 $page->footer();