Skip to content

Commit

Permalink
Merge pull request #88 from SebastianHollizeck/master
Browse files Browse the repository at this point in the history
cleanup of spagetti code through inheritance
  • Loading branch information
illusional authored Dec 14, 2020
2 parents 55456d4 + 14e1e7e commit cf9c2de
Show file tree
Hide file tree
Showing 21 changed files with 419 additions and 769 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
from .freebayessomaticworkflow import FreeBayesSomaticWorkflow
from .freebayessomaticworkflow_cram import FreeBayesSomaticWorkflowCram

from .mutect2jointsomaticworkflow import Mutect2JointSomaticWorkflow
from .mutect2jointsomaticworkflow_cram import Mutect2JointSomaticWorkflowCram

from .strelka2passworkflow import Strelka2PassWorkflow
from .strelka2passworkflow_cram import Strelka2PassWorkflowCram
from .freebayes import *
from .mutect2 import *
from .strelka2 import *
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from .freebayessomaticworkflow import FreeBayesSomaticWorkflow
from .freebayessomaticworkflow_cram import FreeBayesSomaticWorkflowCram
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
from datetime import date

from janis_bioinformatics.data_types import BamBai, FastaFai
from janis_bioinformatics.data_types import FastaFai
from janis_bioinformatics.tools import BioinformaticsWorkflow
from janis_bioinformatics.tools.bcftools import BcfToolsNormLatest as BcfToolsNorm
from janis_bioinformatics.tools.dawson import (
CallSomaticFreeBayes_0_1 as CallSomaticFreeBayes,
)
from janis_bioinformatics.tools.dawson.createcallregions.base import CreateCallRegions
from janis_bioinformatics.tools.freebayes.versions import FreeBayes_1_3 as FreeBayes

from janis_bioinformatics.tools.htslib import BGZipLatest as BGZip, TabixLatest as Tabix
from janis_bioinformatics.tools.vcflib import (
VcfAllelicPrimitivesLatest as VcfAllelicPrimitives,
Expand All @@ -31,10 +31,10 @@ def tool_provider(self):
return "Dawson Labs"

def version(self):
return "0.1"
return "0.1.1"

def bind_metadata(self):
self.metadata.version = "0.1"
self.metadata.version = "0.1.1"
self.metadata.dateCreated = date(2019, 10, 18)
self.metadata.dateUpdated = date(2020, 12, 10)

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

# this is a way to get the tool without spagetti code in bam and cram format
def getFreebayesTool(self):
from janis_bioinformatics.tools.freebayes.versions import (
FreeBayes_1_3 as freebayes,
)

return freebayes

def getFreebayesInputType(self):
from janis_bioinformatics.data_types import BamBai

return BamBai

def constructor(self):

self.input("bams", Array(BamBai))
self.input(
"bams",
Array(self.getFreebayesInputType()),
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.",
)

self.input("reference", FastaFai)
self.input("regionSize", int, default=10000000)
self.input(
"reference",
FastaFai,
doc="The reference the bams were aligned to, with a fai index.",
)
self.input(
"regionSize",
int,
default=10000000,
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.",
)

self.input("normalSample", String)
self.input(
"normalSample",
String,
doc="The sample id of the normal sample, as it is specified in the bam header.",
)

# this is the coverage per sample that is the max we will analyse. It will automatically
# multiplied by the amount of input bams we get
self.input("skipCov", Int(optional=True), default=500)
self.input(
"skipCov",
Int(optional=True),
default=500,
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.",
)

# the same is true for min cov
self.input("minCov", Int(optional=True), default=10)
self.input(
"minCov",
Int(optional=True),
default=10,
doc="Minimum coverage over all samples, to still call variants.",
)

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

self.step(
"callVariants",
FreeBayes(
self.getFreebayesTool()(
bams=self.bams,
reference=self.reference,
pooledDiscreteFlag=True,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from .freebayessomaticworkflow import (
FreeBayesSomaticWorkflow,
)


class FreeBayesSomaticWorkflowCram(FreeBayesSomaticWorkflow):
def id(self):
return "FreeBayesSomaticWorkflowCram"

def friendly_name(self):
return "Freebayes somatic workflow (CRAM)"

# this is a way to get the tool without spagetti code in bam and cram format
def getFreebayesTool(self):
from janis_bioinformatics.tools.freebayes.versions import (
FreeBayesCram_1_3 as freebayes,
)

return freebayes

def getFreebayesInputType(self):
from janis_bioinformatics.data_types import CramCrai

return CramCrai


if __name__ == "__main__":

wf = FreeBayesSomaticWorkflowCram()
wdl = wf.translate("wdl", to_console=True, to_disk=False, write_inputs_file=False)

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from .mutect2jointsomaticworkflow import Mutect2JointSomaticWorkflow
from .mutect2jointsomaticworkflow_cram import Mutect2JointSomaticWorkflowCram
Loading

0 comments on commit cf9c2de

Please sign in to comment.