From 72b95a7d16135bbb9701d946627d7d926d2b859c Mon Sep 17 00:00:00 2001
From: David Sehnal <david.sehnal@gmail.com>
Date: Mon, 24 Sep 2018 11:51:31 +0200
Subject: [PATCH] Fix structure validation custom prop

---
 src/mol-model-props/pdbe/structure-quality-report.ts | 8 ++++----
 src/mol-model/structure/model/formats/mmcif.ts       | 3 ++-
 src/servers/model/properties/providers/pdbe.ts       | 5 +----
 3 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/src/mol-model-props/pdbe/structure-quality-report.ts b/src/mol-model-props/pdbe/structure-quality-report.ts
index 8eed13c6f..a517f8ee3 100644
--- a/src/mol-model-props/pdbe/structure-quality-report.ts
+++ b/src/mol-model-props/pdbe/structure-quality-report.ts
@@ -21,7 +21,7 @@ import Type from 'mol-script/language/type';
 type IssueMap = ResidueCustomProperty<string[]>
 
 const _Descriptor = ModelPropertyDescriptor({
-    isStatic: true,
+    isStatic: false,
     name: 'structure_quality_report',
     cifExport: {
         prefix: 'pdbe',
@@ -114,7 +114,7 @@ export namespace StructureQualityReport {
         // provide JSON from api
         PDBe_apiSourceJson?: (model: Model) => Promise<any>
     }) {
-        if (model.customProperties.has(Descriptor)) return true;
+        if (get(model)) return true;
 
         let issueMap;
 
@@ -132,12 +132,12 @@ export namespace StructureQualityReport {
         }
 
         model.customProperties.add(Descriptor);
-        model._staticPropertyData.__StructureQualityReport__ = issueMap;
+        model._dynamicPropertyData.__StructureQualityReport__ = issueMap;
         return true;
     }
 
     export function get(model: Model): IssueMap | undefined {
-        return model._staticPropertyData.__StructureQualityReport__;
+        return model._dynamicPropertyData.__StructureQualityReport__;
     }
 
     const _emptyArray: string[] = [];
diff --git a/src/mol-model/structure/model/formats/mmcif.ts b/src/mol-model/structure/model/formats/mmcif.ts
index b03ed9663..309e19470 100644
--- a/src/mol-model/structure/model/formats/mmcif.ts
+++ b/src/mol-model/structure/model/formats/mmcif.ts
@@ -146,7 +146,8 @@ function createStandardModel(format: mmCIF_Format, atom_site: AtomSite, entities
             ...previous,
             id: UUID.create(),
             modelNum: atom_site.pdbx_PDB_model_num.value(0),
-            atomicConformation: atomic.conformation
+            atomicConformation: atomic.conformation,
+            _dynamicPropertyData: Object.create(null)
         };
     }
 
diff --git a/src/servers/model/properties/providers/pdbe.ts b/src/servers/model/properties/providers/pdbe.ts
index 14a2119aa..2f2403a20 100644
--- a/src/servers/model/properties/providers/pdbe.ts
+++ b/src/servers/model/properties/providers/pdbe.ts
@@ -13,10 +13,7 @@ const cacheKey = UUID.create();
 export function PDBe_structureQualityReport(model: Model, cache: any) {
     return StructureQualityReport.attachFromCifOrApi(model, {
         PDBe_apiSourceJson: async model => {
-            if (cache[cacheKey]) {
-                console.log('cache hit');
-                return cache[cacheKey];
-            }
+            if (cache[cacheKey]) return cache[cacheKey];
             const rawData = await fetchRetry(`https://www.ebi.ac.uk/pdbe/api/validation/residuewise_outlier_summary/entry/${model.label.toLowerCase()}`, 1500, 5);
             const json = await rawData.json();
             cache[cacheKey] = json;
-- 
GitLab