This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Cut fastq files

Hello, I have a couple of fastq files of approximately 20 million reads (transcriptomes) and I want to extract 5-10 thousand reads to test assemble them on my laptop, is it possible?

I just want to do an exercise with few reads. .

files fastq cut

3 answers

gunzip -c in.fastq.gz | paste - - - - | head -n 10000 | tr "\t" "\n" | gzip > sub.fastq.gz

Thanks for your response, this command extracts the first 1000 reads from the fastq file right?

Why not just head -n 40000 on the unzipped fastq stream directly?

Thanks for you answer AT.

Use reformat.sh from BBMap suite. Relevant options for sampling.

reformat.sh -Xmx4g in=file.fq.gz out=sampled.fq.gz RELEVANT_OPTIONS_BELOW

reads=-1                Set to a positive number to only process this many INPUT reads (or pairs), then quit.
skipreads=-1            Skip (discard) this many INPUT reads before processing the rest.
samplerate=1            Randomly output only this fraction of reads; 1 means sampling is disabled.
sampleseed=-1           Set to a positive number to use that prng seed for sampling (allowing deterministic sampling).
samplereadstarget=0     (srt) Exact number of OUTPUT reads (or pairs) desired.
samplebasestarget=0     (sbt) Exact number of OUTPUT bases desired.

get randon reads from fastq file use seqtk: seqtk sample read.fq.gz 1000000 |gzip > sub_reads.fq.gz

Log in to answer this question.