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

Merge branch 'picture' into 'dev'

fixes

See merge request !16
parents dc04c84a 8c1e24f2
No related branches found
No related tags found
2 merge requests!18Release v2.1.0,!16fixes
...@@ -38,7 +38,7 @@ class DeploySpeciesStack(speciesData.SpeciesData): ...@@ -38,7 +38,7 @@ class DeploySpeciesStack(speciesData.SpeciesData):
""" """
def make_directory_tree(self): def make_directory_tree(self, picture_path):
""" """
Generate the directory tree for an organism Generate the directory tree for an organism
...@@ -76,19 +76,19 @@ class DeploySpeciesStack(speciesData.SpeciesData): ...@@ -76,19 +76,19 @@ class DeploySpeciesStack(speciesData.SpeciesData):
logging.debug("Using default banner for Tripal pages") logging.debug("Using default banner for Tripal pages")
self.config.pop(constants.CONF_TRIPAL_BANNER_PATH, None) self.config.pop(constants.CONF_TRIPAL_BANNER_PATH, None)
# Copy the organism picture for tripal if one was specified in the input species # Copy the organism picture for tripal
if self.picture_path is not None: if picture_path is not None:
if os.path.isfile(self.picture_path): if os.path.isfile(picture_path):
picture_path_basename = os.path.basename(self.picture_path) picture_path_basename = os.path.basename(picture_path)
picture_path_filename, picture_path_extension = os.path.splitext(picture_path_basename) picture_path_filename, picture_path_extension = os.path.splitext(picture_path_basename)
if picture_path_extension == ".png" or picture_path_extension == ".jpg": if picture_path_extension == ".png" or picture_path_extension == ".jpg":
picture_dest_name = "species%s" % picture_path_extension picture_dest_name = "species%s" % picture_path_extension
picture_dest_path = os.path.join(self.species_dir, picture_dest_name) picture_dest_path = os.path.join(self.species_dir, picture_dest_name)
shutil.copy(self.picture_path, picture_dest_path) shutil.copy(picture_path, picture_dest_path)
else: else:
logging.error("Specified organism picture has wrong extension (must be '.png' or '.jpg'): {0}".format(self.picture_path)) logging.error("Specified organism picture has wrong extension (must be '.png' or '.jpg'): {0}".format(picture_path))
else: else:
logging.error("Specified organism picture not found {0} for {1}".format(self.picture_path, self.genus_uppercase + " " + self.species)) logging.error("Specified organism picture not found {0} for {1}".format(picture_path, self.genus_uppercase + " " + self.species))
# Create nginx dirs and write/re-write nginx conf # Create nginx dirs and write/re-write nginx conf
make_dirs(dir_paths_li=["./nginx", "./nginx/conf"]) make_dirs(dir_paths_li=["./nginx", "./nginx/conf"])
...@@ -127,10 +127,10 @@ class DeploySpeciesStack(speciesData.SpeciesData): ...@@ -127,10 +127,10 @@ class DeploySpeciesStack(speciesData.SpeciesData):
# Create input file vars dict # Create input file vars dict
input_vars = {"genus": self.genus_lowercase, "Genus": self.genus_uppercase, "species": self.species, input_vars = {"genus": self.genus_lowercase, "Genus": self.genus_uppercase, "species": self.species,
"genus_species": self.genus_species, "genus_species_strain_sex": self.species_folder_name, "genus_species": self.genus_species, "genus_species_strain_sex": self.species_folder_name,
"genus_species_sex": "{0}_{1}_{2}".format(self.genus_lowercase, self.species.lower(), self.sex), "genus_species_sex": "{0}_{1}_{2}".format(self.genus_lowercase, self.species_lower(), self.sex),
"strain": self.strain, "sex": self.sex, "Genus_species": self.genus_species[0].upper() + self.genus_species[1:], "strain": self.strain, "sex": self.sex, "Genus_species": "{0} {1}".format(self.genus_uppercase, self.species_lower()),
"blast": self.blast, "picture_path": self.picture_path} "blast": self.blast, "picture_path": self.picture_path}
if (len(self.config.keys()) == 0): if (len(self.config.keys()) == 0):
logging.error("Empty config dictionary") logging.error("Empty config dictionary")
# Merge the two dicts # Merge the two dicts
...@@ -402,6 +402,7 @@ if __name__ == "__main__": ...@@ -402,6 +402,7 @@ if __name__ == "__main__":
make_traefik_compose_files(config=config, main_dir=main_dir) make_traefik_compose_files(config=config, main_dir=main_dir)
unique_sp_dict_list = utilities.get_unique_species_dict_list(sp_dict_list=sp_dict_list) unique_sp_dict_list = utilities.get_unique_species_dict_list(sp_dict_list=sp_dict_list)
sp_picture_dict = utilities.get_sp_picture(sp_dict_list=sp_dict_list)
logging.info("Deploying stacks for organisms in input file %s" % args.input) logging.info("Deploying stacks for organisms in input file %s" % args.input)
for sp_dict in unique_sp_dict_list: for sp_dict in unique_sp_dict_list:
...@@ -422,7 +423,8 @@ if __name__ == "__main__": ...@@ -422,7 +423,8 @@ if __name__ == "__main__":
logging.info("gga_init.py called for %s %s", deploy_stack_for_current_organism.genus, deploy_stack_for_current_organism.species) logging.info("gga_init.py called for %s %s", deploy_stack_for_current_organism.genus, deploy_stack_for_current_organism.species)
# Make/update directory tree # Make/update directory tree
deploy_stack_for_current_organism.make_directory_tree() picture_path = sp_picture_dict[deploy_stack_for_current_organism.genus_species]
deploy_stack_for_current_organism.make_directory_tree(picture_path)
logging.info("Successfully generated the directory tree for %s %s", deploy_stack_for_current_organism.genus, deploy_stack_for_current_organism.species) logging.info("Successfully generated the directory tree for %s %s", deploy_stack_for_current_organism.genus, deploy_stack_for_current_organism.species)
# Make compose files # Make compose files
......
...@@ -93,20 +93,25 @@ class SpeciesData: ...@@ -93,20 +93,25 @@ class SpeciesData:
else: else:
self.picture_path = None self.picture_path = None
self.genus_lowercase = self.genus[0].lower() + self.genus[1:] self.genus_lowercase = self.genus.lower()
self.genus_uppercase = self.genus[0].upper() + self.genus[1:] self.species_lower = self.species.lower()
self.genus_uppercase = self.genus[0].upper() + self.genus_lowercase[1:]
self.genus_species = "{0}_{1}".format(self.genus_lowercase, self.species_lower)
self.chado_species_name = "{0} {1}".format(self.species, self.sex) self.chado_species_name = "{0} {1}".format(self.species, self.sex)
self.full_name = ' '.join(utilities.filter_empty_not_empty_items([self.genus_uppercase, self.species, self.strain, self.sex])["not_empty"]) self.full_name = ' '.join(utilities.filter_empty_not_empty_items([self.genus_uppercase, self.species, self.strain, self.sex])["not_empty"])
self.full_name_lowercase = self.full_name.lower() self.full_name_lowercase = self.full_name.lower()
self.abbreviation = "_".join(utilities.filter_empty_not_empty_items([self.genus_lowercase[0], self.species, self.strain, self.sex])["not_empty"]) self.abbreviation = "_".join(utilities.filter_empty_not_empty_items([self.genus_lowercase[0], self.species, self.strain, self.sex])["not_empty"])
self.genus_species = "{0}_{1}".format(self.genus.lower(), self.species.lower()) self.species_folder_name = "_".join(utilities.filter_empty_not_empty_items(
[self.genus_lowercase, self.species_lower(), self.strain.lower(),
self.sex.lower()])["not_empty"])
self.dataset_prefix = None self.dataset_prefix = None
if self.sex is not None or self.sex != "": if self.sex is not None or self.sex != "":
self.dataset_prefix = self.genus[0].lower() + "_" + self.species.lower() + "_" + self.sex[0].lower() self.dataset_prefix = self.genus[0].lower() + "_" + self.species_lower + "_" + self.sex[0].lower()
else: else:
self.dataset_prefix = self.genus[0].lower() + "_" + self.species.lower() self.dataset_prefix = self.genus[0].lower() + "_" + self.species_lower
# Bioblend/Chado IDs for an organism analyses/organisms/datasets/history/library # Bioblend/Chado IDs for an organism analyses/organisms/datasets/history/library
self.org_id = None self.org_id = None
...@@ -131,6 +136,3 @@ class SpeciesData: ...@@ -131,6 +136,3 @@ class SpeciesData:
self.api_key = None # API key used to communicate with the galaxy instance. Cannot be used to do user-tied actions self.api_key = None # API key used to communicate with the galaxy instance. Cannot be used to do user-tied actions
self.datasets = dict() self.datasets = dict()
self.config = None # Custom config used to set environment variables inside containers self.config = None # Custom config used to set environment variables inside containers
self.species_folder_name = "_".join(utilities.filter_empty_not_empty_items(
[self.genus_lowercase.lower(), self.species.lower(), self.strain.lower(),
self.sex.lower()])["not_empty"])
...@@ -38,18 +38,18 @@ services: ...@@ -38,18 +38,18 @@ services:
- ./docker_data/galaxy/:/export/:ro - ./docker_data/galaxy/:/export/:ro
- ./src_data/:/project_data/:ro - ./src_data/:/project_data/:ro
- ./src_data:/data:ro - ./src_data:/data:ro
{% if 'tripal_banner_path' is defined %} {% if 'tripal_banner_path' is defined %}
- ./banner.png:/var/www/html/banner.png:ro - ./banner.png:/var/www/html/banner.png:ro
{% endif %} {% endif %}
#- /groups/XXX/:/groups/XXX/:ro # We do this when we have symlinks in src_data pointing to /groups/XXX/... #- /groups/XXX/:/groups/XXX/:ro # We do this when we have symlinks in src_data pointing to /groups/XXX/...
{% if 'picture_path' is defined %} {% if 'picture_path' is defined %}
{% if 'png' in picture_path %} {% if 'png' in picture_path %}
- ./species.png:/var/www/html/species.png:ro - ./species.png:/var/www/html/species.png:ro
{% endif %} {% endif %}
{% if 'jpg' in picture_path %} {% if 'jpg' in picture_path %}
- ./species.jpg:/var/www/html/species.jpg:ro - ./species.jpg:/var/www/html/species.jpg:ro
{% endif %}
{% endif %} {% endif %}
{% endif %}
environment: environment:
DB_HOST: tripal-db.{{ genus_species }} DB_HOST: tripal-db.{{ genus_species }}
BASE_URL_PATH: /sp/{{ genus_species }} BASE_URL_PATH: /sp/{{ genus_species }}
......
...@@ -162,14 +162,28 @@ def get_unique_species_dict_list(sp_dict_list): ...@@ -162,14 +162,28 @@ def get_unique_species_dict_list(sp_dict_list):
if gspecies not in unique_species_dict.keys() or ( constants.ORG_PARAM_DESC_MAIN_SPECIES in sp[constants.ORG_PARAM_DESC].keys() and if gspecies not in unique_species_dict.keys() or ( constants.ORG_PARAM_DESC_MAIN_SPECIES in sp[constants.ORG_PARAM_DESC].keys() and
sp[constants.ORG_PARAM_DESC][constants.ORG_PARAM_DESC_MAIN_SPECIES] == True ) : sp[constants.ORG_PARAM_DESC][constants.ORG_PARAM_DESC_MAIN_SPECIES] == True ) :
unique_species_dict[gspecies] = sp unique_species_dict[gspecies] = sp
else:
continue
for k, v in unique_species_dict.items(): for k, v in unique_species_dict.items():
unique_species_list_of_dict.append(v) unique_species_list_of_dict.append(v)
return unique_species_list_of_dict return unique_species_list_of_dict
def get_sp_picture(sp_dict_list):
"""
Get the picture for each species: the picture of the main strain if exists, other strain if not
"""
sp_picture_dict = {}
for sp in sp_dict_list:
gspecies = get_gspecies_string_from_sp_dict(sp)
if gspecies not in sp_picture_dict.keys() or ( constants.ORG_PARAM_DESC_MAIN_SPECIES in sp[constants.ORG_PARAM_DESC].keys() and
sp[constants.ORG_PARAM_DESC][constants.ORG_PARAM_DESC_MAIN_SPECIES] == True ):
if sp[constants.ORG_PARAM_DESC_PICTURE_PATH] != "":
sp_picture_dict[gspecies] = sp[constants.ORG_PARAM_DESC_PICTURE_PATH]
return sp_picture_dict
def run_tool(instance, tool_id, history_id, tool_inputs): def run_tool(instance, tool_id, history_id, tool_inputs):
output_dict = None output_dict = None
...@@ -223,4 +237,4 @@ def create_org_param_dict_from_constants(): ...@@ -223,4 +237,4 @@ def create_org_param_dict_from_constants():
org_param_dict["org_param_services"] = constants.ORG_PARAM_SERVICES org_param_dict["org_param_services"] = constants.ORG_PARAM_SERVICES
org_param_dict["org_param_services_blast"] = constants.ORG_PARAM_SERVICES_BLAST org_param_dict["org_param_services_blast"] = constants.ORG_PARAM_SERVICES_BLAST
return org_param_dict return org_param_dict
\ No newline at end of file
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