Dear Masters,
I have a data that looks like this (fastq format). Note that each entry consist of chunk of four lines. Each chunk begins with an entry with "@"sign and ends with octal values (e.g. (IIII... ).
@SRR016086.1 308GJAAXX:2:1:911:957 length=36 CCCCCCCCCCACCCCCCCACACCACAAACACACCAC +SRR016086.1 308GJAAXX:2:1:911:957 length=36 (IIIIIIII:&H68;I-3%/)*-/4$$')(0&$&,$ @SRR016086.2 308GJAAXX:2:1:916:735 length=36 AGATCAGTTTTGCACTCCACTTAAGTTTGTTCATAT +SRR016086.2 308GJAAXX:2:1:916:735 length=36 I*IIIIIIIIIII%%CI()I2E6.I5;>+"=C+#%I @SRR016086.3 308GJAAXX:2:1:908:956 length=36 CCCCCCCCCAACACAAAAACAAAATCCAAAACAATA +SRR016086.3 308GJAAXX:2:1:908:956 length=36 II@III50I*9I+<00%.<9/,%-"$*2('&"&)""
What I want to do is to extract line 2, 3 and 4 of each chunk from the above file. I've tried Bioperl with this script but fail:
use Bio::SeqIO; my $file = $ARGV[0] || "test.fastq"; my $in = Bio::SeqIO->new(-file => $file , '-format' => 'fastq'); while ( my $seq = $in->next_seq() ) { print "$seq->id\n"; }
Nor with my attempted homebrew method, in which I'm stuck with the logic.
my $INFILE_file_name = $file; # input file name open ( INFILE, '<', $INFILE_file_name ) or croak "$0 : failed to open input $INFILE_file_name : $!\n"; my $count = 0; my $seqlinec = 2; while ( <INFILE> ) { chomp; # Trying to catch line 2 of each chunk.. if ( $seqlinc eq $count ) { print "$_\n"; } $seqlinec += 4; } close ( INFILE ); # close input file
What's the right way to do it?

---
neversaint and everlastingly indebted.......

In reply to Getting Lines 2,3, and 4 from FASTQ file's Chunk by neversaint

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!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • 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, details, 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, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            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.