Package Bio :: Package Nexus :: Module Nexus :: Class Nexus
[hide private]
[frames] | no frames]

Class Nexus

source code

object --+
         |
        Nexus

Instance Methods [hide private]
 
__init__(self, input=None)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
get_original_taxon_order(self)
Included for backwards compatibility (DEPRECATED).
source code
 
set_original_taxon_order(self, value)
Included for backwards compatibility (DEPRECATED).
source code
 
read(self, input)
Read and parse NEXUS input (a filename, file-handle, or string).
source code
 
_get_nexus_block(self, file_contents)
Generator for looping through Nexus blocks.
source code
 
_unknown_nexus_block(self, title, contents) source code
 
_parse_nexus_block(self, title, contents)
Parse a known Nexus Block (PRIVATE).
source code
 
_title(self, options) source code
 
_link(self, options) source code
 
_dimensions(self, options) source code
 
_format(self, options) source code
 
_set(self, options) source code
 
_options(self, options) source code
 
_eliminate(self, options) source code
 
_taxlabels(self, options)
Get taxon labels (PRIVATE).
source code
 
_check_taxlabels(self, taxon)
Check for presence of taxon in self.taxlabels.
source code
 
_charlabels(self, options) source code
 
_charstatelabels(self, options) source code
 
_statelabels(self, options) source code
 
_matrix(self, options) source code
 
_translate(self, options) source code
 
_utree(self, options)
Some software (clustalx) uses 'utree' to denote an unrooted tree.
source code
 
_tree(self, options) source code
 
_apply_block_structure(self, title, lines) source code
 
_taxset(self, options) source code
 
_charset(self, options) source code
 
_taxpartition(self, options) source code
 
_codonposset(self, options)
Read codon positions from a codons block as written from McClade.
source code
 
_codeset(self, options) source code
 
_charpartition(self, options) source code
 
_get_indices(self, options, set_type='chars', separator='=')
Parse the taxset/charset specification (PRIVATE).
source code
 
_name_n_vector(self, opts, separator='=')
Extract name and check that it's not in vector format.
source code
 
_parse_list(self, options_buffer, set_type)
Parse a NEXUS list (PRIVATE).
source code
 
_resolve(self, identifier, set_type=None)
Translate identifier in list into character/taxon index.
source code
 
_stateset(self, options) source code
 
_changeset(self, options) source code
 
_treeset(self, options) source code
 
_treepartition(self, options) source code
 
write_nexus_data_partitions(self, matrix=None, filename=None, blocksize=None, interleave=False, exclude=[], delete=[], charpartition=None, comment='', mrbayes=False)
Writes a nexus file for each partition in charpartition.
source code
 
write_nexus_data(self, filename=None, matrix=None, exclude=[], delete=[], blocksize=None, interleave=False, interleave_by_partition=False, comment=None, omit_NEXUS=False, append_sets=True, mrbayes=False, codons_block=True)
Writes a nexus file with data and sets block to a file or handle.
source code
 
append_sets(self, exclude=[], delete=[], mrbayes=False, include_codons=True, codons_only=False)
Returns a sets block.
source code
 
export_fasta(self, filename=None, width=70)
Writes matrix into a fasta file.
source code
 
export_phylip(self, filename=None)
Writes matrix into a PHYLIP file.
source code
 
constant(self, matrix=None, delete=[], exclude=[])
Return a list with all constant characters.
source code
 
cstatus(self, site, delete=[], narrow=True)
Summarize character.
source code
 
weighted_stepmatrix(self, name='your_name_here', exclude=[], delete=[])
Calculates a stepmatrix for weighted parsimony.
source code
 
crop_matrix(self, matrix=None, delete=[], exclude=[])
Return a matrix without deleted taxa and excluded characters.
source code
 
bootstrap(self, matrix=None, delete=[], exclude=[])
Return a bootstrapped matrix.
source code
 
add_sequence(self, name, sequence)
Adds a sequence (string) to the matrix.
source code
 
insert_gap(self, pos, n=1, leftgreedy=False)
Add a gap into the matrix and adjust charsets and partitions.
source code
 
_adjust_charlabels(self, exclude=None, insert=None)
Return adjusted indices of self.charlabels if characters are excluded or inserted.
source code
 
invert(self, charlist)
Returns all character indices that are not in charlist.
source code
 
gaponly(self, include_missing=False)
Return gap-only sites.
source code
 
terminal_gap_to_missing(self, missing=None, skip_n=True)
Replaces all terminal gaps with missing character.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]
  original_taxon_order
Included for backwards compatibility (DEPRECATED).

Inherited from object: __class__

Method Details [hide private]

__init__(self, input=None)
(Constructor)

source code 
x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

_taxlabels(self, options)

source code 
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.

_codonposset(self, options)

source code 
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

_get_indices(self, options, set_type='chars', separator='=')

source code 
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]

_parse_list(self, options_buffer, set_type)

source code 
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).

_resolve(self, identifier, set_type=None)

source code 
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.

write_nexus_data_partitions(self, matrix=None, filename=None, blocksize=None, interleave=False, exclude=[], delete=[], charpartition=None, comment='', mrbayes=False)

source code 
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.

write_nexus_data(self, filename=None, matrix=None, exclude=[], delete=[], blocksize=None, interleave=False, interleave_by_partition=False, comment=None, omit_NEXUS=False, append_sets=True, mrbayes=False, codons_block=True)

source code 
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 '#NEXUS' line normally at the
           start of the file is omitted.

Returns the filename/handle used to write the data.

export_phylip(self, filename=None)

source code 
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.

cstatus(self, site, delete=[], narrow=True)

source code 
Summarize character.

narrow=True:  paup-mode (a c ? --> ac; ? ? ? --> ?)
narrow=false:           (a c ? --> a c g t -; ? ? ? --> a c g t -)

weighted_stepmatrix(self, name='your_name_here', exclude=[], delete=[])

source code 
Calculates a stepmatrix for weighted parsimony.

See Wheeler (1990), Cladistics 6:269-275 and
Felsenstein (1981), Biol. J. Linn. Soc. 16:183-196

insert_gap(self, pos, n=1, leftgreedy=False)

source code 
Add a gap into the matrix and adjust charsets and partitions.

pos=0: first position
pos=nchar: last position

terminal_gap_to_missing(self, missing=None, skip_n=True)

source code 
Replaces all terminal gaps with missing character.

Mixtures like ???------??------- are properly resolved.


Property Details [hide private]

original_taxon_order

Included for backwards compatibility (DEPRECATED).

Get Method:
get_original_taxon_order(self) - Included for backwards compatibility (DEPRECATED).
Set Method:
set_original_taxon_order(self, value) - Included for backwards compatibility (DEPRECATED).