Skip to content

Commit f177eb2

Browse files
authored
Merge pull request #1156 from maxplanck-ie/allelic_whatshap_dna
Allelic whatshap dna
2 parents 99aa7fe + 74512a3 commit f177eb2

File tree

10 files changed

+74
-14
lines changed

10 files changed

+74
-14
lines changed

conda-recipe/meta.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{% set version = "3.4.0" %}
1+
{% set version = "3.5.0" %}
22

33
package:
44
name: snakepipes

docs/content/News.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
snakePipes News
22
===============
33

4+
snakePipes 3.5.0
5+
----------------
6+
7+
* Allelic-whatshap mode was added to DNAmapping. Requires --phasedVcf.
8+
* Allelic-whatshap mode now works with alignment-free mode and fromBAM in the mRNAseq workflow.
9+
10+
411
snakePipes 3.4.0
512
----------------
613

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta"
66
name = "snakePipes"
77
description = 'Snakemake workflows and wrappers for NGS data processing from the MPI-IE'
88
readme = "README.md"
9-
version = "3.4.0"
9+
version = "3.5.0"
1010
keywords = [
1111
"DNAmapping",
1212
"ChIPSeq",

snakePipes/shared/rules/multiQC.snakefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ def multiqc_input_check(return_value):
5858
infiles.append( expand("allelic_bams/{sample}.filtered.SNPsplit_report.yaml", sample = samples) )
5959
infiles.append( expand("allelic_bams/{sample}.filtered.SNPsplit_sort.yaml", sample = samples) )
6060
indir += "allelic_bams"
61+
if "allelic-whatshap" in mode:
62+
infiles.append( expand("allelic_bams/{sample}.{suffix}.sorted.bam",sample=samples,suffix=['allele_flagged', 'genome1', 'genome2', 'unassigned']))
63+
indir += "allelic_bams"
6164
elif pipeline=="rnaseq":
6265
# must be RNA-mapping, add files as per the mode
6366
if ( "alignment" in mode or "deepTools_qc" in mode or "three-prime-seq" in mode ) and not "allelic-mapping" in mode and not "allelic-counting" in mode and not "allelic-whatshap" in mode:

snakePipes/workflows/DNAmapping/DNAmapping.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ def parse_args(defaults={"verbose": False, "configFile": None,
2626
"alignerOpts": "", "mateOrientation": "--fr",
2727
"UMIDedup": False, "UMIDedupOpts": "",
2828
"UMIDedupSep": "_", "UMIBarcode": False, "cutntag": False,
29-
"bcPattern": "NNNNCCCCCCCC", "aligner":"Bowtie2"}):
29+
"bcPattern": "NNNNCCCCCCCC", "aligner":"Bowtie2",
30+
"pvcf": None}):
3031
"""
3132
Parse arguments from the command line.
3233
"""
@@ -47,7 +48,7 @@ def parse_args(defaults={"verbose": False, "configFile": None,
4748
optional.add_argument("-m", "--mode",
4849
dest="mode",
4950
help="workflow running modes (available: 'mapping,"
50-
"allelic-mapping')(default: '%(default)s')",
51+
"allelic-mapping, allelic-whatshap')(default: '%(default)s')",
5152
default=defaults["mode"])
5253

5354
parserCommon.commonOptions(optional, defaults)
@@ -113,6 +114,11 @@ def parse_args(defaults={"verbose": False, "configFile": None,
113114
choices=["Bowtie2","bwa","bwa-mem2"],
114115
default=defaults["aligner"])
115116

117+
optional.add_argument("--phasedVcf",
118+
dest="pvcf",
119+
help="Phased vcf required for whatshap haplotagging. (default: '%(default)s')",
120+
default=defaults["pvcf"])
121+
116122
return parser
117123

118124

snakePipes/workflows/DNAmapping/Snakefile

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ else:
8484
elif aligner == "bwa-mem2":
8585
include: os.path.join(maindir, "shared", "rules", "bwa-mem2.snakefile")
8686

87+
if "allelic-whatshap" in mode:
88+
include: os.path.join(maindir, "shared", "rules", "whatshap.snakefile")
89+
include: os.path.join(maindir, "shared", "rules", "deepTools_qc_allelic.snakefile")
90+
8791
### conditional/optional rules #################################################
8892
################################################################################
8993

@@ -126,12 +130,6 @@ def run_deepTools_qc():
126130
file_list.append(expand("deepTools_qc/estimateReadFiltering/{sample}_filtering_estimation.txt",sample = samples))
127131
return (file_list)
128132

129-
def run_Qualimap():
130-
file_list = []
131-
if qualimap:
132-
file_list += expand("Qualimap_qc/{sample}.filtered.bamqc_report.html", sample = samples)
133-
file_list += expand("Qualimap_qc/{sample}.filtered.bamqc_results.txt", sample = samples)
134-
return (file_list)
135133
# allele specific
136134
def make_nmasked_genome():
137135
if allele_mode == 'create_and_map':
@@ -160,6 +158,21 @@ def run_allelesp_mapping():
160158
else:
161159
return([])
162160

161+
def run_whatshap():
162+
if "allelic-whatshap" in mode:
163+
allele_suffix = ['allele_flagged', 'genome1', 'genome2', 'unassigned']
164+
file_list = [
165+
expand("allelic_bams/{sample}.{suffix}.sorted.bam", sample = samples,
166+
suffix = allele_suffix),
167+
expand("allelic_bams/{sample}.{suffix}.sorted.bam.bai", sample = samples,
168+
suffix = allele_suffix),
169+
expand("bamCoverage/allele_specific/{sample}.{suffix}.seq_depth_norm.bw", sample = samples,
170+
suffix = ['genome1', 'genome2'])
171+
]
172+
return(file_list)
173+
else:
174+
return([])
175+
163176
### execute before workflow starts #############################################
164177
################################################################################
165178
onstart:
@@ -196,9 +209,9 @@ rule all:
196209
expand("bamCoverage/{sample}.filtered.seq_depth_norm.bw", sample = samples),
197210
run_computeGCBias(GCBias),
198211
run_deepTools_qc(),
199-
run_Qualimap(),
200212
make_nmasked_genome(),
201213
run_allelesp_mapping(),
214+
run_whatshap(),
202215
"multiQC/multiqc_report.html"
203216

204217
### execute after workflow finished ############################################

snakePipes/workflows/DNAmapping/defaults.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,5 @@ UMIDedupOpts:
6464
fragmentLength: 200
6565
qualimap: false
6666
verbose: false
67+
#phased vcf
68+
pvcf:

snakePipes/workflows/DNAmapping/internals.snakefile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@ if trim:
2727

2828
### Initialization #############################################################
2929

30+
if "allelic-whatshap" in mode:
31+
if "allelic-mapping" in mode:
32+
sys.exit("Allelic-mapping and allelic-whatshap modes are not compatible. Please choose one or another.")
33+
if not pvcf:
34+
sys.exit("Allelic-whatshap mode was specified but no phased vcf file was provided. Please provided the path to a phased vcf file.")
35+
if not os.path.isfile(pvcf):
36+
sys.exit(f"File {pvcf} doesn't exist.")
37+
38+
3039
infiles = sorted(glob.glob(os.path.join(str(indir or ''), '*'+ext)))
3140
if infiles == []:
3241
sys.exit("Error! Samples extnesion in {} are not {}. "
@@ -71,3 +80,4 @@ else:
7180
f = open(filter_rules, "w")
7281
f.write(filt)
7382
f.close()
83+

snakePipes/workflows/mRNAseq/mRNAseq.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def parse_args(defaults={"verbose": False, "configFile": None,
103103
default=defaults["LRT"])
104104

105105

106-
optional.add_argument("--phased-vcf",
106+
optional.add_argument("--phasedVcf",
107107
dest="pvcf",
108108
help="Phased vcf required for whatshap haplotagging. (default: '%(default)s')",
109109
default=defaults["pvcf"])

tests/test_jobcounts.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,25 @@ def test_allelic_2strains(self,ifs):
549549
_p = sp.run(ci, capture_output=True, text=True)
550550
assert _p.returncode == 0
551551
assert parseSpOut(_p) == 143
552+
def test_whatshap_allelic(self, ifs):
553+
ci = [
554+
"DNAmapping",
555+
'-i',
556+
ifs / 'PE',
557+
'-o',
558+
ifs / 'outdir',
559+
'--snakemakeOptions',
560+
SMKOPTS,
561+
ifs / 'org.yaml',
562+
'-m',
563+
'allelic-whatshap',
564+
'--phasedVcf',
565+
ifs / 'allelic_input' / 'file.vcf.gz'
566+
]
567+
print(' '.join([str(i) for i in ci]))
568+
_p = sp.run(ci, capture_output=True, text=True)
569+
assert _p.returncode == 0
570+
assert parseSpOut(_p) == 180
552571

553572
class TestChIPseq:
554573
def test_default(self, ifs):
@@ -1832,7 +1851,7 @@ def test_whatshap_allelic(self, ifs):
18321851
ifs / 'sampleSheet.tsv',
18331852
'-m',
18341853
'allelic-whatshap,deepTools_qc',
1835-
'--phased-vcf',
1854+
'--phasedVcf',
18361855
ifs / 'allelic_input' / 'file.vcf.gz'
18371856
]
18381857
print(' '.join([str(i) for i in ci]))
@@ -1856,7 +1875,7 @@ def test_whatshap_allelic_fromBAM(self, ifs):
18561875
ifs / 'sampleSheet.tsv',
18571876
'-m',
18581877
'allelic-whatshap,deepTools_qc',
1859-
'--phased-vcf',
1878+
'--phasedVcf',
18601879
ifs / 'allelic_input' / 'file.vcf.gz'
18611880
]
18621881
print(' '.join([str(i) for i in ci]))

0 commit comments

Comments
 (0)