I know this question already exists here in Biostars, (see https://www.biostars.org/p/6544/#361743) but it has very old answers (the majority being from 7 years ago), so I wanted to update it.
Context: I created a script that recognises the extension of my file and: 1) if it is fastq, it maps it using Bowtie2; 2) if it's BAM, it does something else. I want to test my script with test files that are small enough for the program to run as fast as possible so I can correct it, but I only've got my original samples (big, human ChIP-seq data). (Bash script, Linux, Bash 4).
The question: I want to know how can I take a subset of reads from the fastq and make a test file with it. It has to be small enough for the program to run fast, but reasonable enough to get mapped without causing errors that might distract me from debugging my script. Which is the current best practice for this? Thank you!
Given a compressed fastq which you probably already have from whatever source:
By the way, it is good practice to reference (provide links) threads you mention in questions. I am sure they contain helpful material.
fastq-sample from fastq-tools