mothurmakeshared.py 1.53 KB
Newer Older
Penom Nom's avatar
Penom Nom committed
1
2
3
4
5
6
7
8
9
10
11
12
from jflow.component import Component
from jflow.iotypes import OutputFile, OutputFileList, InputFile, InputFileList, Formats
from jflow.abstraction import MultiMap

from weaver.function import ShellFunction


class MothurMakeShared(Component):
    """
    Create a table that indicates the number of times an OTU shows up in each sample
    """
    
Penom Nom's avatar
Penom Nom committed
13
    def define_parameters(self, an_list_files, groups_files, label="unique-0.01"):
Penom Nom's avatar
Penom Nom committed
14
15
16
17
18
        """
        :param an_list_files: an list files to process
        :type an_list_files: str
        :param groups_files: groups files to process
        :type groups_files: str
Penom Nom's avatar
Penom Nom committed
19
20
        :param label : 
        :type label : str
Penom Nom's avatar
Penom Nom committed
21
        """
Penom Nom's avatar
Penom Nom committed
22
23
        #define parameters
        self.label = label
Penom Nom's avatar
Penom Nom committed
24
25
26
27
28
29
30
31
        #define input files
        self.an_list_files = InputFileList(an_list_files)
        self.groups_files = InputFileList(groups_files, Formats.MOTHUR_GROUPS)
        #define output files
        self.an_shared_files = OutputFileList(self.get_outputs('{basename_woext}.shared', self.an_list_files))
        self.stdout = OutputFileList(self.get_outputs('{basename_woext}.stdout', self.an_list_files))
    def process(self):
        print ">>>Process make.shared"
Penom Nom's avatar
Penom Nom committed
32
33
        makeshared = ShellFunction(self.get_exec_path("mothur") + ' "#make.shared(list=$1,group=$2,label='+self.label+',outputdir='+self.output_directory+'/)" > $3',\
                                   cmd_format='{EXE} {IN} {OUT}')
Penom Nom's avatar
Penom Nom committed
34
        makeshared = MultiMap(makeshared, inputs=[self.an_list_files,self.groups_files], outputs=[self.stdout,self.an_shared_files])