Hi,
first of all, I have to admit I am new to Bioperl and Perl in general, so please be patient if I am asking a stupid question.
I want to calculate how much of my query sequence (in %) are matched by the hits in my BLAST output. A formula would look like this: (length of the BLAST alignment) / (length of the query sequence)
The length of the query is given in the header of each BLAST result as "Length = .." .
Currently I am accessing the data in the BLAST output like this (the e-value and other attributes works fine):
#!/usr/bin/perl
use strict;
use warnings;
use Bio::SearchIO;
my $report_obj = new Bio::SearchIO(-format => 'blast',
-file => 'test.blastx');
while (my $result = $report_obj -> next_result) {
while (my $hit = $result -> next_hit) {
# get the e-value
my $evalue = $hit -> expect;
print "\n" . 'e: ' . $evalue . "\n";
while ( my $hsp = $hit->next_hsp ) {
# get the query length
my $length_q = $hsp -> length('query');
print 'query length: ' . $length_q . "\n";
}
}
}
Does $hsp also have an attribute like query length, if so: how do I access it?
Or is there another way of getting the information I want to extract?
I appreciate every help :)