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
......@@ -2,7 +2,6 @@
# -*- coding: utf-8 -*-
import re
import bioblend
import argparse
import os
import logging
......@@ -39,27 +38,6 @@ class LoadData(speciesData.SpeciesData):
self.bam_metadata_cache = {}
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):
"""
Run the GMOD tool to remove the "Homo sapiens" default organism from the original database
......@@ -304,6 +282,7 @@ if __name__ == "__main__":
logging.basicConfig(level=logging.DEBUG)
else:
logging.basicConfig(level=logging.INFO)
logging.getLogger("urllib3").setLevel(logging.INFO)
# Parsing the config file if provided, using the default config otherwise
if args.config:
......@@ -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))
# 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
# TODO: set a dedicated history for removing H. sapiens (instead of doing it into a species history)
......
......@@ -139,4 +139,5 @@ class SpeciesData:
self.instance_url = None
self.instance = None
self.history_id = None
self.history_name = str(self.genus_species)
self.library_id = None
......@@ -34,21 +34,24 @@ def get_galaxy_instance(instance_url, email, password):
return instance
def get_history(instance, history_name):
"""
Create or set the working history to the current species one
:return:
"""
try:
histories = instance.histories.get_histories(name=history_name)
history_id = histories[0]["id"]
logging.debug("History ID set for {0}: {1}".format(history_name, history_id))
except IndexError:
histories = instance.histories.get_histories(name=str(history_name))
if len(histories) == 0:
logging.info("Creating history for %s" % history_name)
history = instance.histories.create_history(name=history_name)
history_id = history["id"]
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:
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
......
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