Is there a way to sample sequences from the `fastq.gz` file? I have files that contain hundreds of millions of reads, I want to sample about 100 million reads from each file. Is there a way to do this?
[BBTools's][1] reformat tool does this, keeping pairs together if they are interleaved:

    reformat.sh in=reads.fq.gz out=sampled.fq.gz samplereadstarget=100000000

or for reads in 2 files:

    reformat.sh in1=reads1.fq.gz in2=reads2.fq.gz out=sampled1.fq.gz out2=sample2.fq.gz samplereadstarget=100000000

You can also just sample a fraction of the reads without respect to the final number, which is faster since it only needs to read the file once:

    reformat.sh in=reads.fq.gz out=sampled.fq.gz samplerate=0.1

or just sample the first X reads, which is faster still:

    reformat.sh in=reads.fq.gz out=sampled.fq.gz reads=100000000

Reformat is multithreaded and extremely fast.

 [1]: https://sourceforge.net/projects/bbmap/