Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
panacota
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Amandine PERRIN
panacota
Commits
13bbb5cf
Commit
13bbb5cf
authored
4 years ago
by
Amandine PERRIN
Browse files
Options
Downloads
Patches
Plain Diff
Add argument to give a configfile
parent
b86f5c5c
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
PanACoTA/subcommands/all_modules.py
+28
-6
28 additions, 6 deletions
PanACoTA/subcommands/all_modules.py
PanACoTA/utils_argparse.py
+14
-4
14 additions, 4 deletions
PanACoTA/utils_argparse.py
with
42 additions
and
10 deletions
PanACoTA/subcommands/all_modules.py
+
28
−
6
View file @
13bbb5cf
...
...
@@ -175,6 +175,9 @@ def build_parser(parser):
# Create command-line parser for all options and arguments to give
general
=
parser
.
add_argument_group
(
"
General arguments
"
)
general
.
add_argument
(
"
-c
"
,
dest
=
"
configfile
"
,
help
=
(
"
Path to your configuration file, defining values of parameters.
"
)
)
general
.
add_argument
(
"
-o
"
,
dest
=
"
outdir
"
,
required
=
True
,
help
=
(
"
Path to your output folder, where all results
"
"
from all 6 modules will be saved.
"
)
...
...
@@ -305,7 +308,6 @@ def check_args(parser, argv):
# If a bool argument (quiet, mixed, multi, prodigal_only) is not in the user command-line,
# it still exists in argv but is set to False -> ignore it to replace by info from
# config file if any, or default otherwise
argv
.
conffile
=
"
configfile.ini
"
dict_argv
=
{
key
:
val
for
key
,
val
in
vars
(
argv
).
items
()
if
val
is
not
None
and
val
!=
False
}
final_dict
=
{}
...
...
@@ -359,9 +361,14 @@ def get_prepare(dict_argv):
Check that arguments given for prepare step are compatible
"""
# Get arguments from config file and add them (overwrite if needed)
conf_conffile
=
utils_argparse
.
Conf_all_parser
(
dict_argv
[
'
conffile
'
],
sections
=
[
"
prepare
"
])
if
not
"
configfile
"
in
dict_argv
:
conf_conffile
=
utils_argparse
.
Conf_all_parser
(
""
,[
"
prepare
"
])
else
:
conf_conffile
=
utils_argparse
.
Conf_all_parser
(
dict_argv
[
'
configfile
'
],
sections
=
[
"
prepare
"
])
# Add arguments from commandline
conf_conffile
.
update
(
dict_argv
,
"
prepare
"
)
# Add default arguments if not found in comd line nor config file
defaults
=
{
"
verbose
"
:
0
,
"
threads
"
:
1
,
"
cutn
"
:
5
,
"
l90
"
:
100
,
"
nbcont
"
:
999
,
"
min_id
"
:
0.8
,
"
levels
"
:
""
,
"
quiet
"
:
False
,
"
ncbi_species
"
:
""
,
"
ncbi_species_taxid
"
:
""
,
"
tmp_dir
"
:
""
,
"
db_dir
"
:
""
,
...
...
@@ -388,7 +395,11 @@ def get_annotate(dict_argv):
Check that arguments given for prepare step are compatible
"""
# Get arguments from config file and add them (overwrite if needed)
conf_conffile
=
utils_argparse
.
Conf_all_parser
(
dict_argv
[
'
conffile
'
],
sections
=
[
"
annotate
"
])
if
not
"
configfile
"
in
dict_argv
:
conf_conffile
=
utils_argparse
.
Conf_all_parser
(
""
,[
"
annotate
"
])
else
:
conf_conffile
=
utils_argparse
.
Conf_all_parser
(
dict_argv
[
'
configfile
'
],
sections
=
[
"
annotate
"
])
# Add arguments from commandline
conf_conffile
.
update
(
dict_argv
,
"
annotate
"
)
if
"
date
"
not
in
dict
(
conf_conffile
[
"
annotate
"
]):
...
...
@@ -417,7 +428,11 @@ def get_pangenome(dict_argv):
Check that arguments given for prepare step are compatible
"""
# Get arguments from config file and add them (overwrite if needed)
conf_conffile
=
utils_argparse
.
Conf_all_parser
(
dict_argv
[
'
conffile
'
],
sections
=
[
"
pangenome
"
])
if
not
"
configfile
"
in
dict_argv
:
conf_conffile
=
utils_argparse
.
Conf_all_parser
(
""
,[
"
pangenome
"
])
else
:
conf_conffile
=
utils_argparse
.
Conf_all_parser
(
dict_argv
[
'
configfile
'
],
sections
=
[
"
pangenome
"
])
# Add arguments from commandline
conf_conffile
.
update
(
dict_argv
,
"
pangenome
"
)
# Add default arguments if not found in commandline nor config file
...
...
@@ -437,7 +452,11 @@ def get_corepers(dict_argv):
Check that arguments given for prepare step are compatible
"""
# Get arguments from config file and add them (overwrite if needed)
conf_conffile
=
utils_argparse
.
Conf_all_parser
(
dict_argv
[
'
conffile
'
],
sections
=
[
"
corepers
"
])
if
not
"
configfile
"
in
dict_argv
:
conf_conffile
=
utils_argparse
.
Conf_all_parser
(
""
,[
"
corepers
"
])
else
:
conf_conffile
=
utils_argparse
.
Conf_all_parser
(
dict_argv
[
'
configfile
'
],
sections
=
[
"
corepers
"
])
# Add arguments from commandline
conf_conffile
.
update
(
dict_argv
,
"
corepers
"
)
# Add default arguments if not found in commandline nor config file
...
...
@@ -460,7 +479,10 @@ def get_tree(dict_argv):
Check that arguments given for prepare step are compatible
"""
# Get arguments from config file and add them (overwrite if needed)
conf_conffile
=
utils_argparse
.
Conf_all_parser
(
dict_argv
[
'
conffile
'
],
sections
=
[
"
tree
"
])
if
not
"
configfile
"
in
dict_argv
:
conf_conffile
=
utils_argparse
.
Conf_all_parser
(
""
,[
"
tree
"
])
else
:
conf_conffile
=
utils_argparse
.
Conf_all_parser
(
dict_argv
[
'
configfile
'
],
sections
=
[
"
tree
"
])
# Add arguments from commandline
conf_conffile
.
update
(
dict_argv
,
"
tree
"
)
# Add default arguments if not found in commandline nor config file
...
...
This diff is collapsed.
Click to expand it.
PanACoTA/utils_argparse.py
+
14
−
4
View file @
13bbb5cf
...
...
@@ -162,7 +162,13 @@ class Conf_all_parser(configparser.ConfigParser):
self
.
read
(
conffile
)
self
.
sec_dicts
=
{}
for
sec
in
sections
:
self
.
sec_dicts
[
sec
]
=
dict
(
self
[
sec
])
# If section in configfile, put its arguments and values to a dict
# If not, create empty section, and associate with empty dict
if
sec
in
dict
(
self
):
self
.
sec_dicts
[
sec
]
=
dict
(
self
[
sec
])
else
:
self
.
sec_dicts
[
sec
]
=
{}
self
.
add_section
(
sec
)
def
get_section_dict
(
self
,
section
):
"""
...
...
@@ -172,7 +178,8 @@ class Conf_all_parser(configparser.ConfigParser):
def
add_default
(
self
,
defargs
,
section
):
"""
Add all default arguments (defargs) in section dict.
Complete
'
section
'
dict with default parameters.
If key already defined, keep current value.
"""
for
key
,
val
in
defargs
.
items
():
if
key
not
in
self
.
sec_dicts
[
section
]:
...
...
@@ -191,6 +198,7 @@ class Conf_all_parser(configparser.ConfigParser):
def
set_boolean
(
self
,
section
,
param
):
"""
Change param of section to boolean
raise error if problem
"""
try
:
bool_param
=
self
.
getboolean
(
section
,
param
)
...
...
@@ -202,7 +210,8 @@ class Conf_all_parser(configparser.ConfigParser):
def
set_int
(
self
,
section
,
param
):
"""
Change param of section to boolean
Change param of section to int
raise error if problem
"""
try
:
int_param
=
self
.
getint
(
section
,
param
)
...
...
@@ -214,7 +223,8 @@ class Conf_all_parser(configparser.ConfigParser):
def
set_float
(
self
,
section
,
param
):
"""
Change param of section to boolean
Change param of section to float
raise error if problem
"""
try
:
float_param
=
self
.
getfloat
(
section
,
param
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment