Skip to content

Commits on Source 8

Release 4.3.0
-------------
- [SumTrees]: Important bugfix in tracking splits on consensus tree from rooted trees: previously it was possible for a split on the consensus tree to be ignored, resulting in a null (0) edge length and no (0.0) support.
- Added ``sumlabels.py`` application.
- BD tree (``dendropy.model.birth_death_tree``) now allows for preservation of extinct tips.
- Improved performance of character subset export
Release 4.2.0
-------------
......
Metadata-Version: 1.1
Name: DendroPy
Version: 4.2.0
Version: 4.3.0
Summary: A Python library for phylogenetics and phylogenetic computing: reading, writing, simulation, processing and manipulation of phylogenetic trees (phylogenies) and characters.
Home-page: http://packages.python.org/DendroPy/
Author: Jeet Sukumaran and Mark T. Holder
......@@ -115,7 +115,7 @@ Description: .. image:: https://raw.githubusercontent.com/jeetsukumaran/DendroPy
Current Release
===============
The current release of DendroPy is version 4.2.0 (master-5051a46, 2016-12-28 13:25:19).
The current release of DendroPy is version 4.3.0 (master-e251bcf, 2017-07-06 21:23:19).
Keywords: phylogenetics phylogeny phylogenies phylogeography evolution evolutionary biology systematics coalescent population genetics phyloinformatics bioinformatics
......@@ -131,5 +131,7 @@ Classifier: Programming Language :: Python :: 3.1
Classifier: Programming Language :: Python :: 3.2
Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
......@@ -11,6 +11,7 @@ DendroPy.egg-info/entry_points.txt
DendroPy.egg-info/requires.txt
DendroPy.egg-info/top_level.txt
DendroPy.egg-info/zip-safe
applications/sumlabels/sumlabels.py
applications/sumtrees/sumtrees.py
dendropy/__init__.py
dendropy/__main__.py
......@@ -63,6 +64,7 @@ dendropy/interop/genbank.py
dendropy/interop/muscle.py
dendropy/interop/paup.py
dendropy/interop/raxml.py
dendropy/interop/rspr.py
dendropy/interop/rstats.py
dendropy/interop/seqgen.py
dendropy/legacy/__init__.py
......
Metadata-Version: 1.1
Name: DendroPy
Version: 4.2.0
Version: 4.3.0
Summary: A Python library for phylogenetics and phylogenetic computing: reading, writing, simulation, processing and manipulation of phylogenetic trees (phylogenies) and characters.
Home-page: http://packages.python.org/DendroPy/
Author: Jeet Sukumaran and Mark T. Holder
......@@ -115,7 +115,7 @@ Description: .. image:: https://raw.githubusercontent.com/jeetsukumaran/DendroPy
Current Release
===============
The current release of DendroPy is version 4.2.0 (master-5051a46, 2016-12-28 13:25:19).
The current release of DendroPy is version 4.3.0 (master-e251bcf, 2017-07-06 21:23:19).
Keywords: phylogenetics phylogeny phylogenies phylogeography evolution evolutionary biology systematics coalescent population genetics phyloinformatics bioinformatics
......@@ -131,5 +131,7 @@ Classifier: Programming Language :: Python :: 3.1
Classifier: Programming Language :: Python :: 3.2
Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
#! /usr/bin/env python
##############################################################################
## DendroPy Phylogenetic Computing Library.
##
## Copyright 2010 Jeet Sukumaran and Mark T. Holder.
## All rights reserved.
##
## See "LICENSE.txt" for terms and conditions of usage.
##
## If you use this work or any portion thereof in published work,
## please cite it as:
##
## Sukumaran, J. and M. T. Holder. 2010. DendroPy: a Python library
## for phylogenetic computing. Bioinformatics 26: 1569-1571.
##
##############################################################################
"""
Marge labels of splits/branches from different input trees onto corresponding
splits/branches of a single tree.
"""
import os
import sys
import argparse
import datetime
import time
import socket
try:
import getpass
except:
pass
import platform
import dendropy
from dendropy.utility.messaging import ConsoleMessenger
from dendropy.utility.cli import confirm_overwrite, show_splash
_program_name = "SumLabels"
_program_subtitle = "Phylogenetic Tree Label Concatenation"
_program_date = "Jan 20 2017"
_program_version = "Version 2.0.0 (%s)" % _program_date
_program_author = "Jeet Sukumaran"
_program_contact = "jeetsukumaran@gmail.com"
_program_copyright = "Copyright (C) 2017 Jeet Sukumaran.\n" \
"License GPLv3+: GNU GPL version 3 or later.\n" \
"This is free software: you are free to change\nand redistribute it. " \
"There is NO WARRANTY,\nto the extent permitted by law."
def main_cli():
description = "%s %s %s" % (_program_name, _program_version, _program_subtitle)
parser = argparse.ArgumentParser(version =_program_version, description=description)
parser.add_argument(
"sources",
metavar="TREEFILE",
nargs="+")
parser.add_argument("-t","--target",
dest="target_tree_filepath",
default=None,
help="path to file with tree (Newick or NEXUS format) "
+ "to which labels will be written")
parser.add_argument("--preserve-target-labels",
action="store_true",
dest="preserve_target_labels",
default=False,
help="keep any existing labels on target tree (by default, these will be cleared before writing the new labels)")
parser.add_argument("--rooted",
action="store_true",
dest="rooted_trees",
default=None,
help="treat trees as rooted")
parser.add_argument("--unrooted",
action="store_false",
dest="rooted_trees",
default=None,
help="treat trees as unrooted")
parser.add_argument("--ignore-missing-source",
action="store_true",
dest="ignore_missing_source",
default=False,
help="ignore missing source tree files (at least one must exist!)")
parser.add_argument("-o","--output",
dest="output_filepath",
default=None,
help="path to output file (if not given, will print to standard output)")
parser.add_argument("-s","--separator",
dest="separator",
default="/",
help="string to use to separate labels from different source trees (default='%(default)s')")
parser.add_argument("--no-taxa-block",
action="store_false",
dest="include_taxa_block",
default=True,
help="do not include a taxa block in the output treefile (otherwise will create taxa block by default)")
parser.add_argument("-c", "--additional-comments",
action="store",
dest="additional_comments",
default=None,
help="additional comments to be added to the summary file")
parser.add_argument("--to-newick",
action="store_true",
dest="to_newick_format",
default=False,
help="save results in NEWICK (PHYLIP) format (default is to save in NEXUS format)")
parser.add_argument("--to-phylip",
action="store_true",
dest="to_newick_format",
default=False,
help="same as --to-newick")
parser.add_argument("-r", "--replace",
action="store_true",
dest="replace",
default=False,
help="replace/overwrite output file without asking if it already exists ")
parser.add_argument("-q", "--quiet",
action="store_true",
dest="quiet",
default=False,
help="suppress ALL logging, progress and feedback messages")
args = parser.parse_args()
if args.quiet:
messaging_level = ConsoleMessenger.ERROR_MESSAGING_LEVEL
else:
messaging_level = ConsoleMessenger.INFO_MESSAGING_LEVEL
messenger = ConsoleMessenger(name="SumLabels", messaging_level=messaging_level)
# splash
if not args.quiet:
show_splash(prog_name=_program_name,
prog_subtitle=_program_subtitle,
prog_version=_program_version,
prog_author=_program_author,
prog_copyright=_program_copyright,
dest=sys.stderr,
)
###################################################
# Source file idiot checking
source_filepaths = []
if len(args.sources) > 0:
for fpath in args.sources:
fpath = os.path.expanduser(os.path.expandvars(fpath))
if not os.path.exists(fpath):
if args.ignore_missing_source:
messenger.send_warning("Source file not found: '%s'" % fpath)
else:
messenger.error("Terminating due to missing source files. "
+ "Use the '--ignore-missing-source' option to continue even "
+ "if some files are missing.")
sys.exit(1)
else:
source_filepaths.append(fpath)
if len(source_filepaths) == 0:
messenger.error("No valid sources of input trees specified. "
+ "Please provide the path to at least one (valid and existing) file "
+ "containing trees")
sys.exit(1)
else:
messenger.info("No sources of input trees specified. "
+ "Please provide the path to at least one (valid and existing) file "
+ "containing tree samples to summarize. See '--help' for other options.")
sys.exit(1)
###################################################
# Lots of other idiot-checking ...
# target tree
if args.target_tree_filepath is not None:
target_tree_filepath = os.path.expanduser(os.path.expandvars(args.target_tree_filepath))
if not os.path.exists(target_tree_filepath):
messenger.error("Target tree file not found: '%s'" % target_tree_filepath)
sys.exit(1)
else:
messenger.error("Target tree file not specified: use the '-t' or '--target' option to provide path to target tree")
sys.exit(1)
# output
if args.output_filepath is None:
output_dest = sys.stdout
else:
output_fpath = os.path.expanduser(os.path.expandvars(args.output_filepath))
if confirm_overwrite(filepath=output_fpath, replace_without_asking=args.replace):
output_dest = open(output_fpath, "w")
else:
sys.exit(1)
# taxon set to handle target trees
master_taxon_namespace = dendropy.TaxonNamespace()
is_rooted = args.rooted_trees
messenger.info("Reading target tree: '%s'" % target_tree_filepath)
target_tree = None
if is_rooted:
rooting = "force-rooted"
else:
rooting = None
for tree in dendropy.Tree.yield_from_files(
[target_tree_filepath, "rU",],
schema='nexus/newick',
taxon_namespace=master_taxon_namespace,
rooting=rooting):
target_tree = tree
break
bipartition_labels = {}
for src_fpath in source_filepaths:
messenger.info("Reading source tree(s) from: '%s'" % src_fpath)
for tree in dendropy.Tree.yield_from_files(
[src_fpath,],
schema='nexus/newick',
taxon_namespace=master_taxon_namespace,
rooting=rooting):
tree.encode_bipartitions()
for bipartition, edge in tree.bipartition_edge_map.items():
label = edge.head_node.label
if not label:
continue
try:
bipartition_labels[bipartition].append(label)
except KeyError:
bipartition_labels[bipartition] = [label]
messenger.info("Mapping labels")
target_tree.encode_bipartitions()
for bipartition, edge in target_tree.bipartition_edge_map.items():
label = []
if args.preserve_target_labels and edge.head_node.label:
label.append(edge.head_node.label)
elif not args.preserve_target_labels:
edge.head_node.label = None
if bipartition in bipartition_labels:
label.extend(bipartition_labels[bipartition])
else:
pass
# messenger.send_warning("Split on target tree not found in source trees: ignoring")
if label:
edge.head_node.label = args.separator.join(label)
output_dataset = dendropy.DataSet()
tree_list = output_dataset.new_tree_list(taxon_namespace=master_taxon_namespace)
tree_list.append(target_tree)
if args.to_newick_format:
output_dataset.write(
file=output_dest,
schema="newick",
suppress_rooting=False,
suppress_edge_lengths=False,
unquoted_underscores=False,
preserve_spaces=False,
store_tree_weights=False,
suppress_annotations=False,
annotations_as_nhx=False,
suppress_item_comments=False,
suppress_leaf_taxon_labels=False,
suppress_leaf_node_labels=True,
suppress_internal_taxon_labels=False,
suppress_internal_node_labels=False,
node_label_element_separator=' ',
)
else:
if args.include_taxa_block:
simple = False
else:
simple = True
comment = []
try:
username = getpass.getuser()
except:
username = "a user"
comment.append("%s %s by %s." % (_program_name, _program_version, _program_author))
comment.append("Using DendroPy Version %s by Jeet Sukumaran and Mark T. Holder."
% dendropy.__version__)
python_version = sys.version.replace("\n", "").replace("[", "(").replace("]",")")
comment.append("Running under Python %s on %s." % (python_version, sys.platform))
comment.append("Executed on %s by %s@%s." % (platform.node(), username, socket.gethostname()))
if args.additional_comments:
comment.append("\n")
comment.append(args.additional_comments)
output_dataset.write(
file=output_dest,
schema="nexus",
simple=simple,
file_comments=comment,
suppress_rooting=False,
unquoted_underscores=False,
preserve_spaces=False,
store_tree_weights=False,
suppress_annotations=False,
annotations_as_nhx=False,
suppress_item_comments=False,
suppress_leaf_taxon_labels=False,
suppress_leaf_node_labels=True,
suppress_internal_taxon_labels=False,
suppress_internal_node_labels=False,
node_label_element_separator=' ',
)
if not args.output_filepath:
pass
else:
messenger.info("Results written to: '%s'." % (output_fpath))
if __name__ == '__main__':
main_cli()
......@@ -1659,6 +1659,7 @@ def main():
else:
raise ValueError(args.summary_target)
_message_and_log(msg, wrap=True)
tree.encode_bipartitions()
target_trees.append(tree)
else:
try:
......
python-dendropy (4.3.0+dfsg-1) unstable; urgency=medium
* New upstream version
* Standards-Version: 4.1.3
* debhelper 11
* d/rules: do not parse d/changelog
* Testsuite: autopkgtest-pkg-python
-- Andreas Tille <tille@debian.org> Mon, 19 Feb 2018 09:31:21 +0100
python-dendropy (4.2.0+dfsg-1) unstable; urgency=medium
* New upstream version
......
......@@ -2,14 +2,15 @@ Source: python-dendropy
Maintainer: Debian Med Packaging Team <debian-med-packaging@lists.alioth.debian.org>
Uploaders: Andreas Tille <tille@debian.org>
Section: python
Testsuite: autopkgtest-pkg-python
Priority: optional
Build-Depends: debhelper (>= 10),
Build-Depends: debhelper (>= 11~),
dh-python,
python-all,
python-setuptools,
python3-all,
python3-setuptools
Standards-Version: 3.9.8
Standards-Version: 4.1.3
Vcs-Browser: https://anonscm.debian.org/cgit/debian-med/python-dendropy.git
Vcs-Git: https://anonscm.debian.org/git/debian-med/python-dendropy.git
Homepage: http://dendropy.org/
......
......@@ -9,7 +9,7 @@ Subject: [PATCH] Fix bug where encoding for default locale is None.
--- a/dendropy/utility/textprocessing.py
+++ b/dendropy/utility/textprocessing.py
@@ -42,6 +42,9 @@ ENCODING = locale.getdefaultlocale()[1]
@@ -45,6 +45,9 @@ except ValueError:
if ENCODING == None:
ENCODING = 'UTF-8'
......
......@@ -2,9 +2,6 @@
DH_VERBOSE := 1
DEBPKGNAME:=$(shell dpkg-parsechangelog | awk '/^Source:/ {print $$2}')
docpkg:=$(DEBPKGNAME)-doc
SUMTREES:=sumtrees
export PYBUILD_NAME=dendropy
......
......@@ -104,7 +104,7 @@ import collections
version_info = collections.namedtuple("dendropy_version_info",
["major", "minor", "micro", "releaselevel"])(
major=4,
minor=2,
minor=3,
micro=0,
releaselevel=""
)
......
......@@ -303,7 +303,8 @@ class NewickReader(ioservice.DataReader):
taxon_symbol_map_fn=taxon_symbol_mapper.require_taxon_for_symbol)
yield tree
if tree is None:
raise StopIteration
# raise StopIteration
return
def _read(self,
stream,
......
......@@ -178,7 +178,7 @@ class NexusWriter(ioservice.DataWriter):
# and need to be removed so as not to cause problems with our keyword
# validation scheme
self.simple = kwargs.pop("simple", False)
self.suppress_taxa_blocks = kwargs.pop("suppress_taxa_block", None)
self.suppress_taxa_blocks = kwargs.pop("suppress_taxa_blocks", None)
self.suppress_block_titles = kwargs.pop("suppress_block_titles", None)
self.file_comments = kwargs.pop("file_comments", [])
if self.file_comments is None:
......
......@@ -1606,7 +1606,7 @@ class CharacterMatrix(
# recalculated, which will require some careful and perhaps arbitrary
# handling of corner cases
clone.character_subsets = container.OrderedCaselessDict()
# clone.clone_from(self)
indices = set(indices)
for vec in clone.values():
for cell_idx in range(len(vec)-1, -1, -1):
if cell_idx not in indices:
......
......@@ -548,6 +548,7 @@ class TaxonNamespace(
raise TypeError("TaxonNamespace() takes at most 1 non-keyword argument ({} given)".format(len(args)))
elif len(args) == 1:
# special case: construct from argument
basemodel.DataObject.__init__(self, label=kwargs_set_label)
other = args[0]
for i in other:
if isinstance(i, Taxon):
......
......@@ -772,6 +772,9 @@ class Edge(
def __eq__(self, other):
return self is other
def __lt__(self, other):
return id(self) < id(other)
###########################################################################
### Basic Structure
......@@ -6103,7 +6106,7 @@ class Tree(
output.write(s)
return s
def as_python_source(self, tree_obj_name=None, tree_args=None, oids=False):
def as_python_source(self, tree_obj_name=None, tree_args=None):
"""
Returns string that will rebuild this tree in Python.
"""
......@@ -6119,10 +6122,9 @@ class Tree(
tree_args = ""
else:
tree_args = ", " + tree_args
p.append("%s = dendropy.Tree(label=%s%s%s)" \
p.append("%s = dendropy.Tree(label=%s%s)" \
% (tree_obj_name,
label,
oid_str,
tree_args))
taxon_obj_namer = lambda x: "tax_%s" % id(x)
......@@ -6132,11 +6134,11 @@ class Tree(
label = "'" + taxon.label + "'"
else:
label = "None"
p.append("%s = %s.taxon_namespace.require_taxon(label=%s%s)" \
p.append("%s = %s.taxon_namespace.require_taxon(label=%s)" \
% (tobj_name,
tree_obj_name,
label,
oid_str))
))
node_obj_namer = lambda x: "nd_%s" % id(x)
for node in self.preorder_node_iter():
......@@ -6153,13 +6155,13 @@ class Tree(
ct = taxon_obj_namer(child.taxon)
else:
ct = "None"
p.append("%s = %s.new_child(label=%s, taxon=%s, edge_length=%s%s)" %
p.append("%s = %s.new_child(label=%s, taxon=%s, edge_length=%s)" %
(node_obj_namer(child),
nn,
label,
ct,
child.edge.length,
oid_str))
))
return "\n".join(p)
......
#! /usr/bin/env python
##############################################################################
## DendroPy Phylogenetic Computing Library.
##
## Copyright 2010-2015 Jeet Sukumaran and Mark T. Holder.
## All rights reserved.
##
## See "LICENSE.rst" for terms and conditions of usage.
##
## If you use this work or any portion thereof in published work,
## please cite it as:
##
## Sukumaran, J. and M. T. Holder. 2010. DendroPy: a Python library
## for phylogenetic computing. Bioinformatics 26: 1569-1571.
##
##############################################################################
"""
Wrapper for interacting with RSPR
"""
import subprocess
import uuid
import tempfile
import socket
import random
import os
import sys
import dendropy
from dendropy.utility.messaging import get_logger
from dendropy.utility import processio
from dendropy.utility import textprocessing
_LOG = get_logger("interop.rspr")
HOSTNAME = socket.gethostname()
PID = os.getpid()
class Rspr(object):
"""
This class wraps all attributes and input needed to make a call to RSPR.
https://github.com/cwhidden/rspr
RSPR:
Calculate approximate and exact Subtree Prune and Regraft (rSPR)
distances and the associated maximum agreement forests (MAFs) between pairs
of rooted binary trees from STDIN in newick format. Supports arbitrary labels.
The second tree may be multifurcating.
Copyright 2009-2014 Chris Whidden
whidden@cs.dal.ca
http://kiwi.cs.dal.ca/Software/RSPR
"""
###
# NOTE ON THE ``--pairwise`` FLAG
# -------------------------------
# This determines the type of comparisons done.
#
# Specified without arguments, it does all distinct pairwise comparisons of
# the input tree. Output by default is a matrix with only the upper half
# filled. So, assuming the source has 4 trees, then:
#
# $ cat 4trees.tre | rspr -pairwise
# 0,23,24,24
# ,0,5,7
# ,,0,6
#
# Further (numerical) arguments specify the row/columns to restrict the
# comparisons.
#
# E.g., first row only: first tree to all other trees:
#
# $ cat 4trees.tre | rspr -pairwise 0 1
# 0,23,24,24
#
# E.g. first two rows only: first two trees to all other trees:
#
# $ cat 4trees.tre | rspr -pairwise 0 2
# 0,23,24,24
# ,0,5,7
#
# E.g. third row only:
#
# $ cat 4trees.tre | rspr -pairwise 2 3
# ,,0,6
#
# E.g. last column only: last tree to all other trees:
#
# $ cat 4trees.tre | rspr -pairwise 0 4 3 4
# 24
# 7
# 6
# 0
def __init__(self,
algorithm="bb",
optimizations=None,
cc=None,
):
"""
Parameters
----------
algorithm : str
One of "fpt", "bb", "approx".
optimizations: list[str] or None
Will be passed directly rspr (with each element prefixed by ``-``).
cc: bool
Calculate a potentially better approximation with a quadratic time
algorithm.
"""
self.algorithm = algorithm
self.optimizations = optimizations
def compare_one_to_many(self,
ref_tree,
comparison_trees,
command_args=None,
newick_output_kwargs=None,
):
"""
Compare ``ref_tree'' to each tree in ``comparison_trees``.
Parameters
----------
ref_tree : |Tree|
A |Tree| object to be compared to every tree in ``comparison_trees``.
comparison_trees : |Tree|
An (ordered) iterable of trees to which ``ref_tree`` should be
compared.
command_args : list or None
An iterable of (string) arguments to be passed to the program.
newick_output_kwargs : dict or None
A collection of keyword arguments to pass to the tree string
composition routines (that will generate the tree strings to be
used as input to rspr).
Returns
-------
scores : list[numeric]
A list of the SPR distances from ``ref_tree'' to
``comparison_trees``, in order of the trees given.
"""
if newick_output_kwargs is None:
newick_output_kwargs = {}
# tf = tempfile.NamedTemporaryFile("w", delete=True)
tf = textprocessing.StringIO()
ref_tree.write(file=tf, schema="newick", **newick_output_kwargs)
for t in comparison_trees:
t.write(file=tf, schema="newick", **newick_output_kwargs)
command = []
command.append("rspr") # TODO: command path as instance attribute
command.extend(["-pairwise", "0", "1"])
if command_args is not None:
command.extend(command_args)
p = subprocess.Popen(command,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,)
stdout, stderr = processio.communicate(p, commands=tf.getvalue())
result_fields = stdout.strip("\n").split(",")
assert len(result_fields) == 1 + len(comparison_trees), "Expecting length {} + 1 for results, but received {}: {}".format(len(comparison_trees), len(result_fields), result_fields)
return [int(v) for v in result_fields[1:]]
This diff is collapsed.
......@@ -59,7 +59,7 @@ class BirthDeathTreeTest(unittest.TestCase):
"""test that the birth-death process produces the correct number of tips with GSA."""
_RNG = MockRandom()
for num_leaves in range(2, 15):
t = birthdeath.birth_death_tree(birth_rate=1.0, death_rate=0.2, ntax=num_leaves, gsa_ntax=3*num_leaves, rng=_RNG)
t = birthdeath.birth_death_tree(birth_rate=1.0, death_rate=0.2, num_extant_tips=num_leaves, gsa_ntax=3*num_leaves, rng=_RNG)
self.assertTrue(t._debug_tree_is_valid())
self.assertEqual(num_leaves, len(t.leaf_nodes()))
......@@ -67,7 +67,7 @@ class BirthDeathTreeTest(unittest.TestCase):
"""test that the pure-birth process produces the correct number of tips."""
_RNG = MockRandom()
for num_leaves in range(2, 20):
t = birthdeath.birth_death_tree(birth_rate=1.0, death_rate=0.0, ntax=num_leaves, rng=_RNG)
t = birthdeath.birth_death_tree(birth_rate=1.0, death_rate=0.0, num_extant_tips=num_leaves, rng=_RNG)
self.assertTrue(t._debug_tree_is_valid())
self.assertEqual(num_leaves, len(t.leaf_nodes()))
......@@ -75,7 +75,7 @@ class BirthDeathTreeTest(unittest.TestCase):
"""test that the pure-birth process produces the correct number of tips with GSA."""
_RNG = MockRandom()
for num_leaves in range(2, 20):
t = birthdeath.birth_death_tree(birth_rate=1.0, death_rate=0.0, ntax=num_leaves, gsa_ntax=4*num_leaves, rng=_RNG)
t = birthdeath.birth_death_tree(birth_rate=1.0, death_rate=0.0, num_extant_tips=num_leaves, gsa_ntax=4*num_leaves, rng=_RNG)
self.assertTrue(t._debug_tree_is_valid())
self.assertEqual(num_leaves, len(t.leaf_nodes()))
......@@ -83,7 +83,7 @@ class BirthDeathTreeTest(unittest.TestCase):
"""PureCoalescentTreeTest -- tree generation without checking [TODO: checks]"""
_RNG = MockRandom()
for num_leaves in range(2, 20):
t = birthdeath.birth_death_tree(birth_rate=1.0, death_rate=0.2, ntax=num_leaves, rng=_RNG)
t = birthdeath.birth_death_tree(birth_rate=1.0, death_rate=0.2, num_extant_tips=num_leaves, rng=_RNG)
self.assertTrue(t._debug_tree_is_valid())
self.assertEqual(num_leaves, len(t.leaf_nodes()))
......