async function getChromosomeAndPosition(rsIDs, genomeBuild, apiKey) {
const requestLimit = 10;
const results = await asyncPool(requestLimit, rsIDs, async (rsID) => {
rsID = rsID.split('rs')[1];
const eutilsURL = `https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=snp&id=${rsID}&retmode=json&api_key=${apiKey}`;
try {
const response = await httpRequest(eutilsURL);
const assembly = response.refsnp[0].placements_with_allele.filter(
(item) => item.assembly_name === genomeBuild
)[0];
if (!assembly) {
throw new Error(`Genome build ${genomeBuild} not found for rsID ${rsID}.`);
}
const chromosome = assembly.seq_id;
const position = assembly.alleles[0].hgvs.lct.position;
return { rsID, chromosome, position };
} catch (error) {
console.error(`Error fetching SNP information for rsID ${rsID}: ${error.message}`);
return null;
}
});
return results;
}