From 70a9c170ca47954c1c5ecc34a4009afb3f0ba4f7 Mon Sep 17 00:00:00 2001 From: "Bruce W. Herr II" Date: Wed, 6 Sep 2023 18:30:40 -0400 Subject: [PATCH] Add validation check for CT/1 having a CL ID --- asctb-api/scripts/generate-draft-validation-reports.js | 4 +++- asctb-api/src/functions/api.functions.ts | 4 ++++ asctb-api/src/utils/warnings.ts | 6 ++++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/asctb-api/scripts/generate-draft-validation-reports.js b/asctb-api/scripts/generate-draft-validation-reports.js index 6adbfad2..0ece1219 100644 --- a/asctb-api/scripts/generate-draft-validation-reports.js +++ b/asctb-api/scripts/generate-draft-validation-reports.js @@ -43,6 +43,7 @@ async function getData(draftItems) { "Missing Uberon or CL IDs?", "Unmapped Data found?", "Bad Column found?", + "CT/1 has CL ID?" ], ]; const workbook = XLSX.utils.book_new(); @@ -65,7 +66,7 @@ async function getData(draftItems) { title, ...data .split("\n") - .slice(0, 8) + .slice(0, rows[0].length - 1) .map((d) => { const status = d.slice(-6); return status === "passed" ? checkmark : crossmark; @@ -85,6 +86,7 @@ async function getData(draftItems) { crossmark, crossmark, crossmark, + crossmark, ]); console.log( "Invalid CSV!", diff --git a/asctb-api/src/functions/api.functions.ts b/asctb-api/src/functions/api.functions.ts index 2560877e..d1eb3906 100644 --- a/asctb-api/src/functions/api.functions.ts +++ b/asctb-api/src/functions/api.functions.ts @@ -208,6 +208,10 @@ function checkMissingIds(column: string[], index: number, row: Row, value: strin const colName = columnIndexToName(index-1); warnings.add(`WARNING: Missing RDFS Label for ID ${idValue} at Column: ${colName}, Row: ${row.rowNumber+1} (Code ${WarningCode.MissingCTorAnatomy})`); } + if (column.join('/') == 'CT/1/ID' && (!idValue || !idValue.startsWith('CL:'))) { + const colName = columnIndexToName(index); + warnings.add(`WARNING: CT/1/ID is not a CL ID (required) at Column: ${colName}, Row: ${row.rowNumber+1} (Code ${WarningCode.NoIdInCT1})`); + } } } } diff --git a/asctb-api/src/utils/warnings.ts b/asctb-api/src/utils/warnings.ts index 1c2180a6..e69d981a 100644 --- a/asctb-api/src/utils/warnings.ts +++ b/asctb-api/src/utils/warnings.ts @@ -8,7 +8,8 @@ export enum WarningCode { InvalidCharacter = 5, MissingCTorAnatomy = 6, UnmappedData = 7, - BadColumn = 8 + BadColumn = 8, + NoIdInCT1 = 9 } export const WarningLabels = { @@ -19,5 +20,6 @@ export const WarningLabels = { [WarningCode.InvalidCharacter]: 'Invalid Character found?', [WarningCode.MissingCTorAnatomy]: 'Missing Uberon or CL IDs?', [WarningCode.UnmappedData]: 'Unmapped Data found?', - [WarningCode.BadColumn]: 'Bad Column found?' + [WarningCode.BadColumn]: 'Bad Column found?', + [WarningCode.NoIdInCT1]: 'CT/1 has CL ID?', };