@rcsb/rcsb-saguaro-app
Version:
RCSB 1D Saguaro Web App
55 lines • 5.15 kB
JavaScript
import { __awaiter } from "tslib";
import { rcsbClient } from "../../RcsbGraphQL/RcsbClient";
import { Assertions } from "../../RcsbUtils/Helpers/Assertions";
var assertDefined = Assertions.assertDefined;
var assertElementListDefined = Assertions.assertElementListDefined;
export class MultipleEntryPropertyCollector {
constructor() {
this.rcsbFvQuery = rcsbClient;
}
collect(requestConfig) {
return __awaiter(this, void 0, void 0, function* () {
const result = yield this.rcsbFvQuery.requestMultipleEntriesProperties(requestConfig);
return result.map(r => MultipleEntryPropertyCollector.getEntryProperties(r));
});
}
static getEntryProperties(r) {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
return {
rcsbId: r.rcsb_id,
entryId: r.rcsb_id,
experimentalMethod: (_a = r.rcsb_entry_info.experimental_method) !== null && _a !== void 0 ? _a : "NA",
resolution: (_c = (_b = r.rcsb_entry_info.resolution_combined) === null || _b === void 0 ? void 0 : _b[0]) !== null && _c !== void 0 ? _c : undefined,
name: (_e = (_d = r.struct) === null || _d === void 0 ? void 0 : _d.title) !== null && _e !== void 0 ? _e : "NA",
description: (_g = (_f = r.pdbx_molecule_features) === null || _f === void 0 ? void 0 : _f.map(mf => mf === null || mf === void 0 ? void 0 : mf.details).filter((x) => x != null)) !== null && _g !== void 0 ? _g : [],
taxNames: (_j = (_h = r.polymer_entities) === null || _h === void 0 ? void 0 : _h.map((entity) => { var _a; return ((_a = entity === null || entity === void 0 ? void 0 : entity.rcsb_entity_source_organism) === null || _a === void 0 ? void 0 : _a.map((so) => (so === null || so === void 0 ? void 0 : so.ncbi_scientific_name))); }).flat().filter((x) => x != null)) !== null && _j !== void 0 ? _j : [],
entryMolecularWeight: (_k = r.rcsb_entry_info.molecular_weight) !== null && _k !== void 0 ? _k : undefined,
entityToInstance: (_m = (_l = r.polymer_entities) === null || _l === void 0 ? void 0 : _l.map(pe => { var _a; return [pe === null || pe === void 0 ? void 0 : pe.rcsb_id, (_a = pe === null || pe === void 0 ? void 0 : pe.polymer_entity_instances) === null || _a === void 0 ? void 0 : _a.map(pei => pei === null || pei === void 0 ? void 0 : pei.rcsb_id)]; }).reduce((r, x) => r.set(x[0], x[1]), new Map())) !== null && _m !== void 0 ? _m : new Map(),
structureDeterminationMethodology: r.rcsb_entry_info.structure_determination_methodology,
nonPolymerEntityToInstance: (_p = (_o = r.nonpolymer_entities) === null || _o === void 0 ? void 0 : _o.map(pe => { var _a; return [pe === null || pe === void 0 ? void 0 : pe.rcsb_id, (_a = pe === null || pe === void 0 ? void 0 : pe.nonpolymer_entity_instances) === null || _a === void 0 ? void 0 : _a.map(pei => pei === null || pei === void 0 ? void 0 : pei.rcsb_id)]; }).reduce((r, x) => r.set(x[0], x[1]), new Map())) !== null && _p !== void 0 ? _p : new Map(),
instanceToOperator: MultipleEntryPropertyCollector.instanceToOperator(r),
entityToPrd: (_r = (_q = r.polymer_entities) === null || _q === void 0 ? void 0 : _q.filter((pe) => typeof pe != "undefined").map(pe => { var _a, _b, _c; return [(_a = pe === null || pe === void 0 ? void 0 : pe.rcsb_id) !== null && _a !== void 0 ? _a : "", (_c = (_b = pe === null || pe === void 0 ? void 0 : pe.entity_poly) === null || _b === void 0 ? void 0 : _b.rcsb_prd_id) !== null && _c !== void 0 ? _c : ""]; }).reduce((map, pair) => map.set(pair[0], pair[1]), new Map())) !== null && _r !== void 0 ? _r : new Map(),
representativeModel: (_s = r.rcsb_entry_info.representative_model) !== null && _s !== void 0 ? _s : 1
};
}
static instanceToOperator(r) {
const out = new Map();
assertDefined(r.assemblies);
r.assemblies.forEach(assembly => {
assertDefined(assembly === null || assembly === void 0 ? void 0 : assembly.rcsb_id), assertDefined(assembly === null || assembly === void 0 ? void 0 : assembly.pdbx_struct_assembly_gen);
out.set(assembly.rcsb_id, new Map());
assembly.pdbx_struct_assembly_gen.forEach(assemblyGen => {
assertDefined(assemblyGen === null || assemblyGen === void 0 ? void 0 : assemblyGen.oper_expression), assertElementListDefined(assemblyGen.asym_id_list);
const operators = assemblyGen.oper_expression.split(",");
const instances = assemblyGen.asym_id_list;
instances.forEach(asymId => {
var _a, _b, _c;
const instanceId = `${r.rcsb_id}.${asymId}`;
(_a = out.get(assembly.rcsb_id)) === null || _a === void 0 ? void 0 : _a.set(instanceId, [...operators, ...(_c = (_b = out.get(assembly.rcsb_id)) === null || _b === void 0 ? void 0 : _b.get(instanceId)) !== null && _c !== void 0 ? _c : []]);
});
});
});
return out;
}
}
//# sourceMappingURL=MultipleEntryPropertyCollector.js.map