[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
module?
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) {
$sbj_count++;
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 ) {
$hsp_count++;
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".
$hsp->query_string."\n".
$hsp->homology_string."\n".
$hsp->hit_string."\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;
$sth->execute($format,$sbj_name,$sbj_count,$hsp_count,$hsp_length,$evalue,$score,$bits,$percent_id,$query_begin,$query_end,$sbj_length,$sbj_begin,$sbj_end,$frame_value,$align);
}
}
Many thanks in advance!
Marcus
More information about the Bioperl-l
mailing list