示例#1
0
 def test_newick_to_tree_node_invalid_files(self):
     for invalid, error_fragments in self.invalid_newicks:
         fh = StringIO(invalid)
         with self.assertRaises(NewickFormatError) as cm:
             _newick_to_tree_node(fh)
         for frag in error_fragments:
             self.assertIn(frag, str(cm.exception))
         fh.close()
示例#2
0
 def test_newick_to_tree_node_invalid_files(self):
     for invalid, error_fragments in self.invalid_newicks:
         fh = StringIO(invalid)
         with self.assertRaises(NewickFormatError) as cm:
             _newick_to_tree_node(fh)
         for frag in error_fragments:
             self.assertIn(frag, str(cm.exception))
         fh.close()
示例#3
0
    def test_roundtrip(self):
        for tree, newicks in self.trees_newick_lists:
            newick = newicks[0]
            fh = StringIO(newick)
            tree = _newick_to_tree_node(fh)
            fh2 = StringIO()
            _tree_node_to_newick(tree, fh2)
            fh2.seek(0)
            tree2 = _newick_to_tree_node(fh2)

            self.assertEqual(newick, fh2.getvalue())
            self._assert_equal(tree, tree2)

            fh.close()
            fh2.close()
示例#4
0
    def test_roundtrip(self):
        for tree, newicks in self.trees_newick_lists:
            newick = newicks[0]
            fh = StringIO(newick)
            tree = _newick_to_tree_node(fh)
            fh2 = StringIO()
            _tree_node_to_newick(tree, fh2)
            fh2.seek(0)
            tree2 = _newick_to_tree_node(fh2)

            self.assertEqual(newick, fh2.getvalue())
            self._assert_equal(tree, tree2)

            fh.close()
            fh2.close()
示例#5
0
 def test_newick_to_tree_node_convert_underscores(self):
     fh = StringIO('(_:0.1, _a, _b)__;')
     tree = _newick_to_tree_node(fh, convert_underscores=False)
     fh2 = StringIO()
     _tree_node_to_newick(tree, fh2)
     self.assertEquals(fh2.getvalue(), "('_':0.1,'_a','_b')'__';\n")
     fh2.close()
     fh.close()
示例#6
0
 def test_newick_to_tree_node_convert_underscores(self):
     fh = StringIO('(_:0.1, _a, _b)__;')
     tree = _newick_to_tree_node(fh, convert_underscores=False)
     fh2 = StringIO()
     _tree_node_to_newick(tree, fh2)
     self.assertEquals(fh2.getvalue(), "('_':0.1,'_a','_b')'__';\n")
     fh2.close()
     fh.close()
示例#7
0
    def test_newick_to_tree_node_valid_files(self):
        for tree, newicks in self.trees_newick_lists:
            for newick in newicks:
                fh = StringIO(newick)
                read_tree = _newick_to_tree_node(fh)

                self._assert_equal(tree, read_tree)

                fh.close()
示例#8
0
    def test_newick_to_tree_node_valid_files(self):
        for tree, newicks in self.trees_newick_lists:
            for newick in newicks:
                fh = StringIO(newick)
                read_tree = _newick_to_tree_node(fh)

                self._assert_equal(tree, read_tree)

                fh.close()