Browse Source

Merge pull request #907 from JonStargaryen/ccd-aromatic

CCD extension: Make visuals for aromatic bonds configurable
Alexander Rose 1 year ago
parent
commit
c3daa1a162
2 changed files with 8 additions and 5 deletions
  1. 1 0
      CHANGELOG.md
  2. 7 5
      src/extensions/wwpdb/ccd/representation.ts

+ 1 - 0
CHANGELOG.md

@@ -8,6 +8,7 @@ Note that since we don't clearly distinguish between a public and private interf
 
 - Do not call `updateFocusRepr` if default `StructureFocusRepresentation` isn't present.
 - Treat "tap" as a click in `InputObserver`
+- CCD extension: Make visuals for aromatic bonds configurable
 - Add optional `file?: CifFile` to `MmcifFormat.data`
 
 ## [v3.39.0] - 2023-09-02

+ 7 - 5
src/extensions/wwpdb/ccd/representation.ts

@@ -22,6 +22,7 @@ const CCDParams = (a: PluginStateObject.Molecule.Trajectory | undefined, plugin:
     representationPresetParams: PD.Optional(PD.Group(StructureRepresentationPresetProvider.CommonParams)),
     showOriginalCoordinates: PD.Optional(PD.Boolean(true, { description: `Show original coordinates for 'model' and 'ideal' structure and do not align them.` })),
     shownCoordinateType: PD.Select('ideal', PD.arrayToOptions(['ideal', 'model', 'both'] as const), { description: `What coordinate sets are visible.` }),
+    aromaticBonds: PD.Boolean(false, { description: 'Display aromatic bonds with dashes' }),
     ...TrajectoryHierarchyPresetProvider.CommonParams(a, plugin)
 });
 
@@ -77,8 +78,8 @@ export const ChemicalCompontentTrajectoryHierarchyPreset = TrajectoryHierarchyPr
             }
         }
 
-        await builder.representation.applyPreset(idealStructureProperties, representationPreset, { ...representationPresetParams, coordinateType: 'ideal', isHidden: params.shownCoordinateType === 'model' });
-        await builder.representation.applyPreset(modelStructureProperties, representationPreset, { ...representationPresetParams, coordinateType: 'model', isHidden: params.shownCoordinateType === 'ideal' });
+        await builder.representation.applyPreset(idealStructureProperties, representationPreset, { ...representationPresetParams, aromaticBonds: params.aromaticBonds, coordinateType: 'ideal', isHidden: params.shownCoordinateType === 'model' });
+        await builder.representation.applyPreset(modelStructureProperties, representationPreset, { ...representationPresetParams, aromaticBonds: params.aromaticBonds, coordinateType: 'model', isHidden: params.shownCoordinateType === 'ideal' });
 
         return { models: [idealModel, modelModel], structures: [idealStructure, modelStructure] };
     }
@@ -134,14 +135,15 @@ export const ChemicalComponentPreset = StructureRepresentationPresetProvider({
     },
     params: () => ({
         ...StructureRepresentationPresetProvider.CommonParams,
+        aromaticBonds: PD.Boolean(true),
         coordinateType: PD.Select<CCDFormat.CoordinateType>('ideal', PD.arrayToOptions(['ideal', 'model'])),
-        isHidden: PD.Boolean(false)
+        isHidden: PD.Boolean(false),
     }),
     async apply(ref, params, plugin) {
         const structureCell = StateObjectRef.resolveAndCheck(plugin.state.data, ref);
         if (!structureCell) return {};
 
-        const { coordinateType, isHidden } = params;
+        const { aromaticBonds, coordinateType, isHidden } = params;
         const components = {
             [coordinateType]: await presetStaticComponent(plugin, structureCell, 'all', { label: capitalize(coordinateType), tags: [coordinateType] })
         };
@@ -150,7 +152,7 @@ export const ChemicalComponentPreset = StructureRepresentationPresetProvider({
         const { update, builder, typeParams } = StructureRepresentationPresetProvider.reprBuilder(plugin, params);
 
         const representations = {
-            [coordinateType]: builder.buildRepresentation(update, components[coordinateType], { type: 'ball-and-stick', typeParams }, { initialState: { isHidden } }),
+            [coordinateType]: builder.buildRepresentation(update, components[coordinateType], { type: 'ball-and-stick', typeParams: { ...typeParams, aromaticBonds } }, { initialState: { isHidden } }),
         };
         // sync UI state
         if (components[coordinateType]?.cell?.state && isHidden) {