This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Are there any GNU parallel or similar Shell/Bash code examples on how to run Snap and BWA aligners on a batch of paired .fastq files?

Are there any GNU parallel or similar Shell/Bash code examples on how to run Snap and BWA aligners on a batch of paired .fastq files? We have almost a 1000 of them. Thx.

gnu parallel shell snap bwa

1 answer

Yes, plenty but you should give some more details what you need. Given that your files end with _1.fastq.gz and _2.fastq.gz, you can do:

ls *_1.fastq.gz | awk -F "_1.fastq.gz" '{print $1}' | parallel "bwa mem idx.fa {}_1.fastq.gz {}_2.fastq.gz > out.sam"

Passing the -j parameter to parallel will allow to specifiy how many files are to be processed in parallel.

Or shorter: ls *_1.fastq.gz | parallel --plus "bwa mem idx.fa {} {%_1.fastq.gz}_2.fastq.gz > {%_1.fastq.gz}.sam"

Log in to answer this question.