Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Maintenance - Mise à jour mensuelle Lundi 6 Février entre 7h00 et 9h00
Open sidebar
genotoul-bioinfo
ng6
Commits
9b606774
Commit
9b606774
authored
Aug 29, 2013
by
Penom Nom
Browse files
fix bug label in otuanalysis component
parent
a0cdc5c3
Changes
1
Hide whitespace changes
Inline
Side-by-side
workflows/components/mothurotuanalysis.py
View file @
9b606774
...
...
@@ -21,8 +21,8 @@ def get_taxonomy_to_Krona(exec_krona,output_directory,*files):
#case of 454
start
=
"an."
end
=
".cons"
substrings
=
map
(
lambda
string
:
re
.
search
(
'%s(.*)%s'
%
(
start
,
end
),
string
).
group
(
1
),
taxonomy_files
)
result
=
dict
(
zip
(
substrings
,
taxonomy_files
))
substrings
_labels
=
map
(
lambda
string
:
re
.
search
(
'%s(.*)%s'
%
(
start
,
end
),
string
).
group
(
1
),
taxonomy_files
)
result
=
dict
(
zip
(
substrings
_labels
,
taxonomy_files
))
taxonomy_outputs
=
[]
for
label
,
tax_file
in
result
.
items
():
source
=
tax_file
...
...
@@ -117,12 +117,7 @@ class MothurOTUAnalysis(Analysis):
:param freq :
:type freq : int
"""
#define parameters
self
.
calc
=
calc
self
.
tree_calc
=
tree_calc
self
.
label
=
label
self
.
tree_label
=
tree_label
self
.
freq
=
freq
#define input files
self
.
an_list_files
=
InputFileList
(
an_list_files
)
self
.
taxonomy_files
=
InputFileList
(
taxonomy_files
,
Formats
.
MOTHUR_TAXONOMY
)
...
...
@@ -134,9 +129,16 @@ class MothurOTUAnalysis(Analysis):
else
:
self
.
groups_files
=
None
if
count_table_files
:
self
.
count_table_files
=
InputFileList
(
count_table_files
,
Formats
.
MOTHUR_COUNT_TABLE
)
else
:
self
.
count_table_files
=
None
labels
=
self
.
label
.
split
(
'-'
)
#define parameters
self
.
calc
=
calc
self
.
tree_calc
=
tree_calc
self
.
tree_label
=
tree_label
self
.
freq
=
freq
labels
=
label
.
split
(
'-'
)
user_labels
=
[
lines
.
split
(
'
\t
'
)[
0
]
for
lines
in
open
(
self
.
an_list_files
[
0
]).
readlines
()]
good_label
=
list
(
set
(
user_labels
).
intersection
(
set
(
labels
)))
good_labels
=
list
(
set
(
user_labels
).
intersection
(
set
(
labels
)))
self
.
label
=
good_labels
#define makeshared output files
self
.
shared_files
=
OutputFileList
(
self
.
get_outputs
(
'{basename_woext}.shared'
,
self
.
an_list_files
))
self
.
makeshared_stdout
=
OutputFileList
(
self
.
get_outputs
(
'{basename_woext}.makeshared.stdout'
,
self
.
an_list_files
))
...
...
@@ -147,7 +149,7 @@ class MothurOTUAnalysis(Analysis):
self
.
rarefaction_single_files
=
OutputFileList
(
self
.
get_outputs
(
'{basename_woext}.groups.rarefaction'
,
self
.
shared_files
))
self
.
rarefactionsingle_stdout
=
OutputFileList
(
self
.
get_outputs
(
'{basename_woext}.rarefactionsingle.stdout'
,
self
.
shared_files
))
#define treeshared output files
# list_tree_files = [os.path.splitext(self.shared_files[0])[0]+"."+tree_calc+"."+label+".tre" for label in
good_
label]
# list_tree_files = [os.path.splitext(self.shared_files[0])[0]+"."+tree_calc+"."+label+".tre" for label in
self.
label]
# self.tree_files = OutputFileList(self.get_outputs('{basename}', list_tree_files))
# self.treeshared_stdout = OutputFileList(self.get_outputs('{basename_woext}.treeshared.stdout', self.shared_files))
#define subsample output files
...
...
@@ -159,23 +161,21 @@ class MothurOTUAnalysis(Analysis):
self
.
subsample_count_files
=
OutputFileList
(
self
.
get_outputs
(
'{basename_woext}.subsample.count_table'
,
self
.
count_table_files
),
Formats
.
MOTHUR_COUNT_TABLE
)
self
.
subsample_stdout
=
OutputFileList
(
self
.
get_outputs
(
'{basename_woext}.subsample.stdout'
,
self
.
count_table_files
))
#define classifyotu output files
self
.
cons_taxonomy_files
=
OutputFileList
([
os
.
path
.
join
(
self
.
output_directory
,
l
+
".taxonomy"
)
for
l
in
good_label
],
Formats
.
MOTHUR_TAXONOMY
)
#self.cons_tax_taxonomy_files = OutputFileList(self.get_outputs('{basename_woext}.'+str(self.label.split('-')[0])+'.cons.tax.summary', self.an_list_files))
self
.
cons_taxonomy_files
=
OutputFileList
([
os
.
path
.
join
(
self
.
output_directory
,
l
+
".taxonomy"
)
for
l
in
self
.
label
],
Formats
.
MOTHUR_TAXONOMY
)
self
.
classifyotu_stdout
=
OutputFileList
(
self
.
get_outputs
(
'{basename_woext}.classifyotu.stdout'
,
self
.
an_list_files
))
#define krona output files
#self.krona_files = OutputFileList(self.get_outputs('{basename_woext}.html', self.classifyotu_stdout), Formats.HTML)
#self.krona_stdout = OutputFileList(self.get_outputs('{basename_woext}.krona.stdout', self.cons_taxonomy_files))
def
define_analysis
(
self
):
self
.
name
=
"OTUAnalysis"
self
.
description
=
"Organizational Taxon Unit analysis."
self
.
software
=
"mothur"
label
=
"-"
.
join
(
self
.
label
)
if
self
.
groups_files
:
self
.
options
+=
'#make.shared(list=FILE.an.list,group=FILE.groups,label='
+
self
.
label
+
');'
self
.
options
+=
'#make.shared(list=FILE.an.list,group=FILE.groups,label='
+
label
+
');'
if
self
.
count_table_files
:
self
.
options
+=
'#make.shared(list=FILE.an.list,count=FILE.count_table_files,label='
+
self
.
label
+
');'
self
.
options
+=
'#summary.single(shared=FILE.shared,calc='
+
self
.
calc
+
',label='
+
self
.
label
+
');'
self
.
options
+=
'#rarefaction.single(shared=FILE.shared,label='
+
self
.
label
+
',freq='
+
str
(
self
.
freq
)
+
');'
self
.
options
+=
'#make.shared(list=FILE.an.list,count=FILE.count_table_files,label='
+
label
+
');'
self
.
options
+=
'#summary.single(shared=FILE.shared,calc='
+
self
.
calc
+
',label='
+
label
+
');'
self
.
options
+=
'#rarefaction.single(shared=FILE.shared,label='
+
label
+
',freq='
+
str
(
self
.
freq
)
+
');'
self
.
options
+=
'#tree.shared(shared=FILE.shared,calc='
+
self
.
tree_calc
+
',label='
+
self
.
tree_label
+
');'
if
self
.
fasta_subsample_files
and
self
.
count_table_files
:
self
.
options
+=
'#sub.sample(fasta=FILE.fasta,count=FILE.count_table);'
...
...
@@ -186,13 +186,13 @@ class MothurOTUAnalysis(Analysis):
elif
self
.
an_list_files
and
not
self
.
count_table_files
:
self
.
options
+=
'#sub.sample(list=FILE.list);'
if
self
.
names_files
and
not
self
.
groups_files
:
self
.
options
+=
'#classify.otu(list=FILE.list,taxonomy=FILE.taxonomy,name=FILE.names,label='
+
str
(
self
.
label
)
+
');'
self
.
options
+=
'#classify.otu(list=FILE.list,taxonomy=FILE.taxonomy,name=FILE.names,label='
+
str
(
label
)
+
');'
elif
self
.
names_files
and
self
.
groups_files
:
self
.
options
+=
'#classify.otu(list=FILE.list,taxonomy=FILE.taxonomy,name=FILE.names,group=$4,label='
+
str
(
self
.
label
)
+
');'
self
.
options
+=
'#classify.otu(list=FILE.list,taxonomy=FILE.taxonomy,name=FILE.names,group=$4,label='
+
str
(
label
)
+
');'
elif
self
.
count_table_files
:
self
.
options
+=
'#classify.otu(list=FILE.list,taxonomy=FILE.taxonomy,count=FILE.count_table,label='
+
str
(
self
.
label
)
+
');'
self
.
options
+=
'#classify.otu(list=FILE.list,taxonomy=FILE.taxonomy,count=FILE.count_table,label='
+
str
(
label
)
+
');'
else
:
self
.
options
+=
'#classify.otu(list=FILE.list,taxonomy=FILE.taxonomy,label='
+
str
(
self
.
label
)
+
');'
self
.
options
+=
'#classify.otu(list=FILE.list,taxonomy=FILE.taxonomy,label='
+
str
(
label
)
+
');'
self
.
options
+=
'ImportMothurTaxonomy.pl '
+
" "
.
join
([
os
.
path
.
basename
(
tax
)
for
tax
in
self
.
cons_taxonomy_files
])
+
' -o FILE.html;'
def
get_version
(
self
):
...
...
@@ -355,20 +355,21 @@ class MothurOTUAnalysis(Analysis):
#self._create_and_archive(result_files, archive_name)
def
process
(
self
):
label
=
"-"
.
join
(
self
.
label
)
#Divertsity
if
self
.
groups_files
:
makeshared
=
ShellFunction
(
self
.
get_exec_path
(
"mothur"
)
+
' "#make.shared(list=$1,group=$2,label='
+
self
.
label
+
',outputdir='
+
self
.
output_directory
+
'/)" > $3'
,
\
makeshared
=
ShellFunction
(
self
.
get_exec_path
(
"mothur"
)
+
' "#make.shared(list=$1,group=$2,label='
+
label
+
',outputdir='
+
self
.
output_directory
+
'/)" > $3'
,
\
cmd_format
=
'{EXE} {IN} {OUT}'
)
makeshared
=
MultiMap
(
makeshared
,
inputs
=
[
self
.
an_list_files
,
self
.
groups_files
],
outputs
=
[
self
.
makeshared_stdout
,
self
.
shared_files
])
if
self
.
count_table_files
:
makeshared
=
ShellFunction
(
self
.
get_exec_path
(
"mothur"
)
+
' "#make.shared(list=$1,count=$2,label='
+
self
.
label
+
',outputdir='
+
self
.
output_directory
+
'/)" > $3'
,
\
makeshared
=
ShellFunction
(
self
.
get_exec_path
(
"mothur"
)
+
' "#make.shared(list=$1,count=$2,label='
+
label
+
',outputdir='
+
self
.
output_directory
+
'/)" > $3'
,
\
cmd_format
=
'{EXE} {IN} {OUT}'
)
makeshared
=
MultiMap
(
makeshared
,
inputs
=
[
self
.
an_list_files
,
self
.
count_table_files
],
outputs
=
[
self
.
makeshared_stdout
,
self
.
shared_files
])
# Alpha diversity analysis
summarysingle
=
ShellFunction
(
self
.
get_exec_path
(
"mothur"
)
+
' "#summary.single(shared=$1,calc='
+
self
.
calc
+
',label='
+
self
.
label
+
',outputdir='
+
\
summarysingle
=
ShellFunction
(
self
.
get_exec_path
(
"mothur"
)
+
' "#summary.single(shared=$1,calc='
+
self
.
calc
+
',label='
+
label
+
',outputdir='
+
\
self
.
output_directory
+
'/)" > $2'
,
cmd_format
=
'{EXE} {IN} {OUT}'
)
summarysingle
=
MultiMap
(
summarysingle
,
inputs
=
[
self
.
shared_files
],
outputs
=
[
self
.
summarysingle_stdout
,
self
.
summary_single_files
])
rarefactionsingle
=
ShellFunction
(
self
.
get_exec_path
(
"mothur"
)
+
' "#rarefaction.single(shared=$1,label='
+
self
.
label
+
',freq='
+
str
(
self
.
freq
)
+
',outputdir='
+
\
rarefactionsingle
=
ShellFunction
(
self
.
get_exec_path
(
"mothur"
)
+
' "#rarefaction.single(shared=$1,label='
+
label
+
',freq='
+
str
(
self
.
freq
)
+
',outputdir='
+
\
self
.
output_directory
+
'/)" > $2'
,
cmd_format
=
'{EXE} {IN} {OUT}'
)
rarefactionsingle
=
MultiMap
(
rarefactionsingle
,
inputs
=
[
self
.
shared_files
],
outputs
=
[
self
.
rarefactionsingle_stdout
,
self
.
rarefaction_single_files
])
# Beta diversity analysis
...
...
@@ -391,18 +392,18 @@ class MothurOTUAnalysis(Analysis):
subsample
=
MultiMap
(
subsample
,
inputs
=
[
self
.
an_list_files
],
outputs
=
[
self
.
subsample_stdout
,
self
.
subsample_list_files
])
if
self
.
names_files
and
not
self
.
groups_files
:
classifyotu
=
ShellFunction
(
self
.
get_exec_path
(
"mothur"
)
+
' "#classify.otu(list=$1,taxonomy=$2,name=$3,outputdir='
+
self
.
output_directory
+
'/,
\
label='
+
str
(
self
.
label
)
+
')" > $4'
,
cmd_format
=
'{EXE} {IN} {OUT}'
)
label='
+
str
(
label
)
+
')" > $4'
,
cmd_format
=
'{EXE} {IN} {OUT}'
)
classifyotu
=
MultiMap
(
classifyotu
,
inputs
=
[
self
.
an_list_files
,
self
.
taxonomy_files
,
self
.
names_files
,],
outputs
=
[
self
.
classifyotu_stdout
])
elif
self
.
names_files
and
self
.
groups_files
:
classifyotu
=
ShellFunction
(
self
.
get_exec_path
(
"mothur"
)
+
' "#classify.otu(list=$1,taxonomy=$2,name=$3,group=$4,outputdir='
+
self
.
output_directory
+
'/,
\
label='
+
str
(
self
.
label
)
+
')" > $5'
,
cmd_format
=
'{EXE} {IN} {OUT}'
)
label='
+
str
(
label
)
+
')" > $5'
,
cmd_format
=
'{EXE} {IN} {OUT}'
)
classifyotu
=
MultiMap
(
classifyotu
,
inputs
=
[
self
.
an_list_files
,
self
.
taxonomy_files
,
self
.
names_files
,
self
.
groups_files
],
outputs
=
[
self
.
classifyotu_stdout
])
elif
self
.
count_table_files
:
classifyotu
=
ShellFunction
(
self
.
get_exec_path
(
"mothur"
)
+
' "#classify.otu(list=$1,taxonomy=$2,count=$3,outputdir='
+
self
.
output_directory
+
'/,
\
label='
+
str
(
self
.
label
)
+
')" > $4'
,
cmd_format
=
'{EXE} {IN} {OUT}'
)
label='
+
str
(
label
)
+
')" > $4'
,
cmd_format
=
'{EXE} {IN} {OUT}'
)
classifyotu
=
MultiMap
(
classifyotu
,
inputs
=
[
self
.
an_list_files
,
self
.
taxonomy_files
,
self
.
count_table_files
,],
outputs
=
[
self
.
classifyotu_stdout
])
else
:
classifyotu
=
ShellFunction
(
self
.
get_exec_path
(
"mothur"
)
+
' "#classify.otu(list=$1,taxonomy=$2,outputdir='
+
self
.
output_directory
+
'/,label='
+
str
(
self
.
tree_
label
)
+
')"
\
classifyotu
=
ShellFunction
(
self
.
get_exec_path
(
"mothur"
)
+
' "#classify.otu(list=$1,taxonomy=$2,outputdir='
+
self
.
output_directory
+
'/,label='
+
str
(
label
)
+
')"
\
> $3'
,
cmd_format
=
'{EXE} {IN} {OUT}'
)
classifyotu
=
MultiMap
(
classifyotu
,
inputs
=
[
self
.
an_list_files
,
self
.
taxonomy_files
],
outputs
=
[
self
.
classifyotu_stdout
])
krona
=
PythonFunction
(
get_taxonomy_to_Krona
,
cmd_format
=
"{EXE} {ARG} {IN} {OUT}"
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment