__init__.py 3.41 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#
# 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 jflow.workflow import Workflow

import re

class RNAdiversity (Workflow):

	def process(self):

26
		# first create a oligos file to give as input to mothur 
27
28
29
30
31
32
33
		oligos_fullpath = self.get_temporary_file(suffix=".oligos")
		f = open(oligos_fullpath,"w")
		if self.args["forward_primer"]:
			f.write('forward\t%s\tGroup1\n' % self.args["forward_primer"])
		if self.args["reverse_primer"]:
			f.write('reverse\t%s\n' % self.args["reverse_primer"])
		if self.args["sample_barcodes"]:
Penom Nom's avatar
Penom Nom committed
34
			dict_barcode = dict(re.findall("[\w.]+", self.args["sample_barcodes"])[i:i+2] for i in range(0, len(re.findall("[\w.]+", self.args["sample_barcodes"])), 2))
35
36
37
			for i,j in dict_barcode.items():
				f.write('barcode\t%s\t%s\n' % (j,i))
		f.close()
Penom Nom's avatar
Penom Nom committed
38
 		
39
  		# then process the workflow
40
  		sffinfo = self.add_component("MothurSffinfo", [self.args["sff_files"]])
41
 		shhhflows = self.add_component("MothurShhhFlows",[sffinfo.flow_files])
Jerome Mariette's avatar
Jerome Mariette committed
42
43
   		trimseqs = self.add_component("MothurTrimSeqs",[shhhflows.fasta_files, oligos_fullpath, shhhflows.names_files])
		uniqueseqs = self.add_component("MothurUniqueSeqs",[trimseqs.trim_fasta_files, trimseqs.trim_names_files])
Penom Nom's avatar
Penom Nom committed
44
		alignseqs = self.add_component("MothurAlignSeqs",[uniqueseqs.unique_fasta_files,self.args["reference_alignment"]])
Jerome Mariette's avatar
Jerome Mariette committed
45
46
		summaryseqs_align = self.add_component("MothurSummarySeqs", [alignseqs.align_files,uniqueseqs.unique_names_files],component_prefix="align")	

Jerome Mariette's avatar
Jerome Mariette committed
47
48
49
50
51
52
53
54
55
		#screenseqs = self.add_component("MothurScreenSeqs",[alignseqs.align_files,uniqueseqs.names_files,trimseqs.groups_files])
		#filterseqs = self.add_component("MothurFilterSeqs",[screenseqs.good_align_files])
		#uniqueseqs_filter = self.add_component("MothurUniqueSeqs",[filterseqs.filter_fasta_files,screenseqs.good_names_files],{},"filter")
		#precluster = self.add_component("MothurPreCluster",[uniqueseqs_filter.unique_fasta_files,uniqueseqs_filter.names_files,screenseqs.good_groups_files])
		#chimerauchime = self.add_component("MothurChimeraUchime",[precluster.precluster_fasta_files,precluster.precluster_names_files,screenseqs.good_groups_files])
		#removeseqs = self.add_component("MothurRemoveSeqs",[chimerauchime.uchime_accnos_files,precluster.precluster_fasta_files,precluster.precluster_names_files,\
		#												screenseqs.good_groups_files])
		#classifyseqs = self.add_component("MothurClassifySeqs",[removeseqs.pick_fasta_files,removeseqs.pick_names_files,removeseqs.pick_groups_files,self.args["template"],\
		#														self.args["taxonomy"]])
Penom Nom's avatar
Penom Nom committed
56
57
58
59
#   		removegroups = self.add_component("MothurRemoveGroups", [removeseqs.pick_fasta_files,removeseqs.pick_names_files,removeseqs.pick_groups_files,classifyseqs.taxonomy_files])
# 		krona = self.add_component("MothurKrona", [classifyseqs.taxonomy_files])
# 		distseqs = self.add_component("MothurDistSeqs", [removeseqs.pick_fasta_files, processors])