pacbio_multi.smk 3.6 KB
Newer Older
Raphael Müller's avatar
Raphael Müller committed
1
OF = WD+"assembly_pacbio_multi/perl/"
Raphael Müller's avatar
Raphael Müller committed
2
perl2nf = lambda s: s.replace(r"/perl/",r"/nextflow/")
Raphael Müller's avatar
Raphael Müller committed
3
4
perl2nf_params = lambda s: s.replace(r"/perl/",r"/nextflow_params/")
NAME = "papapa"
Raphael Müller's avatar
Raphael Müller committed
5

Raphael Müller's avatar
Raphael Müller committed
6
rule assembly_pacbio_multi_perl:
Raphael Müller's avatar
Raphael Müller committed
7
8
  input:
    assembly = ASSEMBLY,
Raphael Müller's avatar
Raphael Müller committed
9
10
11
12
13
    pacbio = [
        "data_prep/pacbio.10000.1.fastq",
        "data_prep/pacbio.10000.5.fastq",
        "data_prep/pacbio.10000.9.fastq"
        ],
Raphael Müller's avatar
Raphael Müller committed
14
  output:
Raphael Müller's avatar
Raphael Müller committed
15
16
    sort_stats_pb = multiext(OF+NAME+".pb.sort_stats/", "genome_results.txt", "qualimapReport.html"),
    pacbio = multiext(OF+NAME+".pb","1.bam","2.bam","3.bam",".bam",*multiext(".sort.bam","",*multiext(".cov-hist","",".pdf"), ".stats",".stats.err"),*multiext(".sort_stats_bamqc.","err","log")) + multiext(OF+NAME+"_minimap_pb","1.err","2.err","3.err"),
Raphael Müller's avatar
Raphael Müller committed
17
18
19
  params:
    prefix=NAME,
    outdir=OF,
Raphael Müller's avatar
Raphael Müller committed
20
    pacbio = lambda wildcards, input: ["-pb "+pb for pb in input.pacbio],
Raphael Müller's avatar
Raphael Müller committed
21
    prgm=config["original_perl_script"]
Raphael Müller's avatar
Raphael Müller committed
22
  threads: 16
23
  conda: "../envs/perl.yml"
Raphael Müller's avatar
Raphael Müller committed
24
  benchmark: repeat("benchmarks/nextflow/{}.tsv".format(NAME), config["benchmark_repeats"])
Raphael Müller's avatar
Raphael Müller committed
25
  log:
Raphael Müller's avatar
Raphael Müller committed
26
27
    stdout = "{folder}{name}.stdout.log".format(folder=OF, name=NAME),
    stderr = "{folder}{name}.stderr.log".format(folder=OF, name=NAME)
Raphael Müller's avatar
Raphael Müller committed
28
29
  shell:
    """
Raphael Müller's avatar
Raphael Müller committed
30
31
32
    rm -rf {params.outdir};
    mkdir -p {params.outdir};
    {params.prgm} -kt -v -a {input.assembly} -o {params.outdir} -pre {params.prefix} -t {threads} {params.pacbio} 1> {log.stdout} 2> {log.stderr}
Raphael Müller's avatar
Raphael Müller committed
33
34
    """

Raphael Müller's avatar
Raphael Müller committed
35
rule assembly_pacbio_multi_nextflow:
Raphael Müller's avatar
Raphael Müller committed
36
  input:
Raphael Müller's avatar
Raphael Müller committed
37
38
    assembly = rules.assembly_pacbio_multi_perl.input.assembly,
    pacbio = rules.assembly_pacbio_multi_perl.input.pacbio,
Raphael Müller's avatar
Raphael Müller committed
39
  output:
Raphael Müller's avatar
Raphael Müller committed
40
    [perl2nf(x) for x in rules.assembly_pacbio_multi_perl.output]
Raphael Müller's avatar
Raphael Müller committed
41
  params:
Raphael Müller's avatar
Raphael Müller committed
42
43
44
    prefix=rules.assembly_pacbio_multi_perl.params.prefix,
    outdir=perl2nf(rules.assembly_pacbio_multi_perl.params.outdir),
    pacbio=lambda wildcards, input: ",".join(input.pacbio),
Raphael Müller's avatar
Raphael Müller committed
45
    prgm=config["nextflow_script"]
Raphael Müller's avatar
Raphael Müller committed
46
  threads: 16
47
  conda: "../envs/nextflow.yml"
Raphael Müller's avatar
Raphael Müller committed
48
  benchmark: repeat("benchmarks/nextflow/{}.tsv".format(NAME), config["benchmark_repeats"])
Raphael Müller's avatar
Raphael Müller committed
49
  log:
Raphael Müller's avatar
Raphael Müller committed
50
51
    stdout = perl2nf(rules.assembly_pacbio_multi_perl.log.stdout),
    stderr = perl2nf(rules.assembly_pacbio_multi_perl.log.stderr),
Raphael Müller's avatar
Raphael Müller committed
52
53
  shell:
    """
Raphael Müller's avatar
Raphael Müller committed
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
    rm -rf {params.outdir};
    mkdir -p {params.outdir};
    {params.prgm} --keep-temporary --assembly {input.assembly} --output {params.outdir} --prefix {params.prefix} --pacbio {params.pacbio} 1> {log.stdout} 2> {log.stderr}
    """

rule assembly_pacbio_multi_nextflow_params:
  input:
    assembly = rules.assembly_pacbio_multi_perl.input.assembly,
    pacbio = rules.assembly_pacbio_multi_perl.input.pacbio,
  output:
    all = [perl2nf_params(x) for x in rules.assembly_pacbio_multi_perl.output],
    params_file = "params_files/pacbio_multi.yaml"
  params:
    prefix=rules.assembly_pacbio_multi_perl.params.prefix,
    outdir=perl2nf_params(rules.assembly_pacbio_multi_perl.params.outdir),
    pacbio=lambda wildcards, input: "\\n".join([ " - " + x for x in input.pacbio]),
    prgm=config["nextflow_script"]
  threads: 16
72
  conda: "../envs/nextflow.yml"
Raphael Müller's avatar
Raphael Müller committed
73
74
75
76
77
78
79
80
81
82
83
84
85
  benchmark: repeat("benchmarks/nextflow_params/{}.tsv".format(NAME), config["benchmark_repeats"])
  log:
    stdout = perl2nf_params(rules.assembly_pacbio_multi_perl.log.stdout),
    stderr = perl2nf_params(rules.assembly_pacbio_multi_perl.log.stderr),
  shell:
    """
    rm -rf {params.outdir};
    mkdir -p {params.outdir};

    echo "pacbio:" > {output.params_file} 
    echo -e "{params.pacbio}" >> {output.params_file}

    {params.prgm} --keep-temporary --assembly {input.assembly} --output {params.outdir} --prefix {params.prefix} -params-file {output.params_file} 1> {log.stdout} 2> {log.stderr}
Raphael Müller's avatar
Raphael Müller committed
86
87
    """