Commit bb725773 authored by Penom Nom's avatar Penom Nom
Browse files

add multimap screenseqs

parent 4e974f1b
......@@ -21,24 +21,28 @@ from jflow.abstraction import MultiMap
from weaver.function import PythonFunction, ShellFunction
def screen_seqs(exec_path, output_directory, processors, criteria, *files):
def screen_seqs(*files):
import os
# define files
exec_path = files[-4]
output_directory = files[-3]
processors = files[-2]
criteria = files[-1]
# define files
log_summary_files = files[0]
align_path = files[1]
with open(log_summary_files) as log:
for line in log:
if line.startswith(str(criteria)+"%-tile:"):
start, end = line.split()[1:3]
# if names files and groups files are True
if len (files) == 8:
if len (files[:-4]) == 8:
trim_names_path = files [2]
groups_path = files [3]
cmd = str(exec_path)+' "#screen.seqs(fasta='+str(align_path)+',name='+str(trim_names_path)+',group='+str(groups_path)+',outputdir='+str(output_directory)+'/,start='+str(start)+\
',end='+str(end)+',processors='+str(processors)+')"'
# if names files is True but without groups files
elif len(files) == 6:
elif len(files[:-4]) == 6:
trim_names_path = files [2]
cmd = str(exec_path)+' "#screen.seqs(fasta='+str(align_path)+',name='+str(trim_names_path)+',outputdir='+str(output_directory)+'/,start='+str(start)+\
',end='+str(end)+',processors='+str(processors)+')"'
......@@ -91,7 +95,9 @@ class MothurScreenSeqs(Component):
summary = ShellFunction(self.get_exec_path("mothur") + ' "#summary.seqs(fasta=$1,outputdir='+self.output_directory+'/,processors='+str(self.processors)+')" > $2',\
cmd_format='{EXE} {IN} {OUT}')
summary = MultiMap(summary, inputs=[self.align_files], outputs=[self.log])
screenseqs = PythonFunction(screen_seqs, cmd_format="{EXE} {ARG} {IN} {OUT}")
screenseqs(arguments=[self.get_exec_path("mothur"),self.output_directory,self.processors,self.criteria],inputs=[self.log,self.align_files,self.names_files,self.groups_files],\
outputs=[self.good_align_files,self.bad_accnos_files,self.good_names_files,self.good_groups_files])
inputs_filter = [input for input in [self.log, self.align_files, self.names_files, self.groups_files] if input is not None]
outputs_filter = [output for output in [self.good_align_files,self.bad_accnos_files,self.good_names_files, self.good_groups_files] if output is not None]
ARG = " ".join([str(x) for x in [self.get_exec_path("mothur"),self.output_directory,self.processors,self.criteria]])
screenseqs = PythonFunction(screen_seqs,cmd_format='{EXE} {IN} {OUT} '+ARG)
screenseqs = MultiMap(screenseqs,inputs=inputs_filter,outputs=outputs_filter)
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