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
......@@ -224,10 +224,11 @@ class NedrexImporter:
self.cache.init_proteins()
bulk = set()
existing = set()
delete = set()
existing = dict()
if update:
for edge in models.ProteinDrugInteraction.objects.filter(pdi_dataset=dataset):
existing.add(edge.__hash__())
existing[edge.__hash__()] = edge
source_datasets = dict()
source_is_licenced = dict()
......@@ -248,6 +249,12 @@ class NedrexImporter:
protein = self.cache.get_protein_by_uniprot(to_id(edge['targetDomainId']))
actions = json.dumps(edge['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:
bulk.add(e)
for source in edge['dataSources']:
......@@ -260,6 +267,8 @@ class NedrexImporter:
pass
iter_edge_collection('drug_has_target', add_dpi)
for d in delete:
d.delete()
models.ProteinDrugInteraction.objects.bulk_create(bulk)
# new_datasets = [dataset].extend(source_datasets.values())
# DatasetLoader.remove_old_pdi_data(new_datasets, licenced)
......
......@@ -8,7 +8,6 @@ if [ -z "$DB_UPDATE_ON_START" ] || [ "$DB_UPDATE_ON_START" = "0" ]
then
echo "Update on startup disabled!"
else
python3 manage.py populate_db --delete_model PDI
python3 manage.py populate_db --update -a
python3 manage.py make_graphs
fi
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment