diff --git a/requirements.txt b/requirements.txt index 6f25331d..25951965 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ # version requirement? dpath==2.0.6 black -linkml_runtime +linkml-runtime \ No newline at end of file diff --git a/script/data-harmonizer/index.js b/script/data-harmonizer/index.js index 623cab08..880f5d1a 100644 --- a/script/data-harmonizer/index.js +++ b/script/data-harmonizer/index.js @@ -147,7 +147,10 @@ let DataHarmonizer = { return template_name; } catch(err) { - console.log(err); + console.log(err); + $('#missing-template-msg').text(`Unable to load template at path "${template_path}". Path should consist of [template folder name]/[template name] with correct capitalization.`); + $('#missing-template-modal').modal('show'); + return false; } }, diff --git a/template/export.js b/template/export.js index bd643840..e3b9b815 100644 --- a/template/export.js +++ b/template/export.js @@ -1,15 +1,38 @@ - // A list of the export functions keyed by the Export menu name they should appear as: var EXPORT_FORMATS = { + /* + Example_Format_Name: { + 'fileType': 'xls', // or 'xlsx', 'tsv', 'csv' + 'status': 'published', // or 'draft' + method: function (dh) { + // Conversion code + const ExportHeaders = new Map([ + ['sample_name', [optional list of source fields to join values from; delimiter is usually semicolon]], + /// ... list of export table fields in order. + ]) -}; + const sourceFields = dh.getFields(dh.table); + const sourceFieldNameMap = dh.getFieldNameMap(sourceFields); + // Fills in the above mapping (or just set manually above) + dh.getHeaderMap(ExportHeaders, sourceFields, 'BIOSAMPLE'); -/* -// Examples: -var EXPORT_FORMATS = { - "IRIDA": {'method': exportIRIDA, 'fileType': 'xls', 'status': 'published'}, - "GISAID": {'method': exportGISAID,'fileType': 'xls', 'status': 'published'}, - "BioSample": {'method': exportBioSample,'fileType': 'xls', 'status': 'published'}, - "CNPHI LaSER": {'method': exportLASER, 'fileType': 'csv (ASCII)', 'status': 'published'} + // Copy headers to 1st row of new export table + const outputMatrix = [[...ExportHeaders.keys()]]; + + for (const inputRow of dh.getTrimmedData(dh.hot)) { + const outputRow = []; + for (const [headerName, sources] of ExportHeaders) { + + // Any custom rules here for data conversions + + // Otherwise apply source (many to one) to target field transform: + const value = dh.getMappedField(headerName, inputRow, sources, sourceFields,sourceFieldNameMap, ':', 'Example_Format_Name') + outputRow.push(value); + } + outputMatrix.push(outputRow); + } + + return outputMatrix + } + */ }; -*/ diff --git a/template/monkeypox/export.js b/template/monkeypox/export.js index 13f9a3a0..e2d270f0 100644 --- a/template/monkeypox/export.js +++ b/template/monkeypox/export.js @@ -262,7 +262,7 @@ var EXPORT_FORMATS = { ['PH_RELATED_RELATIONSHIP_TYPE', []], ['PH_ISOLATION_SITE_DESC', []], ['PH_ISOLATION_SITE', []], - //['PH_SPECIMEN_SOURCE', []], // Calculated field (not in import) + ['PH_SPECIMEN_SOURCE', []], // Calculated field (not in import) ['PH_SPECIMEN_SOURCE_DESC', []], //['PH_ENVIRONMENTAL_MATERIAL', []], //['PH_ENVIRONMENTAL_SITE', []],