Skip to content

Commit

Permalink
update apptainers and add vcf to bcf
Browse files Browse the repository at this point in the history
  • Loading branch information
cokelaer committed Nov 21, 2022
1 parent a8929e7 commit 1db904d
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 21 deletions.
3 changes: 2 additions & 1 deletion README.rst
Expand Up @@ -127,7 +127,8 @@ Changelog
========= ======================================================================
Version Description
========= ======================================================================
0.11.1 * Updae rule sambamba to use latest wrappers
0.12.0 * set all apptainers containers and add vcf to bcf conversions
* Update rule sambamba to use latest wrappers
0.11.0 * Add singularity containers
0.10.0 * fully integrated sequana wrappers and simplification of HTML reports
0.9.10 * Uses new sequana_pipetools and wrappers
Expand Down
10 changes: 6 additions & 4 deletions sequana_pipelines/variant_calling/config.yaml
Expand Up @@ -15,7 +15,8 @@ input_pattern: '*fastq.gz'
annotation_file:
reference_file:


apptainers:
sequana_tools: https://zenodo.org/record/7341710/files/sequana_tools_0.14.5.img


# you may add ID, PF, SM, PU, LB read tags
Expand Down Expand Up @@ -63,7 +64,8 @@ bwa_mem:
#
snpeff:
do: true
options: -no-downstream -no-upstream
build_options: # -noCheckCds -noCheckProtein
options: -no-downstream -no-upstream

##############################################################################
# Freebayes - Variant caller
Expand All @@ -85,7 +87,7 @@ freebayes:
# - options: any options recognised by freebayes.
# - Note that ploidy is the one from the 'freebayes' section
joint_freebayes:
do: true
do: false
options: ''

##############################################################################
Expand Down Expand Up @@ -155,7 +157,7 @@ sequana_coverage:
#
freebayes_vcf_filter:
freebayes_score: 20
frequency: 0.7
frequency: 0.1
min_depth: 10
forward_depth: 3
reverse_depth: 3
Expand Down
5 changes: 5 additions & 0 deletions sequana_pipelines/variant_calling/schema.yaml
Expand Up @@ -19,6 +19,9 @@ mapping:
type: str
required: True

"apptainers":
type: any

"bwa_mem":
type: map
mapping:
Expand Down Expand Up @@ -61,6 +64,8 @@ mapping:
mapping:
"do":
type: bool
"build_options":
type: str
"options":
type: str

Expand Down
69 changes: 55 additions & 14 deletions sequana_pipelines/variant_calling/variant_calling.rules
Expand Up @@ -77,10 +77,12 @@ if config["snpeff"]["do"]:
config["annotation_file"]
output:
new_reference
params:
options=config["snpeff"]["build_options"]
log:
"common_logs/snpeff_add_locus_in_fasta.log"
container:
"https://zenodo.org/record/7102074/files/sequana_tools_0.14.3.img"
config['apptainers']['sequana_tools']
wrapper:
f"{sequana_wrapper_branch}/wrappers/snpeff_add_locus_in_fasta"

Expand Down Expand Up @@ -117,7 +119,7 @@ if not config["input_pattern"].endswith("bam"):
options="",
index_algorithm="is"
container:
"https://zenodo.org/record/7102074/files/sequana_tools_0.14.3.img"
config['apptainers']['sequana_tools']
threads: 2
wrapper:
f"{sequana_wrapper_branch}/wrappers/bwa/build"
Expand All @@ -137,7 +139,7 @@ if not config["input_pattern"].endswith("bam"):
options=config["bwa_mem"]["options"],
tmp_directory=config["bwa_mem"]["tmp_directory"]
container:
"https://zenodo.org/record/7102074/files/sequana_tools_0.14.3.img"
config['apptainers']['sequana_tools']
threads: 2
wrapper:
f"{sequana_wrapper_branch}/wrappers/bwa/align"
Expand All @@ -157,7 +159,7 @@ rule add_read_group:
options=config["add_read_group"]["options"],
SM="{sample}"
container:
"https://zenodo.org/record/7102074/files/sequana_tools_0.14.3.img"
config['apptainers']['sequana_tools']
wrapper:
f"{sequana_wrapper_branch}/wrappers/add_read_group"

Expand All @@ -177,7 +179,7 @@ if config["sambamba_markdup"]["do"]:
tmp_directory=config["sambamba_markdup"]["tmp_directory"],
remove_duplicates=config["sambamba_markdup"]["remove_duplicates"]
container:
"https://zenodo.org/record/7102074/files/sequana_tools_0.14.3.img"
config['apptainers']['sequana_tools']
wrapper:
f"{sequana_wrapper_branch}/wrappers/sambamba_markdup"

Expand All @@ -203,7 +205,7 @@ if config["sambamba_filter"]["do"]:
threshold=config["sambamba_filter"]["threshold"],
options=config["sambamba_filter"]["options"]
container:
"https://zenodo.org/record/7102074/files/sequana_tools_0.14.3.img"
config['apptainers']['sequana_tools']
wrapper:
f"{sequana_wrapper_branch}/wrappers/sambamba_filter"

Expand All @@ -224,7 +226,7 @@ if config["sequana_coverage"]["do"]:
log:
"{sample}/samtools_depth/{sample}.log"
container:
"https://zenodo.org/record/7102074/files/sequana_tools_0.14.3.img"
config['apptainers']['sequana_tools']
wrapper:
f"{sequana_wrapper_branch}/wrappers/samtools_depth"

Expand Down Expand Up @@ -276,7 +278,7 @@ rule freebayes:
ploidy=config["freebayes"]["ploidy"],
options=config["freebayes"]["options"]
container:
"https://zenodo.org/record/7102074/files/sequana_tools_0.14.3.img"
config['apptainers']['sequana_tools']
wrapper:
f"{sequana_wrapper_branch}/wrappers/freebayes"

Expand All @@ -298,7 +300,7 @@ if config["snpeff"]["do"]:
params:
options=config["snpeff"]["options"]
container:
"https://zenodo.org/record/7102074/files/sequana_tools_0.14.3.img"
config['apptainers']['sequana_tools']
wrapper:
f"{sequana_wrapper_branch}/wrappers/snpeff"

Expand All @@ -324,11 +326,27 @@ rule freebayes_vcf_filter:
params:
filter_dict=config["freebayes_vcf_filter"]
container:
"https://zenodo.org/record/7102074/files/sequana_tools_0.14.3.img"
config['apptainers']['sequana_tools']
wrapper:
f"{sequana_wrapper_branch}/wrappers/freebayes_vcf_filter"


rule vcf2bcf:
input:
vcf_filter="{sample}/freebayes_vcf_filter/{sample}.filter.vcf"
output:
bcf_filter="{sample}/freebayes_vcf_filter/{sample}.filter.bcf"
container:
config['apptainers']['sequana_tools']
shell:
"""
bgzip -c {input.vcf_filter} > {input.vcf_filter}.gz
tabix {input.vcf_filter}.gz
bcftools view {input.vcf_filter}.gz -O b -o {output.bcf_filter}
"""

expected_output += expand("{sample}/freebayes_vcf_filter/{sample}.filter.bcf", sample=manager.samples)

# ========================================= Joint variant calling with freebayes
#
#
Expand All @@ -346,7 +364,7 @@ if config["joint_freebayes"]["do"]:
ploidy=config["freebayes"]["ploidy"],
options=config["joint_freebayes"]["options"]
container:
"https://zenodo.org/record/7102074/files/sequana_tools_0.14.3.img"
config['apptainers']['sequana_tools']
wrapper:
f"{sequana_wrapper_branch}/wrappers/freebayes"

Expand All @@ -366,7 +384,7 @@ if config["joint_freebayes"]["do"]:
params:
options=config["snpeff"]["options"]
container:
"https://zenodo.org/record/7102074/files/sequana_tools_0.14.3.img"
config['apptainers']['sequana_tools']
wrapper:
f"{sequana_wrapper_branch}/wrappers/snpeff"

Expand All @@ -376,9 +394,16 @@ if config["joint_freebayes"]["do"]:
expected_output+=["joint_calling/joint_calling.raw.vcf"]

# ============================================= freebayes vcf filter
#
def get_joint_freebayes_vcf_filter_input():
if config["snpeff"]["do"]:
return "joint_calling/joint_calling.ann.vcf"
else:
return "joint_calling/joint_calling.raw.vcf"

rule joint_freebayes_vcf_filter:
input:
"joint_calling/joint_calling.raw.vcf"
get_joint_freebayes_vcf_filter_input
output:
vcf="joint_calling/joint_calling.filter.vcf",
csv="joint_calling/joint_calling.filter.csv",
Expand All @@ -387,11 +412,27 @@ if config["joint_freebayes"]["do"]:
filter_dict=config["freebayes_vcf_filter"],
report_dir="joint_calling"
container:
"https://zenodo.org/record/7102074/files/sequana_tools_0.14.3.img"
config['apptainers']['sequana_tools']
wrapper:
f"{sequana_wrapper_branch}/wrappers/freebayes_vcf_filter"
expected_output+=["joint_calling/variant_calling.html"]

rule vcf2bcf_joint:
input:
vcf="joint_calling/joint_calling.filter.vcf"
output:
bcf="joint_calling/joint_calling.filter.bcf"
container:
config['apptainers']['sequana_tools']
shell:
"""
bgzip -c {input.vcf_filter} > {input.vcf_filter}.gz
tabix {input.vcf_filter}.gz
bcftools view {input.vcf}.gz -O b -o {output.bcf}
"""
expected_output += ["joint_calling/joint_calling.filter.bcf"]



# ================================================================= some stats for HTML report
rule stats:
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Expand Up @@ -5,8 +5,8 @@
import subprocess

_MAJOR = 0
_MINOR = 11
_MICRO = 1
_MINOR = 12
_MICRO = 0

version = '%d.%d.%d' % (_MAJOR, _MINOR, _MICRO)
release = '%d.%d' % (_MAJOR, _MINOR)
Expand Down

0 comments on commit 1db904d

Please sign in to comment.