in reply to concatenate/stitch multiple GZip fastq files and output combined gzip file

I'm not sure that there is any real merit in using Perl for something like this? I'd anticipate that a simple command shell pipe line would use less memory and run faster.

In theory, you ought to be able to do something like:

gunzip *.fastq.gz | gzip combined.fastq.gz

You'd need a little appropriate shell syntax to get the list of files from your input file, depending upon your chosen shell. ( <( type filelist.txt ) inplace of the wildcard?)


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority". I knew I was on the right track :)
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^2: concatenate/stitch multiple GZip fastq files and output combined gzip file
by Anonymous Monk on Dec 02, 2015 at 17:01 UTC

    Or if you have a truly absurd number of input files,

    xargs gunzip < filelist | gzip > combined.gz

      Or, you could just cat the compressed files together. Says gunzip

      Multiple compressed files can be concatenated. In this case, gunzip will extract all members at once.
      ... and conversely, for gzip -c
      If there are several input files, the output consists of a sequence of independently compressed members. To obtain better compression, concatenate all input files before compressing them.

Re^2: concatenate/stitch multiple GZip fastq files and output combined gzip file
by Bioinfocoder (Novice) on Dec 03, 2015 at 16:32 UTC
    Thanks a lot for your replies - The script works for me now :
    #!/usr/bin/perl use strict; use warnings; use File::Slurp; use IO::Compress::Gzip qw(gzip $GzipError); my @data = read_file('./File_list.txt'); my $out = "./test.txt"; foreach my $data_file (@data) { chomp($data_file); system("zcat $data_file >> $out"); } my $outzip = "./test.gz"; gzip $out => $outzip;