Commit 5b9ca8cf authored by Penom Nom's avatar Penom Nom
Browse files

1st commit: delly, breakdancer, cnvnator, pindel

Lot of param not defined
parent 97c63a5b
#
# Copyright (C) 2012 INRA
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
import sys, tempfile
from jflow.workflow import Workflow
class SVDetection (Workflow):
def get_description(self):
return "Detect strucural variation in whole genome"
def define_parameters(self, function="process"):
self.add_input_file_list("input_bam", "Which bam files to process", file_format="bam", required=True)
self.add_input_file("reference_genome", "Which genome should the read being align on", file_format="fasta", required=True)
def process(self):
self.add_component("Delly", [self.input_bam, self.reference_genome])
self.add_component("CnvNator", [self.input_bam, self.reference_genome])
self.add_component("Breakdancer", [self.input_bam, self.reference_genome])
self.add_component("Pindel", [self.input_bam, self.reference_genome])
#
# Copyright (C) 2012 INRA
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
\ No newline at end of file
#
# Copyright (C) 2012 INRA
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
from weaver.function import ShellFunction
from jflow.component import Component
from jflow import utils as utils
class Breakdancer (Component):
def define_parameters(self, input_bam, reference_genome):
self.add_input_file_list("input_bam", "Which bam files to process", default=input_bam,
file_format="bam", required=True)
self.add_output_file("breakdancer_cfg", "Breakdancer configuration file", filename="breakdancer.cfg")
self.add_output_file("sv_file", "Breakdancer output file", filename="breadancer.ctx")
def process(self):
bam2cfg = ShellFunction(self.get_exec_path("bam2cfg.pl") + " " + utils.get_argument_pattern(self.input_bam)[0] + " > $1", cmd_format='{EXE} {OUT} {IN}')
bam2cfg(self.input_bam, self.breakdancer_cfg)
breakdancer = ShellFunction(self.get_exec_path("breakdancer-max") + " $1 > $2", cmd_format='{EXE} {IN} {OUT}')
breakdancer(self.breakdancer_cfg, self.sv_files)
\ No newline at end of file
#
# Copyright (C) 2012 INRA
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
from weaver.function import PythonFunction
from jflow.component import Component
from jflow.abstraction import MultiMap
from fileinput import filename
#ma function(ses param)
def cnvnator_func(ref, output, *bam): # Wrapper qui permet de gérer les entrées-sorties complexes de cnvnator
import subprocess
fOut = open(output,'w')
tmp = output+"_tmp.root"
subprocess.Popen(["cnvnator","-root",tmp,"-genome",ref,"-tree",bam]) #TREE
subprocess.Popen(["cnvnator","-root",tmp,"-genome",ref,"-his","100"]) #HIS
subprocess.Popen(["cnvnator","-root",tmp,"-genome",ref,"-stat","100"]) #STAT
subprocess.Popen(["cnvnator","-root",tmp,"-genome",ref,"-partition","100"]) #PARTITION
subprocess.Popen(["cnvnator","-root",tmp,"-genome",ref,"-call","100"],stdout=fOut) #CALL
fOut.close()
class CnvNator (Component):
def define_parameters(self, input_bam, reference_genome):
self.add_input_file_list("input_bam", "Which bam files to process", default=input_bam,
file_format="bam", required=True)
self.add_input_file("reference_genome", "Animal ref file", default=reference_genome,
file_format="fasta", required=True)
self.add_output_file("sv_file", "CNV output file", filename="cnv.out")
def process(self):
cnvnator = PythonFunction(cnvnator_func, cmd_format="{EXE} " + self.reference_genome + " {OUT} {IN}")
cnvnator(self.sv_file, self.input_bam)
\ No newline at end of file
#
# Copyright (C) 2012 INRA
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
from weaver.function import ShellFunction
from jflow.component import Component
from jflow import utils as utils
class Delly (Component):
def define_parameters(self, input_bam, reference_genome):
self.add_input_file_list("input_bam", "Which bam files to process", default=input_bam, file_format="bam", required=True)
self.add_input_file("reference_genome", "Animal ref file", default=reference_genome, file_format="fasta", required=True)
self.add_output_file("sv_file", "By default, DEL output with delly", filename="delly.vcf")
def process(self):
delly = ShellFunction(self.get_exec_path("delly") + " -g " + self.reference_genome + " -o $1 " + utils.get_argument_pattern(self.input_bam)[0], cmd_format='{EXE} {OUT} {IN}')
delly(self.input_bam, self.sv_file)
#
# Copyright (C) 2012 INRA
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
from weaver.function import ShellFunction
from jflow.component import Component
from jflow.abstraction import MultiMap
class Pindel (Component):
def define_parameters(self, input_bam, reference_genome):
self.add_input_file_list("input_bam", "Which bam files to process", default=input_bam,
file_format="bam", required=True)
self.add_input_file("reference_genome", "Animal ref file", default=reference_genome,
file_format="fasta", required=True)
self.add_output_file("pindel_cfg", "Pindel configuration file", filename="pindel.cfg")
self.add_output_file("sv_files", "Pindel output file", filename="pindel.ctx")
def process(self):
# create the config file
cfgh = open(self.pindel_cfg)
h=0
for i in self.input_bam:
h=h+1
cfgh.write(i+"\t380\t"+h)
cfgh.close()
pindel = ShellFunction(self.get_exec_path("pindel") + " -f " + self.reference_genome + " -i $1 -o $2", cmd_format='{EXE} {IN} {OUT}')
pindel(self.pindel_cfg, self.sv_files)
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment