added sol100 and chado cvterm pages to validate_all.t
[sgn.git] / lib / CXGN / BioTools / SearchIOHTMLWriter.pm
blob808a49628ecacb52157411b662a69164e64ae18c
1 package CXGN::BioTools::SearchIOHTMLWriter;
2 use strict;
3 use warnings;
5 use CXGN::Tools::Identifiers;
6 use CXGN::BlastDB;
8 use base qw/Bio::SearchIO::Writer::HTMLResultWriter/;
10 sub new {
11 my ($class,$db_id, @args) = @_;
12 my $self = $class->SUPER::new(@args);
16 $self->id_parser( sub {
17 my ($idline) = @_;
18 my ($ident,$acc) = Bio::SearchIO::Writer::HTMLResultWriter::default_id_parser($idline);
19 #The default implementation checks for NCBI-style identifiers in the given string ('gi|12345|AA54321').
20 #For these IDs, it extracts the GI and accession and
21 #returns a two-element list of strings (GI, acc).
23 return ($ident,$acc) if $acc;
24 return CXGN::Tools::Identifiers::clean_identifier($ident) || $ident;
25 });
26 my $hit_link = sub {
27 my ($self, $hit, $result) = @_;
28 #see if we can link it as a CXGN identifier. Otherwise,
29 #use the default bioperl link generator
30 my $url = CXGN::Tools::Identifiers::link_identifier($hit->name())
31 || $self->default_hit_link_desc($hit,$result,$db_id);
33 return $url;
35 $self->hit_link_desc($hit_link);
36 $self->hit_link_align($hit_link);
37 $self->start_report(sub {''});
38 return $self;
41 sub end_report {
42 return '';
46 sub default_hit_link_desc {
47 my $self = shift;
48 my $hit = shift;
49 my $result = shift;
50 my $db_id = shift;
52 my $coords_string =
53 "hilite_coords="
54 .join ',',
55 map $_->start('subject').'-'.$_->end('subject'),
56 $hit->hsps;
58 my $id = $hit->name();
59 return qq{<a href="show_match_seq.pl?blast_db_id=$db_id&amp;id=$id&amp;$coords_string">$id</a>};
62 ###
63 1;#do not remove
64 ###