コード例 #1
0
ファイル: service.py プロジェクト: idekerlab/graph-services
    def process(self, params, input_stream):
        logging.debug(params)

        # Convert to graph-tool objects
        gs = GraphToolAdapter.to_graph_tool(input_stream)
        ts, tposs = self.process_graphs(params, gs)
        return GraphToolAdapter.from_graph_tool(ts, tposs, False)
コード例 #2
0
 def testMultipleNetworks(self):
     nets = [
         create_mock_graph_tool('net1')[0],
         create_mock_graph_tool('net2')[0]
     ]
     streams = GraphToolAdapter.from_graph_tool(nets)
     res_nets = GraphToolAdapter.to_graph_tool(streams)
     compare_graph_tool(nets[0], res_nets[0])
     compare_graph_tool(nets[1], res_nets[1])
コード例 #3
0
 def testUnusualAttributeType(self):
     net, edgeList = create_mock_graph_tool(num_nodes=100,
                                            num_edges=50,
                                            data={'keyDict': {
                                                1: 2
                                            }})
     stream = GraphToolAdapter.from_graph_tool([net])
     net_res_list = GraphToolAdapter.to_graph_tool(stream)
     compare_graph_tool(net, net_res_list[0])
     # autoconvert to string for unrecognized value types
     self.assertEqual(str(net.gp['keyDict']), net_res_list[0].gp['keyDict'])
コード例 #4
0
    def test_to_graph_tool(self):
        net, edgeList = create_mock_graph_tool(num_nodes=100,
                                               num_edges=50,
                                               data={
                                                   'keyStr': 'value',
                                                   'keyInt': 1,
                                                   'keyFloat': 1.2,
                                                   'keyBool': True
                                               })

        stream = GraphToolAdapter.from_graph_tool([net])
        net_res_list = GraphToolAdapter.to_graph_tool(stream)
        compare_graph_tool(net, net_res_list[0])
        self.assertEqual(net.gp.keys(), net_res_list[0].gp.keys())
        for k in net.gp.keys():
            self.assertEqual(net.gp[k], net_res_list[0].gp[k])
コード例 #5
0
 def testLargeNetwork(self):
     net, edgeList = create_mock_graph_tool(num_nodes=10000, num_edges=5000)
     stream = GraphToolAdapter.from_graph_tool([net])
     net_res_list = GraphToolAdapter.to_graph_tool(stream)
     compare_graph_tool(net, net_res_list[0])
コード例 #6
0
 def process(self, params, input_stream):
     logging.debug(params)
     ol = params.pop("only-layout")
     gs = GraphToolAdapter.to_graph_tool(input_stream)
     gs, poss = self.process_graphs(params, gs)
     return GraphToolAdapter.from_graph_tool(gs, poss, ol)