示例#1
0
    def test_read(self, tmpdir, prepare_file):
        prepare_file(
            "file1.json",
            """
            {
                "a": 5,
                "nodes": {
                    "NODE_1": { "x": 5 },
                    "NODE_2": { "x": 6 },
                    "NODE_3": { "x": 7 }
                }
            }
            """,
        )
        prepare_file(
            "file2.json",
            """
            {
                "nodes": {
                    "NODE_3": { "y": 8 },
                    "NODE_4": { "x": 9 }
                }
            }
            """,
        )

        node_data = NodeDataReader(
            [f"{tmpdir}/file1.json", f"{tmpdir}/file2.json"]).read()
        assert node_data == {
            "a": 5,
            "nodes": {
                "NODE_1": {
                    "x": 5
                },
                "NODE_2": {
                    "x": 6
                },
                "NODE_3": {
                    "x": 7,
                    "y": 8
                },
                "NODE_4": {
                    "x": 9
                },
            },
        }
示例#2
0
    def test_read_check_against_tree(self, tmpdir, prepare_file):
        prepare_file(
            "file1.json",
            """
            {
                "a": 5,
                "nodes": {
                    "NODE_1": { "x": 5 },
                    "NODE_2": { "x": 6 },
                    "NODE_3": { "x": 7 }
                }
            }
            """,
        )
        prepare_file("tree.newick", "(NODE_1, NODE_2) NODE_3")

        NodeDataReader([f"{tmpdir}/file1.json"],
                       f"{tmpdir}/tree.newick").read()
示例#3
0
    def test_read_check_against_tree_bad(self, tmpdir, prepare_file):
        prepare_file(
            "file1.json",
            """
            {
                "a": 5,
                "nodes": {
                    "NODE_1": { "x": 5 },
                    "NODE_2": { "x": 6 },
                    "NODE_3": { "x": 7 }
                }
            }
            """,
        )
        prepare_file("tree.newick", "Noooooooooope")

        with pytest.raises(SystemExit):
            NodeDataReader([f"{tmpdir}/file1.json"],
                           f"{tmpdir}/tree.newick").read()
示例#4
0
 def test_read_dict_nonuniformity(self, tmpdir, prepare_file):
     prepare_file(
         "file1.json",
         """
         {
             "nodes": {},
             "a": {}
         }
         """,
     )
     prepare_file(
         "file2.json",
         """
         {
             "nodes": {},
             "a": "nah"
         }
         """,
     )
     with pytest.raises(SystemExit):
         NodeDataReader([f"{tmpdir}/file1.json",
                         f"{tmpdir}/file2.json"]).read()
示例#5
0
 def test_read_bad_file(self):
     NodeDataReader(["/does/not/exist.json"])
示例#6
0
文件: utils.py 项目: tomkinsc/augur
def read_node_data(fnames, tree=None):
    return NodeDataReader(fnames, tree).read()
示例#7
0
 def test_read_check_against_missing_tree(self, tmpdir):
     with pytest.raises(SystemExit):
         node_names_from_tree = NodeDataReader(
             [f"{tmpdir}/file1.json"],
             f"{tmpdir}/missing_file.txt").node_names_from_tree_file