Browse Source

fix Loci stats for partial residue selections

Alexander Rose 5 years ago
parent
commit
d0189523e4

+ 10 - 22
src/mol-model/structure/structure/element/stats.ts

@@ -54,34 +54,22 @@ export namespace Stats {
                 while (i < size) {
                     const eI = elements[OrderedSet.getAt(indices, i)]
                     const rI = index[eI]
-                    if (offsets[rI] !== eI) {
-                        // partial residue, start missing
+                    while (i < size && index[elements[OrderedSet.getAt(indices, i)]] === rI) {
                         ++i
-                        stats.elementCount += 1
-                        while (i < size && index[elements[OrderedSet.getAt(indices, i)]] === rI) {
-                            ++i
-                            stats.elementCount += 1
-                        }
-                    } else {
-                        ++i
-                        while (i < size && index[elements[OrderedSet.getAt(indices, i)]] === rI) {
-                            ++i
-                        }
+                    }
 
-                        if (offsets[rI + 1] - 1 === elements[OrderedSet.getAt(indices, i - 1)]) {
-                            // full residue
-                            stats.residueCount += 1
-                            if (stats.residueCount === 1) {
-                                Location.set(stats.firstResidueLoc, unit, elements[OrderedSet.start(indices)])
-                            }
-                        } else {
-                            // partial residue, end missing
-                            stats.elementCount += offsets[rI + 1] - 1 - elements[OrderedSet.getAt(indices, i - 1)]
+                    if (offsets[rI + 1] - offsets[rI] === i) {
+                        // full residue
+                        stats.residueCount += 1
+                        if (stats.residueCount === 1) {
+                            Location.set(stats.firstResidueLoc, unit, elements[OrderedSet.start(indices)])
                         }
+                    } else {
+                        // partial residue
+                        stats.elementCount += i
                     }
                 }
             } else {
-                // TODO
                 stats.elementCount += size
                 if (stats.elementCount === 1) {
                     Location.set(stats.firstElementLoc, unit, elements[OrderedSet.start(indices)])

+ 1 - 1
src/mol-plugin/util/structure-selection-helper.ts

@@ -207,7 +207,7 @@ const surroundings = StructureSelectionQuery('Surrounding Residues (5 \u212B)',
     })
 ]), 'Select residues within 5 \u212B of the current selection.')
 
-const complement = StructureSelectionQuery('Complement', MS.struct.modifier.union([
+const complement = StructureSelectionQuery('Inverse / Complement', MS.struct.modifier.union([
     MS.struct.modifier.exceptBy({
         0: MS.struct.generator.all(),
         by: MS.internal.generator.current()