Skip to content

Instantly share code, notes, and snippets.

@tryshchenko
Created October 6, 2018 12:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tryshchenko/a472fd28faf06e510b21629ab547a315 to your computer and use it in GitHub Desktop.
Save tryshchenko/a472fd28faf06e510b21629ab547a315 to your computer and use it in GitHub Desktop.
// In order to reduce json file size with such an amount of entities I used short key names:
// gt = alleles group
// rs = Rs[XXXXXX] string
module.exports = (snps, data) =>
snps.reduce((prev, next) => {
if (!next || !next.rs) {
return prev;
}
const rs = next.rs.toLowerCase();
const gt = next.gt;
if (next.gt !== null) {
if (Array.isArray(data[rs]) && data[rs].indexOf(gt) > -1) {
prev.push(next);
}
return prev;
}
if (Array.isArray(data[rs])) {
prev.push(next);
}
return prev;
}, []);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment