Skip to content

Commit

Permalink
Merge pull request #112 from biothings/fix-nodenorm
Browse files Browse the repository at this point in the history
Fix Nodenorm URLs and add conflation options
  • Loading branch information
tokebe authored Mar 8, 2024
2 parents 9918b20 + cd90746 commit c4c2f7f
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/sri.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ axiosRetry(axios, {

/** convert object of arrays into array of unique IDs */
function combineInputs(userInput: ResolverInput): string[] {
const result = Object.keys(userInput).reduce(function(r, k) {
const result = Object.keys(userInput).reduce(function (r, k) {
return r.concat(userInput[k]);
}, []);
return [...new Set(result)];
Expand All @@ -32,9 +32,9 @@ function combineInputs(userInput: ResolverInput): string[] {
async function query(api_input: string[]) {
const url = {
dev: 'https://nodenormalization-sri.renci.org/get_normalized_nodes',
ci: 'https://nodenorm.ci.transltr.io/1.3/get_normalized_nodes',
test: 'https://nodenorm.test.transltr.io/1.3/get_normalized_nodes',
prod: 'https://nodenorm.transltr.io/1.3/get_normalized_nodes',
ci: 'https://nodenorm.ci.transltr.io/get_normalized_nodes',
test: 'https://nodenorm.test.transltr.io/get_normalized_nodes',
prod: 'https://nodenorm.transltr.io/get_normalized_nodes',
}[process.env.INSTANCE_ENV ?? 'prod'];

const chunked_input = _.chunk(api_input, 1000);
Expand All @@ -44,7 +44,11 @@ async function query(api_input: string[]) {
`Node/${process.version} ${process.platform}`,
].join(' ');
const axios_queries = chunked_input.map((input) => {
return axios.post(url, { curies: input }, { headers: { 'User-Agent': userAgent } });
return axios.post(
url,
{ curies: input, conflate: true, drug_chemical_conflate: true },
{ headers: { 'User-Agent': userAgent } },
);
});
//convert res array into single object with all curies
let res = await Promise.all(axios_queries);
Expand Down

0 comments on commit c4c2f7f

Please sign in to comment.