Skip to content
Snippets Groups Projects

Release v2.1.0

Merged Loraine Gueguen requested to merge dev into master
2 files
+ 45
36
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 44
35
@@ -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))
# Set or get the history for the current organism
load_data_for_current_species.history_id = utilities_bioblend.get_history(
# Get 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"
Loading