cidgoh / DataHarmonizer

A standardized browser-based spreadsheet editor and validator that can be run offline and locally, and which includes templates for SARS-CoV-2 and Monkeypox sampling data. This project, created by the Centre for Infectious Disease Genomics and One Health (CIDGOH), at Simon Fraser University, is now an open-source collaboration with contributions from the National Microbiome Data Collaborative (NMDC), the LinkML development team, and others.
MIT License
92 stars 25 forks source link

worked example of default export? #236

Closed turbomam closed 2 years ago

turbomam commented 2 years ago

I have read https://github.com/cidgoh/DataHarmonizer/wiki/DataHarmonizer-Templates#export_-fields but still don't understand how to use it.

I know there the templates bundled with this repo have exports enabled, but I believe they all use custom methods. Are they any examples of enabling exports without any custom JS programming?

For example, I added an EXPORT_MIxS column to my template's data.tsv and populated that with the the values that I want to appear as column headers in the export.

What else do I have to do on top of that? The documentation says to list the "export format keyword" in the TEMPLATES dictionary in main.js, but the dictionary entries look like

'CanCOGeN Covid-19': {'folder': 'canada_covid19', 'status': 'published'}

Would I enter EXPORT_MIxS or MIxS as they key? What should I enter for the folder and status?

ddooley commented 2 years ago

Hi, The TEMPLATES dictionary in main.js serves as a menu system of the templates only. In each template folder the export.js code provides the list of possible export formats for that template in the EXPORT_FORMATS dictionary. I see I toasted the simplest example because it wasn't in use a number of months ago but here it is, so if you have this in your export.js with appropriate name change it should work, i.e. swap in "EXPORT_MIxS" for "Generic":

/**

// A list of the above functions keyed by the Export menu name they should appear as: var EXPORT_FORMATS = { "Generic": {'method': exportGeneric, 'fileType': 'tsv', 'status': 'published'}, //etc };

There is just a default few lines of code that have to be provided for a generic export; otherwise it is a more complicated process if field values or ordering have to be adjusted as part of the export.

turbomam commented 2 years ago

Progress! The export process starts now and I get a download, but there's no header and I'm getting the following error message. I'll remove my creation of the empty 'unknown section' and experiment some more.

Failed to map: The template for the loaded file has a configuration error: unknown section This is a field that has no parent, or a section that has no fields.

turbomam commented 2 years ago

The export looks good now. Thanks.

turbomam commented 2 years ago

Thanks

https://turbomam.github.io/DataHarmonizer/main.html https://turbomam.github.io/DataHarmonizer/main.html

I built that with my new general purpose LinkML to DH converter. Here’s the relevant lines form the Makefile, as a starting point. I haven't documented anything yet, including the dependency on Python Poetry.

https://github.com/turbomam/linkml-round-trips/blob/b3067266d337afb777b8826068475445e191e774/Makefile#L30-L34 https://github.com/turbomam/linkml-round-trips/blob/b3067266d337afb777b8826068475445e191e774/Makefile#L30-L34

On Nov 23, 2021, at 5:59 PM, Damion Dooley @.***> wrote:

Hi, The TEMPLATES dictionary in main.js serves as a menu system of the templates only. In each template folder the export.js code provides the list of possible export formats for that template in the EXPORT_FORMATS dictionary. I see I toasted the simplest example because it wasn't in use a number of months ago but here it is, so if you have this in your export.js with appropriate name change it should work, i.e. swap out "EXPORT_MIxS" for "Generic":

/**

Download secondary headers and grid data. @param https://github.com/param {String} baseName Basename of downloaded file. @param https://github.com/param {Object} hot Handonstable grid instance. @param https://github.com/param {Object} data See data.js. @param https://github.com/param {Object} xlsx SheetJS variable. */ var exportGeneric = (baseName, hot, data, xlsx, fileType) => { // Create an export table with template's headers (2nd row) and remaining rows of data const matrix = [getFlatHeaders(data)[1], ...getTrimmedData(hot)]; runBehindLoadingScreen(exportFile, [matrix, baseName, fileType, xlsx]); }; // A list of the above functions keyed by the Export menu name they should appear as: var EXPORT_FORMATS = { "Generic": {'method': exportGeneric, 'fileType': 'tsv', 'status': 'published'}, //etc };

There is just a default few lines of code that have to be provided for a generic export; otherwise it is a more complicated process if field values or ordering have to be adjusted as part of the export.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/cidgoh/DataHarmonizer/issues/236#issuecomment-977250872, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGAEX6IKJEW3TSZCBXD355DUNQMETANCNFSM5IURUI3A.

ddooley commented 2 years ago

Hi, so if I get this right, the round trip is a good test of what is preserved in a linkml spec in DH, and what is lost at moment, e.g. I presume LinkML fields which are the combo decimal + unit are probably converted to xsd:token fields at moment. I'd still need you to describe to me what your code examples are doing i/o wise.

I'm just turning to more DH work today on smaller items (having validate normalize capitalization of entries to match selection menus for example); next week I aim to finesse the native DH LinkML model, and hopefully tackle the number+unit issue.