dendropy.dataobject.dataset – Primary Data Manager

class dendropy.dataobject.dataset.DataSet(*args, **kwargs)

The main data manager, consisting of a lists of taxa, trees, and character phylogenetic data objects, as well as methods to create, populate, access, and delete them.

__init__ takes a new DataSet object from another DataSet object or by parsing an input stream.

Can be invoked with:

  • a single unnamed argument that is an instance of a DataSet (which will result in a deep copy of all taxa, trees and characters),
  • 1 or more unnamed TaxonSet, TreeList or CharacterMatrix (which is like calling DataSet.add with each argument)
  • keyword arguments that supply a file-like object (stream) to be parsed and a string (schema) specifying the schema of the data in the file-like object.
add(data_object, **kwargs)

Generic add for TaxonSet, TreeList or CharacterMatrix objects.

add_char_matrix(char_matrix)

Accession of existing CharacterMatrix into chars of self.

add_taxon_set(taxon_set)

Adds an existing TaxonSet object to this DataSet.

add_tree_list(tree_list)

Accession of existing TreeList object into tree_lists of self.

attach_taxon_set(taxon_set=None)

Forces all read() calls on this DataSet to use the same TaxonSet. If taxon_set If taxon_set is None, then a new TaxonSet will be created, added to self.taxa, and that is the TaxonSet that will be attached.

description(depth=1, indent=0, itemize='', output=None)

Returns description of object, up to level depth.

get_default_taxon_set(**kwargs)

Returns an existing TaxonSet object in this DataSet, selected by keywords oid or label.

get_tree_list(**kwargs)

Returns a TreeList object specified by one (and exactly one) of the following keyword arguments:

  • label
  • oid

Raises KeyError if no matching TreeList is found, unless ignore_error is set to True.

new_char_matrix(char_matrix_type, *args, **kwargs)

Creation and accession of new CharacterMatrix (of class char_matrix_type) into chars of self.”

new_taxon_set(*args, **kwargs)

Creates a new TaxonSet object, according to the arguments given (passed to TaxonSet()), and adds it to this DataSet.

new_tree_list(*args, **kwargs)

Creation and accession of new TreeList into trees of self.

read(stream, schema, **kwargs)

Populates this DataSet object from a file-like object data source stream, formatted in schema. schema must be a recognized and supported phylogenetic data file schema. If reading is not implemented for the schema specified, then a UnsupportedSchemaError is raised.

The following optional keyword arguments are also recognized:

  • exclude_trees if True skips over tree data

  • exclude_chars if True skips over character data

  • encode_splits specifies whether or not split bitmasks will be

    calculated and attached to the edges.

  • finish_node_func is a function that will be applied to each node

    after it has been constructed.

The following keyword arguments are recognized when parsing NEXUS or NEWICK sources:

  • taxon_set TaxonSet object to use when reading data

  • as_rooted=True (or as_unrooted=False) interprets trees as rooted

  • as_unrooted=True (or as_rooted=False) interprets trees as rooted

  • default_as_rooted (or default_as_unrooted=False) interprets

    all trees as rooted if rooting not given by [&R] or [&U] comments

  • default_as_unrooted (or default_as_rooted=False) interprets

    all trees as rooted if rooting not given by [&R] or [&U] comments

  • edge_len_type specifies the type of the edge lengths (int or float)

Additional keyword arguments may be handled by various readers specialized to handle specific data formats.

unify_taxa(taxon_set=None, bind=True)

Reindices taxa across all subcomponents, mapping to single taxon set.

write(stream, schema, **kwargs)

Writes this DataSet object to the file-like object stream in schema. schema must be a recognized and supported phylogenetic data file schema. If writing is not implemented for the schema specified, then a UnsupportedSchemaError is raised.

The following optional keyword arguments are also recognized:

  • exclude_trees if True skips over tree data
  • exclude_chars if True skips over character data

Additional keyword arguments may be handled by various writers specialized to handle specific data formats.

Previous topic

dendropy.dataobject.tree – Tree Data

Next topic

dendropy.dataobject.char – Character Data

Documentation

Obtaining

AnnouncementsGoogle Groups

Join the "DendroPy Announcements" group to receive announcements of new releases, updates, changes and other news of interest to DendroPy users and developers.

Enter your e-mail address in the box above and click the "subscribe" button to subscribe to the "dendropy-announce" group, or click here to visit this group page directly.

DiscussionGoogle Groups

Join the "DendroPy Users" group to follow and participate in discussion, troubleshooting, help, information, suggestions, etc. on the usage and development of the DendroPy phylogenetic computing library.

Enter your e-mail address in the box above and click the "subscribe" button to subscribe to the "dendropy-users" group, or click here to visit this group page directly.