Browse Source

fix stats for single element in multi-chain unit

- observe in, e.g., label for water molecule in 3pqr
Alexander Rose 3 years ago
parent
commit
6294ef2db2
2 changed files with 8 additions and 0 deletions
  1. 1 0
      CHANGELOG.md
  2. 7 0
      src/mol-model/structure/structure/element/stats.ts

+ 1 - 0
CHANGELOG.md

@@ -9,6 +9,7 @@ Note that since we don't clearly distinguish between a public and private interf
 - Add PDBj as a ``pdb-provider`` option
 - Move Viewer APP to a separate file to allow use without importing light theme & index.html
 - Add symmetry support for mol2 files (only spacegroup setting 1)
+- Fix label/stats of single atom selection in multi-chain units
 
 ## [v3.0.0-dev.8] - 2021-12-31
 

+ 7 - 0
src/mol-model/structure/structure/element/stats.ts

@@ -72,6 +72,7 @@ export namespace Stats {
             }
         } else if (size === 1) {
             if (Unit.Traits.is(unit.traits, Unit.Trait.MultiChain)) {
+                // handled in `handleUnitChainsSimple`
                 return;
             } else {
                 stats.elementCount += 1;
@@ -193,6 +194,12 @@ export namespace Stats {
                 if (stats.chainCount === 1) {
                     Location.set(stats.firstChainLoc, structure, unit, offsets[cI]);
                 }
+            } else if (size === 1) {
+                // need to handle here, skipped in `handleElement`
+                stats.elementCount += 1;
+                if (stats.elementCount === 1) {
+                    Location.set(stats.firstElementLoc, structure, unit, eI);
+                }
             }
         }
     }