Parallelise Output Of Input Function In Snakemake
Hello Snakemake community, I am having quite some troubles to define correctly a function in Snakemake and call it in the params section. The output of the function is a list and m
Solution 1:
What about this below? Note that your get_scontigs_names
doesn't make use of wildcards.
import os, glob
defget_scontigs_names():
scontigs = glob.glob(os.path.join("reference", "Supercontig*"))
files = [os.path.basename(s) for s in scontigs]
name = [i.split('_')[0] for i in files]
return name
supercontigs= get_scontigs_names()
rule all:
input:
"updated/all_supercontigs.sorted.vcf.gz"
rule update_vcf:
input:
len="genome/genome_contigs_len_cumsum.txt",
vcf="filtered/all.vcf.gz",
output:
upd= "updated/{supercontig}.updated.vcf.gz",
shell:
r"""
python 3.7 scripts/update_genomic_reg.py -len {input.len} \
-vcf {input.vcf} -scaf {wildcards.supercontig}
"""
rule list_updated:
input:
expand("updated/{supercontig}.updated.vcf.gz", supercontig= supercontigs),
output:
"updated/all_supercontigs.sorted.vcf.gz",
shell:
r"""
ls {input} > {output}
"""
Solution 2:
I have found the solution to my question inspired by @dariober.
rule all:
input:
"updated/all_supercontigs.updated.list"import os, glob
defget_scontigs_names(wildcards):
scontigs = glob.glob(os.path.join("reference", "Supercontig*"))
files = [os.path.basename(s) for s in scontigs]
name = [i.split('_')[0] for i in files]
return name
rule update_vcf:
input:
len="genome/genome_contigs_len_cumsum.txt",
vcf="filtered/all.vcf.gz"
output:
vcf="updated/all_{supercontig}.updated.vcf.gz"
params:
py3=config["modules"]["py3"],
scaf=get_scontigs_names
shell:
"""
{params.py3} scripts/update_genomic_reg.py -len {input.len} -vcf
{input.vcf} -scaf {wildcards.supercontig}
"""
rule list_updated:
input:
expand("updated/all_{supercontig}.updated.vcf.gz", supercontig =
supercontigs)
output:
"updated/all_supercontigs.updated.list"
shell:
"""
ls {input} > {output}
"""
Post a Comment for "Parallelise Output Of Input Function In Snakemake"