-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_rnj.py
40 lines (33 loc) · 1.2 KB
/
test_rnj.py
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
37
38
39
40
#! /usr/bin/env python
import unittest, os
from cogent.phylo.distance import *
from rnj import rnj
from cogent import LoadTree
__author__ = "Justin Kuczynski"
__copyright__ = ""
__credits__ = ["Justin Kuczynski"]
__license__ = "GPL"
__version__ = "1.0"
__maintainer__ = "Justin Kuczynski"
__email__ = "[email protected]"
__status__ = "Prototype"
class TreeReconstructionTests(unittest.TestCase):
def setUp(self):
pass
def _test_tree(self, method, treestring):
t = LoadTree(treestring=treestring)
t_distances = t.getDistances()
reconstructed = method(t_distances)
distances = reconstructed.getDistances()
for key in t_distances:
self.assertAlmostEqual(t_distances[key], distances[key])
def _test_phylo_method(self, method):
"""testing (well, exercising at least), rnj"""
self._test_tree(method, '((a:3,b:4):20,(c:6,d:7):30,e:5)')
self._test_tree(method, '((a:3,b:4):0,(c:6,d:7):30,e:5)')
self._test_tree(method, '((a:3,b:4,c:6,d:7):30,e:5)')
def test_rnj(self):
"""testing (well, exercising at least), rnj"""
self._test_phylo_method(rnj)
if __name__ == '__main__':
unittest.main()