UNPKG

@rcsb/rcsb-saguaro-3d

Version:
49 lines 2.34 kB
/* * Copyright (c) 2021 RCSB PDB and contributors, licensed under MIT, See LICENSE file for more info. * @author Joan Segura Mora <joan.segura@rcsb.org> */ import { __awaiter } from "tslib"; import { LoadMethod } from "../MolstarActionManager"; import { AlignmentTrajectoryPresetProvider } from "../TrajectoryPresetProvider/AlignmentTrajectoryPresetProvider"; import { TagDelimiter } from "@rcsb/rcsb-api-tools/lib/RcsbUtils/TagDelimiter"; import { RcsbRequestContextManager } from "@rcsb/rcsb-saguaro-app/lib/app"; export class MolstarAlignmentLoader { constructor(loadParamsProvider) { this.structureMap = new Set(); this.loadParamsProvider = loadParamsProvider; } load(structureViewer, pdb, targetAlignment) { return __awaiter(this, void 0, void 0, function* () { var _a; const structureId = `${pdb.entryId}${"entityId" in pdb ? TagDelimiter.entity : TagDelimiter.instance}${"entityId" in pdb ? pdb.entityId : pdb.instanceId}`; if (!this.structureMap.has(structureId)) { this.structureMap.add(structureId); const loadParams = 'instanceId' in pdb ? (_a = this.loadParamsProvider) === null || _a === void 0 ? void 0 : _a.get(pdb) : undefined; return loadParams ? yield structureViewer.load(loadParams) : yield structureViewer.load({ loadMethod: LoadMethod.loadPdbId, loadParams: { id: structureId, entryId: pdb.entryId, reprProvider: AlignmentTrajectoryPresetProvider, params: { modelIndex: ((yield RcsbRequestContextManager.getEntryProperties(pdb.entryId))[0].representativeModel - 1), pdb, targetAlignment } } }); } else { yield structureViewer.removeStructure({ loadMethod: LoadMethod.loadPdbId, loadParams: { id: structureId } }); this.structureMap.delete(structureId); return; } }); } } //# sourceMappingURL=MolstarAlignmentLoader.js.map