diff --git a/drugstone/management/commands/cleanuptasks.py b/drugstone/management/commands/cleanuptasks.py index 470611a8c3931ef1db55804a3879b88890395a78..ee6fe53a835a44679b226f1ddc37e6cdf0a7a721 100755 --- a/drugstone/management/commands/cleanuptasks.py +++ b/drugstone/management/commands/cleanuptasks.py @@ -11,7 +11,6 @@ class Command(BaseCommand): def handle(self, *args, **kwargs): print('Task cleanup...') - print() print(f'Closing {Task.objects.filter(started_at__isnull=True).count()} queued tasks') Task.objects.filter(started_at__isnull=True).update(started_at=timezone.now(), finished_at=timezone.now(), diff --git a/drugstone/util/nedrex.py b/drugstone/util/nedrex.py deleted file mode 100644 index d3f85eb65900916f724c433d616a7035138026a4..0000000000000000000000000000000000000000 --- a/drugstone/util/nedrex.py +++ /dev/null @@ -1,8 +0,0 @@ -def fetch_nedrex_data(): - print('fetching') - return - - -def integrate_nedrex_data(): - print('integrating') - return diff --git a/drugstone/views.py b/drugstone/views.py index c08171816da2306b77db5c86ab8b5975d1714b86..fa5ea27d152a21866105de5eff30a7db939a4876 100755 --- a/drugstone/views.py +++ b/drugstone/views.py @@ -337,16 +337,8 @@ def result_view(request) -> Response: for node_id in nodes: is_seed[node_id] = node_id in seeds node_type = node_types.get(node_id).lower() - # if node_type == 'node': - # # TODO remove this if after next make_graphs - # node_type = 'protein' pvd_entity = None details_s = None - # if not node_type: - # # TODO can this be removed? should never be reached - # print('we should not see this 2') - # node_type, pvd_entity = infer_node_type_and_details(int(node_id[1:])) - # else: if node_type == 'protein': pvd_entity = Protein.objects.get(id=int(node_id[1:])) elif node_type == 'drug': @@ -409,14 +401,20 @@ def result_view(request) -> Response: nodes_mapped, id_key = query_proteins_by_identifier(edge_endpoint_ids, identifier) # change data structure to dict in order to be quicker when merging nodes_mapped_dict = {node[id_key]: node for node in nodes_mapped} - for edge in edges: # change edge endpoints if they were matched with a protein in the database edge['from'] = nodes_mapped_dict[edge['from']][node_name_attribute] if edge['from'] in nodes_mapped_dict else \ edge['from'] edge['to'] = nodes_mapped_dict[edge['to']][node_name_attribute] if edge['to'] in nodes_mapped_dict else edge[ 'to'] - + if 'autofill_edges' in parameters['config'] and parameters['config']['autofill_edges']: + proteins = set(map(lambda n:n[node_name_attribute][1:],filter(lambda n: node_name_attribute in n,parameters['input_network']['nodes']))) + dataset = 'STRING' if 'interaction_protein_protein' not in parameters['config'] else parameters['config']['interaction_protein_protein'] + dataset_object = models.PPIDataset.objects.filter(name__iexact=dataset).last() + interaction_objects = models.ProteinProteinInteraction.objects.filter( + Q(ppi_dataset=dataset_object) & Q(from_protein__in=proteins) & Q(to_protein__in=proteins)) + auto_edges = list(map(lambda n: {"from": f'p{n.from_protein_id}', "to":f'p{n.to_protein_id}'} ,interaction_objects)) + edges.extend(auto_edges) result['network']['edges'].extend(edges) if not view: diff --git a/tasks/util/read_graph_tool_graph.py b/tasks/util/read_graph_tool_graph.py index 94db0756351fca1be345aed37c178e59ae31434d..1e9caf22c2c4545105768891e0830917d5dbc5f3 100755 --- a/tasks/util/read_graph_tool_graph.py +++ b/tasks/util/read_graph_tool_graph.py @@ -106,6 +106,8 @@ def read_graph_tool_graph(file_path, seeds, max_deg, include_indirect_drugs=Fals deleted_edges.append(edge) if indir_drug and int(edge.source()) in drug_ids: drug_ids.remove(int(edge.source())) + else: + deleted_edges.append(edge) g.set_fast_edge_removal(fast=True) for edge in deleted_edges: