Entering edit mode
12.5 years ago
Rajesh
▴
30
Hi friends,
I have written perl code to parse blast result and generating .png image for alignment on html page. The image can not be generated when i run the code in apache2 server. The error message is cannot write the file .png and hence not able to view image from the below code. Please if you have any suggestions so it will be greatful.
#!/usr/bin/perl
use Bio::Graphics;
use Bio::SeqFeature::Generic;
print "Content-type: text/html\n\n";
open(FH,"BR_results.txt") or die "Cannot open the blastfile\n";
# i need to show image in html but gives error cant write png file.
open(FW,">Data.png") or die "Cannot write the png file\n";
@BR_Query=();
@BR_Gene=();
@BR_Length=();
@BR_start=();
@BR_end=();
$count_hit=0;
while(<FH>)
{
chomp($_);
if($_=~/^>.*/)
{
$count_hit++;
}
if($_=~/Query= (.*)/)
{
$Query=$1;
chomp($Query);
push(@BR_Query,$Query);
}
if($_=~/^>(.*)\s+\w+/)
{
$Gene=$1;
push(@BR_Gene,$Gene);
}
if($_=~/ Length = (\d+)/)
{
$Length=$1;
push(@BR_Length,$Length);
}
if($_=~/Sbjct: (\d+)\s+.*\s+(\d+)/)
{
$start=$1; $end=$2;
push(@BR_start,$start);
push(@BR_end,$end);
}
}
$len=@BR_Gene;
for($i=0;$i<$len;$i++)
{
my $panel = Bio::Graphics::Panel->new( -length => $BR_Length[$i],
-width => 700,
-pad_left => 10,
-pad_right => 10,
);
my $full_length = Bio::SeqFeature::Generic->new(-start=>1,-end=> $BR_Length[$i]);
$panel->add_track($full_length,
-glyph => 'arrow',
-tick => 2,
-bump => 0,
-fgcolor => 'black',
-double => 2,
);
$panel->add_track($full_length,
-glyph => 'generic',
-fgcolor => 'green',
-label => $BR_Gene[$i],
);
my $track = $panel->add_track(-glyph => 'graded_segments',
-label => 1,
-bgcolor => 'red',
-min_score => 0,
-max_score => 1000);
my $feature1 = Bio::SeqFeature::Generic->new(-display_name=> $BR_Query[$i],
-start => $BR_start[$i],
-end => $BR_end[$i] );
$track->add_feature($feature1);
# question how to print png image in html directly without saving to image file
$x=$panel->png;
print FW "$x";
}
close FH;
close FW;
How can i show image generated using perl code as shown above. Thanks