This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to adapt a for loop of `muscle` alignments using GNU Parallel?

I'm trying to adapt the following lines of code for use with GNU parallel:

for ID in $(cut -f1 markers.tsv);
    do echo $ID;
    FAA=${ID}.faa.gz
    zcat ${FAA} | muscle -out ${ID}.msa
    done

However, the examples I'm seeing here do not show where I can use my ${ID} argument.

Can someone help me adapt this using --jobs 16?

This could be one a one liner:

for ID in $(cut -f1 markers.tsv);
    do echo $ID && FAA=${ID}.faa.gz && zcat ${FAA} | muscle -out ${ID}.msa
    done

Preferably without an intermediate script

alignment bash parallel

2 answers

cut -f1 markers.tsv | parallel --jobs 16 'zcat {}.faa.gz | muscle -out {}.msa'

How about something like this:

    cut -f1 markers.tsv | parallel --jobs 16 'zcat {1}.faa.gz | muscle -out {1}.msa'

If you want to test how the parallel commands will look, add --dry-run for example:

    cut -f1 markers.tsv | parallel --dry-run --jobs 16 'zcat {1}.faa.gz | muscle -out {1}.msa'

@OP: Cut may not be necessary here. Try:

$ parallel --dry-run --colsep '\t'   'zcat {1}.faa.gz | muscle -out {1}.msa' :::: markers.tsv

you can also try:

$ parallel --dry-run --colsep '\t'  ' muscle < zcat {1}.faa.gz > {1}.msa' :::: markers.tsv

Log in to answer this question.