Ver código fonte

Issue #967: auth_asym_id - label_asym_id conflict resolved in overpaint requests

cycle20 5 meses atrás
pai
commit
be4eae65ec

+ 14 - 8
src/Tm3DStandaloneApp/tmdet-viewer/TmViewerStandalone.ts

@@ -81,14 +81,24 @@ export class TmViewerStandalone extends Viewer {
 
     /**
      * Util function to handle overpaint logic.
-     * @param labelAsymId 
+     * @param labelAsymId if empty, it clears the overpaint color
      * @param hexRgb default color grey, when it is false
      * @param clear if true, it clears the overpaint color
      */
     protected overPaint(labelAsymIds: string[], hexRgb: string|false = false, clear: boolean = false) {
+
+        let script: string;
         if (labelAsymIds.length == 0) {
-            console.warn('No specified chain(s) for overpaintings');
-            return;
+            // switching to clear mode to reset overpaint,
+            // if there is no overpaint request for any chain
+            clear = true;
+            script = `(sel.atom.all)`;
+        } else {
+            const chainList = labelAsymIds.join(' ');
+            script = `(sel.atom.atom-groups :chain-test
+                        (or (set.has (set ${chainList}) atom.auth_asym_id)
+                            (set.has (set ${chainList}) atom.label_asym_id))
+            )`;
         }
 
         const state = this.plugin.state.data;
@@ -99,16 +109,12 @@ export class TmViewerStandalone extends Viewer {
             return;
         }
 
-        const chainList = labelAsymIds.join(' ');
         selected.forEach(async (representation) => {
             const update = this.plugin.build().to(representation);
             update.apply(StateTransforms.Representation.OverpaintStructureRepresentation3DFromScript, {
                 layers: [
                     {
-                        script:  Script(
-                            `(sel.atom.atom-groups :chain-test (set.has (set ${chainList}) atom.label_asym_id))`,
-                            'mol-script'
-                        ),
+                        script:  Script(script, 'mol-script'),
                         color:  hexRgb !== false ? Color.fromHexString(hexRgb) : ColorNames.white,
                         clear: clear
                     }