Split an interleaved nexus file into different gene alignments - Python
1
0
Entering edit mode
8.8 years ago
rafa.rios.50 ▴ 60

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!

python nexus nexus file Python • 3.1k views
ADD COMMENT
1
Entering edit mode
8.8 years ago
Brice Sarver ★ 3.8k

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)
ADD COMMENT

Login before adding your answer.

Traffic: 1850 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