Skip to content

Commit

Permalink
Merge pull request #396 from cidgoh/grdi-6.2.1
Browse files Browse the repository at this point in the history
update to grdi schema
  • Loading branch information
ddooley authored May 4, 2023
2 parents bce5ef6 + 8e14ee9 commit be9a054
Show file tree
Hide file tree
Showing 8 changed files with 45,349 additions and 7,638 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "data-harmonizer",
"version": "1.4.9",
"version": "1.4.10",
"description": "A standardized spreadsheet editor and validator that can be run offline and locally",
"repository": "git@github.com:cidgoh/DataHarmonizer.git",
"license": "MIT",
Expand Down
6 changes: 3 additions & 3 deletions script/tabular_to_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@

# Cleanup of cell contents.
for field in row:
if field != None:
if field != None and field != '':
row[field] = row[field].strip();

# A row may set a list of new class names to cycle through, which remain
Expand Down Expand Up @@ -292,11 +292,11 @@
if row.get('meaning','') > '':
choice['meaning'] = row.get('meaning');

# At moment linkml doesn't support exact_mappings on
# Export mappings can be established for any enumeration items too.
if len(EXPORT_FORMAT) > 0:
mappings = []
for export_field in EXPORT_FORMAT:
if row[export_field] > '':
if export_field in row and row[export_field] > '':
prefix = export_field[7:] + ':'
for value in row[export_field].split(';'):
mappings.append(prefix + value)
Expand Down
109 changes: 107 additions & 2 deletions web/templates/grdi/export.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,107 @@
// A dictionary of possible export formats
export default {};
// Adds existing functions/methods to DataHarminizer.
export default {
/**
* Download secondary headers and grid data.
* @param {String} baseName Basename of downloaded file.
* @param {Object} hot Handonstable grid instance.
* @param {Object} data See `data.js`.
* @param {Object} xlsx SheetJS variable.
*/

BioSample: {
fileType: 'xls',
status: 'published',
method: function (dh) {
// Create an export table with template's headers (2nd row) and remaining rows of data
const ExportHeaders = new Map([
['sample_name', []], // *
['bioproject_accession',[]], // *
// ['attribute_package',[]],
// ['GISAID_accession',[]],
// ['GISAID_virus_name',[]],
// ['collection_date',[]],
['collected_by', []], // *
['sequenced_by', []], // *`
// ['sequence_submitted_by', []],

['sample collection date',[]], // *

[ // *
'geo_loc_name',
['geo_loc_name (country)', 'geo_loc_name (state/province/region)', 'geo_loc_name (site)'],
],
['organism', []],
// ['isolate', []],
[
'isolation_source',
[
'anatomical_material',
'anatomical_part',
'body_product',
'environmental_material',
'environmental_site',
'collection_device',
'collection_method',
'food_product',
'food_product_properties',
'food_packaging'
],
],
['anatomical_material', []],
['anatomical_part', []],
['body_product', []],
['environmental_material', []],
['environmental_site', []],
['collection_device', []],
['collection_method', []],
// ['lab_host', []],
// ['passage_history', []],
// ['passage_method', []],
['host', []], // *
['host_disease', []], // *
// ['host_health_state', []],
// ['host_disease_outcome', []],
// ['host_age', []],
// ['host_age_unit', []],
// ['host_age_bin', []],
// ['host_sex', []],
// ['host_subject_id', []],
['purpose_of_sampling',[]], // *
['purpose_of_sequencing', []], // *
// ['gene_name_1', []],
// ['diagnostic_PCR_CT_value_1', []],
// ['gene_name_2', []],
// ['diagnostic_PCR_CT_value_2', []],
// ['description',[]],
]);

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');

// 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) {
// Otherwise apply source (many to one) to target field transform:
const value = dh.getMappedField(
headerName,
inputRow,
sources,
sourceFields,
sourceFieldNameMap,
':',
'BIOSAMPLE'
);
outputRow.push(value);
}
outputMatrix.push(outputRow);
}

return outputMatrix;
},
},
};
Loading

0 comments on commit be9a054

Please sign in to comment.