Skip to content

Commit

Permalink
Tighter check on valid AS IDs
Browse files Browse the repository at this point in the history
  • Loading branch information
bherr2 committed Dec 1, 2023
1 parent 73399a0 commit f0ca8f2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/normalization/normalize-asct-b.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
getPatchesForAnatomicalStructure,
getPatchesForBiomarker,
getPatchesForCellType,
isAsIdValid,
isCtIdValid,
isDoiValid,
isIdValid,
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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;
}
Expand Down
4 changes: 4 additions & 0 deletions src/normalization/patches.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit f0ca8f2

Please sign in to comment.