帮忙检查一个小程序

帮忙检查一个小程序

帮忙检查一个小程序
#!/usr/bin/perl -w

use strict;
use Bio::SearchIO;
use Bio::Seq;


my $input="/picb/home4/limingkun/Desktop/try.fasta";

my $searchio = Bio::SearchIO->new(-format => 'blast',
-file => $input);

while( my $result = $searchio->next_result ) {
my $query_id = $result->query_name();
while( my $hit = $result->next_hit ) {
while( my $hsp = $hit->next_hsp ) {

my ($id,$cons) = $hsp->matches(-SEQ=>'query',-START=>85,-STOP=>90);

my $query_seq=$hsp->query_string;
my $hit_seq=$hsp->hit_string;
my $homology_seq=$hsp->homology_string;
(my $start, my $end)=$hsp->range('query');
my $align_length=length($query_seq);
my @identity=$hsp->seq_inds('query','id');
my $number_id=$hsp->num_identical();
my $hit_rank=$hit->rank;
my $hsp_rank=$hsp->rank;
my $newposition=&newposition($hsp,101);


my $query_length=$hsp->length('query');
print "$query_id","$query_length\n";
#print "$start","$end\n";
print "$align_length\n";
print "$number_id\n";
print "$hit_rank\n";
print "$hsp_rank\n";
print "$id\n";
print "$newposition\n";

}
}
}

sub newposition
{
my($self,$no)=@_;
my @seq=split //,$self->query_string;
(my $start, my $end)=$self->range('query');
my $aim=$no-$start;
for (my $i=0;$i<=201;$i++)
{
[color=red]my $n++ if ($seq[$i] ne "-");
if($n eq $aim)[/color]
{
$aim=$i+1;
last;
}
}
return $aim;
}

子程序里面的两行,总是报错,希望大家指导一下,谢谢。
Use of uninitialized value in string ne at megablast.pl line 56, <GEN1> line 231.
Use of uninitialized value in string eq at megablast.pl line 57, <GEN1> line 99.




   

你的 $n 值只是在$seq[$i].
你的 $n 值只是在$seq[$i] ne "-" 才被声明, 没声明的时候你就做 $n eq $aim 就会提示你 $n 还没有声明.
太感谢强哥了, 我在外面加了一个 my $n, 就搞定了, thanks, thanks many thanks.