From 49840ec52fa8b7253e2eb8c10ef5620e1e7771c5 Mon Sep 17 00:00:00 2001 From: Alexander Rose <alex.rose@rcsb.org> Date: Tue, 27 Nov 2018 11:43:24 -0800 Subject: [PATCH] check if structure has gaps or nucleotides when setting default visuals --- src/mol-repr/structure/representation/cartoon.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/mol-repr/structure/representation/cartoon.ts b/src/mol-repr/structure/representation/cartoon.ts index ff3859fc6..5dfed8882 100644 --- a/src/mol-repr/structure/representation/cartoon.ts +++ b/src/mol-repr/structure/representation/cartoon.ts @@ -12,7 +12,7 @@ import { UnitsRepresentation } from '../units-representation'; import { StructureRepresentation, StructureRepresentationProvider } from '../representation'; import { Representation, RepresentationParamsGetter, RepresentationContext } from 'mol-repr/representation'; import { PolymerDirectionVisual, PolymerDirectionParams } from '../visual/polymer-direction-wedge'; -import { Structure } from 'mol-model/structure'; +import { Structure, Unit } from 'mol-model/structure'; import { ThemeRegistryContext } from 'mol-theme/theme'; const CartoonVisuals = { @@ -34,7 +34,17 @@ export const CartoonParams = { } export type CartoonParams = typeof CartoonParams export function getCartoonParams(ctx: ThemeRegistryContext, structure: Structure) { - return PD.clone(CartoonParams) + const params = PD.clone(CartoonParams) + let hasNucleotides = false + let hasGaps = false + structure.units.forEach(u => { + if (!hasNucleotides && Unit.isAtomic(u) && u.nucleotideElements.length) hasNucleotides = true + if (!hasGaps && u.gapElements.length) hasGaps = true + }) + params.visuals.defaultValue = ['polymer-trace'] + if (hasNucleotides) params.visuals.defaultValue.push('nucleotide-block') + if (hasGaps) params.visuals.defaultValue.push('polymer-gap') + return params } export type CartoonRepresentation = StructureRepresentation<CartoonParams> -- GitLab