Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
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!')...

However BioPerl can gift you valuable hints were you adhering to and observing the mantra of:

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 .

In reply to Re: Reading in Qual File Using Bio::SeqIO by biohisham
in thread Reading in Qual File Using Bio::SeqIO by twaddlac

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others lurking in the Monastery: (10)
    As of 2014-11-28 10:07 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      My preferred Perl binaries come from:














      Results (195 votes), past polls