Skip to content
Snippets Groups Projects
Commit 1cc4a050 authored by David Sehnal's avatar David Sehnal
Browse files

mol-plugin: return deposited structure if assemly is not found

parent 227aff38
No related branches found
No related tags found
No related merge requests found
......@@ -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);
......
......@@ -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);
}
......
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