Ver Fonte

add unit kind helpers to Structure

Alexander Rose há 5 anos atrás
pai
commit
feab3a38f9
2 ficheiros alterados com 25 adições e 5 exclusões
  1. 24 4
      src/mol-model/structure/structure/structure.ts
  2. 1 1
      src/mol-repr/util.ts

+ 24 - 4
src/mol-model/structure/structure/structure.ts

@@ -149,8 +149,11 @@ class Structure {
         return this._props.atomicResidueCount;
     }
 
-    /** Coarse structure, defined as Containing less than twice as many elements as polymer residues */
-    get isCoarse() {
+    /**
+     * Coarse-grained structure, defined as containing less than
+     * twice as many elements as polymer residues
+     */
+    get isCoarseGrained() {
         const ec = this.elementCount
         const prc = this.polymerResidueCount
         return prc && ec ? ec / prc < 2 : false
@@ -271,13 +274,30 @@ class Structure {
             || (this._props.uniqueAtomicResidueIndices = getUniqueAtomicResidueIndices(this));
     }
 
+    /** Contains only atomic units */
     get isAtomic() {
-        for (const u of this.units) {
-            if (u.kind !== Unit.Kind.Atomic) return false;
+        for (const u of this.units) if (Unit.isAtomic(u)) return false;
+        return true;
         }
+
+    /** Contains some atomic units */
+    get hasAtomic() {
+        for (const u of this.units) if (Unit.isAtomic(u)) return true;
+        return false;
+    }
+
+    /** Contains only coarse units */
+    get isCoarse() {
+        for (const u of this.units) if (Unit.isCoarse(u)) return false;
         return true;
     }
 
+    /** Contains some coarse units */
+    get hasCoarse() {
+        for (const u of this.units) if (Unit.isCoarse(u)) return true;
+        return false;
+    }
+
     /**
      * Provides mapping for serial element indices accross all units.
      *

+ 1 - 1
src/mol-repr/util.ts

@@ -55,7 +55,7 @@ export interface QualityProps {
 
 export function getStructureQuality(structure: Structure): VisualQuality {
     let score = structure.elementCount
-    if (structure.isCoarse) score *= 10
+    if (structure.isCoarseGrained) score *= 10
     if (score > 500_000) {
         return 'lowest'
     } else if (score > 200_000) {