BCCDC-PHL / tbprofiler-nf

Nextflow Wrapper for TBProfiler
4 stars 2 forks source link

Pretty-print tbprofiler_full_report.json file when writing file #39

Open dfornika opened 1 week ago

dfornika commented 1 week ago

Our tbprofiler_full_report.json files don't have any newlines or indentation. They're fairly large/complex documents so this makes it difficult for a person to visually read the files directly. They can be re-formatted with a text editor, but it would be simpler and more convenient to write the files in "pretty-printed" form (with newlines and indentation).

One way to do this is to just stream the file through python's json.tool module before writing to disk:

On this line:

https://github.com/BCCDC-PHL/tbprofiler-nf/blob/3f8a41da1675cda2fa43e4f6a7e5e74dbf37e838/modules/tbprofiler.nf#L87

We could instead do:

cat results/${sample_id}.results.json | python -m json.tool > ${sample_id}_tbprofiler_full_report.json