From f0ca8f26beda93f7dc4abf51e394fa80ab3059ab Mon Sep 17 00:00:00 2001 From: "Bruce W. Herr II" Date: Fri, 1 Dec 2023 14:51:58 -0500 Subject: [PATCH] Tighter check on valid AS IDs --- src/normalization/normalize-asct-b.js | 9 +++++++-- src/normalization/patches.js | 4 ++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/normalization/normalize-asct-b.js b/src/normalization/normalize-asct-b.js index d7782a0..40c9068 100644 --- a/src/normalization/normalize-asct-b.js +++ b/src/normalization/normalize-asct-b.js @@ -9,6 +9,7 @@ import { getPatchesForAnatomicalStructure, getPatchesForBiomarker, getPatchesForCellType, + isAsIdValid, isCtIdValid, isDoiValid, isIdValid, @@ -80,7 +81,7 @@ function normalizeAsData(context, data) { is_provisional: !checkNotEmpty(id), }; }) - .filter(({ id }) => passIdFilterCriteria(context, id)) + .filter(({ id }) => passAsIdFilterCriteria(context, id)) .reduce(normalizeAs, collector); return collector; }, getPatchesForAnatomicalStructure(context)); @@ -133,7 +134,7 @@ function normalizeCtData(context, data) { const last_as = row.anatomical_structures .filter(({ id, name }) => checkNotEmpty(id) || checkNotEmpty(name)) .map(({ id, name }) => generateIdWhenEmpty(id, name)) - .filter((id) => passIdFilterCriteria(context, id)) + .filter((id) => passAsIdFilterCriteria(context, id)) .pop(); const last_ct = row.cell_types .filter(({ id, name }) => checkNotEmpty(id) || checkNotEmpty(name)) @@ -278,6 +279,10 @@ function passIdFilterCriteria(context, id) { return isIdValid(id) || !context.excludeBadValues; } +function passAsIdFilterCriteria(context, id) { + return isAsIdValid(id) || !context.excludeBadValues; +} + function passCtIdFilterCriteria(context, id) { return isCtIdValid(id) || !context.excludeBadValues; } diff --git a/src/normalization/patches.js b/src/normalization/patches.js index 3029abb..ef05b42 100644 --- a/src/normalization/patches.js +++ b/src/normalization/patches.js @@ -260,6 +260,10 @@ export function isIdValid(id) { return /(UBERON|FMA|CL|PCL|LMHA|HGNC):\d+|ASCTB-TEMP:[a-zA-Z0-9\-]+/.test(id); } +export function isAsIdValid(id) { + return /(UBERON|FMA):\d+|ASCTB-TEMP:[a-zA-Z0-9\-]+/.test(id); +} + export function isCtIdValid(id) { return /(CL|PCL|LMHA):\d+|ASCTB-TEMP:[a-zA-Z0-9\-]+/.test(id); }