|
@@ -11,13 +11,15 @@ import { DnatcoConfalPyramids } from '../../extensions/dnatco';
|
|
|
import { G3DFormat, G3dProvider } from '../../extensions/g3d/format';
|
|
|
import { GeometryExport } from '../../extensions/geo-export';
|
|
|
import { MAQualityAssessment } from '../../extensions/model-archive/quality-assessment/behavior';
|
|
|
+import { QualityAssessmentPLDDTPreset, QualityAssessmentQmeanPreset } from '../../extensions/model-archive/quality-assessment/behavior';
|
|
|
+import { QualityAssessment } from '../../extensions/model-archive/quality-assessment/prop';
|
|
|
import { Mp4Export } from '../../extensions/mp4-export';
|
|
|
import { PDBeStructureQualityReport } from '../../extensions/pdbe';
|
|
|
import { RCSBAssemblySymmetry, RCSBValidationReport } from '../../extensions/rcsb';
|
|
|
import { DownloadStructure, PdbDownloadProvider } from '../../mol-plugin-state/actions/structure';
|
|
|
import { DownloadDensity } from '../../mol-plugin-state/actions/volume';
|
|
|
import { PresetTrajectoryHierarchy } from '../../mol-plugin-state/builder/structure/hierarchy-preset';
|
|
|
-import { StructureRepresentationPresetProvider } from '../../mol-plugin-state/builder/structure/representation-preset';
|
|
|
+import { PresetStructureRepresentations, StructureRepresentationPresetProvider } from '../../mol-plugin-state/builder/structure/representation-preset';
|
|
|
import { DataFormatProvider } from '../../mol-plugin-state/formats/provider';
|
|
|
import { BuildInStructureFormat } from '../../mol-plugin-state/formats/structure';
|
|
|
import { BuiltInTrajectoryFormat } from '../../mol-plugin-state/formats/trajectory';
|
|
@@ -34,7 +36,7 @@ import { PluginConfig } from '../../mol-plugin/config';
|
|
|
import { PluginLayoutControlsDisplay } from '../../mol-plugin/layout';
|
|
|
import { PluginSpec } from '../../mol-plugin/spec';
|
|
|
import { PluginState } from '../../mol-plugin/state';
|
|
|
-import { StateObjectSelector } from '../../mol-state';
|
|
|
+import { StateObjectRef, StateObjectSelector } from '../../mol-state';
|
|
|
import { Asset } from '../../mol-util/assets';
|
|
|
import { Color } from '../../mol-util/color';
|
|
|
import '../../mol-util/polyfill';
|
|
@@ -151,7 +153,8 @@ export class Viewer {
|
|
|
[PluginConfig.VolumeStreaming.DefaultServer, o.volumeStreamingServer],
|
|
|
[PluginConfig.VolumeStreaming.Enabled, !o.volumeStreamingDisabled],
|
|
|
[PluginConfig.Download.DefaultPdbProvider, o.pdbProvider],
|
|
|
- [PluginConfig.Download.DefaultEmdbProvider, o.emdbProvider]
|
|
|
+ [PluginConfig.Download.DefaultEmdbProvider, o.emdbProvider],
|
|
|
+ [PluginConfig.Structure.DefaultRepresentationPreset, ViewerAutoPreset.id],
|
|
|
]
|
|
|
};
|
|
|
|
|
@@ -160,6 +163,8 @@ export class Viewer {
|
|
|
: elementOrId;
|
|
|
if (!element) throw new Error(`Could not get element with id '${elementOrId}'`);
|
|
|
this.plugin = createPlugin(element, spec);
|
|
|
+
|
|
|
+ this.plugin.builders.structure.representation.registerPreset(ViewerAutoPreset);
|
|
|
}
|
|
|
|
|
|
setRemoteSnapshot(id: string) {
|
|
@@ -253,6 +258,22 @@ export class Viewer {
|
|
|
}));
|
|
|
}
|
|
|
|
|
|
+ loadAfdb(afdb: string) {
|
|
|
+ const params = DownloadStructure.createDefaultParams(this.plugin.state.data.root.obj!, this.plugin);
|
|
|
+ return this.plugin.runTask(this.plugin.state.data.applyAction(DownloadStructure, {
|
|
|
+ source: {
|
|
|
+ name: 'alphafolddb' as const,
|
|
|
+ params: {
|
|
|
+ id: afdb,
|
|
|
+ options: {
|
|
|
+ ...params.source.params.options,
|
|
|
+ representation: 'preset-structure-representation-ma-quality-assessment-plddt'
|
|
|
+ },
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }));
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @example Load X-ray density from volume server
|
|
|
viewer.loadVolumeFromUrl({
|
|
@@ -411,4 +432,32 @@ export interface LoadTrajectoryParams {
|
|
|
| { kind: 'coordinates-data', data: string | number[] | ArrayBuffer | Uint8Array, format: BuildInStructureFormat },
|
|
|
coordinatesLabel?: string,
|
|
|
preset?: keyof PresetTrajectoryHierarchy
|
|
|
-}
|
|
|
+}
|
|
|
+
|
|
|
+export const ViewerAutoPreset = StructureRepresentationPresetProvider({
|
|
|
+ id: 'preset-structure-representation-viewer-auto',
|
|
|
+ display: {
|
|
|
+ name: 'Automatic (w/ Annotation)', group: 'Annotation',
|
|
|
+ description: 'Show standard automatic representation but colored by quality assessment (if available in the model).'
|
|
|
+ },
|
|
|
+ isApplicable(a) {
|
|
|
+ return (
|
|
|
+ !!a.data.models.some(m => QualityAssessment.isApplicable(m, 'pLDDT')) ||
|
|
|
+ !!a.data.models.some(m => QualityAssessment.isApplicable(m, 'qmean'))
|
|
|
+ );
|
|
|
+ },
|
|
|
+ params: () => StructureRepresentationPresetProvider.CommonParams,
|
|
|
+ async apply(ref, params, plugin) {
|
|
|
+ const structureCell = StateObjectRef.resolveAndCheck(plugin.state.data, ref);
|
|
|
+ const structure = structureCell?.obj?.data;
|
|
|
+ if (!structureCell || !structure) return {};
|
|
|
+
|
|
|
+ if (!!structure.models.some(m => QualityAssessment.isApplicable(m, 'pLDDT'))) {
|
|
|
+ return await QualityAssessmentPLDDTPreset.apply(ref, params, plugin);
|
|
|
+ } else if (!!structure.models.some(m => QualityAssessment.isApplicable(m, 'qmean'))) {
|
|
|
+ return await QualityAssessmentQmeanPreset.apply(ref, params, plugin);
|
|
|
+ } else {
|
|
|
+ return await PresetStructureRepresentations.auto.apply(ref, params, plugin);
|
|
|
+ }
|
|
|
+ }
|
|
|
+});
|