Thomas 3 yıl önce
ebeveyn
işleme
c0bbc4741a
4 değiştirilmiş dosya ile 8 ekleme ve 6 silme
  1. 3 2
      index.js
  2. 3 2
      index.ts
  3. 1 1
      test.js
  4. 1 1
      test.ts

+ 3 - 2
index.js

@@ -144,7 +144,8 @@ const getInteractionsFromEntry = (json) => __awaiter(void 0, void 0, void 0, fun
     const gnT = Array.isArray(json.entry.gene.name) ? json.entry.gene.name : [json.entry.gene.name];
     const geneName = gnT.filter((e) => e.type === 'primary').map((e) => e.value)[0];
     // Interactants
-    const interactants = json.entry.comment
+    const jecT = Array.isArray(json.entry.comment) ? json.entry.comment : [json.entry.comment];
+    const interactants = jecT
         .filter((e) => (e === null || e === void 0 ? void 0 : e.type) === 'interaction')
         .flatMap((e) => ({
         type: 'interactant',
@@ -156,7 +157,7 @@ const getInteractionsFromEntry = (json) => __awaiter(void 0, void 0, void 0, fun
     const regExp = new RegExp('INTERACTION WITH |Interacts with |complex with ', 'i');
     const geneRegExp = new RegExp(/[A-Z]{1}[A-Z|0-9]{2,}$/);
     // uniprot_comment_text_value
-    const commentInteractsWith = json.entry.comment
+    const commentInteractsWith = jecT
         .filter((e) => { var _a; return (_a = e === null || e === void 0 ? void 0 : e.text) === null || _a === void 0 ? void 0 : _a.value; })
         .filter((e) => regExp.test(e.text.value))
         .map((e) => ({

+ 3 - 2
index.ts

@@ -99,7 +99,8 @@ const getInteractionsFromEntry = async (json:any) => {
     const geneName = gnT.filter((e:any)=> e.type === 'primary').map((e:any)=> e.value)[0]
 
     // Interactants
-    const interactants = json.entry.comment
+    const jecT = Array.isArray(json.entry.comment) ? json.entry.comment : [json.entry.comment]
+    const interactants = jecT
     .filter((e:any)=> e?.type === 'interaction')
     .flatMap((e:any) => ({
         type         : 'interactant',
@@ -113,7 +114,7 @@ const getInteractionsFromEntry = async (json:any) => {
     const geneRegExp = new RegExp(/[A-Z]{1}[A-Z|0-9]{2,}$/)
     
     // uniprot_comment_text_value
-    const commentInteractsWith = json.entry.comment
+    const commentInteractsWith = jecT
     .filter((e:any) => e?.text?.value)
     .filter((e:any) => regExp.test(e.text.value))
     .map((e:any) => ({

+ 1 - 1
test.js

@@ -22,7 +22,7 @@ const fs_1 = __importDefault(require("fs"));
     // const n = await getEntryFromGeneName(idmappingPath, uniprotDB, 'TTC23L')
     // await fs.promises.writeFile('test/test-CITED2.json', JSON.stringify(n, null, 4))
     // console.log(await getInteractionsFromEntry(n))
-    const geneName = 'HTT';
+    const geneName = 'EGF';
     const n = yield (0, _1.getEntryFromGeneName)(idmappingPath, uniprotDB, geneName);
     yield fs_1.default.promises.writeFile('test/test-' + geneName + '.json', JSON.stringify(n, null, 4));
     const tmp = yield (0, _1.getInteractionsFromEntry)(n);

+ 1 - 1
test.ts

@@ -11,7 +11,7 @@ import fs from 'fs'
     // await fs.promises.writeFile('test/test-CITED2.json', JSON.stringify(n, null, 4))
     // console.log(await getInteractionsFromEntry(n))
 
-    const geneName = 'HTT'
+    const geneName = 'EGF'
     const n = await getEntryFromGeneName(idmappingPath, uniprotDB, geneName)
     await fs.promises.writeFile('test/test-' + geneName + '.json', JSON.stringify(n, null, 4))
     const tmp = await getInteractionsFromEntry(n)