Skip to content

Commit

Permalink
added query to get primaryAccession from proteinId
Browse files Browse the repository at this point in the history
  • Loading branch information
akshatbhargava123 committed Aug 10, 2019
1 parent 6b5415f commit c7c0b7f
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/queries/proteinIdToProtein.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
const queryGeneToProtein = proteinId => ({
name: 'Protein_Sequence',
title: 'Protein --> Sequence',
description:
'for a specified protein or list proteins give the protein sequence and length.',
from: 'Protein',
select: ['primaryIdentifier', 'primaryAccession'],
where: [
{
path: 'Protein.id',
op: '=',
value: proteinId,
switched: 'LOCKED',
switchable: false
}
]
});

// eslint-disable-next-line
function queryData(geneId, serviceUrl, imjsClient = imjs) {
return new Promise((resolve, reject) => {
const service = new imjsClient.Service({ root: serviceUrl });
service
.records(queryGeneToProtein(geneId))
.then(data => {
if (data.length) resolve(data[0]);
else reject('No associated proteins found!');
})
.catch(reject);
});
}

module.exports = queryData;

0 comments on commit c7c0b7f

Please sign in to comment.