Hi all,
I am trying to use the following code proposed in the Biopython wiki website to concatenate multiple Nexus files to create one data-matrix with partitions (charsets) at the end of the document.
from Bio.Nexus import Nexus
file_list = ['btCOI.nex', 'btCOII.nex', 'btITS.nex']
nexi = [(fname, Nexus.Nexus(fname)) for fname in file_list]
combined = Nexus.combine(nexi)
combined.write_nexus_data(filename=open('btCOMBINED.nex', 'w'))
It looks very simple and but I have two questions, regarding two errors, concerning this script:
It seems to work pretty fine with my files but the script does not create the partitions at the end of the document. Why? I tried to search something online but finding zero.
2) I premise that my files are identical (not for length) to the one proposed in the biopython page. However if their code works with my nexus files (not completely, see question n°1) when I try using their files, the combined output is totally empty. Why does this happens?
Could these two errors be related to a modified version of my Biopython? Mine version is 1.76, the last released. Could it be too 'new' respect to the Nexus module proposed?
Thank you very much for your help.
P.S.
Please do not advise me to use other tool for the nexus file concatenation, I know them and I generally use them but I just want to try to compile something smarter and faster. Thanks
EDIT: Here there are my datasets (scaled down) plus the output obtained (which is lacking the charset block at the end).
Gene N°1
#NEXUS
begin data;
dimensions ntax=31 nchar=1490;
format datatype=dna missing=? gap=- interleave;
matrix
Trigoniophthalmus_alternatus ATTGGTACTCTCTACCTAATCTTTGGTATTTGAGCGGGACTAATTGGAACCTCATTAAGAGTTTTAATTC
Songmachilis_xinxiangensis ATTGGAACATTATATTTAATTTTTGGAGTATGAGCAGGATTAGTAGGAACATCTTTAAGTGTTTTAATTC
Atelura_formicaria ATTGGCACCCTATACCTTATATTTGGTGCGTGAAGCGGAATGGTTGGCACCTCTCTAAGAATTTTAATTC
Pedetontinus_luanchuanensis ATTGGAACATTATATTTAATTTTCGGTGTCTGGGCAGGCCTGATTGGCACATCCTTAAGAATTTTAATTC
Gene n°2
#NEXUS
begin data;
dimensions ntax=31 nchar=1490;
format datatype=dna missing=? gap=- interleave;
matrix
Trigoniophthalmus_alternatus ATTGGTACTCTCTACCTAATCTTTGGTATTTGAGCGGGACTAATTGGAACCTCATTAAGAGTTTTAATTC
Songmachilis_xinxiangensis ATTGGAACATTATATTTAATTTTTGGAGTATGAGCAGGATTAGTAGGAACATCTTTAAGTGTTTTAATTC
Atelura_formicaria ATTGGCACCCTATACCTTATATTTGGTGCGTGAAGCGGAATGGTTGGCACCTCTCTAAGAATTTTAATTC
Pedetontinus_luanchuanensis ATTGGAACATTATATTTAATTTTCGGTGTCTGGGCAGGCCTGATTGGCACATCCTTAAGAATTTTAATTC
Combined output obtained (cut to
#NEXUS
begin data;
dimensions ntax=31 nchar=2156;
format datatype=dna missing=? gap=-;
matrix
Trigoniophthalmus_alternatus ATGTCAACATGAAACCAATTAGGACTTCAAGATAGTGCCTCCCCCCTAATAGAACAATTAATTTTCTTCCACGATCACACTATTCTAATTATCATTCTAGTCACAACCCTAGTAGGCTA
Songmachilis_xinxiangensis ATGGCAACATGAAGTCAATTAGGTTTACAAGATGGTGCATCACCTTTAATAGAACAATTAATTTTTTTCCATGATCACACTATCCTTATCATCATTATAGTTACAACTTTAGTTGGCTATA
Atelura_formicaria ATGTCAACATGGTCCCACCTCAATACACTCAATGCCTCCTCCCCACTAATAGAACAACTAATCTTCTTCCACGACCACACACTCATAATTCTTTTAATAATCACTATTTTAGTGAGATAT
Pedetontinus_luanchuanensis ATGGCAACATGAGCTCAATTAGGTTTACAGGACGCTGCTTCCCCTCTAATAGAACAATTAATTTTTTTTCATGATCATACTATTTTAATTATTATTTTAGTTACAACTCTAGTTGGATATA
My guess is you're running up against a similar issue as outlined here?: BioPython write combined nexus files
It could be..I cannot understand why some nexus file are processed (mine ones) and not the one provided in the Biopython page....
In both cases you are getting no output, correct? So your premise that it is working with your files and not theirs doesn't hold water..
No, wait. Mine ones are processed even though they have the same structure of the ones provided in the Biopython website. In order to clarify the mess, i'm gonna edit the post adding a short view of my data set.
I checked also my biopython version (1.76) and I uninstalled and reinstalled the older one (1.74) but anything happened......Still I have the concatenation nexus of my files but I lack of charsets. Moreover, I still do not have an output using the nexus files proposed in the biopython website
I think the best option for this is to open an issue on the Biopython github repository. It seems to be cropping up more than once so could be a legitimate bug somewhere, but I can't reproduce it.