def post(self): """Download model and associated pieces from NDEX. Parameters ---------- network_id : str ID of NDEx network to fetch. Returns ------- stored_data : dict Dictionary representing the network. """ args = request.json network_id = args.get('network_id') cx = process_ndex_network(network_id) network_attr = [x for x in cx.cx if x.get('networkAttributes')] network_attr = network_attr[0]['networkAttributes'] keep_keys = [ 'txt_input', 'parser', 'model_elements', 'preset_pos', 'stmts', 'sentences', 'evidence', 'cell_line', 'mrna', 'mutations' ] stored_data = {} for d in network_attr: if d['n'] in keep_keys: stored_data[d['n']] = d['v'] return stored_data
def fetch_model_ndex(): """Download model and associated pieces from NDEX""" if request.method == 'OPTIONS': return {} response = request.body.read().decode('utf-8') body = json.loads(response) network_id = body.get('network_id') cx = process_ndex_network(network_id) network_attr = [x for x in cx.cx if x.get('networkAttributes')] network_attr = network_attr[0]['networkAttributes'] keep_keys = ['txt_input', 'parser', 'model_elements', 'preset_pos', 'stmts', 'sentences', 'evidence', 'cell_line', 'mrna', 'mutations'] stored_data = {} for d in network_attr: if d['n'] in keep_keys: stored_data[d['n']] = d['v'] return stored_data