File: NeXML.py

package info (click to toggle)
python-biopython 1.73%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 57,852 kB
  • sloc: python: 169,977; xml: 97,539; ansic: 15,653; sql: 1,208; makefile: 159; sh: 63
file content (36 lines) | stat: -rw-r--r-- 1,314 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# Copyright (C) 2013 Ben Morris (ben@bendmorris.com)
# based on code by Eric Talevich (eric.talevich@gmail.com)
# This code is part of the Biopython distribution and governed by its
# license. Please see the LICENSE file that should have been included
# as part of this package.

"""Classes corresponding to NeXML trees.

See classes in `Bio.Nexus`: Trees.Tree, Trees.NodeData, and Nodes.Chain.
"""

from Bio.Phylo import BaseTree


class Tree(BaseTree.Tree):
    """NeXML Tree object."""

    def __init__(self, root=None, rooted=False, id=None, name=None, weight=1.0):
        """Instantiate a NeXML tree object with the given parameters."""
        BaseTree.Tree.__init__(self, root=root or Clade(),
                               rooted=rooted, id=id, name=name)
        self.weight = weight


class Clade(BaseTree.Clade):
    """NeXML Clade (sub-tree) object."""

    def __init__(self, branch_length=1.0, name=None, clades=None,
                 confidence=None, comment=None, **kwargs):
        """Initialize parameters for NeXML Clade object."""
        BaseTree.Clade.__init__(self, branch_length=branch_length,
                                name=name, clades=clades, confidence=confidence)
        self.comment = comment

        for key, value in kwargs.items():
            setattr(self, key, value)