UNPKG

@rcsb/rcsb-saguaro-app

Version:
93 lines 7.18 kB
import { __awaiter } from "tslib"; import { rcsbClient } from "../../RcsbGraphQL/RcsbClient"; import { Assertions } from "../../RcsbUtils/Helpers/Assertions"; var assertElementListDefined = Assertions.assertElementListDefined; var assertDefined = Assertions.assertDefined; export class EntryAssembliesCollector { constructor() { this.rcsbFvQuery = rcsbClient; } collect(requestConfig) { return __awaiter(this, void 0, void 0, function* () { try { const coreEntry = yield this.rcsbFvQuery.requestEntityInstances(requestConfig); return EntryAssembliesCollector.getEntryAssemblies(coreEntry); } catch (error) { console.log(error); throw error; } }); } static getEntryAssemblies(entry) { const out = new Map(); out.set(EntryAssembliesCollector.modelKey, new Array()); const asymInstanceMap = new Map(); if ((entry === null || entry === void 0 ? void 0 : entry.polymer_entities) instanceof Array) { entry.polymer_entities.forEach(entity => { if ((entity === null || entity === void 0 ? void 0 : entity.polymer_entity_instances) && Array.isArray(entity === null || entity === void 0 ? void 0 : entity.polymer_entity_instances)) { assertElementListDefined(entity.polymer_entity_instances); EntryAssembliesCollector.parsePolymerEntityInstances(entity.polymer_entity_instances, asymInstanceMap, out); } }); } if ((entry === null || entry === void 0 ? void 0 : entry.assemblies) instanceof Array) { entry.assemblies.forEach(assembly => { if (assembly) EntryAssembliesCollector.parsePolymerEntityAssemblies(assembly, asymInstanceMap, out); }); } return out; } static parsePolymerEntityInstances(polymerEntityInstances, asymInstanceMap, out) { polymerEntityInstances.forEach(instance => { var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3; const taxIds = new Set(); if (((_a = instance === null || instance === void 0 ? void 0 : instance.polymer_entity) === null || _a === void 0 ? void 0 : _a.rcsb_entity_source_organism) instanceof Array) instance.polymer_entity.rcsb_entity_source_organism.forEach(sO => { if (typeof (sO === null || sO === void 0 ? void 0 : sO.ncbi_scientific_name) === "string" && sO.ncbi_scientific_name.length > 0) taxIds.add(sO.ncbi_scientific_name); }); const o = instance.rcsb_polymer_entity_instance_container_identifiers; assertDefined(o), assertDefined(o === null || o === void 0 ? void 0 : o.entry_id), assertDefined(o === null || o === void 0 ? void 0 : o.entity_id), assertDefined(o === null || o === void 0 ? void 0 : o.entity_id), assertDefined(o === null || o === void 0 ? void 0 : o.asym_id), assertDefined(o === null || o === void 0 ? void 0 : o.auth_asym_id), assertElementListDefined(o === null || o === void 0 ? void 0 : o.auth_to_entity_poly_seq_mapping); assertDefined((_c = (_b = instance.polymer_entity) === null || _b === void 0 ? void 0 : _b.entity_poly) === null || _c === void 0 ? void 0 : _c.rcsb_sample_sequence_length); assertDefined((_d = instance.polymer_entity.entry) === null || _d === void 0 ? void 0 : _d.rcsb_entry_info.structure_determination_methodology); const d = { rcsbId: instance.rcsb_id, entryId: o.entry_id, entityId: o.entity_id, asymId: o.asym_id, authId: o.auth_asym_id, authResId: o.auth_to_entity_poly_seq_mapping, name: (_m = ((_g = (_f = (_e = instance.polymer_entity) === null || _e === void 0 ? void 0 : _e.rcsb_polymer_entity) === null || _f === void 0 ? void 0 : _f.pdbx_description) !== null && _g !== void 0 ? _g : (_l = (_k = (_j = (_h = instance.polymer_entity) === null || _h === void 0 ? void 0 : _h.rcsb_polymer_entity) === null || _j === void 0 ? void 0 : _j.rcsb_polymer_name_combined) === null || _k === void 0 ? void 0 : _k.names) === null || _l === void 0 ? void 0 : _l.join(", "))) !== null && _m !== void 0 ? _m : "NA", taxNames: Array.from(taxIds), experimentalMethod: (_q = (_p = (_o = instance.polymer_entity) === null || _o === void 0 ? void 0 : _o.entry) === null || _p === void 0 ? void 0 : _p.rcsb_entry_info.experimental_method) !== null && _q !== void 0 ? _q : "NA", resolution: (_u = (_t = (_s = (_r = instance.polymer_entity) === null || _r === void 0 ? void 0 : _r.entry) === null || _s === void 0 ? void 0 : _s.rcsb_entry_info.resolution_combined) === null || _t === void 0 ? void 0 : _t[0]) !== null && _u !== void 0 ? _u : undefined, sequenceLength: (_w = (_v = instance.polymer_entity) === null || _v === void 0 ? void 0 : _v.entity_poly) === null || _w === void 0 ? void 0 : _w.rcsb_sample_sequence_length, entityMolecularWeight: (_y = (_x = instance.polymer_entity.rcsb_polymer_entity) === null || _x === void 0 ? void 0 : _x.formula_weight) !== null && _y !== void 0 ? _y : undefined, entryMolecularWeight: (_0 = (_z = instance.polymer_entity.entry) === null || _z === void 0 ? void 0 : _z.rcsb_entry_info.molecular_weight) !== null && _0 !== void 0 ? _0 : undefined, structureDeterminationMethodology: instance.polymer_entity.entry.rcsb_entry_info.structure_determination_methodology }; (_1 = out.get(EntryAssembliesCollector.modelKey)) === null || _1 === void 0 ? void 0 : _1.push(d); if ((_2 = instance === null || instance === void 0 ? void 0 : instance.rcsb_polymer_entity_instance_container_identifiers) === null || _2 === void 0 ? void 0 : _2.asym_id) asymInstanceMap.set((_3 = instance === null || instance === void 0 ? void 0 : instance.rcsb_polymer_entity_instance_container_identifiers) === null || _3 === void 0 ? void 0 : _3.asym_id, d); }); } static parsePolymerEntityAssemblies(assembly, asymInstanceMap, out) { var _a; out.set(assembly.rcsb_assembly_container_identifiers.assembly_id, new Array()); (_a = assembly.pdbx_struct_assembly_gen) === null || _a === void 0 ? void 0 : _a.forEach(assemblyGen => { var _a; (_a = assemblyGen === null || assemblyGen === void 0 ? void 0 : assemblyGen.asym_id_list) === null || _a === void 0 ? void 0 : _a.forEach(asymId => { var _a; if (!asymId) return; const o = asymInstanceMap.get(asymId); if (o) (_a = out.get(assembly.rcsb_assembly_container_identifiers.assembly_id)) === null || _a === void 0 ? void 0 : _a.push(o); }); }); } } EntryAssembliesCollector.modelKey = "Model"; //# sourceMappingURL=EntryAssembliesCollector.js.map