Commit 2b9a3507 authored by Claire Kuchly's avatar Claire Kuchly
Browse files

add number of times adapter are trimmed

parent e508cd41
......@@ -18,10 +18,10 @@
import os,re
from subprocess import Popen, PIPE
from jflow.component import Component
from jflow.iotypes import OutputFileList, InputFileList, OutputFile, Formats
from jflow.abstraction import MultiMap
import jflow.seqio as seqio
from ng6.analysis import Analysis
from ng6.utils import Utils
......@@ -48,7 +48,7 @@ class CutAdapt (Analysis):
sizes[len(seq)] = 1
return [nb_seq, sizes]
def define_parameters(self, input_files_R1, input_files_R2, adapt_FWD, adapt_REV, is_paired=False, error_rate=0.1, min_length=None, max_length=None, overlap_length=None, archive_name=None):
def define_parameters(self, input_files_R1, input_files_R2, adapt_FWD, adapt_REV, is_paired=False, error_rate=0.1, times=None, min_length=None, max_length=None, overlap_length=None, archive_name=None):
self.input_files_R1=InputFileList(input_files_R1, Formats.FASTQ)
self.input_files_R2=InputFileList(input_files_R2, Formats.FASTQ)
self.adapt_FWD=adapt_FWD
......@@ -63,6 +63,7 @@ class CutAdapt (Analysis):
self.min_length=min_length
self.max_length=max_length
self.overlap_length=overlap_length
self.times=times
self.archive_name=archive_name
def define_analysis(self):
......@@ -85,6 +86,9 @@ class CutAdapt (Analysis):
if self.overlap_length:
self.options += " -O " + str(self.overlap_length)
self.parameters += " -O " + str(self.overlap_length)
if self.times:
self.options += " -n " + str(self.times)
self.parameters += " -n " + str(self.times)
for cle, valeur in self.adapt_FWD.items() :
if cle == 'a' :
for adapt in valeur :
......@@ -177,8 +181,8 @@ class CutAdapt (Analysis):
self._add_result_element(sample, "size", samples[sample]["size"])
self._add_result_element(sample, "nb_size", samples[sample]["nb_size"])
# Finaly create and add the archive to the analyse
# Finaly create and add the archive to the analyse
def get_version(self):
cmd = [self.get_exec_path("cutadapt"),"--version"]
p = Popen(cmd, stdout=PIPE, stderr=PIPE)
......@@ -186,19 +190,17 @@ class CutAdapt (Analysis):
return stdout.split()[0]
def process(self):
print self.get_exec_path("cutadapt")
if self.is_paired :
self.tmp_files_R1 = self.get_outputs('{basename_woext}_tmp.fastq', self.input_files_R1)
self.tmp_files_R2 = self.get_outputs('{basename_woext}_tmp.fastq', self.input_files_R2)
#cutAdapt = PythonFunction(cutadaptateur, cmd_format='{EXE} {IN} {OUT} {ARG}')
cutAdapt = ShellFunction(self.get_exec_path("cutadapt") + self.options_REV + self.parameters + " --paired-output $3 -o $4 $1 $2 > $5", cmd_format = '{EXE} {IN} {OUT}')
#cutAdaptR1 = MultiMap(cutAdaptR1, inputs = [self.input_files_R1, self.input_files_R2], outputs =[self.tmp_files_R1, self.tmp_files_R2, self.log_files_R1])
cutAdapt(inputs = [self.input_files_R1, self.input_files_R2], outputs =[self.tmp_files_R1, self.tmp_files_R2, self.log_files_R1])
cutAdapt = MultiMap(cutAdapt, inputs = [self.input_files_R1, self.input_files_R2], outputs =[self.tmp_files_R1, self.tmp_files_R2, self.log_files_R1])
cutAdapt = ShellFunction(self.get_exec_path("cutadapt") + self.options_FWD + self.parameters + " --paired-output $3 -o $4 $1 $2 > $5", cmd_format = '{EXE} {IN} {OUT} ')
#cutAdaptR2 = MultiMap(cutAdaptR2, inputs = [self.tmp_files_R2, self.tmp_files_R1], outputs = [self.output_files_R2, self.output_files_R1 ,self.log_files_R2])
cutAdapt(inputs = [self.tmp_files_R2, self.tmp_files_R1], outputs = [self.output_files_R2, self.output_files_R1 ,self.log_files_R2])
cutAdapt = MultiMap(cutAdapt, inputs = [self.tmp_files_R2, self.tmp_files_R1], outputs = [self.output_files_R2, self.output_files_R1 ,self.log_files_R2])
print "list R1 output : "+str(self.output_files_R1)
else :
cutAdapt = ShellFunction(self.get_exec_path("cutadapt")+ self.options_FWD + self.parameters + " $1 -o $2 > $3", cmd_format='{EXE} {IN} {OUT}')
......
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