Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
genotoul-bioinfo
jflow
Commits
d9c35cb1
Commit
d9c35cb1
authored
Aug 12, 2014
by
Jerome Mariette
Browse files
workflow example OK
parent
fc95b6f0
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/jflow/parameter.py
View file @
d9c35cb1
...
...
@@ -454,6 +454,8 @@ class InputFileList(ParameterList, AbstractFile):
return
list
.
__init__
(
self
,
[
default
])
elif
default
.
__class__
.
__name__
==
"list"
:
return
list
.
__init__
(
self
,
default
)
elif
default
.
__class__
.
__name__
==
"InputFileList"
:
return
list
.
__init__
(
self
,
default
)
class
OutputFileList
(
ParameterList
,
AbstractFile
):
...
...
src/jflow/workflow.py
View file @
d9c35cb1
...
...
@@ -240,24 +240,25 @@ class Workflow(threading.Thread):
group
=
param
.
group
,
display_name
=
param
.
display_name
)
self
.
__setattr__
(
param
.
name
,
new_param
)
elif
param
.
__class__
==
InputFileList
:
path2test
=
args
[
param
.
name
]
if
not
path2test
.
__class__
.
__name__
==
"list"
:
path2test
=
[
path2test
]
default_vals
=
[]
# handle url inputs
default_vals
,
is_uri
=
[],
False
if
args
[
param
.
name
].
__class__
.
__name__
==
"list"
:
for
path
in
args
[
param
.
name
]:
new_url
,
is_uri
=
self
.
_download_urlfile
(
path
)
if
is_uri
:
default_vals
.
append
(
new_url
)
else
:
new_url
,
is_uri
=
self
.
_download_urlfile
(
args
[
param
.
name
])
if
is_uri
:
default_vals
.
append
(
new_url
)
# handle upload inputs
try
:
is_local
=
os
.
path
.
isfile
(
args
[
param
])
except
:
is_local
=
False
if
not
is_uri
and
not
is_local
and
param
.
type
.
__name__
==
"inputfile"
or
param
.
type
.
__name__
==
"browsefile"
:
if
args
[
param
.
name
].
__class__
.
__name__
==
"list"
:
for
path
in
args
[
param
.
name
]:
default_vals
.
append
(
os
.
path
.
join
(
self
.
jflow_config_reader
.
get_tmp_directory
(),
(
path
)))
else
:
default_vals
.
append
(
os
.
path
.
join
(
self
.
jflow_config_reader
.
get_tmp_directory
(),
(
args
[
param
.
name
])))
for
path
in
path2test
:
new_url
,
is_uri
=
self
.
_download_urlfile
(
path
)
if
is_uri
:
default_vals
.
append
(
new_url
)
path2test
.
remove
(
path
)
# handle localfile
for
path
in
path2test
:
if
os
.
path
.
isfile
(
path
):
default_vals
.
append
(
path
)
path2test
.
remove
(
path
)
# handle upload inputs
if
param
.
type
.
__name__
==
"inputfile"
or
param
.
type
.
__name__
==
"browsefile"
:
for
path
in
path2test
:
default_vals
.
append
(
os
.
path
.
join
(
self
.
jflow_config_reader
.
get_tmp_directory
(),
(
path
)))
self
.
__getattribute__
(
param
.
name
).
extend
(
default_vals
)
elif
param
.
__class__
==
ParameterList
:
self
.
__getattribute__
(
param
.
name
).
extend
(
args
[
param
.
name
])
...
...
workflows/alignment/__init__.py
View file @
d9c35cb1
...
...
@@ -35,9 +35,5 @@ class Alignment (Workflow):
# index the reference genome
bwaindex
=
self
.
add_component
(
"BWAIndex"
,
[
self
.
reference_genome
])
# align reads against indexed genome
#bwa = self.add_component("BWA", [bwaindex.databank, self.args["read_1"], self.args["read_2"]])
bwa
=
self
.
add_component
(
"BWA"
,
[
bwaindex
.
databank
,
self
.
read_1
,
self
.
read_2
])
\ No newline at end of file
workflows/components/bwa.py
View file @
d9c35cb1
...
...
@@ -19,7 +19,7 @@ import os
from
subprocess
import
Popen
,
PIPE
from
jflow.component
import
Component
from
jflow.
iotypes
import
OutputFile
,
OutputFileList
,
InputFile
,
InputFileList
,
Formats
from
jflow.
parameter
import
Formats
from
weaver.function
import
ShellFunction
from
weaver.abstraction
import
Map
...
...
@@ -29,25 +29,24 @@ from jflow.abstraction import MultiMap
class
BWA
(
Component
):
def
define_parameters
(
self
,
reference_genome
,
read1
,
read2
=
None
,
algorithm
=
"aln"
):
self
.
read1
=
InputFileList
(
read1
,
Formats
.
FASTQ
)
self
.
read2
=
None
self
.
add_input_file
(
"reference_genome"
,
"Which reference file should be used"
,
default
=
reference_genome
,
required
=
True
)
self
.
add_input_file
(
"read1"
,
"Which read1 files should be used"
,
file_format
=
Formats
.
FASTQ
,
default
=
read1
,
required
=
True
,
is_list
=
True
)
self
.
add_input_file
(
"read2"
,
"Which read2 files should be used"
,
file_format
=
Formats
.
FASTQ
,
default
=
read2
,
is_list
=
True
)
self
.
add_parameter
(
"algorithm"
,
"Which algorithm should be used to align the reads"
,
default
=
algorithm
,
choices
=
[
"aln"
,
"bwasw"
])
if
algorithm
==
"aln"
:
self
.
sai1
=
O
utput
F
ile
List
(
self
.
get_outputs
(
'{basename_woext}.sai'
,
self
.
read1
)
)
self
.
add_o
utput
_f
ile
(
"sai1"
,
"The BWA sai1 file"
,
pattern
=
'{basename_woext}.sai'
,
basename
=
self
.
read1
,
is_list
=
True
)
else
:
self
.
sai1
=
None
if
read2
:
self
.
read2
=
InputFileList
(
read2
,
Formats
.
FASTQ
)
if
algorithm
==
"aln"
:
self
.
sai2
=
O
utput
F
ile
List
(
self
.
get_outputs
(
'{basename_woext}.sai'
,
self
.
read2
)
)
self
.
add_o
utput
_f
ile
(
"sai2"
,
"The BWA sai2 file"
,
pattern
=
'{basename_woext}.sai'
,
basename
=
self
.
read2
,
is_list
=
True
)
else
:
self
.
sai2
=
None
self
.
bam_files
=
O
utput
F
ile
List
(
self
.
get_outputs
(
'{basename_woext}.bam'
,
[
self
.
read1
,
self
.
read2
]
)
,
Formats
.
BAM
)
self
.
add_o
utput
_f
ile
(
"bam_files"
,
"The BWA bam file"
,
pattern
=
'{basename_woext}.bam'
,
basename
=
[
self
.
read1
,
self
.
read2
],
file_format
=
Formats
.
BAM
,
is_list
=
True
)
else
:
self
.
sai2
=
None
self
.
bam_files
=
OutputFileList
(
self
.
get_outputs
(
'{basename_woext}.bam'
,
self
.
read1
),
Formats
.
BAM
)
self
.
algorithm
=
algorithm
self
.
reference_genome
=
InputFile
(
reference_genome
)
self
.
stderr
=
os
.
path
.
join
(
self
.
output_directory
,
'bwa.stderr'
)
self
.
add_output_file
(
"bam_files"
,
"The BWA bam file"
,
pattern
=
'{basename_woext}.bam'
,
basename
=
self
.
read1
,
file_format
=
Formats
.
BAM
,
is_list
=
True
)
self
.
add_output_file
(
"stderr"
,
"The BWA stderr file"
,
basename
=
'bwa.stderr'
)
def
process
(
self
):
if
self
.
algorithm
==
"bwasw"
:
...
...
@@ -77,7 +76,7 @@ class BWA (Component):
bwasamse
=
ShellFunction
(
self
.
get_exec_path
(
"bwa"
)
+
" samse "
+
self
.
reference_genome
+
\
" $1 $2 2>> "
+
self
.
stderr
+
" | "
+
self
.
get_exec_path
(
"samtools"
)
+
" view -bS - > $3 2>> "
+
self
.
stderr
,
cmd_format
=
'{EXE} {IN} {OUT}'
)
bwasamse
=
MultiMap
(
bwasamse
,
inputs
=
[
self
.
sai1
,
self
.
read1
],
outputs
=
self
.
bam_files
,
includes
=
self
.
reference_genome
)
def
get_version
(
self
):
cmd
=
[
self
.
get_exec_path
(
"bwa"
)]
p
=
Popen
(
cmd
,
stdout
=
PIPE
,
stderr
=
PIPE
)
...
...
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