Package Bio :: Package Phylo :: Module NexusIO
[hide private]
[frames] | no frames]

Module NexusIO

source code

I/O function wrappers for Bio.Nexus trees.
Functions [hide private]
 
parse(handle)
Parse the trees in a Nexus file.
source code
 
write(obj, handle, **kwargs)
Write a new Nexus file containing the given trees.
source code
Variables [hide private]
  NEX_TEMPLATE = '#NEXUS\nBegin Taxa;\n Dimensions NTax=%(count)...
  TREE_TEMPLATE = 'Tree tree%(index)d=[&U]%(tree)s;'
  __package__ = 'Bio.Phylo'
Function Details [hide private]

parse(handle)

source code 

Parse the trees in a Nexus file.

Uses the old Nexus.Trees parser to extract the trees, converts them back to plain Newick trees, and feeds those strings through the new Newick parser. This way we don't have to modify the Nexus module yet. (Perhaps we'll eventually change Nexus to use the new NewickIO parser directly.)

write(obj, handle, **kwargs)

source code 

Write a new Nexus file containing the given trees.

Uses a simple Nexus template and the NewickIO writer to serialize just the trees and minimal supporting info needed for a valid Nexus file.


Variables Details [hide private]

NEX_TEMPLATE

Value:
'''#NEXUS
Begin Taxa;
 Dimensions NTax=%(count)d;
 TaxLabels %(labels)s;
End;
Begin Trees;
 %(trees)s
End;
...