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

removed custom name 'deposited' for structures from model

- use 'model' instead
parent 3415fe08
No related branches found
No related tags found
No related merge requests found
......@@ -69,15 +69,8 @@
$('format').value = format;
$('format').onchange = function (e) { format = e.target.value; }
// var url = 'https://www.ebi.ac.uk/pdbe/entry-files/pdb' + pdbId + '.ent';
// var format = 'pdb';
// var assemblyId = 'deposited';
BasicMolStarWrapper.init('app' /** or document.getElementById('app') */);
BasicMolStarWrapper.setBackground(0xffffff);
// BasicMolStarWrapper.load({ url: url, format: format, assemblyId: assemblyId });
// BasicMolStarWrapper.toggleSpin();
addControl('Load Asym Unit', () => BasicMolStarWrapper.load({ url: url, format: format }));
addControl('Load Assembly', () => BasicMolStarWrapper.load({ url: url, format: format, assemblyId: assemblyId }));
......
......@@ -56,7 +56,13 @@ class BasicWrapper {
const trajectory = await this.plugin.builders.structure.parseTrajectory(data, format);
await this.plugin.builders.structure.hierarchy.applyPreset(trajectory, 'default', {
structure: assemblyId ? { name: 'assembly', params: { id: assemblyId } } : { name: 'deposited', params: { } },
structure: assemblyId ? {
name: 'assembly',
params: { id: assemblyId }
} : {
name: 'model',
params: { }
},
showUnitcell: false,
representationPreset: 'auto'
});
......
......@@ -105,7 +105,7 @@ class LightingDemo {
const data = await this.plugin.builders.data.download({ url: Asset.Url(url), isBinary }, { state: { isGhost: true } });
const trajectory = await this.plugin.builders.structure.parseTrajectory(data, format);
const model = await this.plugin.builders.structure.createModel(trajectory);
const structure = await this.plugin.builders.structure.createStructure(model, assemblyId ? { name: 'assembly', params: { id: assemblyId } } : { name: 'deposited', params: { } });
const structure = await this.plugin.builders.structure.createStructure(model, assemblyId ? { name: 'assembly', params: { id: assemblyId } } : { name: 'model', params: { } });
const polymer = await this.plugin.builders.structure.tryCreateComponentStatic(structure, 'polymer');
if (polymer) await this.plugin.builders.structure.representation.addRepresentation(polymer, { type: 'spacefill', color: 'illustrative' });
......
......@@ -88,10 +88,6 @@
$('isBinary').checked = isBinary;
$('isBinary').onchange = function (e) { isBinary = !!e.target.checked; };
// var url = 'https://www.ebi.ac.uk/pdbe/entry-files/pdb' + pdbId + '.ent';
// var format = 'pdb';
// var assemblyId = 'deposited';
function loadAndSnapshot(params) {
PluginWrapper.load(params).then(() => {
setTimeout(() => snapshot = PluginWrapper.plugin.state.getSnapshot({ canvas3d: false /* do not save spinning state */ }), 500);
......
......@@ -89,9 +89,12 @@ class MolStarProteopediaWrapper {
private structure(assemblyId: string) {
const model = this.state.build().to(StateElements.Model);
const props = {
type: {
type: assemblyId ? {
name: 'assembly' as const,
params: { id: assemblyId || 'deposited' }
params: { id: assemblyId }
} : {
name: 'model' as const,
params: { }
}
};
......@@ -196,7 +199,7 @@ class MolStarProteopediaWrapper {
private emptyLoadedParams: LoadParams = { url: '', format: 'cif', isBinary: false, assemblyId: '' };
private loadedParams: LoadParams = { url: '', format: 'cif', isBinary: false, assemblyId: '' };
async load({ url, format = 'cif', assemblyId = 'deposited', isBinary = false, representationStyle }: LoadParams) {
async load({ url, format = 'cif', assemblyId = '', isBinary = false, representationStyle }: LoadParams) {
let loadType: 'full' | 'update' = 'full';
const state = this.plugin.state.data;
......@@ -220,9 +223,12 @@ class MolStarProteopediaWrapper {
const info = await this.doInfo(true);
const asmId = (assemblyId === 'preferred' && info && info.preferredAssemblyId) || assemblyId;
const props = {
type: {
type: assemblyId ? {
name: 'assembly' as const,
params: { id: asmId || 'deposited' }
params: { id: asmId }
} : {
name: 'model' as const,
params: { }
}
};
tree.to(StateElements.Assembly).update(StateTransforms.Model.StructureFromModel, p => ({ ...p, ...props }));
......
......@@ -35,7 +35,7 @@ export function isBiologicalAssembly(structure: Structure): boolean {
const mmcif = structure.models[0].sourceData.data.db;
if (!mmcif.pdbx_struct_assembly.details.isDefined) return false;
const id = structure.units[0].conformation.operator.assembly?.id || '';
if (id === '' || id === 'deposited') return true;
if (id === '') return true;
const indices = Column.indicesOf(mmcif.pdbx_struct_assembly.id, e => e === id);
if (indices.length !== 1) return false;
const details = mmcif.pdbx_struct_assembly.details.value(indices[0]);
......@@ -63,7 +63,7 @@ export namespace AssemblySymmetry {
const client = new GraphQLClient(props.serverUrl, ctx.assetManager);
const variables: AssemblySymmetryQueryVariables = {
assembly_id: structure.units[0].conformation.operator.assembly?.id || 'deposited',
assembly_id: structure.units[0].conformation.operator.assembly?.id || '',
entry_id: structure.units[0].model.entryId
};
const result = await client.request(ctx.runtime, query, variables);
......
......@@ -90,7 +90,7 @@ export class StructureBuilder {
const model = StateObjectRef.resolveAndCheck(state, modelRef);
if (model) {
const symm = ModelSymmetry.Provider.get(model.obj?.data!);
if (!symm || symm?.assemblies.length === 0) params = { name: 'deposited', params: { } };
if (!symm || symm?.assemblies.length === 0) params = { name: 'model', params: { } };
}
}
......
......@@ -43,7 +43,7 @@ const defaultPreset = TrajectoryHierarchyPresetProvider({
id: 'preset-trajectory-default',
display: {
name: 'Default (Assembly)', group: 'Preset',
description: 'Shows the first assembly or, if that is unavailable, the first deposited model.'
description: 'Shows the first assembly or, if that is unavailable, the first model.'
},
isApplicable: o => {
return true;
......@@ -93,7 +93,7 @@ const allModels = TrajectoryHierarchyPresetProvider({
for (let i = 0; i < tr.length; i++) {
const model = await builder.createModel(trajectory, { modelIndex: i });
const modelProperties = await builder.insertModelProperties(model, params.modelProperties, { isCollapsed: true });
const structure = await builder.createStructure(modelProperties || model, { name: 'deposited', params: {} });
const structure = await builder.createStructure(modelProperties || model, { name: 'model', params: {} });
const structureProperties = await builder.insertStructureProperties(structure, params.structureProperties);
models.push(model);
......
......@@ -17,7 +17,7 @@ import { PluginStateObject as SO } from '../objects';
import { ModelSymmetry } from '../../mol-model-formats/structure/property/symmetry';
export namespace RootStructureDefinition {
export function getParams(model?: Model, defaultValue?: 'auto' | 'deposited' | 'assembly' | 'symmetry' | 'symmetry-mates' | 'symmetry-assembly') {
export function getParams(model?: Model, defaultValue?: 'auto' | 'model' | 'assembly' | 'symmetry' | 'symmetry-mates' | 'symmetry-assembly') {
const symmetry = model && ModelSymmetry.Provider.get(model);
const assemblyIds = symmetry ? symmetry.assemblies.map(a => [a.id, `${a.id}: ${stringToWords(a.details)}`] as [string, string]) : [];
......@@ -41,7 +41,7 @@ export namespace RootStructureDefinition {
const modes = {
auto: PD.EmptyGroup(),
deposited: PD.EmptyGroup(),
model: PD.EmptyGroup(),
assembly: PD.Group({
id: PD.Optional(model
? PD.Select(assemblyIds.length ? assemblyIds[0][0] : '', assemblyIds, { label: 'Asm Id', description: 'Assembly Id' })
......@@ -75,7 +75,7 @@ export namespace RootStructureDefinition {
options.push(['auto', 'Auto']);
}
options.push(['deposited', 'Deposited']);
options.push(['model', 'Model']);
if (assemblyIds.length > 0) {
options.push(['assembly', 'Assembly']);
......@@ -88,7 +88,7 @@ export namespace RootStructureDefinition {
}
return {
type: PD.MappedStatic(defaultValue || 'deposited', modes, { options })
type: PD.MappedStatic(defaultValue || 'model', modes, { options })
};
}
......@@ -110,19 +110,17 @@ export namespace RootStructureDefinition {
}
if (!symmetry || symmetry.assemblies.length === 0) {
if (id !== 'deposited') {
plugin.log.warn(`Model '${model.entryId}' has no assembly, returning deposited structure.`);
}
plugin.log.warn(`Model '${model.entryId}' has no assembly, returning model structure.`);
} else {
asm = Symmetry.findAssembly(model, id || '');
if (!asm) {
plugin.log.warn(`Model '${model.entryId}' has no assembly called '${id}', returning deposited structure.`);
plugin.log.warn(`Model '${model.entryId}' has no assembly called '${id}', returning model structure.`);
}
}
const base = Structure.ofModel(model);
if (!asm) {
const label = { label: 'Deposited', description: Structure.elementDescription(base) };
const label = { label: 'Model', description: Structure.elementDescription(base) };
return new SO.Molecule.Structure(base, label);
}
......@@ -155,14 +153,14 @@ export namespace RootStructureDefinition {
export async function create(plugin: PluginContext, ctx: RuntimeContext, model: Model, params?: Params): Promise<SO.Molecule.Structure> {
const symmetry = ModelSymmetry.Provider.get(model);
if (!symmetry || !params || params.name === 'deposited') {
if (!symmetry || !params || params.name === 'model') {
const s = Structure.ofModel(model);
return new SO.Molecule.Structure(s, { label: 'Deposited', description: Structure.elementDescription(s) });
return new SO.Molecule.Structure(s, { label: 'Model', description: Structure.elementDescription(s) });
}
if (params.name === 'auto') {
if (symmetry.assemblies.length === 0) {
const s = Structure.ofModel(model);
return new SO.Molecule.Structure(s, { label: 'Deposited', description: Structure.elementDescription(s) });
return new SO.Molecule.Structure(s, { label: 'Model', description: Structure.elementDescription(s) });
} else {
return buildAssembly(plugin, ctx, model);
}
......
......@@ -371,7 +371,7 @@ const StructureFromTrajectory = PluginStateTransform.BuiltIn({
type StructureFromModel = typeof StructureFromModel
const StructureFromModel = PluginStateTransform.BuiltIn({
name: 'structure-from-model',
display: { name: 'Structure', description: 'Create a molecular structure (deposited, assembly, or symmetry) from the specified model.' },
display: { name: 'Structure', description: 'Create a molecular structure (model, assembly, or symmetry) from the specified model.' },
from: SO.Molecule.Model,
to: SO.Molecule.Structure,
params(a) { return RootStructureDefinition.getParams(a && a.data); }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment