app.ts 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494
  1. /**
  2. * Copyright (c) 2018-2022 mol* contributors, licensed under MIT, See LICENSE file for more info.
  3. *
  4. * @author David Sehnal <david.sehnal@gmail.com>
  5. * @author Alexander Rose <alexander.rose@weirdbyte.de>
  6. */
  7. import { ANVILMembraneOrientation } from '../../extensions/anvil/behavior';
  8. import { CellPack } from '../../extensions/cellpack';
  9. import { DnatcoConfalPyramids } from '../../extensions/dnatco';
  10. import { G3DFormat, G3dProvider } from '../../extensions/g3d/format';
  11. import { GeometryExport } from '../../extensions/geo-export';
  12. import { MAQualityAssessment } from '../../extensions/model-archive/quality-assessment/behavior';
  13. import { QualityAssessmentPLDDTPreset, QualityAssessmentQmeanPreset } from '../../extensions/model-archive/quality-assessment/behavior';
  14. import { QualityAssessment } from '../../extensions/model-archive/quality-assessment/prop';
  15. import { ModelExport } from '../../extensions/model-export';
  16. import { Mp4Export } from '../../extensions/mp4-export';
  17. import { PDBeStructureQualityReport } from '../../extensions/pdbe';
  18. import { RCSBAssemblySymmetry, RCSBValidationReport } from '../../extensions/rcsb';
  19. import { ZenodoImport } from '../../extensions/zenodo';
  20. import { Volume } from '../../mol-model/volume';
  21. import { DownloadStructure, PdbDownloadProvider } from '../../mol-plugin-state/actions/structure';
  22. import { DownloadDensity } from '../../mol-plugin-state/actions/volume';
  23. import { PresetTrajectoryHierarchy } from '../../mol-plugin-state/builder/structure/hierarchy-preset';
  24. import { PresetStructureRepresentations, StructureRepresentationPresetProvider } from '../../mol-plugin-state/builder/structure/representation-preset';
  25. import { DataFormatProvider } from '../../mol-plugin-state/formats/provider';
  26. import { BuiltInTopologyFormat } from '../../mol-plugin-state/formats/topology';
  27. import { BuiltInCoordinatesFormat } from '../../mol-plugin-state/formats/coordinates';
  28. import { BuiltInTrajectoryFormat } from '../../mol-plugin-state/formats/trajectory';
  29. import { BuildInVolumeFormat } from '../../mol-plugin-state/formats/volume';
  30. import { createVolumeRepresentationParams } from '../../mol-plugin-state/helpers/volume-representation-params';
  31. import { PluginStateObject } from '../../mol-plugin-state/objects';
  32. import { StateTransforms } from '../../mol-plugin-state/transforms';
  33. import { TrajectoryFromModelAndCoordinates } from '../../mol-plugin-state/transforms/model';
  34. import { createPluginUI } from '../../mol-plugin-ui/react18';
  35. import { PluginUIContext } from '../../mol-plugin-ui/context';
  36. import { DefaultPluginUISpec, PluginUISpec } from '../../mol-plugin-ui/spec';
  37. import { PluginCommands } from '../../mol-plugin/commands';
  38. import { PluginConfig } from '../../mol-plugin/config';
  39. import { PluginLayoutControlsDisplay } from '../../mol-plugin/layout';
  40. import { PluginSpec } from '../../mol-plugin/spec';
  41. import { PluginState } from '../../mol-plugin/state';
  42. import { StateObjectRef, StateObjectSelector } from '../../mol-state';
  43. import { Asset } from '../../mol-util/assets';
  44. import { Color } from '../../mol-util/color';
  45. import '../../mol-util/polyfill';
  46. import { ObjectKeys } from '../../mol-util/type-helpers';
  47. export { PLUGIN_VERSION as version } from '../../mol-plugin/version';
  48. export { setDebugMode, setProductionMode } from '../../mol-util/debug';
  49. const CustomFormats = [
  50. ['g3d', G3dProvider] as const
  51. ];
  52. const Extensions = {
  53. 'cellpack': PluginSpec.Behavior(CellPack),
  54. 'dnatco-confal-pyramids': PluginSpec.Behavior(DnatcoConfalPyramids),
  55. 'pdbe-structure-quality-report': PluginSpec.Behavior(PDBeStructureQualityReport),
  56. 'rcsb-assembly-symmetry': PluginSpec.Behavior(RCSBAssemblySymmetry),
  57. 'rcsb-validation-report': PluginSpec.Behavior(RCSBValidationReport),
  58. 'anvil-membrane-orientation': PluginSpec.Behavior(ANVILMembraneOrientation),
  59. 'g3d': PluginSpec.Behavior(G3DFormat),
  60. 'model-export': PluginSpec.Behavior(ModelExport),
  61. 'mp4-export': PluginSpec.Behavior(Mp4Export),
  62. 'geo-export': PluginSpec.Behavior(GeometryExport),
  63. 'ma-quality-assessment': PluginSpec.Behavior(MAQualityAssessment),
  64. 'zenodo-import': PluginSpec.Behavior(ZenodoImport),
  65. };
  66. const DefaultViewerOptions = {
  67. customFormats: CustomFormats as [string, DataFormatProvider][],
  68. extensions: ObjectKeys(Extensions),
  69. layoutIsExpanded: true,
  70. layoutShowControls: true,
  71. layoutShowRemoteState: true,
  72. layoutControlsDisplay: 'reactive' as PluginLayoutControlsDisplay,
  73. layoutShowSequence: true,
  74. layoutShowLog: true,
  75. layoutShowLeftPanel: true,
  76. collapseLeftPanel: false,
  77. collapseRightPanel: false,
  78. disableAntialiasing: PluginConfig.General.DisableAntialiasing.defaultValue,
  79. pixelScale: PluginConfig.General.PixelScale.defaultValue,
  80. pickScale: PluginConfig.General.PickScale.defaultValue,
  81. pickPadding: PluginConfig.General.PickPadding.defaultValue,
  82. enableWboit: PluginConfig.General.EnableWboit.defaultValue,
  83. preferWebgl1: PluginConfig.General.PreferWebGl1.defaultValue,
  84. viewportShowExpand: PluginConfig.Viewport.ShowExpand.defaultValue,
  85. viewportShowControls: PluginConfig.Viewport.ShowControls.defaultValue,
  86. viewportShowSettings: PluginConfig.Viewport.ShowSettings.defaultValue,
  87. viewportShowSelectionMode: PluginConfig.Viewport.ShowSelectionMode.defaultValue,
  88. viewportShowAnimation: PluginConfig.Viewport.ShowAnimation.defaultValue,
  89. pluginStateServer: PluginConfig.State.DefaultServer.defaultValue,
  90. volumeStreamingServer: PluginConfig.VolumeStreaming.DefaultServer.defaultValue,
  91. volumeStreamingDisabled: !PluginConfig.VolumeStreaming.Enabled.defaultValue,
  92. pdbProvider: PluginConfig.Download.DefaultPdbProvider.defaultValue,
  93. emdbProvider: PluginConfig.Download.DefaultEmdbProvider.defaultValue,
  94. };
  95. type ViewerOptions = typeof DefaultViewerOptions;
  96. export class Viewer {
  97. constructor(public plugin: PluginUIContext) {
  98. }
  99. static async create(elementOrId: string | HTMLElement, options: Partial<ViewerOptions> = {}) {
  100. const definedOptions = {} as any;
  101. // filter for defined properies only so the default values
  102. // are property applied
  103. for (const p of Object.keys(options) as (keyof ViewerOptions)[]) {
  104. if (options[p] !== void 0) definedOptions[p] = options[p];
  105. }
  106. const o: ViewerOptions = { ...DefaultViewerOptions, ...definedOptions };
  107. const defaultSpec = DefaultPluginUISpec();
  108. const spec: PluginUISpec = {
  109. actions: defaultSpec.actions,
  110. behaviors: [
  111. ...defaultSpec.behaviors,
  112. ...o.extensions.map(e => Extensions[e]),
  113. ],
  114. animations: [...defaultSpec.animations || []],
  115. customParamEditors: defaultSpec.customParamEditors,
  116. customFormats: o?.customFormats,
  117. layout: {
  118. initial: {
  119. isExpanded: o.layoutIsExpanded,
  120. showControls: o.layoutShowControls,
  121. controlsDisplay: o.layoutControlsDisplay,
  122. regionState: {
  123. bottom: 'full',
  124. left: o.collapseLeftPanel ? 'collapsed' : 'full',
  125. right: o.collapseRightPanel ? 'hidden' : 'full',
  126. top: 'full',
  127. }
  128. },
  129. },
  130. components: {
  131. ...defaultSpec.components,
  132. controls: {
  133. ...defaultSpec.components?.controls,
  134. top: o.layoutShowSequence ? undefined : 'none',
  135. bottom: o.layoutShowLog ? undefined : 'none',
  136. left: o.layoutShowLeftPanel ? undefined : 'none',
  137. },
  138. remoteState: o.layoutShowRemoteState ? 'default' : 'none',
  139. },
  140. config: [
  141. [PluginConfig.General.DisableAntialiasing, o.disableAntialiasing],
  142. [PluginConfig.General.PixelScale, o.pixelScale],
  143. [PluginConfig.General.PickScale, o.pickScale],
  144. [PluginConfig.General.PickPadding, o.pickPadding],
  145. [PluginConfig.General.EnableWboit, o.enableWboit],
  146. [PluginConfig.General.PreferWebGl1, o.preferWebgl1],
  147. [PluginConfig.Viewport.ShowExpand, o.viewportShowExpand],
  148. [PluginConfig.Viewport.ShowControls, o.viewportShowControls],
  149. [PluginConfig.Viewport.ShowSettings, o.viewportShowSettings],
  150. [PluginConfig.Viewport.ShowSelectionMode, o.viewportShowSelectionMode],
  151. [PluginConfig.Viewport.ShowAnimation, o.viewportShowAnimation],
  152. [PluginConfig.State.DefaultServer, o.pluginStateServer],
  153. [PluginConfig.State.CurrentServer, o.pluginStateServer],
  154. [PluginConfig.VolumeStreaming.DefaultServer, o.volumeStreamingServer],
  155. [PluginConfig.VolumeStreaming.Enabled, !o.volumeStreamingDisabled],
  156. [PluginConfig.Download.DefaultPdbProvider, o.pdbProvider],
  157. [PluginConfig.Download.DefaultEmdbProvider, o.emdbProvider],
  158. [PluginConfig.Structure.DefaultRepresentationPreset, ViewerAutoPreset.id],
  159. ]
  160. };
  161. const element = typeof elementOrId === 'string'
  162. ? document.getElementById(elementOrId)
  163. : elementOrId;
  164. if (!element) throw new Error(`Could not get element with id '${elementOrId}'`);
  165. const plugin = await createPluginUI(element, spec, {
  166. onBeforeUIRender: plugin => {
  167. // the preset needs to be added before the UI renders otherwise
  168. // "Download Structure" wont be able to pick it up
  169. plugin.builders.structure.representation.registerPreset(ViewerAutoPreset);
  170. }
  171. });
  172. return new Viewer(plugin);
  173. }
  174. setRemoteSnapshot(id: string) {
  175. const url = `${this.plugin.config.get(PluginConfig.State.CurrentServer)}/get/${id}`;
  176. return PluginCommands.State.Snapshots.Fetch(this.plugin, { url });
  177. }
  178. loadSnapshotFromUrl(url: string, type: PluginState.SnapshotType) {
  179. return PluginCommands.State.Snapshots.OpenUrl(this.plugin, { url, type });
  180. }
  181. loadStructureFromUrl(url: string, format: BuiltInTrajectoryFormat = 'mmcif', isBinary = false, options?: LoadStructureOptions) {
  182. const params = DownloadStructure.createDefaultParams(this.plugin.state.data.root.obj!, this.plugin);
  183. return this.plugin.runTask(this.plugin.state.data.applyAction(DownloadStructure, {
  184. source: {
  185. name: 'url',
  186. params: {
  187. url: Asset.Url(url),
  188. format: format as any,
  189. isBinary,
  190. options: { ...params.source.params.options, representationParams: options?.representationParams as any },
  191. }
  192. }
  193. }));
  194. }
  195. async loadAllModelsOrAssemblyFromUrl(url: string, format: BuiltInTrajectoryFormat = 'mmcif', isBinary = false, options?: LoadStructureOptions) {
  196. const plugin = this.plugin;
  197. const data = await plugin.builders.data.download({ url, isBinary }, { state: { isGhost: true } });
  198. const trajectory = await plugin.builders.structure.parseTrajectory(data, format);
  199. await this.plugin.builders.structure.hierarchy.applyPreset(trajectory, 'all-models', { useDefaultIfSingleModel: true, representationPresetParams: options?.representationParams });
  200. }
  201. async loadStructureFromData(data: string | number[], format: BuiltInTrajectoryFormat, options?: { dataLabel?: string }) {
  202. const _data = await this.plugin.builders.data.rawData({ data, label: options?.dataLabel });
  203. const trajectory = await this.plugin.builders.structure.parseTrajectory(_data, format);
  204. await this.plugin.builders.structure.hierarchy.applyPreset(trajectory, 'default');
  205. }
  206. loadPdb(pdb: string, options?: LoadStructureOptions) {
  207. const params = DownloadStructure.createDefaultParams(this.plugin.state.data.root.obj!, this.plugin);
  208. const provider = this.plugin.config.get(PluginConfig.Download.DefaultPdbProvider)!;
  209. return this.plugin.runTask(this.plugin.state.data.applyAction(DownloadStructure, {
  210. source: {
  211. name: 'pdb' as const,
  212. params: {
  213. provider: {
  214. id: pdb,
  215. server: {
  216. name: provider,
  217. params: PdbDownloadProvider[provider].defaultValue as any
  218. }
  219. },
  220. options: { ...params.source.params.options, representationParams: options?.representationParams as any },
  221. }
  222. }
  223. }));
  224. }
  225. loadPdbDev(pdbDev: string) {
  226. const params = DownloadStructure.createDefaultParams(this.plugin.state.data.root.obj!, this.plugin);
  227. return this.plugin.runTask(this.plugin.state.data.applyAction(DownloadStructure, {
  228. source: {
  229. name: 'pdb-dev' as const,
  230. params: {
  231. provider: {
  232. id: pdbDev,
  233. encoding: 'bcif',
  234. },
  235. options: params.source.params.options,
  236. }
  237. }
  238. }));
  239. }
  240. loadEmdb(emdb: string, options?: { detail?: number }) {
  241. const provider = this.plugin.config.get(PluginConfig.Download.DefaultEmdbProvider)!;
  242. return this.plugin.runTask(this.plugin.state.data.applyAction(DownloadDensity, {
  243. source: {
  244. name: 'pdb-emd-ds' as const,
  245. params: {
  246. provider: {
  247. id: emdb,
  248. server: provider,
  249. },
  250. detail: options?.detail ?? 3,
  251. }
  252. }
  253. }));
  254. }
  255. loadAlphaFoldDb(afdb: string) {
  256. const params = DownloadStructure.createDefaultParams(this.plugin.state.data.root.obj!, this.plugin);
  257. return this.plugin.runTask(this.plugin.state.data.applyAction(DownloadStructure, {
  258. source: {
  259. name: 'alphafolddb' as const,
  260. params: {
  261. id: afdb,
  262. options: {
  263. ...params.source.params.options,
  264. representation: 'preset-structure-representation-ma-quality-assessment-plddt'
  265. },
  266. }
  267. }
  268. }));
  269. }
  270. loadModelArchive(id: string) {
  271. const params = DownloadStructure.createDefaultParams(this.plugin.state.data.root.obj!, this.plugin);
  272. return this.plugin.runTask(this.plugin.state.data.applyAction(DownloadStructure, {
  273. source: {
  274. name: 'modelarchive' as const,
  275. params: {
  276. id,
  277. options: params.source.params.options,
  278. }
  279. }
  280. }));
  281. }
  282. /**
  283. * @example Load X-ray density from volume server
  284. viewer.loadVolumeFromUrl({
  285. url: 'https://www.ebi.ac.uk/pdbe/densities/x-ray/1tqn/cell?detail=3',
  286. format: 'dscif',
  287. isBinary: true
  288. }, [{
  289. type: 'relative',
  290. value: 1.5,
  291. color: 0x3362B2
  292. }, {
  293. type: 'relative',
  294. value: 3,
  295. color: 0x33BB33,
  296. volumeIndex: 1
  297. }, {
  298. type: 'relative',
  299. value: -3,
  300. color: 0xBB3333,
  301. volumeIndex: 1
  302. }], {
  303. entryId: ['2FO-FC', 'FO-FC'],
  304. isLazy: true
  305. });
  306. * *********************
  307. * @example Load EM density from volume server
  308. viewer.loadVolumeFromUrl({
  309. url: 'https://maps.rcsb.org/em/emd-30210/cell?detail=6',
  310. format: 'dscif',
  311. isBinary: true
  312. }, [{
  313. type: 'relative',
  314. value: 1,
  315. color: 0x3377aa
  316. }], {
  317. entryId: 'EMD-30210',
  318. isLazy: true
  319. });
  320. */
  321. async loadVolumeFromUrl({ url, format, isBinary }: { url: string, format: BuildInVolumeFormat, isBinary: boolean }, isovalues: VolumeIsovalueInfo[], options?: { entryId?: string | string[], isLazy?: boolean }) {
  322. const plugin = this.plugin;
  323. if (!plugin.dataFormats.get(format)) {
  324. throw new Error(`Unknown density format: ${format}`);
  325. }
  326. if (options?.isLazy) {
  327. const update = this.plugin.build();
  328. update.toRoot().apply(StateTransforms.Data.LazyVolume, {
  329. url,
  330. format,
  331. entryId: options?.entryId,
  332. isBinary,
  333. isovalues: isovalues.map(v => ({ alpha: 1, volumeIndex: 0, ...v }))
  334. });
  335. return update.commit();
  336. }
  337. return plugin.dataTransaction(async () => {
  338. const data = await plugin.builders.data.download({ url, isBinary }, { state: { isGhost: true } });
  339. const parsed = await plugin.dataFormats.get(format)!.parse(plugin, data, { entryId: options?.entryId });
  340. const firstVolume = (parsed.volume || parsed.volumes[0]) as StateObjectSelector<PluginStateObject.Volume.Data>;
  341. if (!firstVolume?.isOk) throw new Error('Failed to parse any volume.');
  342. const repr = plugin.build();
  343. for (const iso of isovalues) {
  344. const volume: StateObjectSelector<PluginStateObject.Volume.Data> = parsed.volumes?.[iso.volumeIndex ?? 0] ?? parsed.volume;
  345. const volumeData = volume.cell!.obj!.data;
  346. repr
  347. .to(volume)
  348. .apply(StateTransforms.Representation.VolumeRepresentation3D, createVolumeRepresentationParams(this.plugin, firstVolume.data!, {
  349. type: 'isosurface',
  350. typeParams: { alpha: iso.alpha ?? 1, isoValue: Volume.adjustedIsoValue(volumeData, iso.value, iso.type) },
  351. color: 'uniform',
  352. colorParams: { value: iso.color }
  353. }));
  354. }
  355. await repr.commit();
  356. });
  357. }
  358. /**
  359. * @example
  360. * viewer.loadTrajectory({
  361. * model: { kind: 'model-url', url: 'villin.gro', format: 'gro' },
  362. * coordinates: { kind: 'coordinates-url', url: 'villin.xtc', format: 'xtc', isBinary: true },
  363. * preset: 'all-models' // or 'default'
  364. * });
  365. */
  366. async loadTrajectory(params: LoadTrajectoryParams) {
  367. const plugin = this.plugin;
  368. let model: StateObjectSelector, coords: StateObjectSelector;
  369. if (params.model.kind === 'model-data' || params.model.kind === 'model-url') {
  370. const data = params.model.kind === 'model-data'
  371. ? await plugin.builders.data.rawData({ data: params.model.data, label: params.modelLabel })
  372. : await plugin.builders.data.download({ url: params.model.url, isBinary: params.model.isBinary, label: params.modelLabel });
  373. const trajectory = await plugin.builders.structure.parseTrajectory(data, params.model.format ?? 'mmcif');
  374. model = await plugin.builders.structure.createModel(trajectory);
  375. } else {
  376. const data = params.model.kind === 'topology-data'
  377. ? await plugin.builders.data.rawData({ data: params.model.data, label: params.modelLabel })
  378. : await plugin.builders.data.download({ url: params.model.url, isBinary: params.model.isBinary, label: params.modelLabel });
  379. const provider = plugin.dataFormats.get(params.model.format);
  380. model = await provider!.parse(plugin, data);
  381. }
  382. {
  383. const data = params.coordinates.kind === 'coordinates-data'
  384. ? await plugin.builders.data.rawData({ data: params.coordinates.data, label: params.coordinatesLabel })
  385. : await plugin.builders.data.download({ url: params.coordinates.url, isBinary: params.coordinates.isBinary, label: params.coordinatesLabel });
  386. const provider = plugin.dataFormats.get(params.coordinates.format);
  387. coords = await provider!.parse(plugin, data);
  388. }
  389. const trajectory = await plugin.build().toRoot()
  390. .apply(TrajectoryFromModelAndCoordinates, {
  391. modelRef: model.ref,
  392. coordinatesRef: coords.ref
  393. }, { dependsOn: [model.ref, coords.ref] })
  394. .commit();
  395. const preset = await plugin.builders.structure.hierarchy.applyPreset(trajectory, params.preset ?? 'default');
  396. return { model, coords, preset };
  397. }
  398. handleResize() {
  399. this.plugin.layout.events.updated.next(void 0);
  400. }
  401. }
  402. export interface LoadStructureOptions {
  403. representationParams?: StructureRepresentationPresetProvider.CommonParams
  404. }
  405. export interface VolumeIsovalueInfo {
  406. type: 'absolute' | 'relative',
  407. value: number,
  408. color: Color,
  409. alpha?: number,
  410. volumeIndex?: number
  411. }
  412. export interface LoadTrajectoryParams {
  413. model: { kind: 'model-url', url: string, format?: BuiltInTrajectoryFormat /* mmcif */, isBinary?: boolean }
  414. | { kind: 'model-data', data: string | number[] | ArrayBuffer | Uint8Array, format?: BuiltInTrajectoryFormat /* mmcif */ }
  415. | { kind: 'topology-url', url: string, format: BuiltInTopologyFormat, isBinary?: boolean }
  416. | { kind: 'topology-data', data: string | number[] | ArrayBuffer | Uint8Array, format: BuiltInTopologyFormat },
  417. modelLabel?: string,
  418. coordinates: { kind: 'coordinates-url', url: string, format: BuiltInCoordinatesFormat, isBinary?: boolean }
  419. | { kind: 'coordinates-data', data: string | number[] | ArrayBuffer | Uint8Array, format: BuiltInCoordinatesFormat },
  420. coordinatesLabel?: string,
  421. preset?: keyof PresetTrajectoryHierarchy
  422. }
  423. export const ViewerAutoPreset = StructureRepresentationPresetProvider({
  424. id: 'preset-structure-representation-viewer-auto',
  425. display: {
  426. name: 'Automatic (w/ Annotation)', group: 'Annotation',
  427. description: 'Show standard automatic representation but colored by quality assessment (if available in the model).'
  428. },
  429. isApplicable(a) {
  430. return (
  431. !!a.data.models.some(m => QualityAssessment.isApplicable(m, 'pLDDT')) ||
  432. !!a.data.models.some(m => QualityAssessment.isApplicable(m, 'qmean'))
  433. );
  434. },
  435. params: () => StructureRepresentationPresetProvider.CommonParams,
  436. async apply(ref, params, plugin) {
  437. const structureCell = StateObjectRef.resolveAndCheck(plugin.state.data, ref);
  438. const structure = structureCell?.obj?.data;
  439. if (!structureCell || !structure) return {};
  440. if (!!structure.models.some(m => QualityAssessment.isApplicable(m, 'pLDDT'))) {
  441. return await QualityAssessmentPLDDTPreset.apply(ref, params, plugin);
  442. } else if (!!structure.models.some(m => QualityAssessment.isApplicable(m, 'qmean'))) {
  443. return await QualityAssessmentQmeanPreset.apply(ref, params, plugin);
  444. } else {
  445. return await PresetStructureRepresentations.auto.apply(ref, params, plugin);
  446. }
  447. }
  448. });