Skip to content
Snippets Groups Projects
Commit 822a6f77 authored by Lihouck Flavien's avatar Lihouck Flavien
Browse files

Everything should work now

parent e06efb74
No related branches found
No related tags found
No related merge requests found
......@@ -8,17 +8,17 @@ config_file = "workflow/config.yaml"
def create_config() :
pattern = ""
parser = argparse.ArgumentParser(description="Creates the config file for Meta-consensus pipeline")
parser = argparse.ArgumentParser(description="Creates the config file then runs the Meta-consensus pipeline")
parser.add_argument("-input", help="Reads file", required=True)
parser.add_argument("-output", help="Target directory for the pipeline results", required=True)
parser.add_argument("-reference", help="Reference for alignment and statistics")
parser.add_argument("-size", help="The size for cutting region (default: 2000)", default='2000')
parser.add_argument("-list", help="A list of regions to work on (format: [r1, r2, ...] or [rStart_End, ...]) (default: no region)")
parser.add_argument("-size", help="The desired region size (default: 2000)", default='2000')
parser.add_argument("-tools", help="The list of tools to use in the meta-consensus (default: ['abpoa', 'spoa', 'kalign2', 'kalign3', 'mafft', 'muscle'])", default="['abpoa', 'spoa', 'kalign2', 'kalign3', 'mafft', 'muscle']")
parser.add_argument("-consensus_threshold", help="Threshold(s) used for the MSA consensus step (default: [70])", default="[70]")
parser.add_argument("-metaconsensus_threshold", help="Threshold(s) used for the Meta-consensus result (default: [60])", default="[60]")
parser.add_argument("-depth", help="The depth used in the process (default: [60])", default="[60]")
parser.add_argument("-plot", help="Analyse the meta-consensus and MSA consensus quality (requires reference)")
parser.add_argument("-plot", help="Analyse the meta-consensus and MSA consensus quality (requires reference)", action='store_true')
parser.add_argument("-region_overlap", help="The size of the overlap between regions", default="50")
parser.add_argument("-cores", help="The amount of cores to use in the pipeline run (default 1)", default=1)
args = parser.parse_args()
......@@ -43,7 +43,7 @@ def create_config() :
actual_regions+= elem+"_"+str(int(elem)+int(args.size))+","
elif last_elem:
actual_regions+= last_elem+'_'+elem+","
last_elem = None
last_elem = elem
else:
last_elem = elem
print(actual_regions)
......
......@@ -472,47 +472,47 @@ if "ref_file" in config:
shell: "./workflow/scripts/exonerate_stats.sh {output} {input.ref} {input.consensus_per_tool} 2> {log}"
rule plot_depth:
input: expand(rules.exonerate_stats_meta.output, depth=config["depth"], allow_missing=True)
input: expand(rules.exonerate_stats_meta.output, depth=config["depth"], output_folder=config['consensus_folder'], allow_missing=True)
params: target_folder="consensus/plot/{region}/graph"
log: "{output_folder}/logs/plot_depth_r{region}_t{threshold}.log"
output: expand(os.path.join("{output_folder}","plot","{region}","graph","graph_depth_r{region}_t{threshold}_{graph}.png"), graph=GRAPH_TYPES, depth=config["depth"], allow_missing=True)
log: "{plot_folder}/logs/plot_depth_r{region}_t{threshold}.log"
output: expand(os.path.join("{plot_folder}","plot","{region}","graph","graph_depth_r{region}_t{threshold}_{graph}.png"), graph=GRAPH_TYPES, depth=config["depth"], allow_missing=True)
message: "Exonerate comparison between meta-consensus and ref (region: {wildcards.region}, or preliminary consensus threshold in [ {config[threshold_1]} ], meta-consensus threshold in [ {config[threshold_2]} ]"
shell: "./workflow/scripts/plot_results.py {wildcards.output_folder}/plot/{wildcards.region}/graph/graph_depth_r{wildcards.region}_t{wildcards.threshold} '[{config[threshold_2]}]' {input} 2> {log}"
shell: "./workflow/scripts/plot_results.py {wildcards.plot_folder}/plot/{wildcards.region}/graph/graph_depth_r{wildcards.region}_t{wildcards.threshold} '[{config[threshold_2]}]' {input} 2> {log}"
rule plot_depth_all:
input: expand(rules.exonerate_stats_meta.output, depth=config["depth"], allow_missing=True), expand(rules.exonerate_stats_tools.output, tool=config["tool"], depth=config["depth"], allow_missing=True)
input: expand(rules.exonerate_stats_meta.output, depth=config["depth"], output_folder=config["consensus_folder"], allow_missing=True), expand(rules.exonerate_stats_tools.output, tool=config["tool"], depth=config["depth"], output_folder=config["consensus_folder"], allow_missing=True)
params: target_folder="consensus/plot/{region}/graph"
log: "{output_folder}/logs/plot_all_depth_r{region}_t{threshold}.log"
output: expand(os.path.join("{output_folder}","plot","{region}","graph","graph_depth_all_r{region}_t{threshold}_{graph}.png"), graph=GRAPH_TYPES, depth=config["depth"], allow_missing=True)
log: "{plot_folder}/logs/plot_all_depth_r{region}_t{threshold}.log"
output: expand(os.path.join("{plot_folder}","plot","{region}","graph","graph_depth_all_r{region}_t{threshold}_{graph}.png"), graph=GRAPH_TYPES, depth=config["depth"], allow_missing=True)
message: "Exonerate comparison between meta-consensus and ref (region: {wildcards.region}, or preliminary consensus threshold in [ {config[threshold_1]} ], meta-consensus threshold in [ {config[threshold_2]} ]"
shell: "./workflow/scripts/plot_results.py {wildcards.output_folder}/plot/{wildcards.region}/graph/graph_depth_all_r{wildcards.region}_t{wildcards.threshold} '[{config[threshold_2]}]' {input} 2> {log}"
shell: "./workflow/scripts/plot_results.py {wildcards.plot_folder}/plot/{wildcards.region}/graph/graph_depth_all_r{wildcards.region}_t{wildcards.threshold} '[{config[threshold_2]}]' {input} 2> {log}"
rule plot_t1:
input: expand(rules.exonerate_stats_meta.output, threshold=config["threshold_1"], allow_missing=True)
params: target_folder="{output_folder}/plot/{region}/{depth}"
log: "{output_folder}/logs/plot_t1_r{region}_d{depth}.log"
output: expand(os.path.join("{output_folder}","plot","{region}","{depth}","graph_r{region}_d{depth}_{graph}.png"), graph=GRAPH_TYPES, allow_missing=True)
input: expand(rules.exonerate_stats_meta.output, threshold=config["threshold_1"], output_folder=config["consensus_folder"], allow_missing=True)
params: target_folder="{plot_folder}/plot/{region}/{depth}"
log: "{plot_folder}/logs/plot_t1_r{region}_d{depth}.log"
output: expand(os.path.join("{plot_folder}","plot","{region}","{depth}","graph_r{region}_d{depth}_{graph}.png"), graph=GRAPH_TYPES, allow_missing=True)
message: "Creating plot for meta-consensus quality with preliminary threshold in [ {config[threshold_1]} ] and meta-consensus in [ {config[threshold_2]} ] (region: {wildcards.region}, depth: {wildcards.depth})"
shell: "./workflow/scripts/plot_results.py {wildcards.output_folder}/plot/{wildcards.region}/{wildcards.depth}/graph_r{wildcards.region}_d{wildcards.depth} '[{config[threshold_2]}]' {input} 2> {log} "
shell: "./workflow/scripts/plot_results.py {wildcards.plot_folder}/plot/{wildcards.region}/{wildcards.depth}/graph_r{wildcards.region}_d{wildcards.depth} '[{config[threshold_2]}]' {input} 2> {log} "
rule plot_t2:
input: expand(rules.exonerate_stats_tools.output, tool=config["tool"], allow_missing=True),
rules.exonerate_stats_meta.output
params: target_folder="{output_folder}/plot/{region}/{depth}/{threshold}/"
log: "{output_folder}/logs/plot_t2_r{region}_d{depth}_t_{threshold}.log"
output: expand(os.path.join("{output_folder}","plot","{region}","{depth}","{threshold}","graph_r{region}_d{depth}_t1_{threshold}_{graph}.png"), graph=GRAPH_TYPES, allow_missing=True)
input: expand(rules.exonerate_stats_tools.output, tool=config["tool"], output_folder=config["consensus_folder"], allow_missing=True),
expand(rules.exonerate_stats_meta.output, output_folder=config["consensus_folder"], allow_missing=True)
params: target_folder="{plot_folder}/plot/{region}/{depth}/{threshold}/"
log: "{plot_folder}/logs/plot_t2_r{region}_d{depth}_t_{threshold}.log"
output: expand(os.path.join("{plot_folder}","plot","{region}","{depth}","{threshold}","graph_r{region}_d{depth}_t1_{threshold}_{graph}.png"), graph=GRAPH_TYPES, allow_missing=True)
message: "Creating plot for meta-consensus compared to preliminary consensus with meta-consensus threshold in {config[threshold_2]} (region: {wildcards.region}, depth: {wildcards.depth}, threshold: {wildcards.threshold})"
shell: "./workflow/scripts/plot_results.py {wildcards.output_folder}/plot/{wildcards.region}/{wildcards.depth}/{wildcards.threshold}/graph_r{wildcards.region}_d{wildcards.depth}_t1_{wildcards.threshold} '[{config[threshold_2]}]' {input} 2> {log}"
shell: "./workflow/scripts/plot_results.py {wildcards.plot_folder}/plot/{wildcards.region}/{wildcards.depth}/{wildcards.threshold}/graph_r{wildcards.region}_d{wildcards.depth}_t1_{wildcards.threshold} '[{config[threshold_2]}]' {input} 2> {log}"
# --------------------------------------------------------#
rule plot:
input: expand(rules.plot_t2.output, region=config["region"], depth=config["depth"], threshold=config["threshold_1"], output_folder=config["consensus_folder"]),
expand(rules.plot_t1.output, region=config["region"], depth=config["depth"] , output_folder=config["consensus_folder"]),
expand(rules.plot_depth.output, region=config["region"], threshold=config["threshold_1"], output_folder=config["consensus_folder"]),
expand(rules.plot_depth_all.output, region=config["region"], threshold=config["threshold_1"], output_folder=config["consensus_folder"])
input: expand(rules.plot_t2.output, region=config["region"], depth=config["depth"], threshold=config["threshold_1"], plot_folder=config["output_folder"]),
expand(rules.plot_t1.output, region=config["region"], depth=config["depth"] , plot_folder=config["output_folder"]),
expand(rules.plot_depth.output, region=config["region"], threshold=config["threshold_1"], plot_folder=config["output_folder"]),
expand(rules.plot_depth_all.output, region=config["region"], threshold=config["threshold_1"], plot_folder=config["output_folder"])
message: "Created all plots"
else :
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment