$cookie = {};
+ if ( $cgi->param( 'nav_search' ) )
+ {
+ if ( $cgi->param( 'nav_search' ) =~ /([0-9,]+)[ -]([0-9,]+)/ )
+ {
+ $cookie->{ 'NAV_START' } = $1;
+ $cookie->{ 'NAV_END' } = $2;
+ }
+ else
+ {
+ $cookie->{ 'SEARCH' } = $cgi->param( 'nav_search' );
+
+ $cgi->param( 'page', 'search' );
+ }
+ }
+
$cookie->{ 'SCRIPT' } = Maasha::Common::get_scriptname();
$cookie->{ 'DATA_DIR' } = "Data";
$cookie->{ 'LIST_PAGES' } = [ qw( user clade genome assembly contig browse ) ];
$cookie->{ 'S_BEG' } = $cgi->param( 's_beg' );
$cookie->{ 'S_END' } = $cgi->param( 's_end' );
$cookie->{ 'STRAND' } = $cgi->param( 'strand' );
- $cookie->{ 'NAV_START' } = $cgi->param( 'nav_start' );
- $cookie->{ 'NAV_END' } = $cgi->param( 'nav_end' );
$cookie->{ 'ZOOM_IN1' } = $cgi->param( 'zoom_in1' );
$cookie->{ 'ZOOM_IN2' } = $cgi->param( 'zoom_in2' );
$cookie->{ 'ZOOM_IN3' } = $cgi->param( 'zoom_in3' );
cookie_move( $cookie );
}
- $cookie->{ 'STRAND' } = '+' if $cookie->{ 'STRAND' } eq ' ';
+ $cookie->{ 'STRAND' } = '+' if defined $cookie->{ 'STRAND' } and $cookie->{ 'STRAND' } eq ' '; # FIXME ugly HTML fix
return wantarray ? %{ $cookie } : $cookie;
}
# Returns a string.
- my ( @href );
+ my ( @href_list, %href_hash, $href );
while ( 1 )
{
- push @href, "$cookie->{ 'SCRIPT' }?page=$page";
- push @href, "user=$cookie->{ 'USER' }" if $cookie->{ 'USER' };
+ $href_hash{ "user" } = $cookie->{ 'USER' } if $cookie->{ 'USER' };
last if $page eq 'user';
- push @href, "clade=$cookie->{ 'CLADE' }" if $cookie->{ 'CLADE' };
+ $href_hash{ "clade" } = $cookie->{ 'CLADE' } if $cookie->{ 'CLADE' };
last if $page eq 'clade';
- push @href, "genome=$cookie->{ 'GENOME' }" if $cookie->{ 'GENOME' };
+ $href_hash{ "genome" } = $cookie->{ 'GENOME' } if $cookie->{ 'GENOME' };
last if $page eq 'genome';
- push @href, "assembly=$cookie->{ 'ASSEMBLY' }" if $cookie->{ 'ASSEMBLY' };
+ $href_hash{ "assembly" } = $cookie->{ 'ASSEMBLY' } if $cookie->{ 'ASSEMBLY' };
last if $page eq 'assembly';
- push @href, "contig=$cookie->{ 'CONTIG' }" if $cookie->{ 'CONTIG' };
+ $href_hash{ "contig" } = $cookie->{ 'CONTIG' } if $cookie->{ 'CONTIG' };
last if $page eq 'contig';
last;
}
- return join "&", @href;
+ if ( defined $cookie->{ 'NAV_START' } and defined $cookie->{ 'NAV_END' } ) {
+ $href_hash{ "nav_search" } = "$cookie->{ 'NAV_START' }-$cookie->{ 'NAV_END' }";
+ }
+
+ $href_hash{ "s_beg" } = $cookie->{ 'S_BEG' } if defined $cookie->{ 'S_BEG' };
+ $href_hash{ "s_end" } = $cookie->{ 'S_END' } if defined $cookie->{ 'S_END' };
+ $href_hash{ "q_id" } = $cookie->{ 'Q_ID' } if defined $cookie->{ 'Q_ID' };
+ $href_hash{ "strand" } = $cookie->{ 'STRAND' } if defined $cookie->{ 'STRAND' };
+
+ push @href_list, "$cookie->{ 'SCRIPT' }?page=$page";
+
+ foreach $href ( keys %href_hash ) {
+ push @href_list, "$href=$href_hash{ $href }";
+ }
+
+ return join "&", @href_list;
}
if ( $cookie->{ 'PAGE' } eq 'export' ) {
push @html, page_export( $cookie );
+ } elsif ( $cookie->{ 'PAGE' } eq 'search' ) {
+ push @html, page_search( $cookie );
} elsif ( $cookie->{ 'PAGE' } eq 'browse' ) {
push @html, page_browse( $cookie );
} elsif ( $cookie->{ 'PAGE' } eq 'dna' ) {
}
+sub page_search
+{
+ # Martin A. Hansen, December 2009.
+
+ # Renders the search page.
+
+ my ( $cookie,
+ ) = @_;
+
+ # Returns a list.
+
+ my ( @html );
+
+ push @html, section_taxonomy_table( $cookie );
+ push @html, section_search( $cookie );
+
+ return wantarray ? @html : \@html;
+}
+
+
sub page_browse
{
# Martin A. Hansen, November 2009.
# Returns a list.
- my ( @html );
+ my ( @html, $nav_val );
+
+ $nav_val = Maasha::Calc::commify( $cookie->{ 'NAV_START' } ) . "-" . Maasha::Calc::commify( $cookie->{ 'NAV_END' } );
push @html, Maasha::XHTML::table_beg( summary => "Navigation table", align => 'center' );
push @html, Maasha::XHTML::table_row_simple( tr => [
- "Start:",
- Maasha::XHTML::text( name => "nav_start", value => Maasha::Calc::commify( $cookie->{ 'NAV_START' } ), size => 15 ),
- "End:",
- Maasha::XHTML::text( name => "nav_end", value => Maasha::Calc::commify( $cookie->{ 'NAV_END' } ), size => 15 ),
+ "Position or search term:",
+ Maasha::XHTML::text( name => "nav_search", value => $nav_val, size => 30 ),
Maasha::XHTML::submit( name => "nav_submit", value => "Submit" ),
] );
push @html, Maasha::XHTML::table_end;
#$elem->{ 'strand' } = '+' if $elem->{ 'strand' } eq '+';
+ $cookie->{ 'Q_ID' } = $elem->{ 'q_id' };
+ $cookie->{ 'S_BEG' } = $elem->{ 's_beg' };
+ $cookie->{ 'S_END' } = $elem->{ 's_end' };
+ $cookie->{ 'STRAND' } = $elem->{ 'strand' };
+
push @img, Maasha::XHTML::area(
- href => cookie_href( $cookie, "export" ) . "&q_id=$elem->{ 'q_id' }&s_beg=$elem->{ 's_beg' }&s_end=$elem->{ 's_end' }&strand=$elem->{ 'strand' }",
+ href => cookie_href( $cookie, "export" ),
+ # href => cookie_href( $cookie, "export" ) . "&q_id=$elem->{ 'q_id' }&s_beg=$elem->{ 's_beg' }&s_end=$elem->{ 's_end' }&strand=$elem->{ 'strand' }",
shape => "rect",
coords => "$elem->{ x1 }, $elem->{ y1 }, $elem->{ x2 }, $elem->{ y2 }", title => "$elem->{ 'title' }",
);
}
+sub section_search
+{
+ # Martin A. Hansen, November 2009.
+
+ # Returns a HTML section with export table.
+
+ my ( $cookie, # cookie hash
+ ) = @_;
+
+ # Returns a list.
+
+ my ( $results, $result, $count, @html, $export, $browse );
+
+ $results = Maasha::BBrowser::Track::search_tracks( $cookie );
+
+ $count = scalar @{ $results };
+
+ push @html, Maasha::XHTML::h2( txt => "Search", class => 'center' );
+ push @html, Maasha::XHTML::p( txt => qq(Results for "$cookie->{ 'SEARCH' }": $count), class => 'center' );
+
+ if ( $count > 0 )
+ {
+ push @html, Maasha::XHTML::table_beg( summary => "Search table", align => 'center', cellpadding => '5px' );
+ push @html, Maasha::XHTML::table_row_simple( tr => [ qw( S_ID S_BEG S_END Q_ID SCORE STRAND HITS ALIGN BLOCK_COUNT BLOCK_BEGS BLOCK_LENS BLOCK_TYPE) ] );
+
+ foreach $result ( @{ $results } )
+ {
+ $cookie->{ 'CONTIG' } = $result->{ 'S_ID' };
+ $cookie->{ 'NAV_START' } = $result->{ 'S_BEG' };
+ $cookie->{ 'NAV_END' } = $result->{ 'S_END' };
+ $cookie->{ 'S_BEG' } = $result->{ 'S_BEG' };
+ $cookie->{ 'S_END' } = $result->{ 'S_END' };
+ $cookie->{ 'STRAND' } = $result->{ 'STRAND' };
+ $cookie->{ 'Q_ID' } = $result->{ 'Q_ID' };
+
+ $browse = Maasha::XHTML::ln( txt => "browse", href => cookie_href( $cookie, "browse" ) );
+ $export = Maasha::XHTML::ln( txt => "export", href => cookie_href( $cookie, "export" ) );
+
+ push @html, Maasha::XHTML::table_row_advanced(
+ tr => [ { td => $result->{ 'S_ID' } },
+ { td => $result->{ 'S_BEG' }, align => 'right' },
+ { td => $result->{ 'S_END' }, align => 'right' },
+ { td => $result->{ 'Q_ID' } },
+ { td => $result->{ 'SCORE' }, align => 'right' },
+ { td => $result->{ 'STRAND' } },
+ { td => $result->{ 'HITS' }, align => 'right' },
+ { td => $result->{ 'ALIGN' } },
+ { td => $result->{ 'BLOCK_COUNT' }, align => 'right' },
+ { td => $result->{ 'BLOCK_BEGS' } },
+ { td => $result->{ 'BLOCK_LENS' } },
+ { td => $result->{ 'BLOCK_TYPE' } },
+ { td => $browse },
+ { td => $export },
+ ], class => "monospace"
+ );
+ }
+
+ push @html, Maasha::XHTML::table_end;
+ }
+
+ return wantarray ? @html : \@html;
+}
+
+
sub section_dna
{
# Martin A. Hansen, November 2009.