in reply to Reading in Qual File Using Bio::SeqIO
This qual format is similar to FastA but it has its own module interfaces at 'Bio::Seq::PrimaryQual' and Bio::SeqIO::qual, you are mixing between Bio::SeqIO and the others since Bio::SeqIO is the general wrapper for many other packages that intelligently handle many different formats each having their own peculiarities. It is still flexibly possible to interchange methods under such a generalized wrapper btw with some significant differences (read 'potential for things to go wrong!')...
Excellence is an Endeavor of Persistence. A Year-Old Monk :D .
However BioPerl can gift you valuable hints were you adhering to and observing the mantra of:
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->qualuse strict; use warnings;
The above code's $qual_obj can still be initialized directly through Bio::SeqIO: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);
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.
Kudos for providing examples of code and input :)...#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);
Excellence is an Endeavor of Persistence. A Year-Old Monk :D .
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Reading in Qual File Using Bio::SeqIO
by twaddlac (Novice) on Jul 02, 2010 at 18:43 UTC | |
Re^2: Reading in Qual File Using Bio::SeqIO
by twaddlac (Novice) on Jul 06, 2010 at 19:09 UTC |
In Section
Seekers of Perl Wisdom