From 9de16699adaf241a678af5e287f918e9079bf1fd Mon Sep 17 00:00:00 2001 From: David Sehnal <david.sehnal@gmail.com> Date: Thu, 11 Oct 2018 15:10:32 +0200 Subject: [PATCH] mol-model: mmCIF export omit symmetry/asm related categories for "generated" structures --- src/mol-model/structure/export/categories/utils.ts | 5 +++-- src/mol-model/structure/export/mmcif.ts | 14 +++++++++----- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/mol-model/structure/export/categories/utils.ts b/src/mol-model/structure/export/categories/utils.ts index d33f72fac..d0a63367f 100644 --- a/src/mol-model/structure/export/categories/utils.ts +++ b/src/mol-model/structure/export/categories/utils.ts @@ -43,13 +43,14 @@ export function getUniqueEntityIndicesFromStructures(structures: Structure[]): R return ret.array; } -export function copy_mmCif_category(name: keyof mmCIF_Schema, condition?: (model: Model) => boolean): CifWriter.Category<CifExportContext> { +export function copy_mmCif_category(name: keyof mmCIF_Schema, condition?: (structure: Structure) => boolean): CifWriter.Category<CifExportContext> { return { name, instance({ structures }) { + if (condition && !condition(structures[0])) return CifWriter.Category.Empty; + const model = structures[0].model; if (model.sourceData.kind !== 'mmCIF') return CifWriter.Category.Empty; - if (condition && !condition(model)) return CifWriter.Category.Empty; const table = model.sourceData.data[name]; if (!table || !table._rowCount) return CifWriter.Category.Empty; diff --git a/src/mol-model/structure/export/mmcif.ts b/src/mol-model/structure/export/mmcif.ts index 5ed7dd4a4..e0c189ab4 100644 --- a/src/mol-model/structure/export/mmcif.ts +++ b/src/mol-model/structure/export/mmcif.ts @@ -43,6 +43,10 @@ const _entity: CifCategory<CifExportContext> = { } } +function isWithoutSymmetry(structure: Structure) { + return structure.units.every(u => u.conformation.operator.isIdentity) +} + const Categories = [ // Basics copy_mmCif_category('entry'), @@ -50,13 +54,13 @@ const Categories = [ _entity, // Symmetry - copy_mmCif_category('cell'), - copy_mmCif_category('symmetry'), + copy_mmCif_category('cell', isWithoutSymmetry), + copy_mmCif_category('symmetry', isWithoutSymmetry), // Assemblies - copy_mmCif_category('pdbx_struct_assembly'), - copy_mmCif_category('pdbx_struct_assembly_gen'), - copy_mmCif_category('pdbx_struct_oper_list'), + copy_mmCif_category('pdbx_struct_assembly', isWithoutSymmetry), + copy_mmCif_category('pdbx_struct_assembly_gen', isWithoutSymmetry), + copy_mmCif_category('pdbx_struct_oper_list', isWithoutSymmetry), // Secondary structure _struct_conf, -- GitLab