4 use CXGN
::DB
::Connection
;
5 use CXGN
::Tools
::Identifiers qw
/link_identifier/;
7 our ($blastq, $blast_hitq);
9 our $page = CXGN
::Page
->new( "SGN Unigene - Show All Stored BLAST Hits", "Koni");
10 my ($unigene_id, $unigene_length, $target_id) = $page->get_arguments("unigene_id","l", "t");
12 my $dbh = CXGN
::DB
::Connection
->new();
14 if ($target_id =~ /^\d+$/) {
15 $blastq = $dbh->prepare("SELECT blast_annotation_id, blast_targets.blast_target_id,
16 blast_program, db_name, n_hits, hits_stored
17 FROM blast_annotations
18 LEFT JOIN blast_targets USING (blast_target_id)
19 WHERE apply_id=? AND blast_targets.blast_target_id=? AND apply_type=15");
21 $blastq = $dbh->prepare("SELECT blast_annotation_id, blast_targets.blast_target_id,
22 blast_program, db_name, n_hits, hits_stored
23 FROM blast_annotations
24 LEFT JOIN blast_targets USING (blast_target_id)
25 WHERE apply_id=? AND apply_type=15");
28 $blast_hitq = $dbh->prepare("SELECT blast_hits.target_db_id, evalue, score,
29 identity_percentage, apply_start, apply_end, defline
31 LEFT JOIN blast_defline USING (defline_id)
32 WHERE blast_annotation_id=?
33 ORDER BY score DESC");
39 if ($unigene_id eq "") {
43 unless ($unigene_length > 0){
47 if (int($unigene_id) ne $unigene_id) {
48 invalid_search
($unigene_id);
51 my $blast_content = "";
53 if ($target_id =~ /^\d+$/){
55 $blastq->execute($unigene_id, $target_id);
57 warn "XXX querying with ONLY unigene_id";
58 $blastq->execute($unigene_id);
61 while(my ($blast_annotation_id, $blast_target_id, $blast_program,
62 $target_dbname, $n_hits, $hits_stored) = $blastq->fetchrow_array()) {
63 $blast_content .= qq(<tr
><td align
="left"><b
>$target_dbname [$blast_program]</b></td
><td align
="right" colspan
="5"> Showing best
$hits_stored hits recorded
</td></tr
>);
65 $blast_hitq->execute($blast_annotation_id);
66 while(my ($match_id,$evalue,$score,$identity,$start,$end,
67 $defline) = $blast_hitq->fetchrow_array()) {
69 $match_id = link_identifier
($match_id) || $match_id;
71 if (length($defline)>120) {
72 $defline = substr($defline, 0, 117) . "...";
74 my $alignment_length = abs($end - $start) + 1;
76 my $span_percent = sprintf "%3.1f%%",
77 ($alignment_length/$unigene_length)*100.0;
79 # This assumes BLAST start/end coordinates are adjusted to start with
80 # index 0 for the first base, as per C and perl style string addressing
81 # Normally, BLAST addressing indexing the first base as 1.
83 $frame = ($start % 3) + 1;
85 $frame = -((($unigene_length - $start - 1) % 3) + 1);
88 $blast_content .= <<EOF;
89 <tr><td><b>Match:</b> $match_id</td>
90 <td><b>score:</b> $score</td>
91 <td><b>e-value:</b> $evalue</td>
92 <td><b>Identity:</b> $identity%</td>
93 <td><b>Span:</b> ${alignment_length}bp ($span_percent)</td>
94 <td><b>Frame:</b> $frame</td>
96 <tr><td colspan="6">$defline</td></tr>
99 $blast_content .= qq(<tr
><td colspan
="6"><br
/></td
></tr
>);
100 if ($hits_stored < $n_hits) {
101 my $t_hits = $n_hits - $hits_stored;
102 $blast_content .= qq(<tr
><td colspan
="6" align
="center"><font color
="gray">$t_hits lower scoring hits censored
-- only
$hits_stored best hits are stored
.</font></td
></tr
>);
107 if ($blast_content eq "") {
108 $blast_content = qq(<tr
><td
><font color
="gray">No BLAST annotations were found
</td></tr
>);
110 $blast_content = qq(<tr
><td
><table cellspacing
="0" border
="0" width
="100%" align
="center">) . $blast_content ."</table></td></tr>";
118 <table cellpadding="0" cellspacing="0" border="0" width="100%" align="center">
119 <tr><td align="center"><b>All Stored BLAST annotations for SGN-U$unigene_id</b></td></tr>
121 <tr><td><br /></td></tr>
134 <b>Not enough unigene search criteria specified</b>
144 my ($unigene_id) = @_;
150 <b>The specified unigene identifer ($unigene_id) does not result in a valid search.</b>