Browse Source

added mol-script symbol to ValidationReport

Alexander Rose 5 years ago
parent
commit
bdda18de23

+ 23 - 1
src/mol-model-props/rcsb/validation-report.ts

@@ -19,6 +19,9 @@ import { arrayMax } from '../../mol-util/array';
 import { equalEps } from '../../mol-math/linear-algebra/3d/common';
 import { Vec3 } from '../../mol-math/linear-algebra';
 import { MmcifFormat } from '../../mol-model-formats/structure/mmcif';
+import { QuerySymbolRuntime } from '../../mol-script/runtime/query/compiler';
+import { CustomPropSymbol } from '../../mol-script/language/symbol';
+import Type from '../../mol-script/language/type';
 
 export { ValidationReport }
 
@@ -118,6 +121,25 @@ namespace ValidationReport {
             case 'server': return fetch(ctx, model, props.source.params)
         }
     }
+
+    export const symbols = {
+        hasClash: QuerySymbolRuntime.Dynamic(CustomPropSymbol('rcsb', 'validation-report.has-clash', Type.Bool),
+            ctx => {
+                const { unit, element } = ctx.element
+                if (!Unit.isAtomic(unit)) return 0
+                const validationReport = ValidationReportProvider.get(unit.model).value
+                return validationReport && validationReport.clashes.getVertexEdgeCount(element) > 0
+            }
+        ),
+        issueCount: QuerySymbolRuntime.Dynamic(CustomPropSymbol('rcsb', 'validation-report.issue-count', Type.Num),
+            ctx => {
+                const { unit, element } = ctx.element
+                if (!Unit.isAtomic(unit)) return 0
+                const validationReport = ValidationReportProvider.get(unit.model).value
+                return validationReport?.geometryIssues.get(unit.residueIndex[element])?.size || 0
+            }
+        ),
+    }
 }
 
 const FileSourceParams = {
@@ -143,7 +165,7 @@ export const ValidationReportProvider: CustomModelProperty.Provider<ValidationRe
     label: 'RCSB Validation Report',
     descriptor: CustomPropertyDescriptor({
         name: 'rcsb_validation_report',
-        // TODO `cifExport` and `symbol`
+        symbols: ValidationReport.symbols
     }),
     type: 'dynamic',
     defaultParams: ValidationReportParams,

+ 6 - 0
src/mol-plugin/behavior/dynamic/custom-props/rcsb/validation-report.ts

@@ -14,6 +14,7 @@ import { OrderedSet } from '../../../../../mol-data/int';
 import { ClashesRepresentationProvider } from '../../../../../mol-model-props/rcsb/representations/validation-report-clashes';
 import { DensityFitColorThemeProvider } from '../../../../../mol-model-props/rcsb/themes/density-fit';
 import { cantorPairing } from '../../../../../mol-data/util';
+import { DefaultQueryRuntimeTable } from '../../../../../mol-script/runtime/query/compiler';
 
 const Tag = ValidationReport.Tag
 
@@ -34,6 +35,8 @@ export const RCSBValidationReport = PluginBehavior.create<{ autoAttach: boolean,
         }
 
         register(): void {
+            DefaultQueryRuntimeTable.addCustomProp(this.provider.descriptor);
+
             this.ctx.customModelProperties.register(this.provider, this.params.autoAttach);
 
             this.ctx.lociLabels.addProvider(this.label);
@@ -54,6 +57,9 @@ export const RCSBValidationReport = PluginBehavior.create<{ autoAttach: boolean,
         }
 
         unregister() {
+            // TODO
+            // DefaultQueryRuntimeTable.removeCustomProp(this.provider.descriptor);
+
             this.ctx.customStructureProperties.unregister(this.provider.descriptor.name);
 
             this.ctx.lociLabels.removeProvider(this.label);