Skip to content
Snippets Groups Projects

Release v2.1.0

Merged Loraine Gueguen requested to merge dev into master
1 file
+ 1
1
Compare changes
  • Side-by-side
  • Inline
+ 39
21
@@ -13,7 +13,7 @@ from pathlib import Path
from jinja2 import Environment, FileSystemLoader
import utilities
import speciesData
import species_data
import constants
@@ -29,7 +29,7 @@ TODO
"""
class DeploySpeciesStack(speciesData.SpeciesData):
class DeploySpeciesStack(species_data.SpeciesData):
"""
Child of SpeciesData
@@ -37,6 +37,10 @@ class DeploySpeciesStack(speciesData.SpeciesData):
the organism's directory tree to create the required docker-compose files and stack deployment
"""
def __init__(self, parameters_dictionary):
self.picture_path = None
self.jbrowse_links = None
super().__init__(parameters_dictionary)
def make_directory_tree(self):
"""
@@ -76,6 +80,21 @@ class DeploySpeciesStack(speciesData.SpeciesData):
logging.debug("Using default banner for Tripal pages")
self.config.pop(constants.CONF_TRIPAL_BANNER_PATH, None)
# Copy the organism picture for tripal
if self.picture_path is not None:
if os.path.isfile(self.picture_path):
picture_path_basename = os.path.basename(self.picture_path)
picture_path_filename, picture_path_extension = os.path.splitext(picture_path_basename)
if picture_path_extension == ".png" or picture_path_extension == ".jpg":
picture_dest_name = "species%s" % picture_path_extension
picture_dest_path = os.path.join(self.species_dir, picture_dest_name)
shutil.copy(self.picture_path, picture_dest_path)
logging.info("Add picture %s" % self.picture_path)
else:
logging.error("Specified organism picture has wrong extension (must be '.png' or '.jpg'): {0}".format(self.picture_path))
else:
logging.error("Specified organism picture not found {0} for {1}".format(self.picture_path, self.genus_uppercase + " " + self.species))
# Create nginx dirs and write/re-write nginx conf
make_dirs(dir_paths_li=["./nginx", "./nginx/conf"])
try:
@@ -111,12 +130,13 @@ class DeploySpeciesStack(speciesData.SpeciesData):
# We need a dict holding all key (variables) - values that needs to be replaced in the template as our rendering dict
# To do so we need both input file vars and config vars
# Create input file vars dict
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_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:],
"blast": self.blast}
if (len(self.config.keys()) == 0):
"genus_species": self.genus_species, "jbrowse_dataset_id": self.species_folder_name, "jbrowse_links": self.jbrowse_links,
"genus_species_sex": "{0}_{1}_{2}".format(self.genus_lowercase, self.species_lowercase, self.sex),
"strain": self.strain, "sex": self.sex, "Genus_species": "{0} {1}".format(self.genus_uppercase, self.species_lowercase),
"blast": self.blast, "go": self.go, "picture_path": self.picture_path}
if len(self.config.keys()) == 0:
logging.error("Empty config dictionary")
# Merge the two dicts
render_vars = {**self.config, **input_vars}
@@ -146,19 +166,6 @@ class DeploySpeciesStack(speciesData.SpeciesData):
os.chdir(self.main_dir)
def make_orthology_compose_files(self):
"""
Create/update orthology compose files
:return:
"""
os.chdir(self.main_dir)
make_dirs["./orthology", "./orthology/src_data", "./orthology/src_data/genomes",
"./orthology/src_data/gff", "./orthology/src_data/newicks", "./orthology/src_data/proteomes"]
def make_dirs(dir_paths_li):
"""
Recursively create directories from a list of paths with a try-catch condition
@@ -334,6 +341,7 @@ def deploy_stacks(input_list, main_dir, deploy_traefik):
logging.info("Updating traefik stack")
run_docker_stack_deploy("traefik", traefik_dir)
#TODO: add test to check that the network/name resolution is fine in each galaxy container
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Deploy GGA containers")
@@ -371,7 +379,7 @@ if __name__ == "__main__":
else:
config_file = os.path.join(os.path.dirname(os.path.realpath(sys.argv[0])), constants.DEFAULT_CONFIG)
config = utilities.parse_config(config_file)
if (len(config.keys()) == 0):
if len(config.keys()) == 0:
logging.error("Empty config dictionary")
main_dir = None
@@ -382,11 +390,19 @@ if __name__ == "__main__":
sp_dict_list = utilities.parse_input(os.path.abspath(args.input))
#TODO: create SpeciesData objects in utilities.parse_input()
org_list = []
for sp_dict in sp_dict_list:
org = DeploySpeciesStack(parameters_dictionary=sp_dict)
org_list.append(org)
# Create traefik directory and compose files if needed or specified
if args.force_traefik or not os.path.isdir(os.path.join(os.path.abspath(main_dir), "traefik")):
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)
sp_picture_dict = utilities.get_sp_picture(sp_dict_list=sp_dict_list)
sp_jbrowse_links_dict = utilities.get_sp_jbrowse_links(org_list=org_list)
logging.info("Deploying stacks for organisms in input file %s" % args.input)
for sp_dict in unique_sp_dict_list:
@@ -407,10 +423,12 @@ if __name__ == "__main__":
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
deploy_stack_for_current_organism.picture_path = sp_picture_dict[deploy_stack_for_current_organism.genus_species]
deploy_stack_for_current_organism.make_directory_tree()
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
deploy_stack_for_current_organism.jbrowse_links = sp_jbrowse_links_dict[deploy_stack_for_current_organism.genus_species]
deploy_stack_for_current_organism.make_compose_files()
logging.info("Successfully generated the docker-compose files for %s %s", deploy_stack_for_current_organism.genus, deploy_stack_for_current_organism.species)
Loading