|
|
@@ -21,9 +21,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
};
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
exports.getInteractionsFromEntry = exports.getEntryFromGeneName = exports.getEnrty = exports.readOffset = exports.makeIndex = void 0;
|
|
|
+const fast_xml_parser_1 = require("fast-xml-parser");
|
|
|
const fs_1 = __importDefault(require("fs"));
|
|
|
const readline_1 = __importDefault(require("readline"));
|
|
|
-const fast_xml_parser_1 = require("fast-xml-parser");
|
|
|
const line$ = (path) => readline_1.default.createInterface({
|
|
|
input: fs_1.default.createReadStream(path),
|
|
|
crlfDelay: Infinity
|
|
|
@@ -137,14 +137,21 @@ const getAccessFromGene = (idmappingPath, geneName) => __awaiter(void 0, void 0,
|
|
|
return accessions;
|
|
|
});
|
|
|
const getInteractionsFromEntry = (json) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
+ var _k, _l, _m, _o, _p, _q, _r, _s;
|
|
|
const blaskList = ['DNA', 'PHOSPHOSERINE', 'MOTIFS', 'INFECTION', 'PROTEIN', 'PROTEINS', 'GAMMA-SECRETASE', 'CALCIUM',
|
|
|
'MICROBIAL', 'VIRUS', 'HEPATITIS', 'HERPES', 'SIMPLEX', 'RELATED', 'AND', 'CLATHRIN', 'WORTMANNIN',
|
|
|
'NUCLEOSOME', 'undefined'];
|
|
|
const uniprotIDs = Array.isArray(json.entry.accession) ? json.entry.accession : [json.entry.accession];
|
|
|
// geneName
|
|
|
const gnTT = Array.isArray(json.entry.gene) ? json.entry.gene[0] : json.entry.gene;
|
|
|
- const gnT = Array.isArray(gnTT.name) ? gnTT.name : [gnTT.name];
|
|
|
- const geneName = gnT.filter((e) => e.type === 'primary').map((e) => e.value)[0];
|
|
|
+ let geneName = '';
|
|
|
+ if (gnTT === null || gnTT === void 0 ? void 0 : gnTT.name) {
|
|
|
+ const gnT = Array.isArray(gnTT.name) ? gnTT.name : [gnTT.name];
|
|
|
+ geneName = gnT.filter((e) => e.type === 'primary').map((e) => e.value)[0];
|
|
|
+ }
|
|
|
+ else if ((_l = (_k = json.entry) === null || _k === void 0 ? void 0 : _k.protein) === null || _l === void 0 ? void 0 : _l.recommendedName) {
|
|
|
+ geneName = Array.isArray((_o = (_m = json.entry) === null || _m === void 0 ? void 0 : _m.protein) === null || _o === void 0 ? void 0 : _o.recommendedName) ? (_q = (_p = json.entry) === null || _p === void 0 ? void 0 : _p.protein) === null || _q === void 0 ? void 0 : _q.recommendedName[0] : (_s = (_r = json.entry) === null || _r === void 0 ? void 0 : _r.protein) === null || _s === void 0 ? void 0 : _s.recommendedName;
|
|
|
+ }
|
|
|
// Interactants
|
|
|
const jecT = Array.isArray(json.entry.comment) ? json.entry.comment : [json.entry.comment];
|
|
|
const interactants = jecT
|
|
|
@@ -182,7 +189,8 @@ const getInteractionsFromEntry = (json) => __awaiter(void 0, void 0, void 0, fun
|
|
|
text: e.text
|
|
|
})));
|
|
|
// uniprot_reference_scope
|
|
|
- const referenceInteract = json.entry.reference
|
|
|
+ const jerT = Array.isArray(json.entry.reference) ? json.entry.reference : [json.entry.reference];
|
|
|
+ const referenceInteract = jerT
|
|
|
.map((e) => (Object.assign(Object.assign({}, e), { scope: Array.isArray(e.scope) ? e.scope : [e.scope] })))
|
|
|
.filter((e) => regExp.test(e.scope.join('')))
|
|
|
.map((e) => (Object.assign({ to: e.scope
|
|
|
@@ -206,7 +214,6 @@ const getInteractionsFromEntry = (json) => __awaiter(void 0, void 0, void 0, fun
|
|
|
// Group
|
|
|
const byTo = {};
|
|
|
[...interactants, ...referenceInteract, ...commentInteractsWith]
|
|
|
- //.map((e:any)=> byTo[e.to] = byTo[e.to] ? [e, ...byTo[e.to]] : [e] )
|
|
|
.map((e) => byTo[e.to] = byTo[e.to] ? Object.assign(Object.assign({}, e), byTo[e.to]) : Object.assign({}, e));
|
|
|
const results = Object.keys(byTo).map((e) => {
|
|
|
var _a;
|
|
|
@@ -218,7 +225,6 @@ const getInteractionsFromEntry = (json) => __awaiter(void 0, void 0, void 0, fun
|
|
|
};
|
|
|
})
|
|
|
.filter((e) => !blaskList.includes(e.to) && e.to !== geneName);
|
|
|
- // await fs.promises.writeFile('test/tmp.json', JSON.stringify(results.map((e:any)=>e.to), null,4))
|
|
|
return results;
|
|
|
});
|
|
|
exports.getInteractionsFromEntry = getInteractionsFromEntry;
|