generate_multiqc_config.py 1.5 KB
Newer Older
1
2
import re
import sys
mmassaviol's avatar
mmassaviol committed
3
from tools import read_yaml
4
5
6
7

config = read_yaml(sys.argv[1])

def report_section_order():
mmassaviol's avatar
mmassaviol committed
8
9
    res = "skip_generalstats: true\n\n"
    res += "report_section_order:\n"
10
    res += "  Rule_graph:\n" 
11
    res += "    order: 990\n"
12
13
14
15
16
    res += "  params_tab:\n" 
    res += "    order: 980\n"
    res += "  outputs:\n" 
    res += "    order: 970\n"
    cpt = 960
17
    for step in config["steps"]:
18
        tool = config["params"][step["name"]]
19
20
21
22
23
        if (config["multiqc"][tool] != "custom"):
            res += "  " + config["multiqc"][tool] + ":\n"
            res += "    " + "order: " + str(cpt) + "\n"
            cpt += -10
        for rule in config["outputs"][tool]:
mmassaviol's avatar
mmassaviol committed
24
            if ("SeOrPe" not in config.keys() or (config["params"]["SeOrPe"] == "SE" and not("_PE" in rule)) or (config["params"]["SeOrPe"] == "PE" and not("_SE" in rule))):
25
                for output in config["outputs"][tool][rule]:
26
                    if("file" in output.keys() and "mqc" in output["file"] and '{' not in output["file"]): # case of dynamic files ({wildcard}_mqc.png) to deal with
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
                        section = re.sub('\_mqc.*$', '', output["file"])
                        res += "  " + section + ":\n" 
                        res += "    " + "order: " + str(cpt) + "\n"
                        cpt += -10

    return res

def main():
    res = ""
    res += report_section_order()

    with open(sys.argv[2],"w") as out:
        out.write(res)

if __name__ == "__main__":
    # execute only if run as a script
    main()