From 9431430e4a9bc5049ee1f20499cf973bc233f81e Mon Sep 17 00:00:00 2001
From: Loraine Gueguen <loraine.gueguen@sb-roscoff.fr>
Date: Tue, 4 May 2021 12:53:50 +0200
Subject: [PATCH] Fix logging text. Keep species with best assembly in
 get_uniq_species_dict_list() (will be main jbrowse url).

---
 gga_init.py                | 25 ++++++-------------------
 templates/organisms.yml.j2 |  3 +++
 utilities.py               |  2 +-
 3 files changed, 10 insertions(+), 20 deletions(-)

diff --git a/gga_init.py b/gga_init.py
index 660fff5..18daf6e 100755
--- a/gga_init.py
+++ b/gga_init.py
@@ -63,7 +63,7 @@ class DeploySpeciesStack(speciesData.SpeciesData):
         if "banner_path" in self.config.keys():
             if not config["banner_path"] == "" and os.path.isfile(os.path.abspath(config["banner_path"])):
                 try:
-                    logging.debug("Custom banner path: %s" % self.config["banner_path"])
+                    logging.info("Custom banner path: %s" % self.config["banner_path"])
                     shutil.copy(os.path.abspath(self.config["banner_path"]), "%s/banner.png" % self.species_dir)
                 except FileNotFoundError:
                     logging.warning("Could not copy specified banner (%s), using default banner instead" % self.config["banner_path"])
@@ -80,13 +80,13 @@ class DeploySpeciesStack(speciesData.SpeciesData):
         try:
             shutil.copy(os.path.join(self.script_dir, "files/nginx_download.conf"), os.path.abspath("./nginx/conf/default.conf"))
         except Exception as exc:
-            logging.critical("Could not copy nginx configuration file for %s" % self.full_name)
+            logging.critical("Could not copy nginx configuration file for %s %s", self.genus, self.species)
             logging.critical(exc)            
 
         # Return to main directory
         os.chdir(self.main_dir)
 
-        logging.info("Directory tree generated for %s" % self.full_name)
+        logging.info("Directory tree generated for %s %s", self.genus, self.species)
 
 
     def make_compose_files(self):
@@ -391,29 +391,16 @@ if __name__ == "__main__":
         # Parse the config yaml file
         deploy_stack_for_current_organism.config = config
 
-        # # Set the instance url attribute
-        # for env_variable, value in deploy_stack_for_current_organism.config.items():
-        #     if env_variable == "hostname":
-        #         deploy_stack_for_current_organism.instance_url = value + \
-        #                                                          deploy_stack_for_current_organism.genus_lowercase + \
-        #                                                          "_" + deploy_stack_for_current_organism.species + \
-        #                                                          "/galaxy/"
-        #         break
-        #     else:
-        #         deploy_stack_for_current_organism.instance_url = "http://localhost:8888/sp/{0}_{1}/galaxy/".format(
-        #             deploy_stack_for_current_organism.genus_lowercase,
-        #             deploy_stack_for_current_organism.species)
-                                                                    
         # Starting
-        logging.info("gga_init.py called for %s" % deploy_stack_for_current_organism.full_name)
+        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.make_directory_tree()
-        logging.info("Successfully generated the directory tree for %s" % deploy_stack_for_current_organism.full_name)
+        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.make_compose_files()
-        logging.info("Successfully generated the docker-compose files for %s" % deploy_stack_for_current_organism.full_name)
+        logging.info("Successfully generated the docker-compose files for %s %s", deploy_stack_for_current_organism.genus, deploy_stack_for_current_organism.species)
 
     logging.info("Deploying stacks")
     if args.force_traefik:
diff --git a/templates/organisms.yml.j2 b/templates/organisms.yml.j2
index ff71547..83ab58f 100644
--- a/templates/organisms.yml.j2
+++ b/templates/organisms.yml.j2
@@ -6,6 +6,9 @@
     strain: {{ strain }}
     common_name: {{ common_name }}
     origin: {{ origin }}
+    {% if main_species is defined and main_species is sameas true %}
+    main_species: yes
+    {% endif %}
   data:
     genome_path: {{ genome_path }}
     transcripts_path: {{ transcripts_path }}
diff --git a/utilities.py b/utilities.py
index d6b8504..7145430 100755
--- a/utilities.py
+++ b/utilities.py
@@ -166,7 +166,7 @@ def get_unique_species_dict_list(sp_dict_list):
 
     for sp in sp_dict_list:
         for gspecies in unique_species_genus_species:
-            if gspecies not in unique_species_dict.keys():
+            if gspecies not in unique_species_dict.keys() or sp[0]["description"]["main_sp"] == "yes" :
                 unique_species_dict[gspecies] = sp
             else:
                 continue
-- 
GitLab