This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Converting multiple files from Clustal to MEGA format

Hi,

I have ~2000 alignments of a few MB each in Clustal format. I intend to use MEGA (megacc) to calculate pairwise distances for each of these alignments. However, I cannot give the alignment files directly to MEGA without converting them to the .meg format.

Since I have so many files, it is unfeasible to open each and single one in the MEGA GUI and save them as .meg.

Is there any way of calling this function from the command line? Alternatively, is there some other software that can convert clustal (or fasta) to MEGA?

Thanks for your help!

alignment clustalw mega

is there some other software that can convert clustal (or fasta) to MEGA?

Since the MEGA format is probably used only by MEGA you are not likely to find and other software that will do that conversion.

I have not used MEGA on the command line but perhaps there are utils in the command line version of MEGA that can do this.

1 answer

If megacc can't do the conversion you want, I can't think of any other program that would be able to do it.

If you don't mind re-aligning from the scratch, Clustal Omega can do what you want. It is multi-threaded, so it may not take much longer than actually converting the files you already have. It is one of the best multiple aligners out there, so it is possible that it would also improve the alignments you have.

clustalo -i my-in-seqs.fa -o my-out-seqs.aln -v --outfmt=clu --distmat-out=my-out-seqs.dist --threads=20

Thanks for the Clustal Omega tip! However, it calculates the distance with a very simple metric, while I needed MEGA precisely for the K2P-based distance. For anyone else with similar issues, I found an R library that calculates the K2P distance from a DNA alignment in FASTA format:

library(ape)
aln <- read.FASTA("seq.aln")
dist <- dist.dna(aln, model = "k80", as.matrix = TRUE, pairwise.deletion = T)

The output is the same as I get from MEGA with no need to convert to their format.

Log in to answer this question.