Properly parsing FASTQ is a nightmare. It's not possible to start at a random position in the file and guarantee that a seek forward (or backwards) to an '@' symbol will arrive at the start of a FASTQ header. That's a problem if `log(n)` time complexity is desired, because the problem means that it's not possible to read through the entire file to get a sample of sequences.

If the allowed FASTQ format were more strict, i.e. 4 lines per record: [header, sequence, header, quality], then it *would* be possible to do this: seek to a random location in the file, seek to find the next line that contains only a `+` (preceded by a DNA sequence to exclude `+` in the quality string), seek backwards two lines, and there's the start of a FASTQ record.

If the file were indexed, then it would be possible to do the shuffling on the index and use that to select reads from the file... but that would also require a complexity of over `n` (because at least indexing is needed).

`samtools view` has the `-s <float>` option for subsampling aligned reads, but that's in BAM format, rather than FASTQ format (and would still go through the whole file before arriving at the last read).