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
bob
bob.bio.base
Commits
282da01c
Commit
282da01c
authored
Nov 08, 2017
by
Tiago de Freitas Pereira
Browse files
Removed global variable results
parent
21e7371f
Pipeline
#13890
passed with stages
in 10 minutes and 39 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
bob/bio/base/script/collect_results.py
View file @
282da01c
...
...
@@ -184,28 +184,32 @@ def add_results(args, nonorm, ztnorm = None):
else
:
r
.
ztnorm
(
dev_file
)
global
results
results
.
append
(
r
)
return
r
def
recurse
(
args
,
path
):
"""Recurse the directory structure and collect all results that are stored in the desired file names."""
dir_list
=
os
.
listdir
(
path
)
results
=
[]
# check if the score directories are included in the current path
if
args
.
nonorm
in
dir_list
or
args
.
nonorm
==
'.'
:
if
args
.
ztnorm
in
dir_list
or
args
.
ztnorm
==
'.'
:
add_results
(
args
,
os
.
path
.
join
(
path
,
args
.
nonorm
),
os
.
path
.
join
(
path
,
args
.
ztnorm
))
return
results
+
[
add_results
(
args
,
os
.
path
.
join
(
path
,
args
.
nonorm
),
os
.
path
.
join
(
path
,
args
.
ztnorm
))
]
else
:
add_results
(
args
,
os
.
path
.
join
(
path
,
args
.
nonorm
))
return
results
+
[
add_results
(
args
,
os
.
path
.
join
(
path
,
args
.
nonorm
))
]
for
e
in
dir_list
:
real_path
=
os
.
path
.
join
(
path
,
e
)
if
os
.
path
.
isdir
(
real_path
):
recurse
(
args
,
real_path
)
r
=
recurse
(
args
,
real_path
)
if
r
is
not
None
:
results
+=
r
return
results
def
table
():
def
table
(
results
):
"""Generates a table containing all results in a nice format."""
A
=
" "
*
2
+
'dev nonorm'
+
" "
*
5
+
'dev ztnorm'
+
" "
*
6
+
'eval nonorm'
+
" "
*
4
+
'eval ztnorm'
+
" "
*
12
+
'directory
\n
'
A
+=
"-"
*
100
+
"
\n
"
...
...
@@ -219,12 +223,13 @@ def main(command_line_parameters = None):
"""Iterates through the desired directory and collects all result files."""
args
=
command_line_arguments
(
command_line_parameters
)
global
results
results
=
[]
# collect results
directories
=
glob
.
glob
(
args
.
directory
)
for
directory
in
directories
:
recurse
(
args
,
directory
)
r
=
recurse
(
args
,
directory
)
if
r
is
not
None
:
results
+=
r
# sort results if desired
if
args
.
sort
:
...
...
@@ -233,10 +238,10 @@ def main(command_line_parameters = None):
# print the results
if
args
.
self_test
:
table
()
table
(
results
)
elif
args
.
output
:
f
=
open
(
args
.
output
,
"w"
)
f
.
writelines
(
table
())
f
.
writelines
(
table
(
results
))
f
.
close
()
else
:
print
(
table
())
print
(
table
(
results
))
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