how to repeat records in fastq n times efficiently? How to iterate/repeat a record n times in a fastq file using bioawk? I wrote a python code using biopython, but it is very very slow. So, I am wondering if I can get some help by using bioawk. Thank you so much!
for example, in the file.fq file, I'd like to repeat read_id1 for 100times, read_id2 for 100times, ..., and write them to a new file.
Not sure why you would want to do this, but if the aim is to repeat all records in the fastq/fasta files n times, the most efficient way I can think of is just to concatenate the orginal file n times, similar to this thread.
i.e adapting the accepted answer would look something like this (I have not tested this):
for i in {1..n};do cat file.fq &gt;&gt; file_ntimes.fq ; done

Update based on comments:
To replicate each fastq entry back to back, maybe this hacky unix command can be adjusted (say for n=4):
n=10
paste - - - - &lt;file.fq | awk '{for(i=0;i&lt;$n;i++)print}' | tr '\t' '\n' &gt; file_10times.fq

The idea is to paste blocks of 4 lines (i.e. 1 fastq entry) into one line and replicate this line n times. tr is reversing the paste action (since the separation by paste is a tab character). This won't work if fastq file for some reason has tabs in it which I don't expect but didn't test either.
Note, for fasta file this would be paste - - rather than paste - - - -
I haven't tested this, but if it works for you I could polish it up if needed.
Update2
Based on Xioafeis comment this is solution seems to work as well:
bioawk -cfastx '{for(i=1; i&lt;=10; i++) {print &quot;@&quot;$name&quot;\n&quot;$seq&quot;\n+\n&quot;$qual}}' file.fq &gt; file_10times.fq