blast alignemnt query coverage using perl
Dear all I need to calculate query coverage using perl, for which I wrote my own code in perl as well as used -outfmt "6 std qcovs. my perl code is
#!/usr/bin/perl -w
use warnings;
use strict;
my $filename = 'gene_length_u';
my @fields;
open (FH, $filename);
#my $n = 0;
while ( <FH> ) {
chomp;
my @fields = split('\t', $_);
#print "$fields[0]\n";
#print "$fields[1]\n";
#print "$fields[2]\n";
#print "$fields[3]\n";
print "$_";
#$n = $n+1;
#print "\n my line number $n \n";
my $p = ($fields[2] - $fields[1])+1;
my $q = $p/$fields[5] * 100;
print "\t\t$q\n";
}
#foreach (<$filename>){
#print "$_";
#}
close FH;
exit;
Why I am getting different query coverage. I have calculated sequence length using infoseq and I have file (input ) like this.
gene_id gene_start gene_end gene_id gene_length
lcl|NZ_CP018664.1_gene_1121 1 303 NZ_CP018664.1_gene_1121 303
lcl|NZ_CP018664.1_gene_1122 1 1053 NZ_CP018664.1_gene_1122 1053
lcl|NZ_CP018664.1_gene_1123 1 768 NZ_CP018664.1_gene_1123 768
lcl|NZ_CP018664.1_gene_1124 1 1698 NZ_CP018664.1_gene_1124 1698
lcl|NZ_CP018664.1_gene_1125 1 657 NZ_CP018664.1_gene_1125 657
• 936 views
•
link
0 answers
No answers yet.
Log in to answer this question.
Hello sharmatina189059!
Questions similar to yours can already be found at:
We have closed your question to allow us to keep similar content in the same thread.
If you disagree with this please tell us why in a reply below. We'll be happy to talk about it.
Cheers!
I added (code) markup to your post for increased readability. You can do this by selecting the text and clicking the 101010 button. When you compose or edit a post that button is in your toolbar, see image below: