def test_get_neighbors(self): tree = Phylo.read('./TreeConstruction/upgma.tre', 'newick') alphabet = ['A', 'T', 'C', 'G'] step_matrix = [[0], [2.5, 0], [2.5, 1, 0], [1, 2.5, 2.5, 0]] matrix = _Matrix(alphabet, step_matrix) scorer = ParsimonyScorer(matrix) searcher = NNITreeSearcher(scorer) trees = searcher._get_neighbors(tree) self.assertEqual(len(trees), 2 * (5 - 3)) Phylo.write(trees, './TreeConstruction/neighbor_trees.tre', 'newick')
def test_get_neighbors(self): tree = Phylo.read("./TreeConstruction/upgma.tre", "newick") alphabet = ["A", "T", "C", "G"] step_matrix = [[0], [2.5, 0], [2.5, 1, 0], [1, 2.5, 2.5, 0]] matrix = _Matrix(alphabet, step_matrix) scorer = ParsimonyScorer(matrix) searcher = NNITreeSearcher(scorer) trees = searcher._get_neighbors(tree) self.assertEqual(len(trees), 2 * (5 - 3)) Phylo.write(trees, os.path.join(temp_dir, "neighbor_trees.tre"), "newick")
def NNITreeSurgery(treeStr, schema="newick"): tree = Phylo.read(StringIO(treeStr), schema) nniTreeSearcher = NNITreeSearcher(Scorer()) treeList = nniTreeSearcher._get_neighbors(tree) allTreeList = [] for t in treeList: tstr = t.format("newick") tstr.strip() allTreeList.append("[&R] " + tstr[0:len(tstr) - 6] + ";") return allTreeList
def test_get_neighbors(self): tree = Phylo.read('./TreeConstruction/upgma.tre', 'newick') alphabet = ['A', 'T', 'C', 'G'] step_matrix = [[0], [2.5, 0], [2.5, 1, 0], [ 1, 2.5, 2.5, 0]] matrix = _Matrix(alphabet, step_matrix) scorer = ParsimonyScorer(matrix) searcher = NNITreeSearcher(scorer) trees = searcher._get_neighbors(tree) self.assertEqual(len(trees), 2 * (5 - 3)) Phylo.write(trees, './TreeConstruction/neighbor_trees.tre', 'newick')