use strict;
use warnings;
at the top of your program and declaring your variable accordingly, this can save you needless tail-chasing.
$qual_obj->seq is better written as $qual_obj->qual
use strict;
use warnings;
use Bio::SeqIO::qual;
my $file = "Qual.txt";
my $qual_obj = Bio::SeqIO::qual->new(-file =>"<$file",-format=>'qual',
+);
my %qual_hash ;
while(my $qual = $qual_obj->_next_qual){
$qual_hash{$qual->id}= $qual->qual();
}
use Data::Dumper;
print Dumper(\%qual_hash);
The above code's $qual_obj can still be initialized directly through Bio::SeqIO:
use strict;
use warnings;
use Bio::SeqIO;
my $file = "Qual.txt";
my $qual_obj = Bio::SeqIO->new(-file =>"<$file",-format=>'qual',);
You can also read this file in as a FastA file since it has the '>' record identifier, however, each qual record would not be indexed in an array as is the case in the above example since reading the file as a FastA would slurp in all qual values into a single string that is treated as a protein sequence by BioPerl.
#THIS DOESN'T READ THE FILE RIGHT..
my $file = "Qual.txt";
my $qual_obj = Bio::SeqIO->new(-file =>"<$file",-format=>'fasta',);
my %seq_hash = ();
while(my $seq= $qual_obj->next_seq){
$seq_hash{$seq->id} = $seq->seq;
}
use Data::Dumper;
print Dumper(\%seq_hash);
Kudos for providing examples of code and input :)...
Excellence is an Endeavor of Persistence.
A Year-Old Monk :D .
|