Skip to content
GitLab
Menu
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
24db606c
Commit
24db606c
authored
Sep 23, 2015
by
Jerome Mariette
Browse files
from python2 to python3 > ok from command line
parent
67d45e09
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
src/jflow/__init__.py
View file @
24db606c
...
...
@@ -30,7 +30,7 @@ jflowconf = JFlowConfigReader()
# if log file directory does not exist, create it
log_directory
=
os
.
path
.
dirname
(
jflowconf
.
get_log_file_path
())
if
not
os
.
path
.
isdir
(
log_directory
):
os
.
makedirs
(
log_directory
,
0751
)
os
.
makedirs
(
log_directory
,
0
o
751
)
logging
.
basicConfig
(
level
=
logging
.
DEBUG
,
format
=
'%(asctime)s %(name)-12s %(levelname)-8s %(message)s'
,
...
...
src/jflow/abstraction.py
View file @
24db606c
...
...
@@ -90,7 +90,7 @@ class MultiMap(Abstraction):
else
:
iteration_inputs
.
append
(
inputs
[
iter
])
input_pattern
=
self
.
_longestCommonSubstr
(
map
(
os
.
path
.
basename
,
map
(
str
,
iteration_inputs
)))
input_pattern
=
self
.
_longestCommonSubstr
(
list
(
map
(
os
.
path
.
basename
,
list
(
map
(
str
,
iteration_inputs
)))
))
iteration_outputs
=
[]
if
isinstance
(
self
.
outputs
,
list
):
...
...
src/jflow/component.py
View file @
24db606c
...
...
@@ -54,14 +54,14 @@ class Component(object):
@return : the list of outputs updated at the end of component execution.
"""
dynamic_outputs
=
list
()
for
attribute_value
in
self
.
__dict__
.
values
():
for
attribute_value
in
list
(
self
.
__dict__
.
values
()
)
:
if
issubclass
(
attribute_value
.
__class__
,
DynamicOutput
):
dynamic_outputs
.
append
(
attribute_value
)
return
dynamic_outputs
def
get_output_files
(
self
):
outputs
=
{}
for
attribute_value
in
self
.
__dict__
.
values
():
for
attribute_value
in
list
(
self
.
__dict__
.
values
()
)
:
if
(
issubclass
(
attribute_value
.
__class__
,
DynamicOutput
)
or
issubclass
(
attribute_value
.
__class__
,
OutputFileList
)
):
for
f
in
attribute_value
:
...
...
@@ -130,7 +130,7 @@ class Component(object):
self
.
params_order
.
append
(
name
)
self
.
__setattr__
(
name
,
new_param
)
def
add_parameter
(
self
,
name
,
help
,
default
=
None
,
type
=
types
.
StringType
,
choices
=
None
,
def
add_parameter
(
self
,
name
,
help
,
default
=
None
,
type
=
str
,
choices
=
None
,
required
=
False
,
flag
=
None
,
group
=
"default"
,
display_name
=
None
,
cmd_format
=
""
,
argpos
=-
1
):
new_param
=
ParameterFactory
.
factory
(
name
,
help
,
flag
=
flag
,
default
=
default
,
type
=
type
,
choices
=
choices
,
...
...
@@ -140,7 +140,7 @@ class Component(object):
self
.
params_order
.
append
(
name
)
self
.
__setattr__
(
name
,
new_param
)
def
add_parameter_list
(
self
,
name
,
help
,
default
=
None
,
type
=
types
.
StringType
,
choices
=
None
,
def
add_parameter_list
(
self
,
name
,
help
,
default
=
None
,
type
=
str
,
choices
=
None
,
required
=
False
,
flag
=
None
,
group
=
"default"
,
display_name
=
None
,
cmd_format
=
""
,
argpos
=-
1
):
if
default
==
None
:
default
=
[]
...
...
@@ -313,7 +313,7 @@ class Component(object):
def
execute
(
self
):
# first create the output directory
if
not
os
.
path
.
isdir
(
self
.
output_directory
):
os
.
makedirs
(
self
.
output_directory
,
0751
)
os
.
makedirs
(
self
.
output_directory
,
0
o
751
)
# then run the component
self
.
process
()
...
...
@@ -422,7 +422,7 @@ class Component(object):
def
get_temporary_file
(
self
,
suffix
=
".txt"
):
# first check if tmp directory exists
if
not
os
.
path
.
isdir
(
self
.
config_reader
.
get_tmp_directory
()):
os
.
makedirs
(
self
.
config_reader
.
get_tmp_directory
(),
0751
)
os
.
makedirs
(
self
.
config_reader
.
get_tmp_directory
(),
0
o
751
)
tempfile_name
=
os
.
path
.
basename
(
tempfile
.
NamedTemporaryFile
(
suffix
=
suffix
).
name
)
return
os
.
path
.
join
(
self
.
config_reader
.
get_tmp_directory
(),
tempfile_name
)
...
...
src/jflow/config_reader.py
View file @
24db606c
...
...
@@ -20,7 +20,7 @@ import sys
import
inspect
import
logging
from
C
onfig
P
arser
import
ConfigParser
,
NoOptionError
from
c
onfig
p
arser
import
Raw
ConfigParser
,
NoOptionError
from
jflow.utils
import
which
,
display_error_message
...
...
@@ -34,12 +34,12 @@ class JFlowConfigReader(object):
def
__init__
(
self
):
"""
"""
self
.
reader
=
ConfigParser
()
self
.
reader
=
Raw
ConfigParser
()
self
.
reader
.
read
(
os
.
path
.
join
(
os
.
path
.
dirname
(
inspect
.
getfile
(
self
.
__class__
)),
self
.
CONFIG_FILE_PATH
))
def
get_tmp_directory
(
self
):
if
not
os
.
path
.
isdir
(
self
.
reader
.
get
(
"storage"
,
"tmp_directory"
)):
os
.
makedirs
(
self
.
reader
.
get
(
"storage"
,
"tmp_directory"
),
0751
)
os
.
makedirs
(
self
.
reader
.
get
(
"storage"
,
"tmp_directory"
),
0
o
751
)
return
self
.
reader
.
get
(
"storage"
,
"tmp_directory"
)
def
get_work_directory
(
self
):
...
...
@@ -48,7 +48,7 @@ class JFlowConfigReader(object):
def
get_exec
(
self
,
software
):
try
:
return
self
.
reader
.
get
(
"softwares"
,
software
)
except
NoOptionError
,
e
:
except
NoOptionError
:
return
None
def
get_resource
(
self
,
resource
):
...
...
@@ -62,12 +62,12 @@ class JFlowConfigReader(object):
try
:
return
self
.
reader
.
get
(
'storage'
,
'log_file'
)
except
:
raise
Error
(
"Failed when parsing the config file, no section logging found!"
)
raise
NoOption
Error
(
"Failed when parsing the config file, no section logging found!"
)
def
get_makeflow_path
(
self
):
try
:
exec_path
=
self
.
reader
.
get
(
"global"
,
"makeflow"
)
except
NoOptionError
,
e
:
except
NoOptionError
:
exec_path
=
None
if
exec_path
is
None
:
exec_path
=
"makeflow"
if
which
(
exec_path
)
==
None
:
...
...
@@ -79,7 +79,7 @@ class JFlowConfigReader(object):
try
:
date_format
=
self
.
reader
.
get
(
"global"
,
"date_format"
)
except
:
raise
Error
(
"Failed when parsing the config file, no parameter date_format!"
)
raise
NoOption
Error
(
"Failed when parsing the config file, no parameter date_format!"
)
return
date_format
def
get_batch
(
self
):
...
...
@@ -88,7 +88,7 @@ class JFlowConfigReader(object):
options
=
self
.
reader
.
get
(
"global"
,
"batch_options"
)
limit_submission
=
self
.
reader
.
get
(
"global"
,
"limit_submission"
)
return
[
type
,
options
,
limit_submission
]
except
NoOptionError
,
e
:
except
NoOptionError
:
return
None
def
get_socket_options
(
self
):
...
...
src/jflow/extparser.py
View file @
24db606c
...
...
@@ -44,7 +44,7 @@ class ExternalParser(object):
options
=
{
'define_parameters'
:
fn_define_parameters
}
if
kwargs
:
for
key
,
val
in
kwargs
.
items
()
:
for
key
,
val
in
list
(
kwargs
.
items
()
)
:
options
[
key
]
=
val
ComponentType
=
type
(
component_name
,
(
_SerializableNestedComponent
,),
options
)
...
...
src/jflow/featureio.py
View file @
24db606c
...
...
@@ -15,11 +15,11 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
from
featureiolib.bed
import
BEDReader
from
featureiolib.biom
import
Biom
,
BiomIO
from
featureiolib.gff3
import
GFF3Record
,
GFF3IO
from
featureiolib.mpileup
import
MpileupReader
from
featureiolib.obo
import
OboReader
from
featureiolib.vcf
import
VCFReader
from
featureiolib.wego
import
WEGOReader
from
featureiolib.separatedvalue
import
SeparatedValueIO
\ No newline at end of file
from
.featureiolib.bed
import
BEDReader
from
.featureiolib.biom
import
Biom
,
BiomIO
from
.featureiolib.gff3
import
GFF3Record
,
GFF3IO
from
.featureiolib.mpileup
import
MpileupReader
from
.featureiolib.obo
import
OboReader
from
.featureiolib.vcf
import
VCFReader
from
.featureiolib.wego
import
WEGOReader
from
.featureiolib.separatedvalue
import
SeparatedValueIO
\ No newline at end of file
src/jflow/parameter.py
View file @
24db606c
This diff is collapsed.
Click to expand it.
src/jflow/seqio.py
View file @
24db606c
...
...
@@ -28,11 +28,8 @@ import sys
import
struct
import
os
import
io
if
sys
.
version_info
[
0
]
<
3
:
from
itertools
import
izip
as
zip
else
:
basestring
=
str
from
codecs
import
getreader
,
getwriter
str
=
str
from
codecs
import
getreader
,
getwriter
if
sys
.
version_info
<
(
2
,
7
):
buffered_reader
=
lambda
x
:
x
...
...
@@ -51,7 +48,7 @@ def xopen(filename, mode='r'):
is used. If the filename is '-', standard output (mode 'w') or input
(mode 'r') is returned.
"""
assert
isinstance
(
filename
,
basestring
)
assert
isinstance
(
filename
,
str
)
if
filename
==
'-'
:
return
sys
.
stdin
if
'r'
in
mode
else
sys
.
stdout
if
filename
.
endswith
(
'.gz'
):
...
...
@@ -150,7 +147,7 @@ def SequenceReader(file, colorspace=False, fileformat=None):
name
=
None
if
file
==
"-"
:
file
=
sys
.
stdin
elif
isinstance
(
file
,
basestring
):
elif
isinstance
(
file
,
str
):
name
=
file
elif
hasattr
(
file
,
"name"
):
name
=
file
.
name
...
...
@@ -197,7 +194,7 @@ class FastaReader(object):
the file, but may obviously need a lot of memory.
keep_linebreaks -- whether to keep the newline characters in the sequence
"""
if
isinstance
(
file
,
basestring
):
if
isinstance
(
file
,
str
):
file
=
xopen
(
file
,
"r"
)
self
.
fp
=
file
self
.
wholefile
=
wholefile
...
...
@@ -277,7 +274,7 @@ class FastqReader(object):
colorspace -- Usually (when this is False), there must be n characters in the sequence and
n quality values. When this is True, there must be n+1 characters in the sequence and n quality values.
"""
if
isinstance
(
file
,
basestring
):
if
isinstance
(
file
,
str
):
file
=
xopen
(
file
,
"r"
)
self
.
fp
=
file
self
.
colorspace
=
colorspace
...
...
@@ -333,7 +330,7 @@ class SFFReader(object):
file is a filename or a file-like object.
If file is a filename, then .gz files are supported.
"""
if
isinstance
(
file
,
basestring
):
if
isinstance
(
file
,
str
):
file
=
xopen
(
file
,
"r"
)
self
.
fp
=
file
self
.
header_data
=
self
.
read_header
(
file
)
...
...
@@ -631,7 +628,7 @@ class FastaQualReader(object):
lengthdiff
=
1
if
self
.
colorspace
else
0
for
fastaread
,
qualread
in
zip
(
self
.
fastareader
,
self
.
qualreader
):
if
self
.
qual2ascii
:
qualities
=
_quality_to_ascii
(
map
(
int
,
qualread
.
sequence
.
split
()))
qualities
=
_quality_to_ascii
(
list
(
map
(
int
,
qualread
.
sequence
.
split
()))
)
elif
self
.
splitqual
:
qualities
=
qualread
.
sequence
.
split
()
else
:
...
...
@@ -674,7 +671,7 @@ def writefasta(f, seqlist, linelength=None):
header
=
id
f
.
write
(
header
)
f
.
write
(
'
\n
'
)
for
i
in
x
range
(
0
,
len
(
seq
),
linelength
):
for
i
in
range
(
0
,
len
(
seq
),
linelength
):
f
.
write
(
seq
[
i
:
i
+
linelength
])
f
.
write
(
'
\n
'
)
else
:
...
...
@@ -694,7 +691,7 @@ def writequalities(f, seqlist, linelength=None):
"""
if
linelength
is
not
None
:
for
id
,
desc
,
seq
,
qual
in
seqlist
:
if
isinstance
(
qual
,
basestring
):
if
isinstance
(
qual
,
str
):
qual
=
qual
.
split
()
f
.
write
(
'>'
)
header
=
id
+
' '
+
desc
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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