alignment of multiple multifasta files- MAFFT command line
1
2
Entering edit mode
5.0 years ago
Wilber0x ▴ 50

I have a folder with around 100 multifasta files. I want to align each multifasta file inidividually using MAFFT. Each multifasta file ends with .unaligned.fasta I would like to change those file endings to aligned.fasta.

I have tried using MAFFT normally on the command line as so, with asterisks to allow for multiple characters where necessary:

mafft --quiet *.unaligned.fasta > *.aligned.fasta

However, I get error messages like this one

Unknown option:  beaverHb.unaligned.fasta

for all of my multifasta files.

How can I align all my multifasta files using MAFFT in the command line?

mafft alignment sequence • 8.6k views
ADD COMMENT
1
Entering edit mode

Some more general advice, this isn't a quirk of MAFFT, what you're trying to do with that command won't work more broadly.

The shell doesn't know what *.aligned.fasta means for example, so you need to help it out by building the filenames from variables etc (or use parallel's {.} syntax).

I'd advise doing some more reading about working with wildcards and loops in the shell as what you're going to do here is likely end up overwriting most if not all of your data at some point.

ADD REPLY
5
Entering edit mode
5.0 years ago
h.mon 35k

Simplest solution: use a for loop.

for i in *.unaligned.fasta
do
    mafft --quiet $i > ${i%.unaligned.fasta}.aligned.fasta
done

Be a bit fancier with GNU Parallel:

parallel -j 4 'mafft --quiet {} > {.}.aligned.fasta' ::: *.unaligned.fasta

This will run 4 simultaneous mafft alignments - be sure to have the cores and memory for the parallel tasks, though.

ADD COMMENT
3
Entering edit mode

If you are using (t)csh instead of bash:

foreach i ( *.unaligned.fasta )
mafft --quiet $i > $i:r:r.aligned.fasta
end
ADD REPLY

Login before adding your answer.

Traffic: 1032 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6