Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gga_load_data
Manage
Activity
Members
Labels
Plan
Issues
12
Issue boards
Milestones
Wiki
Code
Merge requests
5
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
abims
e-infra
gga_load_data
Commits
9468ac92
Commit
9468ac92
authored
3 years ago
by
Loraine Gueguen
Browse files
Options
Downloads
Patches
Plain Diff
fix get_history(). Change verbosity
parent
3d7eda89
No related branches found
No related tags found
2 merge requests
!24
Run wf
,
!18
Release v2.1.0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
gga_load_data.py
+44
-35
44 additions, 35 deletions
gga_load_data.py
utilities_bioblend.py
+1
-1
1 addition, 1 deletion
utilities_bioblend.py
with
45 additions
and
36 deletions
gga_load_data.py
+
44
−
35
View file @
9468ac92
...
...
@@ -38,33 +38,6 @@ class LoadData(speciesData.SpeciesData):
self
.
bam_metadata_cache
=
{}
super
().
__init__
(
parameters_dictionary
)
def
remove_homo_sapiens_from_db
(
self
):
"""
Run the GMOD tool to remove the
"
Homo sapiens
"
default organism from the original database
Will do nothing if H. sapiens isn
'
t in the database
"""
logging
.
debug
(
"
Getting
'
Homo sapiens
'
ID in chado database
"
)
get_sapiens_id_json_output
=
utilities_bioblend
.
run_tool_and_download_single_output_dataset
(
self
.
instance
,
tool_id
=
constants
.
GET_ORGANISMS_TOOL
,
# If this version if not found, Galaxy will use the one that is found
history_id
=
self
.
history_id
,
tool_inputs
=
{
"
genus
"
:
"
Homo
"
,
"
species
"
:
"
sapiens
"
})
logging
.
info
(
"
Deleting Homo
'
sapiens
'
in the instance
'
s chado database
"
)
try
:
get_sapiens_id_final_output
=
json
.
loads
(
get_sapiens_id_json_output
)[
0
]
sapiens_id
=
str
(
get_sapiens_id_final_output
[
"
organism_id
"
])
# needs to be str to be recognized by the chado tool
utilities_bioblend
.
run_tool
(
self
.
instance
,
tool_id
=
constants
.
DELETE_ORGANISMS_TOOL
,
history_id
=
self
.
history_id
,
tool_inputs
=
{
"
organism
"
:
sapiens_id
})
except
IndexError
:
logging
.
error
(
"
Homo sapiens isn
'
t in the instance
'
s chado database (IndexError)
"
)
pass
def
purge_histories
(
self
):
"""
Delete all histories in the instance
...
...
@@ -256,7 +229,33 @@ class LoadData(speciesData.SpeciesData):
logging
.
info
(
"
Did not find metadata in %s
"
%
meta_file
)
return
self
.
get_bam_label
(
dirname
,
bam_file
)
def
remove_homo_sapiens_from_db
(
instance
,
history_id
):
"""
Run the GMOD tool to remove the
"
Homo sapiens
"
default organism from the original database
Will do nothing if H. sapiens isn
'
t in the database
"""
logging
.
debug
(
"
Getting
'
Homo sapiens
'
ID in chado database
"
)
get_sapiens_id_json_output
=
utilities_bioblend
.
run_tool_and_download_single_output_dataset
(
instance
,
tool_id
=
constants
.
GET_ORGANISMS_TOOL
,
# If this version if not found, Galaxy will use the one that is found
history_id
=
history_id
,
tool_inputs
=
{
"
genus
"
:
"
Homo
"
,
"
species
"
:
"
sapiens
"
})
logging
.
info
(
"
Deleting Homo
'
sapiens
'
in the instance
'
s chado database
"
)
try
:
get_sapiens_id_final_output
=
json
.
loads
(
get_sapiens_id_json_output
)[
0
]
sapiens_id
=
str
(
get_sapiens_id_final_output
[
"
organism_id
"
])
# needs to be str to be recognized by the chado tool
utilities_bioblend
.
run_tool
(
instance
,
tool_id
=
constants
.
DELETE_ORGANISMS_TOOL
,
history_id
=
history_id
,
tool_inputs
=
{
"
organism
"
:
sapiens_id
})
except
IndexError
:
logging
.
error
(
"
Homo sapiens isn
'
t in the instance
'
s chado database (IndexError)
"
)
pass
if
__name__
==
"
__main__
"
:
parser
=
argparse
.
ArgumentParser
(
description
=
"
Load data into Galaxy library
"
)
...
...
@@ -268,6 +267,10 @@ if __name__ == "__main__":
help
=
"
Increase output verbosity
"
,
action
=
"
store_true
"
)
parser
.
add_argument
(
"
-vv
"
,
"
--very_verbose
"
,
help
=
"
Increase output verbosity
"
,
action
=
"
store_true
"
)
parser
.
add_argument
(
"
--config
"
,
type
=
str
,
help
=
"
Config path, default to
'
examples/config.yml
'"
)
...
...
@@ -278,11 +281,14 @@ if __name__ == "__main__":
args
=
parser
.
parse_args
()
if
args
.
verbose
:
if
args
.
verbose
or
args
.
very_verbose
:
logging
.
basicConfig
(
level
=
logging
.
DEBUG
)
else
:
logging
.
basicConfig
(
level
=
logging
.
INFO
)
logging
.
getLogger
(
"
urllib3
"
).
setLevel
(
logging
.
INFO
)
if
not
args
.
very_verbose
:
logging
.
getLogger
(
"
urllib3
"
).
setLevel
(
logging
.
INFO
)
logging
.
getLogger
(
"
bioblend
"
).
setLevel
(
logging
.
INFO
)
# Parsing the config file if provided, using the default config otherwise
if
args
.
config
:
...
...
@@ -338,14 +344,17 @@ if __name__ == "__main__":
load_data_for_current_species
.
setup_library
()
logging
.
debug
(
"
Successfully set up library in galaxy for {0} {1}
"
.
format
(
load_data_for_current_species
.
genus
,
load_data_for_current_species
.
species
))
#
S
et
or get the history for the current organism
load_data_for_current_species
.
history_id
=
utilities_bioblend
.
get_history
(
#
G
et
default history
history_id
=
utilities_bioblend
.
get_history
(
instance
=
load_data_for_current_species
.
instance
,
history_name
=
load_data_for_current_species
.
history
_name
)
history_name
=
"
Unnamed
history
"
)
# Remove H. sapiens from database if here
# TODO: set a dedicated history for removing H. sapiens (instead of doing it into a species history)
load_data_for_current_species
.
remove_homo_sapiens_from_db
()
remove_homo_sapiens_from_db
(
instance
=
load_data_for_current_species
.
instance
,
history_id
=
history_id
)
# logging.info("Importing datasets into history for %s" % load_data_for_current_species.full_name)
# load_data_for_current_species.import_datasets_into_history() # Option "--load-history"
...
...
This diff is collapsed.
Click to expand it.
utilities_bioblend.py
+
1
−
1
View file @
9468ac92
...
...
@@ -47,7 +47,7 @@ def get_history(instance, history_name):
hist_dict
=
instance
.
histories
.
create_history
(
name
=
str
(
history_name
))
history_id
=
hist_dict
[
"
id
"
]
logging
.
debug
(
"
History ID set for {0}: {1}
"
.
format
(
history_name
,
history_id
))
if
len
(
histories
)
==
1
:
el
if
len
(
histories
)
==
1
:
history_id
=
histories
[
0
][
"
id
"
]
logging
.
debug
(
"
History ID set for {0}: {1}
"
.
format
(
history_name
,
history_id
))
else
:
...
...
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