Ver código fonte

ModelPropertyDescriptor.cifExport is now optional

David Sehnal 6 anos atrás
pai
commit
f6be30ba8a

+ 4 - 3
src/mol-model-props/pdbe/structure-quality-report.ts

@@ -20,7 +20,7 @@ import Type from 'mol-script/language/type';
 
 type IssueMap = ResidueCustomProperty<string[]>
 
-const _Descriptor: ModelPropertyDescriptor = {
+const _Descriptor = ModelPropertyDescriptor({
     isStatic: true,
     name: 'structure_quality_report',
     cifExport: {
@@ -41,9 +41,10 @@ const _Descriptor: ModelPropertyDescriptor = {
     },
     symbols: {
         issueCount: QuerySymbolRuntime.Dynamic(CustomPropSymbol('pdbe', 'structure-quality.issue-count', Type.Num),
-            ctx => StructureQualityReport.getIssues(ctx.element).length)
+            ctx => StructureQualityReport.getIssues(ctx.element).length),
+        // TODO: add (hasIssue :: IssueType(extends string) -> boolean) symbol
     }
-}
+})
 
 type ExportCtx = ResidueCustomProperty.ExportCtx<string[]>
 const _structure_quality_report_issues_fields: CifField<number, ExportCtx>[] = [

+ 2 - 0
src/mol-model/structure/export/mmcif.ts

@@ -98,6 +98,8 @@ export function encode_mmCIF_categories(encoder: CifWriter.Encoder, structure: S
         encoder.writeCategory(cat, ctx);
     }
     for (const customProp of model.customProperties.all) {
+        if (!customProp.cifExport || customProp.cifExport.categories.length === 0) continue;
+
         const prefix = customProp.cifExport.prefix;
         const cats = customProp.cifExport.categories;
         for (const cat of cats) {

+ 1 - 1
src/mol-model/structure/model/properties/custom/descriptor.ts

@@ -12,7 +12,7 @@ interface ModelPropertyDescriptor<Symbols extends { [name: string]: QuerySymbolR
     readonly isStatic: boolean,
     readonly name: string,
 
-    cifExport: {
+    cifExport?: {
         // Prefix enforced during export.
         prefix: string,
         categories: CifWriter.Category<CifExportContext>[]