Skip to content
Snippets Groups Projects
Commit b59d2a28 authored by Loraine Gueguen's avatar Loraine Gueguen
Browse files

fix get_history

parent 6c86b6f9
No related branches found
No related tags found
2 merge requests!24Run wf,!18Release v2.1.0
This commit is part of merge request !18. Comments created here will be created in the context of that merge request.
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import re import re
import bioblend
import argparse import argparse
import os import os
import logging import logging
...@@ -39,27 +38,6 @@ class LoadData(speciesData.SpeciesData): ...@@ -39,27 +38,6 @@ class LoadData(speciesData.SpeciesData):
self.bam_metadata_cache = {} self.bam_metadata_cache = {}
super().__init__(parameters_dictionary) super().__init__(parameters_dictionary)
def get_history(self):
"""
Create or set the working history to the current species one
:return:
"""
try:
histories = self.instance.histories.get_histories(name=str(self.genus_species))
if len(histories) == 1:
self.history_id = histories[0]["id"]
logging.debug("History ID set for {0} {1}: {2}".format(self.genus, self.species, self.history_id))
else:
logging.critical("Multiple histories exists for {0}: {1}".format(self.genus, self.species))
except IndexError:
logging.info("Creating history for {0} {1}".format(self.genus, self.species))
hist_dict = self.instance.histories.create_history(name=str(self.genus_species))
self.history_id = hist_dict["id"]
logging.debug("History ID set for {0} {1}: {2}".format(self.genus, self.species, self.history_id))
return self.history_id
def remove_homo_sapiens_from_db(self): def remove_homo_sapiens_from_db(self):
""" """
Run the GMOD tool to remove the "Homo sapiens" default organism from the original database Run the GMOD tool to remove the "Homo sapiens" default organism from the original database
...@@ -304,6 +282,7 @@ if __name__ == "__main__": ...@@ -304,6 +282,7 @@ if __name__ == "__main__":
logging.basicConfig(level=logging.DEBUG) logging.basicConfig(level=logging.DEBUG)
else: else:
logging.basicConfig(level=logging.INFO) logging.basicConfig(level=logging.INFO)
logging.getLogger("urllib3").setLevel(logging.INFO)
# Parsing the config file if provided, using the default config otherwise # Parsing the config file if provided, using the default config otherwise
if args.config: if args.config:
...@@ -360,7 +339,9 @@ if __name__ == "__main__": ...@@ -360,7 +339,9 @@ if __name__ == "__main__":
logging.debug("Successfully set up library in galaxy for {0} {1}".format(load_data_for_current_species.genus, load_data_for_current_species.species)) 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 # Set or get the history for the current organism
load_data_for_current_species.get_history() load_data_for_current_species.history_id = utilities_bioblend.get_history(
instance=load_data_for_current_species.instance,
history_name=load_data_for_current_species.history_name)
# Remove H. sapiens from database if here # Remove H. sapiens from database if here
# TODO: set a dedicated history for removing H. sapiens (instead of doing it into a species history) # TODO: set a dedicated history for removing H. sapiens (instead of doing it into a species history)
......
...@@ -139,4 +139,5 @@ class SpeciesData: ...@@ -139,4 +139,5 @@ class SpeciesData:
self.instance_url = None self.instance_url = None
self.instance = None self.instance = None
self.history_id = None self.history_id = None
self.history_name = str(self.genus_species)
self.library_id = None self.library_id = None
...@@ -34,21 +34,24 @@ def get_galaxy_instance(instance_url, email, password): ...@@ -34,21 +34,24 @@ def get_galaxy_instance(instance_url, email, password):
return instance return instance
def get_history(instance, history_name): def get_history(instance, history_name):
""" """
Create or set the working history to the current species one Create or set the working history to the current species one
:return: :return:
""" """
try: histories = instance.histories.get_histories(name=str(history_name))
histories = instance.histories.get_histories(name=history_name) if len(histories) == 0:
history_id = histories[0]["id"]
logging.debug("History ID set for {0}: {1}".format(history_name, history_id))
except IndexError:
logging.info("Creating history for %s" % history_name) logging.info("Creating history for %s" % history_name)
history = instance.histories.create_history(name=history_name) hist_dict = instance.histories.create_history(name=str(history_name))
history_id = history["id"] history_id = hist_dict["id"]
logging.debug("History ID set for {0}: {1}".format(history_name, history_id)) logging.debug("History ID set for {0}: {1}".format(history_name, history_id))
if len(histories) == 1:
history_id = histories[0]["id"]
logging.debug("History ID set for {0}: {1}".format(history_name, history_id))
else:
logging.critical("Multiple histories exists for {0}".format(history_name))
return history_id return history_id
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment