[Bioperl-l] how to create Graphics object from home-made SQL table with parsed blast data?

Marcus Claesson m.claesson at student.ucc.ie
Fri Oct 29 05:17:46 EDT 2004

Hi there,

My apologies if this already has been adressed in this list. I have a
number of mysql tables with blast data that I parsed using Bio::SearchIO
(see below). I now want to use that data to create graphics overviews in
png-format with the Bio::Graphics module. I guess the normal way for
doing this is by implementing Bio::SeqFeature to the
Bio::Graphics::Panel class. However, all blast-outputs are already
parsed and put into a table and I would like to use that format. Is
there any way of using these tables instead of the Bio::SeqFeature

Here is how it was parsed and put into the table:

    $in = new Bio::SearchIO(-format => 'blast', 
                            -file     => 'blast_output.txt');

    $dbh->do("CREATE TABLE $table(format TEXT NOT NULL,sbj_name TEXT NOT
NULL,sbj_count INTEGER,hsp_count INTEGER,hsp_length INTEGER,E_value
DOUBLE PRECISION,score INTEGER,bits REAL,percent_id REAL,query_begin
INTEGER,query_end INTEGER,sbj_length INTEGER,sbj_begin INTEGER,sbj_end
INTEGER,frame CHAR(3),alignment TEXT)") unless ($add eq "yes");
    $sth = $dbh->prepare("INSERT INTO $table VALUES
    while($result = $in->next_result) {
	$sbj_count = 0;
	while($hit = $result->next_hit) {
	    my $hsp_count = 0;
	    my $sbj_name = $hit->name." ".$hit->description;
	    $sbj_name =~ s/'/\\'/gi;
	    my $sbj_length = $hit->length('query');
	    while($hsp = $hit->next_hsp ) {
		if ($format eq "blast") {
		    $frame_value = ($hsp->query->frame + 1) * $hsp->query->strand;
		} elsif ($format eq "fasta") {
		    $frame_value = "+" if ($hsp->query->strand eq "1");
		    $frame_value = "-" if ($hsp->query->strand eq "-1");
		my $align = "Query -->\n".
		    "Subject -->\n";
		my $evalue = $hsp->evalue;
		$evalue =~ s/^e/1e/gi;
		my $score = $hsp->score;
		my $bits = $hsp->bits;
		my $percent_id = $hsp->percent_identity;
		my $hsp_length = $hsp->length('total');
		my $query_begin = $hsp->query->start + $offset;
		my $query_end = $hsp->query->end + $offset;
		my $sbj_begin = $hsp->hit->start;
		my $sbj_end = $hsp->hit->end;


Many thanks in advance!


More information about the Bioperl-l mailing list