From feb69f498778b5c064e3eb571ffbaff03a64122e Mon Sep 17 00:00:00 2001
From: Jason Pattle <jpattle@exscientia.co.uk>
Date: Wed, 2 Nov 2022 09:49:44 +0000
Subject: [PATCH] Excluded whole residues which match any common protein caps
 from the ligand selection query

---
 .../helpers/structure-selection-query.ts      | 29 +++++++++++++------
 1 file changed, 20 insertions(+), 9 deletions(-)

diff --git a/src/mol-plugin-state/helpers/structure-selection-query.ts b/src/mol-plugin-state/helpers/structure-selection-query.ts
index 8f7edc975..421e09f7a 100644
--- a/src/mol-plugin-state/helpers/structure-selection-query.ts
+++ b/src/mol-plugin-state/helpers/structure-selection-query.ts
@@ -7,7 +7,7 @@
 
 import { CustomProperty } from '../../mol-model-props/common/custom-property';
 import { QueryContext, Structure, StructureQuery, StructureSelection, StructureProperties, StructureElement } from '../../mol-model/structure';
-import { BondType, NucleicBackboneAtoms, ProteinBackboneAtoms, SecondaryStructureType, AminoAcidNamesL, RnaBaseNames, DnaBaseNames, WaterNames, ElementSymbol, PolymerNames } from '../../mol-model/structure/model/types';
+import { BondType, NucleicBackboneAtoms, ProteinBackboneAtoms, SecondaryStructureType, AminoAcidNamesL, RnaBaseNames, DnaBaseNames, WaterNames, ElementSymbol, PolymerNames, CommonProteinCaps } from '../../mol-model/structure/model/types';
 import { PluginContext } from '../../mol-plugin/context';
 import { MolScriptBuilder as MS } from '../../mol-script/language/builder';
 import { Expression } from '../../mol-script/language/expression';
@@ -350,14 +350,25 @@ const ligand = StructureSelectionQuery('Ligand', MS.struct.modifier.union([
                 ])
             ]),
         ]),
-        by: MS.struct.modifier.union([
-            MS.struct.generator.atomGroups({
-                'entity-test': MS.core.rel.eq([MS.ammp('entityType'), 'polymer']),
-                'chain-test': MS.core.rel.eq([MS.ammp('objectPrimitive'), 'atomistic']),
-                'residue-test': MS.core.set.has([
-                    MS.set(...SetUtils.toArray(PolymerNames)), MS.ammp('label_comp_id')
-                ])
-            })
+        by: MS.struct.combinator.merge([
+            MS.struct.modifier.union([
+                MS.struct.generator.atomGroups({
+                    'entity-test': MS.core.rel.eq([MS.ammp('entityType'), 'polymer']),
+                    'chain-test': MS.core.rel.eq([MS.ammp('objectPrimitive'), 'atomistic']),
+                    'residue-test': MS.core.set.has([
+                        MS.set(...SetUtils.toArray(PolymerNames)), MS.ammp('label_comp_id')
+                    ])
+                }),
+            ]),
+            MS.struct.modifier.wholeResidues({
+                0: MS.struct.generator.atomGroups({
+                    'chain-test': MS.core.rel.eq([MS.ammp('objectPrimitive'), 'atomistic']),
+                    'residue-test': MS.core.set.has([
+                        MS.set(...SetUtils.toArray(CommonProteinCaps)),
+                        MS.ammp('label_comp_id'),
+                    ]),
+                }),
+            }),
         ])
     })
 ]), { category: StructureSelectionCategory.Type });
-- 
GitLab