I like this idea, but I suspect an issue with resampling. Perhaps I am missing something. This is what I did to produce reads with 30X coverage. Note that there are 1000000 reads in each fastq file. I used the reads=31250 parameter to restrict the input to a fraction of the original fastq file and then the samplereadstarget=937500 parameter to output new fastq files with 30 times the number of input reads, and finally the upsample=TRUE parameter to upsample (duplicate reads) when the target is greater than input.
reformat.sh in=$read1 in2=$read2 out=$OUT out2=$OUT2 reads=31250 samplereadstarget=937500 upsample=TRUE
I could then vary the value for the samplereadstarget parameter to produce fastq files with different levels of coverage (which I would concatenate in the end), but there is no way to avoid resampling the sample input reads each time I repeat this.
Am I making this far too complicated?
map your reads to a bam file , get the coverage for the RAW bam, and the run
samtools view -saccording to your needs: http://www.htslib.org/doc/samtools-view.htmlI'm not sure mapping before subsetting will work if unmapped reads get thrown out. I'd like to avoid that step if at all possible. Surely there's an easier way to produce synthetic reads with variable (known) known levels of coverage.