Skip to content
Snippets Groups Projects
Commit e1b830a5 authored by Alexander Rose's avatar Alexander Rose
Browse files

improved atomicDetail preset

parent 41e1ac76
Branches
Tags
No related merge requests found
......@@ -56,9 +56,9 @@ export namespace StructConn {
* Heuristic to test if StructConn likely provides all atomic bonds by
* checking if the fraction of bonds and atoms is high (> 0.95).
*/
export function isExhaustive(model: Model) {
export function isExhaustive(model: Model): boolean {
const structConn = StructConn.Provider.get(model);
return structConn && (structConn.data.id.rowCount / model.atomicConformation.atomId.rowCount) > 0.95;
return !!structConn && (structConn.data.id.rowCount / model.atomicConformation.atomId.rowCount) > 0.95;
}
function hasAtom({ units }: Structure, element: ElementIndex) {
......
/**
* Copyright (c) 2019-2020 mol* contributors, licensed under MIT, See LICENSE file for more info.
* Copyright (c) 2019-2021 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author David Sehnal <david.sehnal@gmail.com>
* @author Alexander Rose <alexander.rose@weirdbyte.de>
......@@ -20,6 +20,8 @@ import { StructureFocusRepresentation } from '../../../mol-plugin/behavior/dynam
import { createStructureColorThemeParams } from '../../helpers/structure-representation-params';
import { ChainIdColorThemeProvider } from '../../../mol-theme/color/chain-id';
import { OperatorNameColorThemeProvider } from '../../../mol-theme/color/operator-name';
import { IndexPairBonds } from '../../../mol-model-formats/structure/property/bonds/index-pair';
import { StructConn } from '../../../mol-model-formats/structure/property/bonds/struct_conn';
export interface StructureRepresentationPresetProvider<P = any, S extends _Result = _Result> extends PresetProvider<PluginStateObject.Molecule.Structure, P, S> { }
export function StructureRepresentationPresetProvider<P, S extends _Result>(repr: StructureRepresentationPresetProvider<P, S>) { return repr; }
......@@ -332,8 +334,12 @@ const atomicDetail = StructureRepresentationPresetProvider({
structure.elementCount > 1000 &&
structure.atomicResidueCount / structure.elementCount < 3;
const atomicType = lowResidueElementRatio ? 'spacefill' :
highElementCount ? 'line' : 'ball-and-stick';
const m = structure.models[0];
const bondsGiven = !!IndexPairBonds.Provider.get(m) || StructConn.isExhaustive(m);
const atomicType = lowResidueElementRatio && !bondsGiven
? 'spacefill' : highElementCount
? 'line' : 'ball-and-stick';
const showCarbohydrateSymbol = params.showCarbohydrateSymbol && !highElementCount && !lowResidueElementRatio;
if (showCarbohydrateSymbol) {
......@@ -343,7 +349,7 @@ const atomicDetail = StructureRepresentationPresetProvider({
}
const { update, builder, typeParams, color, ballAndStickColor } = reprBuilder(plugin, params, structure);
const colorParams = lowResidueElementRatio
const colorParams = lowResidueElementRatio && !bondsGiven
? { carbonColor: { name: 'element-symbol', params: {} } }
: ballAndStickColor;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment