#!/usr/bin/perl -w use strict; use Bio::SearchIO; my $filename = 'MET30-vs-swissprot.1.FASTA'; my $input = Bio::SearchIO->new(-format => 'fasta', -file => $filename); #GOAL: # Print out the query, hit names and percent identity, percent query aligned while( my $r = $input->next_result ) { my $qname = $r->query_name; my $qlen = $r->query_length; while( my $hit = $r->next_hit ) { my $hname = $hit->name; while( my $hsp = $hit->next_hsp ) { my $percent_id = $hsp->frac_identical * 100; my $query_aln_len = $hsp->length('query'); # another way to do this # my $query_aln_len = $hsp->query->length; print join("\t", $qname, $hname, $hsp->evalue, sprintf("%.1f",$percent_id), sprintf("%.2f",100 * ( $query_aln_len / $qlen))), "\n"; } } }