Browse Source

add bond location support to qmean & pLDDT color themes

Alexander Rose 3 years ago
parent
commit
8f06b603e6

+ 7 - 1
src/extensions/model-archive/quality-assessment/color/plddt.ts

@@ -8,7 +8,7 @@
 
 import { QualityAssessment, QualityAssessmentProvider } from '../prop';
 import { Location } from '../../../../mol-model/location';
-import { StructureElement, Unit } from '../../../../mol-model/structure';
+import { Bond, StructureElement, Unit } from '../../../../mol-model/structure';
 import { ColorTheme, LocationColor } from '../../../../mol-theme/color';
 import { ThemeDataContext } from '../../../../mol-theme/theme';
 import { Color } from '../../../../mol-util/color';
@@ -36,6 +36,8 @@ export function PLDDTConfidenceColorTheme(ctx: ThemeDataContext, props: PD.Value
     let color: LocationColor = () => DefaultColor;
 
     if (ctx.structure) {
+        const l = StructureElement.Location.create(ctx.structure.root);
+
         const getColor = (location: StructureElement.Location): Color => {
             const { unit, element } = location;
             if (!Unit.isAtomic(unit)) return DefaultColor;
@@ -57,6 +59,10 @@ export function PLDDTConfidenceColorTheme(ctx: ThemeDataContext, props: PD.Value
         color = (location: Location) => {
             if (StructureElement.Location.is(location)) {
                 return getColor(location);
+            } else if (Bond.isLocation(location)) {
+                l.unit = location.aUnit;
+                l.element = location.aUnit.elements[location.aIndex];
+                return getColor(l);
             }
             return DefaultColor;
         };

+ 7 - 1
src/extensions/model-archive/quality-assessment/color/qmean.ts

@@ -6,7 +6,7 @@
 
 import { QualityAssessment, QualityAssessmentProvider } from '../prop';
 import { Location } from '../../../../mol-model/location';
-import { StructureElement, Unit } from '../../../../mol-model/structure';
+import { Bond, StructureElement, Unit } from '../../../../mol-model/structure';
 import { ColorTheme, LocationColor } from '../../../../mol-theme/color';
 import { ThemeDataContext } from '../../../../mol-theme/theme';
 import { Color, ColorScale } from '../../../../mol-util/color';
@@ -31,6 +31,8 @@ export function QmeanScoreColorTheme(ctx: ThemeDataContext, props: PD.Values<Qme
     });
 
     if (ctx.structure) {
+        const l = StructureElement.Location.create(ctx.structure.root);
+
         const getColor = (location: StructureElement.Location): Color => {
             const { unit, element } = location;
             if (!Unit.isAtomic(unit)) return DefaultColor;
@@ -46,6 +48,10 @@ export function QmeanScoreColorTheme(ctx: ThemeDataContext, props: PD.Values<Qme
         color = (location: Location) => {
             if (StructureElement.Location.is(location)) {
                 return getColor(location);
+            } else if (Bond.isLocation(location)) {
+                l.unit = location.aUnit;
+                l.element = location.aUnit.elements[location.aIndex];
+                return getColor(l);
             }
             return DefaultColor;
         };