in reply to Deconvolutinng FastQ files
Here's an option that uses Tie::File to bind the fastq records' file to an array for processing. The files will automatically close when my %FHs falls out of scope. My thanks to BrowserUk for the elegant file handle/hash routine.
use Modern::Perl; use Tie::File; { tie my @fastqLines, 'Tie::File', 'records.fastq', recsep => "\n" o +r die $!; my %FHs = map { open my $fh, '>', "$_.fastq" or die $!; $_ => $fh } qw[ TTGT GGTT ACCT ]; for ( my $i = 0 ; $i < scalar @fastqLines ; $i += 4 ) { $fastqLines[ $i + 1 ] =~ /^...(.{4})/ and print { $FHs{$1} } @fastqLines[ $i .. $i + 3 ]; } untie @fastqLines; }
Update: Don't try this at home, as the OP's 34G file is much too large for Tie::File to efficiently handle.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Deconvolutinng FastQ files
by BrowserUk (Patriarch) on Aug 06, 2012 at 19:57 UTC | |
by Kenosis (Priest) on Aug 06, 2012 at 21:15 UTC | |
by snakebites (Initiate) on Aug 07, 2012 at 14:05 UTC | |
|
Re^2: Deconvolutinng FastQ files
by BrowserUk (Patriarch) on Aug 06, 2012 at 20:55 UTC | |
by Kenosis (Priest) on Aug 06, 2012 at 21:34 UTC | |
by afoken (Chancellor) on Aug 07, 2012 at 05:23 UTC | |
by ww (Archbishop) on Aug 07, 2012 at 13:56 UTC | |
by Kenosis (Priest) on Aug 07, 2012 at 15:18 UTC |