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
d465346d
Commit
d465346d
authored
Nov 17, 2014
by
Frédéric Escudié
Browse files
No commit message
No commit message
parent
ac7821ab
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/jflow/component.py
View file @
d465346d
...
...
@@ -67,10 +67,10 @@ class Component(object):
required
=
False
,
flag
=
None
,
group
=
"default"
,
display_name
=
None
,
add_to
=
None
):
new_param
=
InputFile
(
name
,
help
,
flag
=
flag
,
file_format
=
file_format
,
default
=
default
,
type
=
type
,
required
=
required
,
group
=
group
,
display_name
=
display_name
)
new_param
.
component_nameid
=
self
.
get_nameid
()
# store where the parameter is coming from
if
hasattr
(
default
,
"component_nameid"
):
new_param
.
component_nameid
=
self
.
get_nameid
()
if
issubclass
(
default
.
__class__
,
LinkTraceback
):
new_param
.
parent_component_nameid
=
default
.
component_nameid
# if this input should be added to a particular parameter
...
...
@@ -92,18 +92,24 @@ class Component(object):
if
default
==
None
:
inputs
=
[]
else
:
inputs
=
[
IOFile
(
file
,
self
.
get_nameid
(),
None
,
file_format
)
for
file
in
default
]
inputs
=
[
IOFile
(
file
,
file_format
,
self
.
get_nameid
(),
None
)
for
file
in
default
]
new_param
=
InputFileList
(
name
,
help
,
flag
=
flag
,
file_format
=
file_format
,
default
=
inputs
,
type
=
type
,
required
=
required
,
group
=
group
,
display_name
=
display_name
)
# store where the parameter is coming from
new_param
.
component_nameid
=
self
.
get_nameid
()
if
issubclass
(
default
.
__class__
,
list
):
for
idx
,
val
in
enumerate
(
default
):
if
hasattr
(
val
,
"component_nameid"
):
if
issubclass
(
val
.
__class__
,
LinkTraceback
):
new_param
[
idx
].
parent_component_nameid
=
val
.
component_nameid
elif
hasattr
(
default
,
"component_nameid"
):
new_param
.
parent_component_nameid
=
default
.
component_nameid
new_param
.
parent_component_nameid
.
append
(
val
.
component_nameid
)
else
:
new_param
.
parent_component_nameid
.
append
(
None
)
else
:
if
issubclass
(
default
.
__class__
,
LinkTraceback
):
new_param
[
0
].
parent_component_nameid
=
default
.
component_nameid
new_param
.
parent_component_nameid
.
append
(
default
.
component_nameid
)
else
:
new_param
.
parent_component_nameid
.
append
(
None
)
# if this input should be added to a particular parameter
if
add_to
:
try
:
...
...
@@ -147,6 +153,7 @@ class Component(object):
filename
=
os
.
path
.
basename
(
filename
)
new_param
=
OutputFile
(
name
,
help
,
default
=
os
.
path
.
join
(
self
.
output_directory
,
filename
),
file_format
=
file_format
,
group
=
group
,
display_name
=
display_name
)
# store where the parameter is coming from
new_param
.
component_nameid
=
self
.
get_nameid
()
# if this input should be added to a particular parameter
if
add_to
:
...
...
@@ -160,8 +167,10 @@ class Component(object):
def
add_output_file_list
(
self
,
name
,
help
,
file_format
=
"any"
,
pattern
=
'{basename_woext}.out'
,
items
=
None
,
group
=
"default"
,
display_name
=
None
,
add_to
=
None
):
default
=
[
IOFile
(
file
,
self
.
get_nameid
(),
None
,
file_format
)
for
file
in
self
.
get_outputs
(
pattern
,
items
)]
default
=
[
IOFile
(
file
,
file_format
,
self
.
get_nameid
(),
None
)
for
file
in
self
.
get_outputs
(
pattern
,
items
)]
new_param
=
OutputFileList
(
name
,
help
,
default
=
default
,
file_format
=
file_format
,
group
=
group
,
display_name
=
display_name
)
# store where the parameter is coming from
new_param
.
component_nameid
=
self
.
get_nameid
()
# if this input should be added to a particular parameter
if
add_to
:
try
:
...
...
@@ -176,6 +185,8 @@ class Component(object):
group
=
"default"
,
display_name
=
None
,
add_to
=
None
):
new_param
=
OutputFilesEndsWith
(
name
,
help
,
self
.
output_directory
,
pattern
,
include
=
(
behaviour
==
"include"
),
file_format
=
file_format
,
group
=
group
,
display_name
=
display_name
)
# store where the parameter is coming from
new_param
.
component_nameid
=
self
.
get_nameid
()
# if this input should be added to a particular parameter
if
add_to
:
try
:
...
...
@@ -190,6 +201,8 @@ class Component(object):
group
=
"default"
,
display_name
=
None
,
add_to
=
None
):
new_param
=
OutputFilesPattern
(
name
,
help
,
self
.
output_directory
,
pattern
,
include
=
(
behaviour
==
"exclude"
),
file_format
=
file_format
,
group
=
group
,
display_name
=
display_name
)
# store where the parameter is coming from
new_param
.
component_nameid
=
self
.
get_nameid
()
# if this input should be added to a particular parameter
if
add_to
:
try
:
...
...
src/jflow/parameter.py
View file @
d465346d
...
...
@@ -372,23 +372,27 @@ class AbstractParameter(object):
return
create_test_function
(
self
.
type
)
class
AbstractIOFile
(
object
):
class
LinkTraceback
(
object
):
def
__init__
(
self
,
file_format
=
"any"
):
def
__init__
(
self
,
component_nameid
=
None
,
parent_component_nameid
=
[]):
self
.
component_nameid
=
component_nameid
self
.
parent_component_nameid
=
parent_component_nameid
class
AbstractIOFile
(
LinkTraceback
):
def
__init__
(
self
,
file_format
=
"any"
,
component_nameid
=
None
,
parent_component_nameid
=
[]):
LinkTraceback
.
__init__
(
self
,
component_nameid
,
parent_component_nameid
)
self
.
file_format
=
file_format
self
.
component_nameid
=
None
self
.
parent_component_nameid
=
None
class
IOFile
(
str
):
class
IOFile
(
str
,
AbstractIOFile
):
def
__new__
(
self
,
val
=
""
,
component_nameid
=
None
,
parent_component_nameid
=
[],
file_format
=
"any"
):
def
__new__
(
self
,
val
=
""
,
file_format
=
"any"
,
component_nameid
=
None
,
parent_component_nameid
=
None
):
return
str
.
__new__
(
self
,
val
)
def
__init__
(
self
,
val
,
component_nameid
=
None
,
parent_component_nameid
=
[],
file_format
=
"any"
):
self
.
component_nameid
=
component_nameid
self
.
parent_component_nameid
=
parent_component_nameid
self
.
file_format
=
file_format
def
__init__
(
self
,
val
=
""
,
file_format
=
"any"
,
component_nameid
=
None
,
parent_component_nameid
=
None
):
AbstractIOFile
.
__init__
(
self
,
file_format
,
component_nameid
,
parent_component_nameid
)
class
MultiParameter
(
dict
,
AbstractParameter
):
...
...
@@ -985,9 +989,11 @@ class OutputFilesEndsWith(DynamicOutput):
output_files
=
list
()
for
file
in
os
.
listdir
(
self
.
output_directory
):
if
file
.
endswith
(
self
.
end_str
)
and
self
.
include
:
output_files
.
append
(
IOFile
(
os
.
path
.
join
(
self
.
output_directory
,
file
),
None
,
None
,
self
.
file_format
)
)
output_files
.
append
(
IOFile
(
os
.
path
.
join
(
self
.
output_directory
,
file
),
self
.
file_format
,
self
.
component_nameid
,
None
)
)
self
.
component_parent_nameid
.
append
(
None
)
elif
not
file
.
endswith
(
self
.
end_str
)
and
not
self
.
include
:
output_files
.
append
(
IOFile
(
os
.
path
.
join
(
self
.
output_directory
,
file
),
None
,
None
,
self
.
file_format
)
)
output_files
.
append
(
IOFile
(
os
.
path
.
join
(
self
.
output_directory
,
file
),
self
.
file_format
,
self
.
component_nameid
,
None
)
)
self
.
component_parent_nameid
.
append
(
None
)
list
.
__init__
(
self
,
output_files
)
...
...
@@ -1015,7 +1021,9 @@ class OutputFilesPattern(DynamicOutput):
output_files
=
list
()
for
file
in
os
.
listdir
(
self
.
output_directory
):
if
self
.
include
and
re
.
search
(
self
.
pattern
,
file
)
is
not
None
:
output_files
.
append
(
IOFile
(
os
.
path
.
join
(
self
.
output_directory
,
file
),
None
,
None
,
self
.
file_format
)
)
output_files
.
append
(
IOFile
(
os
.
path
.
join
(
self
.
output_directory
,
file
),
self
.
file_format
,
self
.
component_nameid
,
None
)
)
self
.
component_parent_nameid
.
append
(
None
)
elif
not
self
.
include
and
re
.
search
(
self
.
pattern
,
file
)
is
None
:
output_files
.
append
(
IOFile
(
os
.
path
.
join
(
self
.
output_directory
,
file
),
None
,
None
,
self
.
file_format
)
)
output_files
.
append
(
IOFile
(
os
.
path
.
join
(
self
.
output_directory
,
file
),
self
.
file_format
,
self
.
component_nameid
,
None
)
)
self
.
component_parent_nameid
.
append
(
None
)
return
list
.
__init__
(
self
,
output_files
)
\ No newline at end of file
src/jflow/workflow.py
View file @
d465346d
...
...
@@ -338,13 +338,14 @@ class Workflow(threading.Thread):
gr
.
add_node_attribute
(
cpt
.
get_nameid
(),
self
.
COMPONENT_GRAPH_LABEL
)
for
cpt
in
self
.
components
:
for
ioparameter
in
cpt
.
__dict__
.
values
():
if
issubclass
(
ioparameter
.
__class__
,
InputFile
)
and
hasattr
(
ioparameter
,
"component_nameid"
):
try
:
gr
.
add_edge
((
ioparameter
.
parent_component_nameid
,
ioparameter
.
component_nameid
))
except
:
pass
if
issubclass
(
ioparameter
.
__class__
,
InputFile
):
if
ioparameter
.
parent_component_nameid
!=
None
:
try
:
gr
.
add_edge
((
ioparameter
.
parent_component_nameid
,
ioparameter
.
component_nameid
))
except
:
pass
if
issubclass
(
ioparameter
.
__class__
,
InputFileList
):
for
io
in
ioparameter
:
if
hasattr
(
io
,
"
component_nameid
"
)
:
try
:
gr
.
add_edge
((
io
.
parent_component_nameid
,
io
.
component_nameid
))
for
io
file
in
ioparameter
:
if
iofile
.
parent_
component_nameid
!=
None
:
try
:
gr
.
add_edge
((
io
file
.
parent_component_nameid
,
io
parameter
.
component_nameid
))
except
:
pass
return
gr
...
...
@@ -620,8 +621,6 @@ class Workflow(threading.Thread):
# update outputs
for
output
in
cmpt_object
.
get_dynamic_outputs
():
output
.
update
()
for
file
in
output
:
file
.
component_id
=
cmpt_object
.
get_nameid
()
else
:
if
self
.
_component_is_duplicated
(
cmpt_object
):
raise
ValueError
(
"Component "
+
cmpt_object
.
__class__
.
__name__
+
" with prefix "
+
...
...
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