Commit 02fca5d5 authored by Erwan DELAGE's avatar Erwan DELAGE
Browse files

Report : Add config section

parent 552e35de
......@@ -58,7 +58,11 @@ def initialize_pipeline(arguments):
except ValueError:
json_config_path = ("command line", arguments[arguments.index("--configfiles") + 1])
# Check the configuration file
# Get commit number
global commit_number
commit_number = Repo("./").head.commit
# Check the configuration file
check_config()
# Check if the MANIFEST file is conform
......@@ -135,7 +139,7 @@ def log_config():
microlog.info("Configuration file : {} (from {})".format(json_config_path[1], json_config_path[0]))
# Last commit
microlog.info("Last commit : {}".format(Repo("./").head.commit))
microlog.info("Last commit : {}".format(commit_number))
# Log config
for key, value in sorted(config.items()):
......@@ -1281,10 +1285,12 @@ if "denoiser" in config["global"]:
############################
rule build_report:
input :
config=json_config_path[1]
output:
outdir + "/report.tar.gz"
shell: """
python scripts/build_report/build_report.py {outdir}
python scripts/build_report/build_report.py {outdir} {input.config} {commit_number}
tar czvf {output} -C {outdir} report
rm -r {outdir}/report
"""
......
......@@ -4,7 +4,8 @@
"context": "test/context.tsv",
"outdir": "out_dada2",
"parallel-samples": false,
"nbthreads": 2
"nbthreads": 2,
"project_name": "Toy dataset"
},
"dada2": {
"p-trunc-len-f": 245,
......
......@@ -7,9 +7,10 @@ from jinja2 import Environment, PackageLoader
import os.path
import sys
import shutil
import json
def gather_outputs():
def gather_outputs(config, commit_number):
"""
Gather all interesting pipeline outputs (HTML viz, data tables...) in a single directory and feed
the template dictionary that will be used to generate the html report.
......@@ -25,6 +26,18 @@ def gather_outputs():
pass
os.mkdir(REPORT_DIR)
# Get commit number associated with the run
template_data["commit_number"] = commit_number
# Get run configuration
template_data["config"] = config
# Get project name
try:
template_data["project_name"] = config["global"]["project_name"]
except KeyError:
pass
# Get multiqc report
if os.path.isfile(INDIR + "/multiqc/multiqc_report.html"):
os.mkdir(REPORT_DIR + "/multiqc")
......@@ -145,12 +158,27 @@ if __name__ == "__main__":
global INDIR
INDIR = sys.argv[1]
# Get json config file
config_json = sys.argv[2]
with open(config_json) as json_file:
config = json.load(json_file)
# Replace boolean with strings as javascript boolean notation differs from python
# TODO : if more boolean variables are meant to be used in the pipeline, create a function to handle those cases
if config["global"]["parallel-samples"] == True:
config["global"]["parallel-samples"] = "True"
else:
config["global"]["parallel-samples"] = "False"
# Get commit number
commit_number = sys.argv[3]
# Initialize an empty dictionnary that will feed the template
global template_data
template_data = dict()
# Gather all interesting output (HTML viz, data tables...) in a single directory
gather_outputs()
gather_outputs(config, commit_number)
# Build the html report
build_html_report()
......@@ -13,12 +13,74 @@
<!-- Used to display general infos -->
<link href=".static/bootstrap-3.3.4-dist/css/gentelella.min.css" rel="stylesheet" media="screen">
<style type=“text/css”>
pre {
outline: 1px solid #ccc;
padding: 5px;
margin: 5px;
}
.string {
color: green;
}
.number {
color: darkorange;
}
.boolean {
color: blue;
}
.null {
color: magenta;
}
.key {
color: red;
}
</style>
<!-- Jquery -->
<script src="http://code.jquery.com/jquery.js"></script>
<!-- Bootstrap -->
<script src=".static/bootstrap-3.3.4-dist/js/bootstrap.min.js"></script>
<script src=".static/bootstrap-3.3.4-dist/js/docs.js"></script>
<!-- Prettify json config file -->
<script>
function output(inp) {
document.getElementById("config").appendChild(document.createElement('pre')).innerHTML = inp;
}
function syntaxHighlight(json) {
json = json.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
return json.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g, function (match) {
var cls = 'number';
if (/^"/.test(match)) {
if (/:$/.test(match)) {
cls = 'key';
} else {
cls = 'string';
}
} else if (/true|false/.test(match)) {
cls = 'boolean';
} else if (/null/.test(match)) {
cls = 'null';
}
return '<span class="' + cls + '">' + match + '</span>';
});
}
//var obj = { a: 1, 'b': 'foo', c: [false, 'false', null, 'null', { d: { e: 1.3e5, f: '1.3e5' } }] };
var obj = {{ config }}
var str = JSON.stringify(obj, undefined, 4);
</script>
</head>
<body>
......@@ -26,6 +88,10 @@
<div class="container">
<div class="col-md-12">
<h1>microSysMics report</h1>
{% if project_name %}
<h2>{{project_name}}</h2>
{% endif %}
</div>
</div>
</div>
......@@ -85,6 +151,9 @@
<li>
<a href="#phylogeny">Phylogeny</a>
</li>
<li>
<a href="#config">Configuration</a>
</li>
</ul>
</nav>
</div>
......@@ -297,6 +366,12 @@
href="https://itol.embl.de/upload.cgi" target="_blank">iTol</a> </p>
</div>
<!-- Config -->
<div class="bs-callout bs-callout-info" id="config">
<h4>Configuration</h4>
<p>microSysMics was run with the following configuration </p>
<p>Commit number : <b>{{commit_number}}</b></p>
</div>
</div> <!-- bs-docs-section -->
</div> <!-- col-md-10 -->
......@@ -304,4 +379,9 @@
</div> <!-- container-fluid -->
</body>
<script>
output(syntaxHighlight(str));
</script>
</html>
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment