Example #1
0
 def test_newick_to_tree_node_invalid_files(self):
     for invalid, error_fragments in self.invalid_newicks:
         fh = io.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()
Example #2
0
 def test_newick_to_tree_node_invalid_files(self):
     for invalid, error_fragments in self.invalid_newicks:
         fh = io.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()
Example #3
0
    def test_roundtrip(self):
        for tree, newicks in self.trees_newick_lists:
            newick = newicks[0]
            fh = io.StringIO(newick)
            tree = _newick_to_tree_node(fh)
            fh2 = io.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()
Example #4
0
    def test_roundtrip(self):
        for tree, newicks in self.trees_newick_lists:
            newick = newicks[0]
            fh = io.StringIO(newick)
            tree = _newick_to_tree_node(fh)
            fh2 = io.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()
Example #5
0
 def test_newick_to_tree_node_convert_underscores(self):
     fh = io.StringIO('(_:0.1, _a, _b)__;')
     tree = _newick_to_tree_node(fh, convert_underscores=False)
     fh2 = io.StringIO()
     _tree_node_to_newick(tree, fh2)
     self.assertEqual(fh2.getvalue(), "('_':0.1,'_a','_b')'__';\n")
     fh2.close()
     fh.close()
Example #6
0
 def test_newick_to_tree_node_convert_underscores(self):
     fh = io.StringIO('(_:0.1, _a, _b)__;')
     tree = _newick_to_tree_node(fh, convert_underscores=False)
     fh2 = io.StringIO()
     _tree_node_to_newick(tree, fh2)
     self.assertEqual(fh2.getvalue(), "('_':0.1,'_a','_b')'__';\n")
     fh2.close()
     fh.close()
Example #7
0
    def test_newick_to_tree_node_valid_files(self):
        for tree, newicks in self.trees_newick_lists:
            for newick in newicks:
                fh = io.StringIO(newick)
                read_tree = _newick_to_tree_node(fh)

                self._assert_equal(tree, read_tree)

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

                self._assert_equal(tree, read_tree)

                fh.close()