Skip to content

Commit cf9c2de

Browse files
authored
Merge pull request #88 from SebastianHollizeck/master
cleanup of spagetti code through inheritance
2 parents 55456d4 + 14e1e7e commit cf9c2de

21 files changed

+419
-769
lines changed
Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
from .freebayessomaticworkflow import FreeBayesSomaticWorkflow
2-
from .freebayessomaticworkflow_cram import FreeBayesSomaticWorkflowCram
3-
4-
from .mutect2jointsomaticworkflow import Mutect2JointSomaticWorkflow
5-
from .mutect2jointsomaticworkflow_cram import Mutect2JointSomaticWorkflowCram
6-
7-
from .strelka2passworkflow import Strelka2PassWorkflow
8-
from .strelka2passworkflow_cram import Strelka2PassWorkflowCram
1+
from .freebayes import *
2+
from .mutect2 import *
3+
from .strelka2 import *
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from .freebayessomaticworkflow import FreeBayesSomaticWorkflow
2+
from .freebayessomaticworkflow_cram import FreeBayesSomaticWorkflowCram

janis_bioinformatics/tools/dawson/workflows/variantcalling/multisample/freebayessomaticworkflow.py renamed to janis_bioinformatics/tools/dawson/workflows/variantcalling/multisample/freebayes/freebayessomaticworkflow.py

Lines changed: 52 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
from datetime import date
22

3-
from janis_bioinformatics.data_types import BamBai, FastaFai
3+
from janis_bioinformatics.data_types import FastaFai
44
from janis_bioinformatics.tools import BioinformaticsWorkflow
55
from janis_bioinformatics.tools.bcftools import BcfToolsNormLatest as BcfToolsNorm
66
from janis_bioinformatics.tools.dawson import (
77
CallSomaticFreeBayes_0_1 as CallSomaticFreeBayes,
88
)
99
from janis_bioinformatics.tools.dawson.createcallregions.base import CreateCallRegions
10-
from janis_bioinformatics.tools.freebayes.versions import FreeBayes_1_3 as FreeBayes
10+
1111
from janis_bioinformatics.tools.htslib import BGZipLatest as BGZip, TabixLatest as Tabix
1212
from janis_bioinformatics.tools.vcflib import (
1313
VcfAllelicPrimitivesLatest as VcfAllelicPrimitives,
@@ -31,10 +31,10 @@ def tool_provider(self):
3131
return "Dawson Labs"
3232

3333
def version(self):
34-
return "0.1"
34+
return "0.1.1"
3535

3636
def bind_metadata(self):
37-
self.metadata.version = "0.1"
37+
self.metadata.version = "0.1.1"
3838
self.metadata.dateCreated = date(2019, 10, 18)
3939
self.metadata.dateUpdated = date(2020, 12, 10)
4040

@@ -52,23 +52,63 @@ def bind_metadata(self):
5252
This allows a joint somatic genotyping of multiple samples of the same individual.
5353
""".strip()
5454

55+
# this is a way to get the tool without spagetti code in bam and cram format
56+
def getFreebayesTool(self):
57+
from janis_bioinformatics.tools.freebayes.versions import (
58+
FreeBayes_1_3 as freebayes,
59+
)
60+
61+
return freebayes
62+
63+
def getFreebayesInputType(self):
64+
from janis_bioinformatics.data_types import BamBai
65+
66+
return BamBai
67+
5568
def constructor(self):
5669

57-
self.input("bams", Array(BamBai))
70+
self.input(
71+
"bams",
72+
Array(self.getFreebayesInputType()),
73+
doc="All bams to be analysed. Samples can be split over multiple bams as well as multiple samples can be contained in one bam as long as the sample ids are set properly.",
74+
)
5875

59-
self.input("reference", FastaFai)
60-
self.input("regionSize", int, default=10000000)
76+
self.input(
77+
"reference",
78+
FastaFai,
79+
doc="The reference the bams were aligned to, with a fai index.",
80+
)
81+
self.input(
82+
"regionSize",
83+
int,
84+
default=10000000,
85+
doc="the size of the regions, to parallelise the analysis over. This needs to be adjusted if there are lots of samples or very high depth sequencing in the analysis.",
86+
)
6187

62-
self.input("normalSample", String)
88+
self.input(
89+
"normalSample",
90+
String,
91+
doc="The sample id of the normal sample, as it is specified in the bam header.",
92+
)
6393

6494
# this is the coverage per sample that is the max we will analyse. It will automatically
6595
# multiplied by the amount of input bams we get
66-
self.input("skipCov", Int(optional=True), default=500)
96+
self.input(
97+
"skipCov",
98+
Int(optional=True),
99+
default=500,
100+
doc="The depth per sample, at which the variant calling process will skip a region. This is used to ignore regions with mapping issues, like the centromeres as well as heterochromatin. A good value is 3 times the maximum expected coverage.",
101+
)
67102

68103
# the same is true for min cov
69-
self.input("minCov", Int(optional=True), default=10)
104+
self.input(
105+
"minCov",
106+
Int(optional=True),
107+
default=10,
108+
doc="Minimum coverage over all samples, to still call variants.",
109+
)
70110

71-
# this should be a conditional (if the callregions are supplied we use them, otherwise we
111+
# this could be a conditional (if the callregions are supplied we use them, otherwise we
72112
# create them)
73113
self.step(
74114
"createCallRegions",
@@ -79,7 +119,7 @@ def constructor(self):
79119

80120
self.step(
81121
"callVariants",
82-
FreeBayes(
122+
self.getFreebayesTool()(
83123
bams=self.bams,
84124
reference=self.reference,
85125
pooledDiscreteFlag=True,
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
from .freebayessomaticworkflow import (
2+
FreeBayesSomaticWorkflow,
3+
)
4+
5+
6+
class FreeBayesSomaticWorkflowCram(FreeBayesSomaticWorkflow):
7+
def id(self):
8+
return "FreeBayesSomaticWorkflowCram"
9+
10+
def friendly_name(self):
11+
return "Freebayes somatic workflow (CRAM)"
12+
13+
# this is a way to get the tool without spagetti code in bam and cram format
14+
def getFreebayesTool(self):
15+
from janis_bioinformatics.tools.freebayes.versions import (
16+
FreeBayesCram_1_3 as freebayes,
17+
)
18+
19+
return freebayes
20+
21+
def getFreebayesInputType(self):
22+
from janis_bioinformatics.data_types import CramCrai
23+
24+
return CramCrai
25+
26+
27+
if __name__ == "__main__":
28+
29+
wf = FreeBayesSomaticWorkflowCram()
30+
wdl = wf.translate("wdl", to_console=True, to_disk=False, write_inputs_file=False)

janis_bioinformatics/tools/dawson/workflows/variantcalling/multisample/freebayessomaticworkflow_cram.py

Lines changed: 0 additions & 195 deletions
This file was deleted.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from .mutect2jointsomaticworkflow import Mutect2JointSomaticWorkflow
2+
from .mutect2jointsomaticworkflow_cram import Mutect2JointSomaticWorkflowCram

0 commit comments

Comments
 (0)