|
@@ -8,19 +8,24 @@ import { ThemeDataContext } from 'molstar/lib/mol-theme/theme';
|
|
|
import { ColorTheme } from 'molstar/lib/mol-theme/color';
|
|
|
import { ParamDefinition as PD } from 'molstar/lib/mol-util/param-definition';
|
|
|
import { Color } from 'molstar/lib/mol-util/color';
|
|
|
-import { StructureElement, StructureProperties, Structure } from 'molstar/lib/mol-model/structure';
|
|
|
+import { StructureElement, StructureProperties } from 'molstar/lib/mol-model/structure';
|
|
|
import { Location } from 'molstar/lib/mol-model/location';
|
|
|
-import { ColorLists } from 'molstar/lib/mol-util/color/lists';
|
|
|
-
|
|
|
-const DefaultColor = Color(0xCCCCCC);
|
|
|
|
|
|
export function SuperposeColorTheme(ctx: ThemeDataContext, props: {}): ColorTheme<{}> {
|
|
|
+ const colorLookup = ctx.structure?.inheritedPropertyData.colors;
|
|
|
|
|
|
- let colorLookup = ctx.structure?.inheritedPropertyData.colors;
|
|
|
+ const defaultColorLookup: Map<string, Color> = new Map();
|
|
|
+ for (let [asymId, seqIds] of Object.entries(colorLookup)) {
|
|
|
+ const colorValue = Array.from((seqIds as Map<number, Color>).values())[0];
|
|
|
+ const defaultColor = Color.desaturate(Color.lighten(colorValue, 1.7), 1.2);
|
|
|
+ defaultColorLookup.set(asymId, defaultColor);
|
|
|
+ }
|
|
|
|
|
|
- const index = Structure.Index.get(ctx.structure!).value || 0;
|
|
|
- const { list } = ColorLists['many-distinct']
|
|
|
- let colorCode = list[index % list.length];
|
|
|
+ let DefaultColor = Color(0xCCCCCC);
|
|
|
+ const colorValues: Color[] = Array.from(defaultColorLookup.values());
|
|
|
+ if (colorValues.every( (val, i, arr) => val === arr[0] )) {
|
|
|
+ DefaultColor = colorValues[0];
|
|
|
+ }
|
|
|
|
|
|
const color = (location: Location): Color => {
|
|
|
if (StructureElement.Location.is(location)) {
|
|
@@ -28,9 +33,10 @@ export function SuperposeColorTheme(ctx: ThemeDataContext, props: {}): ColorThem
|
|
|
const seqId = StructureProperties.residue.label_seq_id(location);
|
|
|
if (colorLookup?.[asymId]?.has(seqId)) {
|
|
|
if (colorLookup[asymId]?.get(seqId) !== undefined) {
|
|
|
- colorCode = colorLookup[asymId]?.get(seqId);
|
|
|
+ return colorLookup[asymId]?.get(seqId);
|
|
|
}
|
|
|
- return Array.isArray(colorCode) ? colorCode[0] : colorCode;
|
|
|
+ } else if (colorLookup?.[asymId]) {
|
|
|
+ return defaultColorLookup.get(asymId)!;
|
|
|
}
|
|
|
}
|
|
|
return DefaultColor;
|