Browse Source

RO-2605: check for single space-group & NCS operator

Sebastian Bittrich 3 years ago
parent
commit
f526bf93ef
2 changed files with 16 additions and 1 deletions
  1. 3 0
      CHANGELOG.md
  2. 13 1
      src/viewer/ui/strucmotif.tsx

+ 3 - 0
CHANGELOG.md

@@ -13,6 +13,9 @@
 ### General
 - Mol* 3.0.2
 
+### Bug fixes
+- RO-2605: check for single space-group & NCS operator
+
 ## [2.0.9] - 2022-01-24
 ### General
 - Update to Mol* 3.0.0 

+ 13 - 1
src/viewer/ui/strucmotif.tsx

@@ -97,7 +97,10 @@ class SubmitControls extends PurePluginUIComponent<{}, { isBusy: boolean, residu
 
     submitSearch = () => {
         const { label_atom_id, x, y, z } = StructureProperties.atom;
+        // keep track of seen pdbIds, space-groups, and NCS operators - motifs can only have a single value
         const pdbId: Set<string> = new Set();
+        const sg: Set<number> = new Set();
+        const ncs: Set<number> = new Set();
         const residueIds: ResidueSelection[] = [];
         const exchanges: Exchange[] = [];
         const coordinates: { coords: Vec3, residueId: ResidueSelection }[] = [];
@@ -134,6 +137,8 @@ class SubmitControls extends PurePluginUIComponent<{}, { isBusy: boolean, residu
             const l = loci[i];
             const { structure, elements } = l.loci;
             pdbId.add(structure.model.entry);
+            sg.add(StructureProperties.unit.spgrOp(location));
+            ncs.add(StructureProperties.unit.struct_ncs_oper_id(location));
 
             const struct_oper_list_ids = StructureProperties.unit.pdbx_struct_oper_list_ids(location);
             const struct_oper_id = join(struct_oper_list_ids);
@@ -145,7 +150,6 @@ class SubmitControls extends PurePluginUIComponent<{}, { isBusy: boolean, residu
             }
 
             // handle pure residue-info
-            // TODO honor NCS operators: StructureProperties.unit.struct_ncs_oper_id(location);
             const residueId = {
                 label_asym_id: StructureProperties.chain.label_asym_id(location),
                 // can be empty array if model is selected
@@ -173,6 +177,14 @@ class SubmitControls extends PurePluginUIComponent<{}, { isBusy: boolean, residu
             alert('Motifs can only be extracted from a single model!');
             return;
         }
+        if (sg.size > 1) {
+            alert('Motifs can only appear in a single space-group!');
+            return;
+        }
+        if (ncs.size > 1) {
+            alert('All motif residues must have matching NCS operators!');
+            return;
+        }
         if (residueIds.length > MAX_MOTIF_SIZE) {
             alert(`Maximum motif size is ${MAX_MOTIF_SIZE} residues!`);
             return;