I have an interleaved Nexus file, were each block correspond to a gene in the alignment.
How could I split that file into separate alignments, one for each of those genes.
I have tried using the AlignIO module from biopython, but it just load the whole alignment as one big sequence for each taxa without any clear way to iterate through the genes (blocks) or interleaves of the alignment.
Do you know if there is a way to iterate over the blocks in the nexus file with Biopython? I could not find anything related on the Biopython documentation.
Thanks!
1 answer
The easiest way to do this is to export the interleaved file as a sequential one. Lots of tools will do this (PAUP*, EMBOSS, etc.).
I don't have an example to test, but read.nexus.data() in ape in R might be able to read it in. If so, it's easy to write it out:
library(ape)
a <- read.nexus.data("yourfile.nex")
write.nexus.data(a, "yourfile.sequential.nex", interleaved=FALSE)
Log in to answer this question.