biopython v1.71.0 Bio.Nexus.Nexus.Nexus
Initialize the class.
Link to this section Summary
Functions
Adjusts character sets if gaps are inserted, taking care of new gaps within a coherent character set
Return adjusted indices of self.charlabels if characters are excluded or inserted
Applies Block structure to the NEXUS file (PRIVATE)
Get labels for characters
Collects character partition from NEXUS file (PRIVATE)
Creates unique character set (PRIVATE)
Check for presence of taxon in self.taxlabels
Read codon positions from a codons block as written from McClade
Parse the taxset/charset specification (PRIVATE)
Generator for looping through Nexus blocks
Creates a matrix for NEXUS object (PRIVATE)
Extract name and check that it’s not in vector format
Parse a NEXUS list (PRIVATE)
Parse a known Nexus Block (PRIVATE)
Translate identifier in list into character/taxon index
Get taxon labels (PRIVATE)
Collects taxpartition from a NEXUS file (PRIVATE)
Creates unique taxset (PRIVATE)
Translates a Nexus file (PRIVATE)
Some software (clustalx) uses ‘utree’ to denote an unrooted tree
Adds a sequence (string) to the matrix
Returns a sets block
Return a bootstrapped matrix
Return a list with all constant characters
Return a matrix without deleted taxa and excluded characters
Summarize character
Writes matrix into a fasta file
Writes matrix into a PHYLIP file
Return gap-only sites
Included for backwards compatibility (DEPRECATED)
Add a gap into the matrix and adjust charsets and partitions
Returns all character indices that are not in charlist
Read and parse NEXUS input (a filename, file-handle, or string)
Included for backwards compatibility (DEPRECATED)
Replaces all terminal gaps with missing character
Calculates a stepmatrix for weighted parsimony
Writes a nexus file with data and sets block to a file or handle
Writes a nexus file for each partition in charpartition
Link to this section Functions
Adjusts character sets if gaps are inserted, taking care of new gaps within a coherent character set.
Return adjusted indices of self.charlabels if characters are excluded or inserted.
Applies Block structure to the NEXUS file (PRIVATE).
Get labels for characters.
Collects character partition from NEXUS file (PRIVATE).
Creates unique character set (PRIVATE).
Check for presence of taxon in self.taxlabels.
Read codon positions from a codons block as written from McClade.
Here codonposset is just a fancy name for a character partition with the name CodonPositions and the partitions N,1,2,3
Parse the taxset/charset specification (PRIVATE).
e.g. ‘1 2 3 - 5 dog cat 10 - 20 \ 3’ —> [0,1,2,3,4,’dog’,’cat’,9,12,15,18]
Generator for looping through Nexus blocks.
Creates a matrix for NEXUS object (PRIVATE).
Extract name and check that it’s not in vector format.
Parse a NEXUS list (PRIVATE).
e.g. [1, 2, 4-8\2, dog, cat] —> [1,2,4,6,8,17,21], (assuming dog is taxon no. 17 and cat is taxon no. 21).
Parse a known Nexus Block (PRIVATE).
Translate identifier in list into character/taxon index.
Characters (which are referred to by their index in Nexus.py):
Plain numbers are returned minus 1 (Nexus indices to python indices)
Text identifiers are translated into their indices (if plain character identifiers),
the first hit in charlabels is returned (charlabels don't need to be unique)
or the range of indices is returned (if names of character sets).
Taxa (which are referred to by their unique name in Nexus.py):
Plain numbers are translated in their taxon name, underscores and spaces are considered equal.
Names are returned unchanged (if plain taxon identifiers), or the names in
the corresponding taxon set is returned.
Get taxon labels (PRIVATE).
As the taxon names are already in the matrix, this is superfluous except for transpose matrices, which are currently unsupported anyway. Thus, we ignore the taxlabels command to make handling of duplicate taxon names easier.
Collects taxpartition from a NEXUS file (PRIVATE).
Creates unique taxset (PRIVATE).
Translates a Nexus file (PRIVATE).
Some software (clustalx) uses ‘utree’ to denote an unrooted tree.
Adds a sequence (string) to the matrix.
Returns a sets block.
Return a bootstrapped matrix.
Return a list with all constant characters.
Return a matrix without deleted taxa and excluded characters.
Summarize character.
narrow=True: paup-mode (a c ? —> ac; ? ? ? —> ?) narrow=false: (a c ? —> a c g t -; ? ? ? —> a c g t -)
Writes matrix into a fasta file.
Writes matrix into a PHYLIP file.
Note that this writes a relaxed PHYLIP format file, where the names are not truncated, nor checked for invalid characters.
Return gap-only sites.
Included for backwards compatibility (DEPRECATED).
Add a gap into the matrix and adjust charsets and partitions.
pos=0: first position pos=nchar: last position
Returns all character indices that are not in charlist.
Read and parse NEXUS input (a filename, file-handle, or string).
Included for backwards compatibility (DEPRECATED).
Replaces all terminal gaps with missing character.
Mixtures like ???———??———- are properly resolved.
Calculates a stepmatrix for weighted parsimony.
See Wheeler (1990), Cladistics 6:269-275 and Felsenstein (1981), Biol. J. Linn. Soc. 16:183-196
Writes a nexus file with data and sets block to a file or handle.
Character sets and partitions are appended by default, and are adjusted according to excluded characters (i.e. character sets still point to the same sites (not necessarily same positions), without including the deleted characters.
- filename - Either a filename as a string (which will be opened, written to and closed), or a handle object (which will be written to but NOT closed).
- interleave_by_partition - Optional name of partition (string)
- omit_NEXUS - Boolean. If true, the ‘ start of the file is omitted.
Returns the filename/handle used to write the data.
Writes a nexus file for each partition in charpartition.
Only non-excluded characters and non-deleted taxa are included, just the data block is written.