@rcsb/rcsb-saguaro-app
Version:
RCSB 1D Saguaro Web App
68 lines • 5.03 kB
JavaScript
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 PolymerEntityInstancesCollector {
constructor() {
this.rcsbFvQuery = rcsbClient;
}
collect(requestConfig) {
return __awaiter(this, void 0, void 0, function* () {
try {
const result = yield this.rcsbFvQuery.requestEntityInstances(requestConfig);
return PolymerEntityInstancesCollector.getEntryInstances(result);
}
catch (error) {
console.log(error);
throw error;
}
});
}
static getEntryInstances(entry) {
const out = new Array();
if ((entry === null || entry === void 0 ? void 0 : entry.polymer_entities) instanceof Array) {
entry.polymer_entities.forEach(entity => {
if (entity && Array.isArray(entity === null || entity === void 0 ? void 0 : entity.polymer_entity_instances)) {
assertElementListDefined(entity.polymer_entity_instances);
PolymerEntityInstancesCollector.parsePolymerEntityInstances(entity.polymer_entity_instances, out);
}
});
}
return out;
}
static parsePolymerEntityInstances(polymerEntityInstances, 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;
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;
const p = (_b = instance.polymer_entity) === null || _b === void 0 ? void 0 : _b.entry;
assertDefined(o), assertDefined(o === null || o === void 0 ? void 0 : o.entity_id), assertDefined(o.auth_asym_id), assertElementListDefined(o === null || o === void 0 ? void 0 : o.auth_to_entity_poly_seq_mapping);
assertDefined(p);
assertDefined((_d = (_c = instance.polymer_entity) === null || _c === void 0 ? void 0 : _c.entity_poly) === null || _d === void 0 ? void 0 : _d.rcsb_sample_sequence_length);
assertDefined((_e = instance.polymer_entity.entry) === null || _e === void 0 ? void 0 : _e.rcsb_entry_info.structure_determination_methodology);
out.push({
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: (_o = ((_h = (_g = (_f = instance === null || instance === void 0 ? void 0 : instance.polymer_entity) === null || _f === void 0 ? void 0 : _f.rcsb_polymer_entity) === null || _g === void 0 ? void 0 : _g.pdbx_description) !== null && _h !== void 0 ? _h : (_m = (_l = (_k = (_j = instance.polymer_entity) === null || _j === void 0 ? void 0 : _j.rcsb_polymer_entity) === null || _k === void 0 ? void 0 : _k.rcsb_polymer_name_combined) === null || _l === void 0 ? void 0 : _l.names) === null || _m === void 0 ? void 0 : _m.join(", "))) !== null && _o !== void 0 ? _o : "NA",
taxNames: Array.from(taxIds),
experimentalMethod: (_p = p.rcsb_entry_info.experimental_method) !== null && _p !== void 0 ? _p : "NA",
resolution: (_t = (_s = (_r = (_q = instance.polymer_entity) === null || _q === void 0 ? void 0 : _q.entry) === null || _r === void 0 ? void 0 : _r.rcsb_entry_info.resolution_combined) === null || _s === void 0 ? void 0 : _s[0]) !== null && _t !== void 0 ? _t : undefined,
sequenceLength: instance.polymer_entity.entity_poly.rcsb_sample_sequence_length,
entityMolecularWeight: (_v = (_u = instance.polymer_entity.rcsb_polymer_entity) === null || _u === void 0 ? void 0 : _u.formula_weight) !== null && _v !== void 0 ? _v : undefined,
entryMolecularWeight: (_x = (_w = instance.polymer_entity.entry) === null || _w === void 0 ? void 0 : _w.rcsb_entry_info.molecular_weight) !== null && _x !== void 0 ? _x : undefined,
structureDeterminationMethodology: instance.polymer_entity.entry.rcsb_entry_info.structure_determination_methodology
});
});
}
}
//# sourceMappingURL=PolymerEntityInstancesCollector.js.map