bash - Linux for loop for 2 inputs and 4 outputs -
i need write for
loop.
input:
file01_r1.fastq, file01_r2.fastq. have 100 files e.g., file02_r1.fastq, file02_r2.fastq , on.
output:
file01_r1_pe.fastq, file01_r1_se.fastq, file01_r2_pe.fastq, file01_r2_se.fastq
i need write loop can run executable 100 files. please!
i assume given file
file01_r1.fastq
you want run:
trimmomatic file01_r1.fastq file01_r2.fastq -o file01_r1_pe.fastq file01_r1_se.fastq file01_r2_pe.fastq file01_r2_se.fastq
using gnu parallel looks this:
parallel trimmomatic {} {= s/_r1/_r2/ =} -o {= s/_r1/_r1_pe/ =} {= s/_r1/_r1_se/ =} {= s/_r1/_r2_pe/ =} {= s/_r1/_r2_se/ =} ::: *_r1.fastq
gnu parallel general parallelizer , makes easy run jobs in parallel on same machine or on multiple machines have ssh access to.
if have 32 different jobs want run on 4 cpus, straight forward way parallelize run 8 jobs on each cpu:
gnu parallel instead spawns new process when 1 finishes - keeping cpus active , saving time:
installation
if gnu parallel not packaged distribution, can personal installation, not require root access. can done in 10 seconds doing this:
(wget -o - pi.dk/3 || curl pi.dk/3/ || fetch -o - http://pi.dk/3) | bash
for other installation options see http://git.savannah.gnu.org/cgit/parallel.git/tree/readme
learn more
see more examples: http://www.gnu.org/software/parallel/man.html
watch intro videos: https://www.youtube.com/playlist?list=pl284c9ff2488bc6d1
walk through tutorial: http://www.gnu.org/software/parallel/parallel_tutorial.html
sign email list support: https://lists.gnu.org/mailman/listinfo/parallel
Comments
Post a Comment