Skip to content
Snippets Groups Projects
Snakefile_clique_experiments 2.38 KiB
from progressbar import ProgressBar
pbar = ProgressBar()


OUTDIR="snake_experiments" if "outdir" not in config else config["outdir"]
trials=1
N=[1000] if "n" not in config else config["n"] # Number of molecule to simulate
D=[10] if "d" not in config else config["d"] # Average coverage of each molecule
M=[2, 3] if "m" not in config else config["m"] # Average number of molecule per barcode
# M_DEV=[0, 0.5, 1] if "m_dev" not in config else config["m_dev"] # Std deviation for merging number


rule all:
    input:
        f"{OUTDIR}/results.tsv"

rule generate_tsv:
    input:
        expand(f"{OUTDIR}/simu_{{exp}}_bar_n{{n}}_d{{d}}_m{{m}}_results.txt", exp=list(range(trials)), n=N, m=M, d=D)  #, md=M_DEV)
    output:
        f"{OUTDIR}/results.tsv"
    run:
        with open(str(output), "w") as out:
            out.write("nb_mols\tfusion\trun\ttp_cliques\tcliques\ttp_udgs\tudgs\n")
            for file in input:
                # Values extraction
                tp_clqs=0
                clqs=0
                tp_udgs=0
                udgs=0
                with open(file) as inp:
                    lines = inp.readlines()
                    tp_clqs, clqs = [int(x) for x in lines[1].strip().split(" / ")]
                    tp_udgs, udgs = [int(x) for x in lines[3].strip().split(" / ")]

                # Get the important values from the filename
                file = file.split("/")[-1]
                names = file.split("_")
                idx, nb_mols, fusion = int(names[1]), int(names[3][1:]), int(names[5][1:].split(".")[0])

                out.write(f"{nb_mols}\t{fusion}\t{idx}\t{tp_clqs}\t{clqs}\t{tp_udgs}\t{udgs}\n")


rule mesure_quality:
    input:
        f"{OUTDIR}/simu_{{exp}}_bar_n{{n}}_d{{d}}_m{{m}}.gexf"
    output:
        f"{OUTDIR}/simu_{{exp}}_bar_n{{n}}_d{{d}}_m{{m}}_results.txt"
    shell:
        "python3 experiments/clique_graph_eval.py {input} > {output}"


rule generate_barcodes:
    input:
        "{path}/simu_mol_{params}.gexf"
    output:
        "{path}/simu_{idx}_bar_{params}_m{m}.gexf"
    shell:
        "python3 deconvolution/main/generate_fake_barcode_graph.py --merging_depth {wildcards.m} --input_graph {input} --output {output}"

rule generate_molecules:
    output:
        "{path}/simu_mol_n{n}_d{d}.gexf"
    shell:
        "python3 deconvolution/main/generate_fake_molecule_graph.py --num_molecule {wildcards.n} --avg_depth {wildcards.d} --output {output}"