Skip to content

Commit

Permalink
feat: Regions, samples and targets in get_bcftools_opts (#19)
Browse files Browse the repository at this point in the history
* new input files added

* black formatting

Co-authored-by: tdayris <[email protected]>
  • Loading branch information
tdayris and tdayris authored Aug 16, 2022
1 parent 5c259f5 commit e916c8b
Showing 1 changed file with 38 additions and 6 deletions.
44 changes: 38 additions & 6 deletions snakemake_wrapper_utils/bcftools.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ def get_bcftools_opts(
snakemake,
parse_threads=True,
parse_ref=True,
parse_region=True,
parse_samples=True,
parse_targets=True,
parse_output=True,
parse_output_format=True,
parse_memory=True,
Expand All @@ -27,7 +30,6 @@ def get_bcftools_opts(
bcftools_opts = ""
extra = snakemake.params.get("extra", "")


###############
### Threads ###
###############
Expand All @@ -42,7 +44,6 @@ def get_bcftools_opts(
else "--threads {}".format(snakemake.threads - 1)
)


######################
### Reference file ###
######################
Expand All @@ -55,6 +56,41 @@ def get_bcftools_opts(
if snakemake.input.get("ref"):
bcftools_opts += f" --fasta-ref {snakemake.input.ref}"

####################
### Regions file ###
####################
if parse_region:
if "--region-file" in extra or "-R" in extra:
sys.exit(
"You have specified region file (`-R/--regions-file`) in `params.extra`; this is automatically infered from the `regions` input file."
)

if snakemake.input.get("regions"):
bcftools_opts += f" --regions-file {snakemake.input.regions}"

####################
### Samples file ###
####################
if parse_samples:
if "-S" in extra or "--samples-file" in extra:
sys.exit(
"You have specified samples file (`-S/--samples-file`) in `params.extra`; this is automatically infered from the `samples` input file."
)

if snakemake.input.get("samples"):
bcftools_opts += f" --samples-file {snakemake.input.samples}"

####################
### Targets file ###
####################
if parse_targets:
if "-T" in extra or "--targets-file" in extra:
sys.exit(
"You have specified samples file (`-T/--targets-file`) in `params.extra`; this is automatically infered from the `targets` input file."
)

if snakemake.input.get("targets"):
bcftools_opts += f" --targets-file {snakemake.input.targets}"

###################
### Output file ###
Expand All @@ -66,7 +102,6 @@ def get_bcftools_opts(
)
bcftools_opts += f" -o {snakemake.output[0]}"


#####################
### Output format ###
#####################
Expand All @@ -81,7 +116,6 @@ def get_bcftools_opts(
)
bcftools_opts += f" --output-type {out_format}"


##############
### Memory ###
##############
Expand All @@ -98,7 +132,6 @@ def get_bcftools_opts(
elif "mem_gb" in snakemake.resources.keys():
bcftools_opts += " --max-mem {}G".format(snakemake.resources["mem_gb"])


################
### Temp dir ###
################
Expand All @@ -107,5 +140,4 @@ def get_bcftools_opts(
"You have provided `-T/--temp-dir/--temp-prefix` in `params.extra`; please use `resources.tmpdir`."
)


return bcftools_opts

0 comments on commit e916c8b

Please sign in to comment.