[Bioperl-l] seq_inds method question for blast parsing...
Sajeev Batra
batra@operon.com
Mon, 11 Nov 2002 12:06:42 -0800
Hi Jason and others,
A while back you suggested if I want to useq the seq_inds() method for
Washu and NCBI blastn output, that I should use the 'blast' format in
SearchIO instead of 'psiblast'. Thank you for your tip but
I tried to that but need another tip from you guys.
Here's my error msg:
Can't locate object method "hits" via package
"Bio::Search::Result::GenericResult" at ./custom_writer_sajeev2.pl line
48, <STDIN> line 315.
Any suggestions? Does anyone have a sample code in where they are using
the seq_inds function for the 'blast' format successfully? Your
feedback is appreciated and thank you.
Sajeev.
Here's my code:
use strict;
use lib '../../../';
use Bio::Root::Root;
use Bio::SearchIO::SearchWriterI;
use vars qw( @ISA );
@ISA = qw( Bio::Root::Root Bio::SearchIO::SearchWriterI );
sub to_string {
my ($self, $result, @args) = @_;
my $str = '';
my $hits_reported = 0;
foreach my $hit($result->hits) {
$hits_reported++;
my @seq_inds_array = $hit->seq_inds('query','identical',1);
my @test_inds_array = $hit->seq_inds('subject','identical',1);
my $query_matches = $#seq_inds_array + 1;
print "seq_inds_array id ",@seq_inds_array, "\n";
print "test_inds_array co ",@test_inds_array,"\n";
$str .= sprintf "%s\t%s\t%d\t%d\t%d\t%d\t%d\t%.1e\t%d\t%d\t%f\n",
$result->query_name, $hit->name, $result->query_length,
$hit->length,
$hit->score, $hit->bits, $hit->iteration, $hit->expect,
$query_matches, $hit->length_aln('query'),
$hit->frac_identical('query');
}
$str;
}
package main;
#===================================================
# Start of script
#===================================================
use strict;
use lib '../../../';
use Bio::SearchIO;
select STDOUT; $|=1;
my $in = Bio::SearchIO->new( -format => 'blast' );
my $writer = MyBlastWriter->new();
my $out = Bio::SearchIO->new( -format => 'blast',
-writer => $writer );
while ( my $result = $in->next_result() ) {
#printf STDERR "Report %d: $result\n", $in->report_count;
$out->write_result($result);
}