@rcsb/rcsb-saguaro-app
Version:
RCSB 1D Saguaro Web App
44 lines (43 loc) • 2.02 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.PolymerEntityChromosomeCollector = void 0;
const tslib_1 = require("tslib");
const GqlTypes_1 = require("@rcsb/rcsb-api-tools/lib/RcsbGraphQL/Types/Borrego/GqlTypes");
const RcsbClient_1 = require("../../RcsbGraphQL/RcsbClient");
class PolymerEntityChromosomeCollector {
constructor() {
this.rcsbFvQuery = RcsbClient_1.rcsbClient;
}
collect(entityIds) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const entityMap = new Map();
const result = yield Promise.all(entityIds.map(e => {
return this.entityChromosomes(e);
}));
result.forEach((alignment, n) => {
var _a;
(_a = alignment.target_alignments) === null || _a === void 0 ? void 0 : _a.forEach(ta => {
var _a, _b, _c;
if (((_b = (_a = ta === null || ta === void 0 ? void 0 : ta.aligned_regions) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) > 0) {
if (!entityMap.has(entityIds[n]))
entityMap.set(entityIds[n], new Array());
if (ta === null || ta === void 0 ? void 0 : ta.target_id)
(_c = entityMap.get(entityIds[n])) === null || _c === void 0 ? void 0 : _c.push(ta.target_id);
}
});
});
return entityMap;
});
}
entityChromosomes(entityId) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const request = {
from: GqlTypes_1.SequenceReference.PdbEntity,
to: GqlTypes_1.SequenceReference.NcbiGenome,
queryId: entityId
};
return yield this.rcsbFvQuery.requestAlignment(request);
});
}
}
exports.PolymerEntityChromosomeCollector = PolymerEntityChromosomeCollector;