@rcsb/rcsb-saguaro-3d
Version:
RCSB Molstar/Saguaro Web App
55 lines • 2.95 kB
JavaScript
import { __awaiter } from "tslib";
import { ParamDefinition as PD } from 'molstar/lib/mol-util/param-definition';
import { TrajectoryHierarchyPresetProvider } from "molstar/lib/mol-plugin-state/builder/structure/hierarchy-preset";
import { AssemblyRepresentationPresetProvider } from "./AssemblyRepresentationPresetProvider";
import { FocusResidueColorThemeProvider } from "./FocusTheme/FocusColoring";
import { ModelSymmetry } from "molstar/lib/mol-model-formats/structure/property/symmetry";
export const AssemblyTrajectoryPresetProvider = TrajectoryHierarchyPresetProvider({
id: "rcsb-saguaro-3d",
display: {
name: 'Feature View 3D'
},
params: (trajectory, plugin) => ({
assemblyId: PD.Value("1"),
asymId: PD.Value('A'),
modelIndex: PD.Value(0)
}),
apply(trajectory, params, plugin) {
return __awaiter(this, void 0, void 0, function* () {
var _a;
const builder = plugin.builders.structure;
const model = yield builder.createModel(trajectory, { modelIndex: params.modelIndex });
const modelProperties = yield builder.insertModelProperties(model);
if (!model.data)
return {};
const assemblyId = (_a = params.assemblyId) !== null && _a !== void 0 ? _a : findAssembly(model.data, params.asymId);
const structure = yield builder.createStructure(modelProperties, (assemblyId != "" && assemblyId != "0") ? { name: 'assembly', params: { id: assemblyId } } : { name: "model", params: {} });
const structureProperties = yield builder.insertStructureProperties(structure);
if (!plugin.representation.structure.themes.colorThemeRegistry.has(FocusResidueColorThemeProvider))
plugin.representation.structure.themes.colorThemeRegistry.add(FocusResidueColorThemeProvider);
const unitcell = yield builder.tryCreateUnitcell(modelProperties, undefined, { isHidden: true });
const representation = yield plugin.builders.structure.representation.applyPreset(structureProperties, AssemblyRepresentationPresetProvider);
return {
model,
modelProperties,
unitcell,
structure,
structureProperties,
representation
};
});
}
});
function findAssembly(model, instanceId) {
var _a, _b, _c;
for (const assembly of (_b = (_a = ModelSymmetry.Provider.get(model)) === null || _a === void 0 ? void 0 : _a.assemblies) !== null && _b !== void 0 ? _b : []) {
for (const operatorGroup of assembly.operatorGroups) {
for (const asymId of (_c = operatorGroup.asymIds) !== null && _c !== void 0 ? _c : []) {
if (asymId === instanceId)
return assembly.id;
}
}
}
return '1';
}
//# sourceMappingURL=AssemblyTrajectoryPresetProvider.js.map