1 use CatalystX
::GlobalContext
qw( $c );
5 NOTE: This script has been deprecated. The functionality was moved
6 to SGN::Controller::Blast.
8 show_match_seq.pl - a simple script to show the entire sequence of a
9 match in a blast database with optional highlighting of the matched
14 This script shows a webpage with the sequence from a blast database
15 for a specific id, using CXGN::BlastDB. This is the script that should
16 be called if the CXGN::Tools::Identifiers cannot determine an
17 appropriate link, so that the users still can get at the matched
18 sequence, instead of uselessly defaulting to Genbank.
26 The id of the sequence [string], as it appears in the database (best
27 retrieved from a blast report).
31 The id [int] of the blast database file for CXGN::BlastDB.
35 a list of start and end coordinates, of the form:
37 start1-end1,start2-end2,start3-end3
41 either "text" or "html" to output fasta text or a nicely ;-) formatted
48 Lukas Mueller <lam87@cornell.edu>
50 Robert Buels <rmb32@cornelle.edu>
60 use CXGN::Tools::Text qw/ sanitize_string /;
61 use CXGN::MasonFactory;
63 use CXGN::Page::FormattingHelpers qw | info_section_html html_break_string html_string_linebreak_and_highlight | ;
68 my ( $id ) = $cgi->param( 'id' );
69 my ( $blast_db_id ) = $cgi->param( 'blast_db_id' );
70 my ( $format ) = $cgi->param( 'format' );
71 my ( $hilite_coords ) = $cgi->param( 'hilite_coords' );
76 $id = sanitize_string( $id );
78 $c->forward_to_mason_view('/blast/show_seq/input.mas') unless $blast_db_id && defined $id;
80 # parse the coords param
83 my ($s, $e) = split "-", $_;
84 defined $_ or die 'parse error' for $s, $e;
89 ( $hilite_coords || '' );
91 #die("hilite_coords $hilite_coords. ".(join ",", @coords)."\n");
94 my $bdbo = CXGN::BlastDB->from_id( $blast_db_id )
95 or $c->throw( is_error => 0,
96 message => "The blast database with id $blast_db_id could not be found (please set the blast_db_id parameter).");
98 my $seq = $bdbo->get_sequence( $id ) # returns a Bio::Seq object.
99 or $c->throw( is_error => 0,
100 message => "The sequence could not be found in the blast database with id $blast_db_id.");
102 # dispatch to the proper view
103 if ( $format eq 'html' ) {
104 my $view_link = do { $cgi->param( format => 'fasta_text'); '?'.$cgi->query_string };
105 my $download_link = do { $cgi->param( format => 'fasta_file'); '?'.$cgi->query_string };
107 $c->forward_to_mason_view(
108 '/blast/show_seq/html.mas',
110 highlight_coords => \@coords,
111 source => '"'.$bdbo->title.'" BLAST dataset ',
113 ( $seq->length > 500_000 ? () : [ 'View as FASTA' => $view_link ] ),
114 [ 'Download as FASTA' => $download_link ],
116 blast_url => '/tools/blast/index.pl',
119 } elsif( $format eq 'fasta_file' || $format eq 'fasta_text' ) {
123 print "Content-Type: text/plain\n";
124 my $attachment = $format eq 'fasta_file' ? 'attachment;' : '';
125 print "Content-Disposition: $attachment filename=$id.fa\n";
127 Bio::SeqIO->new( -fh => \*STDOUT, -format => 'fasta' )