UNPKG

pdbe-molstar

Version:
69 lines (68 loc) 2.4 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ImageTitles = void 0; /** Functions for creating informative image (3D state) titles for display in UI */ exports.ImageTitles = { entry(img) { if (img.filename.includes('_chemically_distinct_molecules')) { return { title: 'Deposited model (color by entity)' }; } if (img.filename.includes('_chain')) { return { title: 'Deposited model (color by chain)' }; } return {}; }, validation(img) { return { title: 'Geometry validation' }; }, bfactor(img) { return { title: 'B-factor' }; }, assembly(img, info) { if (img.filename.includes('_chemically_distinct_molecules')) { return { title: `Assembly ${info.assemblyId} (color by entity)` }; } if (img.filename.includes('_chain')) { return { title: `Assembly ${info.assemblyId} (color by chain)` }; } return {}; }, entity(img, info) { const entityName = getSpans(img.description)[1]; return { title: `Entity ${info.entityId}`, subtitle: entityName, }; }, ligand(img, info) { const ligandName = getParenthesis(getSpans(img.description)[0]); return { title: `Ligand environment for ${info.compId}`, subtitle: ligandName, }; }, modres(img, info) { const modresName = getParenthesis(getSpans(img.description)[1]); return { title: `Modified residue ${info.compId}`, subtitle: modresName, }; }, domain(img, info) { const familyName = getParenthesis(getSpans(img.description)[1]); return { title: `${info.db} ${info.familyId} (entity ${info.entityId})`, subtitle: familyName, }; }, }; /** Get contents of `<span ...>...</span>` tags from an HTML string */ function getSpans(text) { const matches = (text !== null && text !== void 0 ? text : '').matchAll(/<span [^>]*>([^<]*)<\/span>/g); return Array.from(matches).map(match => match[1]); } /** Get content of parenthesis (`(...)`) from a string */ function getParenthesis(text) { var _a; return (_a = text === null || text === void 0 ? void 0 : text.match(/\((.*)\)/)) === null || _a === void 0 ? void 0 : _a[1]; }