diff --git a/src/apps/basic-wrapper/index.html b/src/apps/basic-wrapper/index.html index 38c2bf79201f858b859109bfc33f5b8bc6e934e3..3485302910860e68b898003c5bb71ae3ba0dba24 100644 --- a/src/apps/basic-wrapper/index.html +++ b/src/apps/basic-wrapper/index.html @@ -50,6 +50,7 @@ // 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); diff --git a/src/mol-plugin/state/transforms/model.ts b/src/mol-plugin/state/transforms/model.ts index dcc0b6b9af09cfa667475e1059de255d3225edd6..bc45a15add86d39c42b64b80b9e3150a79d90bc3 100644 --- a/src/mol-plugin/state/transforms/model.ts +++ b/src/mol-plugin/state/transforms/model.ts @@ -22,6 +22,7 @@ import { volumeFromDsn6 } from 'mol-model-formats/volume/dsn6'; import { trajectoryFromMmCIF } from 'mol-model-formats/structure/mmcif'; import { parsePDB } from 'mol-io/reader/pdb/parser'; import { trajectoryFromPDB } from 'mol-model-formats/structure/pdb'; +import { Assembly } from 'mol-model/structure/model/properties/symmetry'; export { TrajectoryFromMmCif } type TrajectoryFromMmCif = typeof TrajectoryFromMmCif @@ -141,12 +142,26 @@ const StructureAssemblyFromModel = PluginStateTransform.BuiltIn({ return Task.create('Build Assembly', async ctx => { const model = a.data; let id = params.id; - let asm = ModelSymmetry.findAssembly(model, id || ''); - if (!!id && id !== 'deposited' && !asm) throw new Error(`Assembly '${id}' not found`); + let asm: Assembly | undefined = void 0; + + // if no id is specified, use the 1st assembly. + if (!id && model.symmetry.assemblies.length !== 0) { + id = model.symmetry.assemblies[0].id; + } + + if (model.symmetry.assemblies.length === 0) { + if (id !== 'deposited') { + plugin.log.warn(`Model '${a.label}' has no assembly, returning deposited structure.`); + } + } else { + asm = ModelSymmetry.findAssembly(model, id || ''); + if (!asm) { + plugin.log.warn(`Model '${a.label}' has no assembly called '${id}', returning deposited structure.`); + } + } const base = Structure.ofModel(model); - if ((id && !asm) || model.symmetry.assemblies.length === 0) { - if (!!id && id !== 'deposited') plugin.log.warn(`Model '${a.label}' has no assembly, returning deposited structure.`); + if (!asm) { const label = { label: a.data.label, description: structureDesc(base) }; return new SO.Molecule.Structure(base, label); }