Entering edit mode
7.1 years ago
apulunuj
▴
30
I am making use of a perl script for a pipeline and I'm getting the following error message. I don't know what to do. The error message I'm getting is:
Use of uninitialized value $qulen in division (/) at FAST_kspipe.pl line 167, <$blast_file> line 7. Illegal division by zero at FAST_kspipe.pl line 167, <$blast_file> line 7.
The perl script can be found here:
https://github.com/mrmckain/FASTKs/blob/master/FAST_kspipe.pl
If you can't access it here is the code with the line (the line of interest is , next if (abs(($qend-$qstart)*3)/$qulen) < 0.75 || (abs(($hend-$hstart)*3)/$sublen) < 0.75;
)
sub get_quality_pairs_ORIG {
my %hits;
my %gene_hits;
my (%sseqs, %qseqs);
my $temp_seqid;
open my $qfile, "<", $_[1];
while(<$qfile>){
chomp;
if(/>/){
$temp_seqid = substr($_, 1);
}
else{
$qseqs{$temp_seqid}.=$_;
}
}
open my $sfile, "<", $_[2];
while(<$sfile>){
chomp;
if(/>/){
$temp_seqid = substr($_, 1);
}
else{
$sseqs{$temp_seqid}.=$_;
}
}
open my $blast_file, "<", $_[0];
open my $outfile, ">", "$qsho\_$ssho\_ks/$qsho\_$ssho.paralogs.txt";
my $current_query = "";
while (<$blast_file>) {
chomp;
my ($query,$hit,$perc_id,$aln_len, $mismatch, $indel, $qstart,$qend,$hstart,$hend) = split /\s+/;
next if ($perc_id >= 100.00);
next if $query eq $hit;
#my ($qgene, $sgene);
#$query =~ /(.+c\d+_g\d+)/;
#$qgene = $1;
#$hit =~ /(.+c\d+_g\d+)/;
#$sgene = $1;
#next if $qgene eq $sgene;
my $sublen = length($sseqs{$hit});
my $qulen = length($qseqs{$query});
next if (abs(($qend-$qstart)*3)/$qulen) < 0.75 || (abs(($hend-$hstart)*3)/$sublen) < 0.75;
#next if exists $gene_hits{$sgene}{$qgene} || exists $gene_hits{$qgene}{$sgene};
#next if exists $hits{$hit}{$query} || exists $hits{$query}{$hit};
#next if exists $hits{$hit};
# #next if exists $hits{$query};
# next if exists $gene_hits{$sgene}{$qgene} || exists $gene_hits{$qgene}{$sgene};
# next if exists $hits{$hit}{$query} || exists $hits{$query}{$hit};
What's the question ? The error message is pretty clear. The variable $qulen is not defined, i.e. has no value so you can't use it in a division. Now if you want to find out why you're getting this error, check where this variable is supposed to be initialized:
my $qulen = length($qseqs{$query});
so either $query or $qseqs{$query} is not defined. You should also have got at least a warning about this before the error. Since $query seems to be populated by parsing a blast output, check that its format conforms to the expected format. Since the error happens at <$blast_file> line 7, check this line.
Thank you I fixed it now, it was the blast format.