Ejemplo n.º 1
0
    def test_has_nodetypes_actuallyhas(self, mock_keggapi_link):

        mock_keggapi_link.return_value = [hsa_nodes, enzyme_nodes]

        graph = kgu.kegg_link_graph("hsa", "enzyme")

        self.assertTrue(kgu.has_nodetypes(graph))
Ejemplo n.º 2
0
    def test_get_nodes_by_nodetype_missingnodetype(self, mock_keggapi_link):

        mock_keggapi_link.return_value = [hsa_nodes, enzyme_nodes]

        graph = kgu.kegg_link_graph("hsa", "enzyme")

        with self.assertRaises(errors.MissingNodetypeError):
            kgu.get_nodes_by_nodetype(graph, "map")
Ejemplo n.º 3
0
    def test_get_nodes_by_nodetype_invalidgraph(self, mock_keggapi_link):

        mock_keggapi_link.return_value = [hsa_nodes, enzyme_nodes]

        graph = nx.Graph()

        with self.assertRaises(errors.NotAKeggGraphError):
            kgu.get_nodes_by_nodetype(graph, "hsa")
Ejemplo n.º 4
0
    def test_get_nodes_by_nodetype(self, mock_keggapi_link):

        mock_keggapi_link.return_value = [hsa_nodes, enzyme_nodes]

        graph = kgu.kegg_link_graph("hsa", "enzyme")

        self.assertEqual(
            kgu.get_nodes_by_nodetype(graph, "hsa", return_dict=True),
            dict.fromkeys(hsa_nodes, "hsa"))
Ejemplo n.º 5
0
 def test_neighbor_graph_edges(self):
     self.assertEqual(
         set(
             list(
                 kgu.neighbor_graph(testgraph, {
                     hsa_nodes[0]: 'hsa'
                 }).edges)[0]), set([hsa_nodes[0], enzyme_nodes[0]]))
Ejemplo n.º 6
0
    def test_kegg_link_graph_returns_bipartite_graphs(self, mocker):

        mocker.return_value = [hsa_nodes, enzyme_nodes]

        graph = kgu.kegg_link_graph("hsa", "enzyme")

        self.assertTrue(nx.is_bipartite(graph), "Graph is not bipartite")
Ejemplo n.º 7
0
    def test_kegg_link_graph_adds_nodes(self, mock_keggapi_link):

        mock_keggapi_link.return_value = [hsa_nodes, enzyme_nodes]

        graph = kgu.kegg_link_graph("hsa", "enzyme")

        self.assertTrue(
            set(graph.nodes) == set(hsa_nodes + enzyme_nodes),
            "Different number of nodes")
Ejemplo n.º 8
0
    def test_kegg_link_graph_all_nodes_are_correctly_copied(self, mocker):

        mocker.return_value = [hsa_nodes, enzyme_nodes]

        graph = kgu.kegg_link_graph("hsa", "enzyme")

        self.assertEqual(
            len(hsa_nodes) + len(enzyme_nodes), len(graph.nodes),
            "Not all nodes are being copied")
Ejemplo n.º 9
0
    def test_has_nodetype_doesnthave(self):

        graph = nx.Graph()

        self.assertFalse(kgu.has_nodetypes(graph))
Ejemplo n.º 10
0
 def test_neighbor_graph_nodes(self):
     self.assertEqual(
         set(kgu.neighbor_graph(testgraph, {
             hsa_nodes[0]: "hsa"
         }).nodes), set([hsa_nodes[0], enzyme_nodes[0]]))
Ejemplo n.º 11
0
 def test_linked_nodes(self):
     self.assertEqual(
         kgu.linked_nodes(testgraph, hsa_nodes[0], return_dict=True),
         {enzyme_nodes[0]: "enzyme"})
Ejemplo n.º 12
0
 def test_unique_nodetypes(self):
     self.assertEqual(kgu.get_unique_nodetypes(testgraph),
                      ['enzyme', 'hsa'])
Ejemplo n.º 13
0
 def test_get_nodes_by_nodetype_correct_nodetype_dict(self):
     hsa_nodetypes = dict.fromkeys(hsa_nodes, "hsa")
     self.assertEqual(
         kgu.get_nodes_by_nodetype(testgraph, "hsa", return_dict=True),
         hsa_nodetypes)