Bladeren bron

atomic detail preset tweaks

- handle structures with low residue to element ratio
Alexander Rose 4 jaren geleden
bovenliggende
commit
37da82b138
1 gewijzigde bestanden met toevoegingen van 13 en 4 verwijderingen
  1. 13 4
      src/mol-plugin-state/builder/structure/representation-preset.ts

+ 13 - 4
src/mol-plugin-state/builder/structure/representation-preset.ts

@@ -316,9 +316,14 @@ const atomicDetail = StructureRepresentationPresetProvider({
         };
 
         const structure = structureCell.obj!.data;
-        const highElementCount = structure.elementCount > 200_000; // TODO make configurable
-        const atomicType = highElementCount ? 'line' : 'ball-and-stick';
-        const showCarbohydrateSymbol = params.showCarbohydrateSymbol && !highElementCount;
+        const highElementCount = structure.elementCount > 100_000; // TODO make configurable
+        const lowResidueElementRatio = structure.atomicResidueCount &&
+            structure.elementCount > 1000 &&
+            structure.atomicResidueCount / structure.elementCount < 3;
+
+        const atomicType = lowResidueElementRatio ? 'spacefill' :
+            highElementCount ? 'line' : 'ball-and-stick';
+        const showCarbohydrateSymbol = params.showCarbohydrateSymbol && !highElementCount && !lowResidueElementRatio;
 
         if (showCarbohydrateSymbol) {
             Object.assign(components, {
@@ -327,8 +332,12 @@ const atomicDetail = StructureRepresentationPresetProvider({
         }
 
         const { update, builder, typeParams, color, ballAndStickColor } = reprBuilder(plugin, params);
+        const colorParams = lowResidueElementRatio
+            ? { carbonColor: { name: 'element-symbol', params: {} } }
+            : ballAndStickColor;
+
         const representations = {
-            all: builder.buildRepresentation(update, components.all, { type: atomicType, typeParams, color, colorParams: ballAndStickColor }, { tag: 'all' }),
+            all: builder.buildRepresentation(update, components.all, { type: atomicType, typeParams, color, colorParams }, { tag: 'all' }),
         };
         if (showCarbohydrateSymbol) {
             Object.assign(representations, {