Mercurial > repos > kkonganti > cfsan_bettercallsal
comparison 0.6.1/modules/custom/dump_software_versions/templates/dumpsoftwareversions.py @ 11:749faef1caa9
"planemo upload"
author | kkonganti |
---|---|
date | Tue, 05 Sep 2023 11:51:40 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
10:1b9de878b04a | 11:749faef1caa9 |
---|---|
1 #!/usr/bin/env python | |
2 | |
3 import yaml | |
4 import platform | |
5 import subprocess | |
6 from textwrap import dedent | |
7 | |
8 | |
9 def _make_versions_html(versions): | |
10 html = [ | |
11 dedent( | |
12 """\\ | |
13 <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/v/dt/jszip-2.5.0/dt-1.12.1/b-2.2.3/b-colvis-2.2.3/b-html5-2.2.3/b-print-2.2.3/fc-4.1.0/r-2.3.0/sc-2.0.6/sb-1.3.3/sp-2.0.1/datatables.min.css"/> | |
14 <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.36/pdfmake.min.js"></script> | |
15 <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.36/vfs_fonts.js"></script> | |
16 <script type="text/javascript" src="https://cdn.datatables.net/v/dt/jszip-2.5.0/dt-1.12.1/b-2.2.3/b-colvis-2.2.3/b-html5-2.2.3/b-print-2.2.3/fc-4.1.0/r-2.3.0/sc-2.0.6/sb-1.3.3/sp-2.0.1/datatables.min.js"></script> | |
17 <style> | |
18 #cpipes-software-versions tbody:nth-child(even) { | |
19 background-color: #f2f2f2; | |
20 } | |
21 </style> | |
22 <table class="table" style="width:100%" id="cpipes-software-versions"> | |
23 <thead> | |
24 <tr> | |
25 <th> Process Name </th> | |
26 <th> Software </th> | |
27 <th> Version </th> | |
28 </tr> | |
29 </thead> | |
30 """ | |
31 ) | |
32 ] | |
33 for process, tmp_versions in sorted(versions.items()): | |
34 html.append("<tbody>") | |
35 for i, (tool, version) in enumerate(sorted(tmp_versions.items())): | |
36 html.append( | |
37 dedent( | |
38 f"""\\ | |
39 <tr> | |
40 <td><samp>{process if (i == 0) else ''}</samp></td> | |
41 <td><samp>{tool}</samp></td> | |
42 <td><samp>{version}</samp></td> | |
43 </tr> | |
44 """ | |
45 ) | |
46 ) | |
47 html.append("</tbody>") | |
48 html.append("</table>") | |
49 return "\\n".join(html) | |
50 | |
51 | |
52 versions_this_module = {} | |
53 versions_this_module["${task.process}"] = { | |
54 "python": platform.python_version(), | |
55 "yaml": yaml.__version__, | |
56 } | |
57 | |
58 with open("$versions") as f: | |
59 versions_by_process = yaml.load(f, Loader=yaml.BaseLoader) | |
60 versions_by_process.update(versions_this_module) | |
61 | |
62 # aggregate versions by the module name (derived from fully-qualified process name) | |
63 versions_by_module = {} | |
64 for process, process_versions in versions_by_process.items(): | |
65 module = process.split(":")[-1] | |
66 try: | |
67 assert versions_by_module[module] == process_versions, ( | |
68 "We assume that software versions are the same between all modules. " | |
69 "If you see this error-message it means you discovered an edge-case " | |
70 "and should open an issue in nf-core/tools. " | |
71 ) | |
72 except KeyError: | |
73 versions_by_module[module] = process_versions | |
74 | |
75 versions_by_module["CPIPES"] = { | |
76 "Nextflow": "$workflow.nextflow.version", | |
77 "$workflow.manifest.name": "$workflow.manifest.version", | |
78 "${params.pipeline}": "${params.workflow_version}", | |
79 } | |
80 | |
81 versions_mqc = { | |
82 "id": "software_versions", | |
83 "section_name": "${workflow.manifest.name} Software Versions", | |
84 "section_href": "https://github.com/CFSAN-Biostatistics/bettercallsal", | |
85 "plot_type": "html", | |
86 "description": "Collected at run time from the software output (STDOUT/STDERR).", | |
87 "data": _make_versions_html(versions_by_module), | |
88 } | |
89 | |
90 with open("software_versions.yml", "w") as f: | |
91 yaml.dump(versions_by_module, f, default_flow_style=False) | |
92 | |
93 # print('sed -i -e "' + "s%'%%g" + '" *.yml') | |
94 subprocess.run('sed -i -e "' + "s%'%%g" + '" software_versions.yml', shell=True) | |
95 | |
96 with open("software_versions_mqc.yml", "w") as f: | |
97 yaml.dump(versions_mqc, f, default_flow_style=False) | |
98 | |
99 with open("versions.yml", "w") as f: | |
100 yaml.dump(versions_this_module, f, default_flow_style=False) |