Skip to content
Snippets Groups Projects
Commit cfed08b9 authored by AndiMajore's avatar AndiMajore
Browse files

fixing drug-target-interaction update routine

Former-commit-id: 0b2f1a7cbbc8478e6d464b65a75bfa2e799f9d05 [formerly 76c7bea1b462da0f1eebf7d16367320e3eeffa56]
Former-commit-id: 009e32b1d3120a54f4088f5e073d264aa86ac29f
parent 05691863
No related branches found
No related tags found
No related merge requests found
...@@ -103,7 +103,7 @@ class NedrexImporter: ...@@ -103,7 +103,7 @@ class NedrexImporter:
adjusted_name = name[:idx1 - 1].strip() if idx1 > 0 else '' adjusted_name = name[:idx1 - 1].strip() if idx1 > 0 else ''
if '=' in adjusted_name: if '=' in adjusted_name:
idx2 = adjusted_name.index('=') idx2 = adjusted_name.index('=')
return adjusted_name[idx2+1:].strip() return adjusted_name[idx2 + 1:].strip()
return adjusted_name return adjusted_name
return name return name
...@@ -224,10 +224,11 @@ class NedrexImporter: ...@@ -224,10 +224,11 @@ class NedrexImporter:
self.cache.init_proteins() self.cache.init_proteins()
bulk = set() bulk = set()
existing = set() delete = set()
existing = dict()
if update: if update:
for edge in models.ProteinDrugInteraction.objects.filter(pdi_dataset=dataset): for edge in models.ProteinDrugInteraction.objects.filter(pdi_dataset=dataset):
existing.add(edge.__hash__()) existing[edge.__hash__()] = edge
source_datasets = dict() source_datasets = dict()
source_is_licenced = dict() source_is_licenced = dict()
...@@ -248,6 +249,12 @@ class NedrexImporter: ...@@ -248,6 +249,12 @@ class NedrexImporter:
protein = self.cache.get_protein_by_uniprot(to_id(edge['targetDomainId'])) protein = self.cache.get_protein_by_uniprot(to_id(edge['targetDomainId']))
actions = json.dumps(edge['actions']) actions = json.dumps(edge['actions'])
e = models.ProteinDrugInteraction(pdi_dataset=dataset, drug=drug, protein=protein, actions=actions) e = models.ProteinDrugInteraction(pdi_dataset=dataset, drug=drug, protein=protein, actions=actions)
if update and e.__hash__() in existing:
if existing[e.__hash__()] != e:
delete.add(existing[e.__hash__()])
del existing[e.__hash__()]
else:
return
if not update or e.__hash__() not in existing: if not update or e.__hash__() not in existing:
bulk.add(e) bulk.add(e)
for source in edge['dataSources']: for source in edge['dataSources']:
...@@ -260,6 +267,8 @@ class NedrexImporter: ...@@ -260,6 +267,8 @@ class NedrexImporter:
pass pass
iter_edge_collection('drug_has_target', add_dpi) iter_edge_collection('drug_has_target', add_dpi)
for d in delete:
d.delete()
models.ProteinDrugInteraction.objects.bulk_create(bulk) models.ProteinDrugInteraction.objects.bulk_create(bulk)
# new_datasets = [dataset].extend(source_datasets.values()) # new_datasets = [dataset].extend(source_datasets.values())
# DatasetLoader.remove_old_pdi_data(new_datasets, licenced) # DatasetLoader.remove_old_pdi_data(new_datasets, licenced)
......
...@@ -8,7 +8,6 @@ if [ -z "$DB_UPDATE_ON_START" ] || [ "$DB_UPDATE_ON_START" = "0" ] ...@@ -8,7 +8,6 @@ if [ -z "$DB_UPDATE_ON_START" ] || [ "$DB_UPDATE_ON_START" = "0" ]
then then
echo "Update on startup disabled!" echo "Update on startup disabled!"
else else
python3 manage.py populate_db --delete_model PDI
python3 manage.py populate_db --update -a python3 manage.py populate_db --update -a
python3 manage.py make_graphs python3 manage.py make_graphs
fi fi
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment