Exemplo n.º 1
0
    def test_get_pathway_desc(self):
        desc = QREx.get_pathway_desc('REACT:R-HSA-70326')
        self.assertIsNotNone(desc)
        self.assertEqual(
            desc,
            get_from_test_file('query_desc_test_data.json',
                               'REACT:R-HSA-70326'))

        desc = QREx.get_pathway_desc('REACT:R-HSA-703260')
        self.assertEqual(desc, 'None')
Exemplo n.º 2
0
    def test_update_pathway_entity(self):
        f = open('config.json', 'r')
        config_data = f.read()
        f.close()
        config = json.loads(config_data)

        conn = Neo4jConnection(config['url'], config['username'], config['password'])
        nodes = conn.get_pathway_nodes()

        # generate random number array
        random_indexes = random_int_list(0, len(nodes)-1, 100)

        for i in random_indexes:
            # retrieve data from Reactome API
            node_id = nodes[i]
            extended_info_json_from_api = QueryReactomeExtended.get_pathway_entity(node_id)

            # retrieve data from Neo4j
            node = conn.get_pathway_node(node_id)
            self.assertIsNotNone(node['n']['id'])
            self.assertIsNotNone(node['n']['extended_info_json'])
            self.assertEqual(node_id, node['n']['id'])
            self.maxDiff = None
            if node['n']['extended_info_json'] != "UNKNOWN":
                self.assertEqual(json.loads(extended_info_json_from_api), json.loads(node['n']['extended_info_json']))

        conn.close()
Exemplo n.º 3
0
    def test_update_pathway_nodes_desc(self):
        f = open('config.json', 'r')
        config_data = f.read()
        f.close()
        config = json.loads(config_data)

        conn = Neo4jConnection(config['url'], config['username'],
                               config['password'])
        nodes = conn.get_pathway_nodes()

        # generate random number array
        random_indexes = random_int_list(0, len(nodes) - 1, 100)

        for i in random_indexes:
            # retrieve data from API
            node_id = nodes[i]
            desc = QueryReactomeExtended.get_pathway_desc(node_id)

            # retrieve data from Neo4j
            node = conn.get_pathway_node(node_id)
            self.assertIsNotNone(node['n']['id'])
            self.assertIsNotNone(node['n']['description'])
            self.assertEqual(node_id, node['n']['id'])
            self.assertEqual(desc, node['n']['description'])

        conn.close()
Exemplo n.º 4
0
    def update_pathway_nodes_desc():
        f = open('config.json', 'r')
        config_data = f.read()
        f.close()
        config = json.loads(config_data)

        conn = Neo4jConnection(config['url'], config['username'],
                               config['password'])
        nodes = conn.get_pathway_nodes()
        print("the number of pathway: %d" % len(nodes))

        from time import time
        t = time()

        nodes_array = []
        for i, node_id in enumerate(nodes):
            node = dict()
            node['node_id'] = node_id
            node['desc'] = QueryReactomeExtended.get_pathway_desc(node_id)
            nodes_array.append(node)

        print("pathway api pulling time: %f" % (time() - t))

        nodes_nums = len(nodes_array)
        chunk_size = 10000
        group_nums = nodes_nums // chunk_size + 1
        for i in range(group_nums):
            start = i * chunk_size
            end = (i + 1) * chunk_size if (
                i + 1) * chunk_size < nodes_nums else nodes_nums
            conn.update_pathway_nodes_desc(nodes_array[start:end])

        print("pathway total time: %f" % (time() - t))

        conn.close()
Exemplo n.º 5
0
 def test_get_pathway_entity(self):
     extended_info_json = QREx.get_pathway_entity('REACT:R-HSA-70326')
     self.maxDiff = None
     self.assertIsNotNone(extended_info_json)
     if extended_info_json != "UNKNOWN":
         self.assertEqual(
             json.loads(extended_info_json),
             json.loads(
                 get_from_test_file('query_test_data.json',
                                    'REACT:R-HSA-70326')))