From 342fff322c9c5fd25f7496e5419861434228ad9f Mon Sep 17 00:00:00 2001
From: Loraine Gueguen <loraine.gueguen@sb-roscoff.fr>
Date: Thu, 20 May 2021 17:56:32 +0200
Subject: [PATCH] Add go summary functionality

---
 constants.py                      |  1 +
 examples/citrus_sinensis.yml      |  8 ++++----
 gga_init.py                       |  2 +-
 speciesData.py                    | 14 +++++++++-----
 templates/gspecies_compose.yml.j2 |  2 +-
 templates/organisms.yml.j2        |  3 ++-
 utilities.py                      |  1 +
 7 files changed, 19 insertions(+), 12 deletions(-)

diff --git a/constants.py b/constants.py
index 70724c3..2a50710 100644
--- a/constants.py
+++ b/constants.py
@@ -23,6 +23,7 @@ ORG_PARAM_DATA_OGS_VERSION = "ogs_version"
 ORG_PARAM_DATA_PERFORMED_BY = "performed_by"
 ORG_PARAM_SERVICES = "services"
 ORG_PARAM_SERVICES_BLAST = "blast"
+ORG_PARAM_SERVICES_GO = "go"
 
 
 # Constants used in the config yaml file
diff --git a/examples/citrus_sinensis.yml b/examples/citrus_sinensis.yml
index 63483e4..38087bb 100644
--- a/examples/citrus_sinensis.yml
+++ b/examples/citrus_sinensis.yml
@@ -18,7 +18,7 @@
   # Paths to the different datasets to copy and import into the galaxy container (as a shared library)
   # Must be absolute paths to the dataset
     genome_path: /path/to/repo/examples/src_data/genome/v1.0/Citrus_sinensis-scaffold00001.fasta # Mandatory!
-    transcripts_path: /path/to/repo/examples/src_data/annotation/v1.0/Citrus_sinensis-orange1.1g015632m.g.fasta  # Mandatory!
+    transcripts_path: /path/to/repo/examples/src_data/annotation/v1.0/Citrus_sinensis-orange1.1g015632m.g.fasta
     proteins_path: # Mandatory!
     gff_path: /path/to/repo/examples/src_data/annotation/v1.0/Citrus_sinensis-orange1.1g015632m.g.gff3 # Mandatory!
     interpro_path: /path/to/repo/examples/src_data/annotation/v1.0/functional_annotation/Citrus_sinensis-orange1.1g015632m.g.iprscan.xml
@@ -33,6 +33,6 @@
     ogs_version: 1.0
     performed_by:
   services:
-  # List the optional services to be deploy in the stack
-  # By default, only tripal, tripaldb, galaxy, jbrowse and elasticsearch services will be deployed
-    blast: 0
\ No newline at end of file
+  # List the optional services/resources to add
+    blast: 0 # "1" to add links to blast form, "some/url" to specify, multiple urls as "Name1=url1&Name2=url2", "0" to disable it. Default: "0"
+    go: 1 # "1" to add links to GO summary, "0" to disable it. Default: "0"
\ No newline at end of file
diff --git a/gga_init.py b/gga_init.py
index 6c2f702..a4fdb01 100755
--- a/gga_init.py
+++ b/gga_init.py
@@ -130,7 +130,7 @@ class DeploySpeciesStack(speciesData.SpeciesData):
                         "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": "{0} {1}".format(self.genus_uppercase, self.species_lower()),
-                        "blast": self.blast, "picture_path": self.picture_path}
+                        "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
diff --git a/speciesData.py b/speciesData.py
index 34c817f..d505da6 100755
--- a/speciesData.py
+++ b/speciesData.py
@@ -47,12 +47,18 @@ class SpeciesData:
         else:
             return string
 
+    def set_service_attribute(self, attribute, service, parameters_dictionary):
+        parameters_dictionary_services = parameters_dictionary[constants.ORG_PARAM_SERVICES]
+        if(service in parameters_dictionary_services.keys()):
+            attribute = parameters_dictionary_services[service]
+        else:
+            attribute = "0"
+
     def __init__(self, parameters_dictionary):
         self.parameters_dictionary = parameters_dictionary
         self.name = parameters_dictionary[constants.ORG_PARAM_NAME]
         parameters_dictionary_description=parameters_dictionary[constants.ORG_PARAM_DESC]
         parameters_dictionary_data = parameters_dictionary[constants.ORG_PARAM_DATA]
-        parameters_dictionary_services = parameters_dictionary[constants.ORG_PARAM_SERVICES]
 
         self.species = self.clean_string(parameters_dictionary_description[constants.ORG_PARAM_DESC_SPECIES])
         self.genus = self.clean_string(parameters_dictionary_description[constants.ORG_PARAM_DESC_GENUS])
@@ -83,10 +89,8 @@ class SpeciesData:
         self.blastx_path = parameters_dictionary_data[constants.ORG_PARAM_DATA_BLASTX_PATH]
         self.orthofinder_path = parameters_dictionary_data[constants.ORG_PARAM_DATA_ORTHOFINDER_PATH]
 
-        if(constants.ORG_PARAM_SERVICES_BLAST in parameters_dictionary_services.keys()):
-            self.blast = parameters_dictionary_services[constants.ORG_PARAM_SERVICES_BLAST]
-        else:
-            self.blast = "0"
+        self.set_service_attribute(self.blast, constants.ORG_PARAM_SERVICES_BLAST, parameters_dictionary)
+        self.set_service_attribute(self.go, constants.ORG_PARAM_SERVICES_GO, parameters_dictionary)
 
         if constants.ORG_PARAM_DESC_PICTURE_PATH in parameters_dictionary_description.keys():
             self.picture_path = parameters_dictionary_description[constants.ORG_PARAM_DESC_PICTURE_PATH]
diff --git a/templates/gspecies_compose.yml.j2 b/templates/gspecies_compose.yml.j2
index 97dbb00..1b1e8f8 100644
--- a/templates/gspecies_compose.yml.j2
+++ b/templates/gspecies_compose.yml.j2
@@ -65,7 +65,7 @@ services:
             ENABLE_BLAST: {{ blast }}
             ENABLE_DOWNLOAD: 1
             ENABLE_WIKI: 0
-            ENABLE_GO: 0
+            ENABLE_GO: {{ go }}
             ENABLE_ORTHOLOGY: 0
             ENABLE_ORTHOLOGY_LINKS: 0
             THEME: "{{ tripal_theme_name }}"  # Use this to use another theme
diff --git a/templates/organisms.yml.j2 b/templates/organisms.yml.j2
index 9a05ccf..019fce0 100644
--- a/templates/organisms.yml.j2
+++ b/templates/organisms.yml.j2
@@ -23,4 +23,5 @@
     {{ org_param_data_ogs_version }}: {{ org_param_data_ogs_version_value }}
     {{ org_param_data_performed_by }}: {{ org_param_data_performed_by_value }}
   {{ org_param_services }}:
-    {{ org_param_services_blast }}: {{ org_param_services_blast_value }}
\ No newline at end of file
+    {{ org_param_services_blast }}: {{ org_param_services_blast_value }}
+    {{ org_param_services_go }}: {{ org_param_services_go_value }}
\ No newline at end of file
diff --git a/utilities.py b/utilities.py
index f08c11b..bcee45e 100755
--- a/utilities.py
+++ b/utilities.py
@@ -236,5 +236,6 @@ def create_org_param_dict_from_constants():
     org_param_dict["org_param_data_performed_by"] = constants.ORG_PARAM_DATA_PERFORMED_BY
     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_go"] = constants.ORG_PARAM_SERVICES_GO
 
     return org_param_dict
-- 
GitLab