Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Getting Lines 2,3, and 4 from FASTQ file's Chunk

by Ratazong (Monsignor)
on Apr 16, 2010 at 07:17 UTC ( [id://835026]=note: print w/replies, xml ) Need Help??


in reply to Getting Lines 2,3, and 4 from FASTQ file's Chunk

my $count = 0; my $seqlinec = 2; while ( <INFILE> ) { if ( $seqlinc eq $count ) { print "$_\n"; } $seqlinec += 4; }

I assume you want to somehow count the line you are reading. In that case, you should increment your counter somewhere. Maybe do something like the following (untested!) code

my $count = 0; while ( <INFILE> ) { next if ( !$count++ ); # ignore line zero, increase linec +ount print $_; $count = 0 if ($count >= 3); # reset the counter once we printe +d line 3 }

HTH, Rata

note: of course the code could be easily optimized, e.g. by using ($count++ % 4); see Boolean counter? for some ways (you need to adapt them to count modulo 4)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://835026]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (7)
As of 2024-04-18 07:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found