use warnings;
print "Enter Your BLAST result file name:\t";
chomp($blast = <STDIN>); # BLAST result file name
print "\n";
print "Enter Your Gene list file name:\t";
chomp($database = <STDIN>); # file name
print "\n";
open IN,"$blast" or die "Can not open file $blast: $!";
@ids = ();
@seq_start = ();
@seq_end = ();
while(<IN>){
@feilds = split("\t",$_);
push(@ids,$feilds[0]);
push(@seq_start,$feilds[6]);
push(@seq_end,$feilds[7]);
}
close IN;
open OUT,">Result.fasta" or die "Can not open file $database: $!";
for($i=0;$i<=$#ids;$i++){
($sequence) = &block($ids[$i]);
($idline,$sequence) = split("\n",$sequence);
if($seq_start[$i] <= 70){
$pos_Start = 0;
}
else{
$pos_Start = $seq_start[$i]-70;
}
$pos_end = $seq_end[$i]+70;
if($pos_end >= length($sequence)){
$pos_end = length($sequence);
}
$seqlen = $pos_end - $pos_Start;
$Nucleotides = substr($sequence,$pos_Start,$seqlen);
$Nucleotides =~ s/(.{1,60})/$1\n/gs;
print OUT "$idline\n";
print OUT "$Nucleotides\n";
}
print "\nExtraction Completed...";
sub block{
$id1 =shift;
print "$id1\n";
$start = ();
open IN3,"$database" or die "Can not open file $database: $!";
$blockseq = "";
while(<IN3>){
if (($_ =~ /^>/)&&($start)){
last;
}
if (($_ !~ /^>/)&&($start)){
chomp;
$blockseq .= $_;
}
if (/^>$id1/){
$start = $.;print "$.\n";#-1;
$blockseq .= $_;
}
}
close IN3;
return($blockseq);
}<STDIN>;
I got following errors while running the above code
Use of uninitialized value $seq_start[1] in numeric le (<=) at Blast_Extractor1.pl line 35.
Use of uninitialized value $seq_end[1] in addition (+) at Blast_Extractor1.pl line 42.
Use of uninitialized value in numeric ge (>=) at Blast_Extractor1.pl line 43.
Use of uninitialized value $pos_end in subtraction (-) at Blast_Extractor1.pl line 47.
Use of uninitialized value $sequence in substr at Blast_Extractor1.pl line 49.
Use of uninitialized value $idline in concatenation (.) or string at Blast_Extractor1.pl line 53.
this is my blast out put
Hello akhilvbioinfo!
We believe that this post does not fit the main topic of this site.
This is a pure Perl question.
For this reason we have closed your question. This allows us to keep the site focused on the topics that the community can help with.
If you disagree please tell us why in a reply below, we'll be happy to talk about it.
Cheers!