From 5c2296d0b2836df7a018870bbf95d2863e90c2c8 Mon Sep 17 00:00:00 2001
From: Arthur Le Bars <arthur.le-bars@sb-roscoff.fr>
Date: Mon, 18 Jan 2021 20:02:44 +0100
Subject: [PATCH] Added demo

---
 examples/demo.yaml                |  60 +++++++++
 gga_init.py                       |   1 -
 gga_load_data.py                  |   8 +-
 run_workflow_phaeoexplorer.py     | 216 +++++++++++++++++++++---------
 workflows/Galaxy-Workflow-demo.ga |  91 +++++++++++++
 5 files changed, 306 insertions(+), 70 deletions(-)
 create mode 100644 examples/demo.yaml
 create mode 100644 workflows/Galaxy-Workflow-demo.ga

diff --git a/examples/demo.yaml b/examples/demo.yaml
new file mode 100644
index 0000000..9948a4b
--- /dev/null
+++ b/examples/demo.yaml
@@ -0,0 +1,60 @@
+# Input file for the automated creation GGA docker stacks
+# The file consists in a "list" of species for which the script will have to create these stacks/load data into galaxy/run workflows
+
+ectocarpus_sp2_male:  # Dummy value the user gives to designate the species (isn't used by the script)
+  # Species description, leave blank if unknown or you don't want it to be used
+  # These parameters are used to set up the various urls and adresses in different containers
+  # The script requires at least the genus to be specified
+  description:
+    genus: "ectocarpus"  # Mandatory!
+    species: "sp4"
+    sex: "male"
+    strain: ""
+    common_name: ""
+    origin: ""
+  # Data files scalars contain paths to the source files that have to be loaded into galaxy
+  # WARNING: The paths must be absolute paths!
+  # If any path is left blank and the "parent_directory" scalar is specified, this directory and ALL its subdirectories will be
+  # scanned for files corresponding to the description provided for the species (i.e if the user specified
+  # the sex and strain, the script will look for files containing the genus, species, sex and strain of the species)
+  # If no file corresponding to the description is found, this path will be considered empty and the script will
+  # proceed to the next step (create the directory tree for the GGA docker stack)
+  # If a path is left blank and the "parent_directory" scalar is also blank, no file will be loaded for this "path" scalar
+  # If the files are not named using this nomenclature, please provide all the paths in the corresponding scalars below
+  data:
+    # "parent_directory": (optional) directory from where to search files if a "***_path" scalar is empty
+    # NOTE: Try to set a parent directory "close" to the data files so as not to increase runtime
+    # If empty (""), the script will not search for files and no dataset will be loaded for the corresponding scalar
+    parent_directory: "/path/to/closest/parent/dir"
+    # "***_path": path to the file (optional if parent_directory is set and species "description" scalars are precised)
+    # TODO Not implemented yet
+    genome_path: "/path/to/fasta"
+    transcripts_path: "/path/to/fasta"
+    proteins_path: "/path/to/fasta"
+    gff_path: "/path/to/gff"
+    # If the user has several genomes to upload to galaxy, the next scalar is used by the script to differentiate
+    # between these different versions and name directories according to it.
+    # If left empty, the genome will be considered version "1.0"
+    genome_version: "1.0"
+    # Same as genome version, but for the analysis
+    ogs_version: ""
+    performed_by: ""
+
+# Second example without the comments doc
+ectocarpus_sp2_female:
+  description:
+    genus: "ectocarpus"
+    species: "sp4"
+    sex: "female"
+    strain: ""
+    common_name: ""
+    origin: ""
+  data:
+    parent_directory: "/path/to/closest/parent/dir"
+    genome_path: "/path/to/fasta"
+    transcripts_path: "/path/to/fasta"
+    proteins_path: "/path/to/fasta"
+    gff_path: "/path/to/gff"
+    genome_version: "1.0"
+    ogs_version: "1.0"
+    performed_by: ""
diff --git a/gga_init.py b/gga_init.py
index 2ed11ef..9fd72ae 100644
--- a/gga_init.py
+++ b/gga_init.py
@@ -59,7 +59,6 @@ class DeploySpeciesStack(speciesData.SpeciesData):
         if not os.path.isfile("%s/banner.png" % self.species_dir):
             shutil.copy("%s/misc/banner.png" % self.script_dir, "%s/banner.png" % self.species_dir)
 
-        # TODO: replace custom_theme in the compose !!
         try:
             os.mkdir("./nginx/")
             os.mkdir("./nginx/conf")
diff --git a/gga_load_data.py b/gga_load_data.py
index c499ca1..cff2747 100644
--- a/gga_load_data.py
+++ b/gga_load_data.py
@@ -309,8 +309,6 @@ class LoadData(speciesData.SpeciesData):
     #     - Get any other existing organisms IDs before updating the galaxy instance --> separate
 
     #     Calling this function is mandatory to have a working galaxy instance history
-        
-    #     TODO Move this function to utils (it's also used in "run_workflow")
     #     TODO Run a check to see if the instance is correctly set up
 
     #     :return:
@@ -706,10 +704,10 @@ if __name__ == "__main__":
 
             # # Set or get the history for the current organism
             # load_data_for_current_species.set_get_history()
-            #
-            # # Remove H. sapiens from database if here
+            
+            # Remove H. sapiens from database if here TODO: set a dedicated history for removing H. sapiens (instead of doing it into a species history)
             # logging.info("Removing H. sapiens from Chado database for %s" % load_data_for_current_species.full_name)
-            # load_data_for_current_species.remove_homo_sapiens_from_db()
+            load_data_for_current_species.remove_homo_sapiens_from_db()
             # logging.info("Successfully removed H. sapiens from Chado database for %s" % load_data_for_current_species.full_name)
 
             # logging.info("Importing datasets into history for %s" % load_data_for_current_species.full_name)
diff --git a/run_workflow_phaeoexplorer.py b/run_workflow_phaeoexplorer.py
index 330707b..35e645f 100644
--- a/run_workflow_phaeoexplorer.py
+++ b/run_workflow_phaeoexplorer.py
@@ -11,6 +11,7 @@ import json
 import utilities
 import speciesData
 
+from bioblend.galaxy.objects import GalaxyInstance
 from bioblend import galaxy
 
 """ 
@@ -122,17 +123,17 @@ class RunWorkflow(speciesData.SpeciesData):
 
 
 
-    def import_datasets_to_history(self):
-        """
-        Load the datasets into the current species history
+    # def import_datasets_to_history(self):
+    #     """
+    #     Load the datasets into the current species history
 
-        """
+    #     """
 
-        logging.info("Uploading datasets into history %s" % self.history_id)
-        self.instance.histories.upload_dataset_from_library(history_id=self.history_id, lib_dataset_id=self.datasets["genome_file"])
-        self.instance.histories.upload_dataset_from_library(history_id=self.history_id, lib_dataset_id=self.datasets["gff_file"])
-        self.instance.histories.upload_dataset_from_library(history_id=self.history_id, lib_dataset_id=self.datasets["transcripts_file"])
-        self.instance.histories.upload_dataset_from_library(history_id=self.history_id, lib_dataset_id=self.datasets["proteins_file"])
+    #     logging.info("Uploading datasets into history %s" % self.history_id)
+    #     self.instance.histories.upload_dataset_from_library(history_id=self.history_id, lib_dataset_id=self.datasets["genome_file"])
+    #     self.instance.histories.upload_dataset_from_library(history_id=self.history_id, lib_dataset_id=self.datasets["gff_file"])
+    #     self.instance.histories.upload_dataset_from_library(history_id=self.history_id, lib_dataset_id=self.datasets["transcripts_file"])
+    #     self.instance.histories.upload_dataset_from_library(history_id=self.history_id, lib_dataset_id=self.datasets["proteins_file"])
 
     def connect_to_instance(self):
         """
@@ -196,7 +197,7 @@ class RunWorkflow(speciesData.SpeciesData):
             history_id=self.history_id,
             tool_inputs={"name": self.full_name_lowercase + " OGS" + self.ogs_version,
                          "program": "Performed by Genoscope",
-                         "programversion": str("OGS" + self.ogs_version),
+                         "programversion": str(self.sex + " OGS" + self.ogs_version),
                          "sourcename": "Genoscope",
                          "date_executed": self.date})
 
@@ -207,10 +208,13 @@ class RunWorkflow(speciesData.SpeciesData):
             history_id=self.history_id,
             tool_inputs={"name": self.full_name_lowercase + " genome v" + self.genome_version,
                          "program": "Performed by Genoscope",
-                         "programversion": str("genome v" + self.genome_version),
+                         "programversion": str(self.sex + "genome v" + self.genome_version),
                          "sourcename": "Genoscope",
                          "date_executed": self.date})
+
+        # Also get the organism and analyses IDs
         self.get_organism_and_analyses_ids()
+
         logging.info("Finished initializing instance")
 
 
@@ -230,8 +234,8 @@ class RunWorkflow(speciesData.SpeciesData):
         :return:
         """
 
-        logging.debug("running workflow: " + str(workflow_path))
-        workflow_name = self.full_name + "_base"
+        logging.info("importing workflow: " + str(workflow_path))
+        workflow_name = "demo"  # for workflow demo
         workflow_ga_file = workflow_path
 
         # Name the workflow in galaxy
@@ -247,29 +251,24 @@ class RunWorkflow(speciesData.SpeciesData):
 
         # Solving format issues in the .ga (encoding errors when importing the file via bioblend)
         with open(workflow_ga_file, 'r') as ga_in_file:
-            workflow = str(ga_in_file.readlines())
-            # Ugly fix for the jbrowse parameters (formatting)
-            workflow = workflow.replace('{\\\\\\\\\\\\"unique_id\\\\\\\\\\\\": \\\\\\\\\\\\"UNIQUE_ID\\\\\\\\\\\\"}',
-                                        str('{\\\\\\\\\\\\"unique_id\\\\\\\\\\\\": \\\\\\\\\\\\"' + self.genus + " " + self.species) + '\\\\\\\\\\\\"')
-            workflow = workflow.replace('\\\\\\\\\\\\"name\\\\\\\\\\\\": \\\\\\\\\\\\"NAME\\\\\\\\\\\\"',
-                                        str('\\\\\\\\\\\\"name\\\\\\\\\\\\": \\\\\\\\\\\\"' + self.genus.lower()[0] + self.species) + '\\\\\\\\\\\\"')
+            # workflow = str(ga_in_file.readlines())
+            # # Ugly fix for the jbrowse parameters (formatting) --> TODO: OBSOLETE (everything set at runtime)
+            # workflow = workflow.replace('{\\\\\\\\\\\\"unique_id\\\\\\\\\\\\": \\\\\\\\\\\\"UNIQUE_ID\\\\\\\\\\\\"}',
+            #                             str('{\\\\\\\\\\\\"unique_id\\\\\\\\\\\\": \\\\\\\\\\\\"' + self.genus + " " + self.species) + '\\\\\\\\\\\\"')
+            # workflow = workflow.replace('\\\\\\\\\\\\"name\\\\\\\\\\\\": \\\\\\\\\\\\"NAME\\\\\\\\\\\\"',
+            #                             str('\\\\\\\\\\\\"name\\\\\\\\\\\\": \\\\\\\\\\\\"' + self.genus.lower()[0] + self.species) + '\\\\\\\\\\\\"')
             # workflow = workflow.replace("\\\\", "\\")  # to restore the correct amount of backslashes in the workflow string before import
             
-            # testing with scratchgmodv1
-            workflow = workflow.replace('http://localhost/sp/genus_species/feature/Genus/species/mRNA/{id}',
-                                        "http://http://scratchgmodv1:8888/sp/" + self.genus_lowercase+ "_" + self.species + "/feature/" + self.genus + "/mRNA/{id}")
-            # TODO: Uncomment next lines in production
+            # # OBSOLETE
             # workflow = workflow.replace('http://localhost/sp/genus_species/feature/Genus/species/mRNA/{id}',
-            #                             "http://abims-gga.sb-roscoff.fr/sp/" + self.genus_lowercase + "_" + self.species + "/feature/" + self.genus + "/mRNA/{id}")
-            # workflow = workflow[2:-2]  # if the line under doesn't output a correct json
-            # workflow = "r'" + workflow
-            # workflow = workflow + "'"
-            # workflow = workflow[:-2]  # if the line above doesn't output a correct json
+            #                             "http://" + self.config["custom_host"] + ":8888/sp/" + self.genus_lowercase+ "_" + self.species + "/feature/" + self.genus + "/mRNA/{id}")
 
-            print(workflow[4516])
-            print(workflow)
+            # # The json dict might sometimes turn to be invalid for unknown reasons and the json module will fail to decode it (galaxy export error) 
+            # workflow = workflow[2:-2]  # if the line under doesn't output a correct json
+            # # workflow = workflow[:-2]  # if the line above doesn't output a correct json
 
-            workflow_dict = json.loads(workflow)
+            # Store the decoded json dictionary
+            workflow_dict = json.load(ga_in_file)
 
             self.instance.workflows.import_workflow_dict(workflow_dict=workflow_dict)
             self.workflow_name = workflow_name
@@ -278,15 +277,78 @@ class RunWorkflow(speciesData.SpeciesData):
             show_workflow = self.instance.workflows.show_workflow(workflow_id=workflow_id)
             logging.debug("Workflow ID: " + workflow_id)
 
-            logging.debug("Inputs:")
-            logging.debug(show_workflow["Inputs"])
             self.instance.workflows.invoke_workflow(workflow_id=workflow_id,
                                                     history_id=self.history_id,
                                                     params=workflow_parameters,
                                                     inputs=datamap,
                                                     inputs_by="")
 
-            # self.instance.workflows.delete_workflow(workflow_id=workflow_id) # TODO : Keep for prod (add a "if test" condition)
+            # self.instance.workflows.delete_workflow(workflow_id=workflow_id) # TODO : Keep for prod? (add a "if test" condition)
+
+    def import_datasets_into_history(self):
+        """
+        Find datasets in a library, get their ID and import thme into the current history if they are not already
+
+        :return:
+        """
+
+        # Instanciate the instance 
+        gio = GalaxyInstance(url=self.instance_url,
+                             email=self.config["custom_galaxy_default_admin_email"],
+                             password=self.config["custom_galaxy_default_admin_password"])
+
+        prj_lib = gio.libraries.get_previews(name="Project Data")
+        self.library_id = prj_lib[0].id
+
+        instance_source_data_folders = self.instance.libraries.get_folders(library_id=str(self.library_id))
+
+        folders_ids = {}
+        current_folder_name = ""
+        # Loop over the folders in the library and map folders names to their IDs
+        for i in instance_source_data_folders:
+            for k, v in i.items():
+                if k == "name":
+                    folders_ids[v] = 0
+                    current_folder_name = v
+                if k == "id":
+                    folders_ids[current_folder_name] = v
+
+        # Iterating over the folders to find datasets and map datasets to their IDs
+        logging.info("Datasets IDs: ")
+        for k, v in folders_ids.items():
+            if k == "/genome":
+                sub_folder_content = self.instance.folders.show_folder(folder_id=v, contents=True)
+                final_sub_folder_content = self.instance.folders.show_folder(folder_id=sub_folder_content["folder_contents"][0]["id"], contents=True)
+                for k2, v2 in final_sub_folder_content.items():
+                    for e in v2:
+                        if type(e) == dict:
+                            if e["name"].endswith(".fa"):
+                                self.datasets["genome_file"] = e["ldda_id"]
+                                logging.info("\t" + e["name"] + ": " + e["ldda_id"])
+            if k == "/annotation":
+                sub_folder_content = self.instance.folders.show_folder(folder_id=v, contents=True)
+                final_sub_folder_content = self.instance.folders.show_folder(folder_id=sub_folder_content["folder_contents"][0]["id"], contents=True)
+                for k2, v2 in final_sub_folder_content.items():
+                    for e in v2:
+                        if type(e) == dict:
+                            # TODO: manage versions? (differentiate between the correct folders using self.config)
+                            if "transcripts" in e["name"]:
+                                self.datasets["transcripts_file"] = e["ldda_id"]
+                                logging.info("\t" + e["name"] + ": " + e["ldda_id"])
+                            elif "proteins" in e["name"]:
+                                self.datasets["proteins_file"] = e["ldda_id"]
+                                logging.info("\t" + e["name"] + ": " + e["ldda_id"])
+                            elif "gff" in e["name"]:
+                                self.datasets["gff_file"] = e["ldda_id"]
+                                logging.info("\t" + e["name"] + ": " + e["ldda_id"])
+
+        logging.info("Uploading datasets into history %s" % self.history_id)
+        self.instance.histories.upload_dataset_from_library(history_id=self.history_id, lib_dataset_id=self.datasets["genome_file"])
+        self.instance.histories.upload_dataset_from_library(history_id=self.history_id, lib_dataset_id=self.datasets["gff_file"])
+        self.instance.histories.upload_dataset_from_library(history_id=self.history_id, lib_dataset_id=self.datasets["transcripts_file"])
+        self.instance.histories.upload_dataset_from_library(history_id=self.history_id, lib_dataset_id=self.datasets["proteins_file"])
+
+        return {"history_id": self.history_id, "library_id": self.library_id, "datasets": self.datasets}
 
 
     def get_organism_and_analyses_ids(self):
@@ -425,48 +487,74 @@ if __name__ == "__main__":
         run_workflow_for_current_organism.set_get_history()
         # run_workflow_for_current_organism.get_species_history_id()
 
-        # Prepare the instance+history for the current organism (add organism and analyses in Chado) --> add argument? (no risk as chado refuses to duplicate an analysis/organism)
-        # run_workflow_for_current_organism.prepare_history()
+        # Prepare the instance+history for the current organism (add organism and analyses in Chado) --> add argument? 
+        # (althought there is no risk as chado refuses to duplicate an analysis/organism)
+        run_workflow_for_current_organism.prepare_history()
 
         # Get the attributes of the instance and project data files
         run_workflow_for_current_organism.get_instance_attributes()
 
+        # Import datasets into history (needs to be done in gga_load_data??)
+        run_workflow_for_current_organism.import_datasets_into_history()
+
+
         workflow_parameters = dict()
 
         # Explicit workflow parameter names
         # TODO: Use an external mapping file instead?
 
-        # Base worflow (loading data in chado and first sync into tripal)
-        PARAM_LOAD_FILE1_INTO_HISTORY, PARAM_LOAD_FILE2_INTO_HISTORY, PARAM_LOAD_FILE3_INTO_HISTORY, PARAM_LOAD_FILE4_INTO_HISTORY = "0", "1", "2", "3"
-        PARAM_LOAD_FASTA_IN_CHADO = "4"
-        PARAM_LOAD_GFF_IN_CHADO = "5"
-        PARAM_SYNC_ORGANISM_INTO_TRIPAL = "6"
-        PARAM_SYNC_GENOME_ANALYSIS_INTO_TRIPAL = "7"
-        PARAM_SYNC_OGS_ANALYSIS_INTO_TRIPAL = "8"
-        PARAM_SYNC_FEATURES_INTO_TRIPAL = "9"
-
+        # DEMO WORKFLOW
+        PARAM_LOAD_FASTA_IN_HISTORY = "0"
+        PARAM_LOAD_FASTA_IN_CHADO = "1"
+        # PARAM_SYNC_ORGANISM_INTO_TRIPAL = "2"
+        # PARAM_SYNC_GENOME_ANALYSIS_INTO_TRIPAL = "3"
+        # PARAM_SYNC_FEATURES_INTO_TRIPAL = "4"
 
-        workflow_parameters[PARAM_LOAD_FILE1_INTO_HISTORY] = {}
-        workflow_parameters[PARAM_LOAD_FILE2_INTO_HISTORY] = {}
-        workflow_parameters[PARAM_LOAD_FILE3_INTO_HISTORY] = {}
-        workflow_parameters[PARAM_LOAD_FILE4_INTO_HISTORY] = {}
+        # Mapping parameters
+        workflow_parameters[PARAM_LOAD_FASTA_IN_HISTORY] = {}
         workflow_parameters[PARAM_LOAD_FASTA_IN_CHADO] = {"organism": run_workflow_for_current_organism.org_id,
-                                    "analysis_id": run_workflow_for_current_organism.genome_analysis_id,
-                                    "do_update": "true"}
-        workflow_parameters[PARAM_LOAD_GFF_IN_CHADO] = {"organism": run_workflow_for_current_organism.org_id,
-                                    "analysis_id": run_workflow_for_current_organism.ogs_analysis_id}
-        workflow_parameters[PARAM_SYNC_ORGANISM_INTO_TRIPAL] = {"organism_id": run_workflow_for_current_organism.org_id}
-        workflow_parameters[PARAM_SYNC_GENOME_ANALYSIS_INTO_TRIPAL] = {"analysis_id": run_workflow_for_current_organism.ogs_analysis_id}
-        workflow_parameters[PARAM_SYNC_OGS_ANALYSIS_INTO_TRIPAL] = {"analysis_id": run_workflow_for_current_organism.genome_analysis_id}
-        workflow_parameters[PARAM_SYNC_FEATURES_INTO_TRIPAL] = {"organism_id": run_workflow_for_current_organism.org_id}
-
-        # Loading files into history works a bit different than the others as it's not a GMOD tool but a standard Galaxy tool
-        # It requires this additional "datamap" (conveniently named "datamap" here), requiring the source type of the file and its corresponding ID (unique)
+                                                        "analysis_id": run_workflow_for_current_organism.genome_analysis_id,
+                                                        "do_update": "true"}
+        # workflow_parameters[PARAM_SYNC_ORGANISM_INTO_TRIPAL] = {"organism_id": run_workflow_for_current_organism.org_id}
+        # workflow_parameters[PARAM_SYNC_GENOME_ANALYSIS_INTO_TRIPAL] = {"analysis_id": run_workflow_for_current_organism.ogs_analysis_id}
+        # workflow_parameters[PARAM_SYNC_FEATURES_INTO_TRIPAL] = {"organism_id": run_workflow_for_current_organism.org_id}
+
         run_workflow_for_current_organism.datamap = dict()
-        run_workflow_for_current_organism.datamap[PARAM_LOAD_FILE1_INTO_HISTORY] = {"src": "hda", "id": run_workflow_for_current_organism.datasets["genome_file"]}
-        run_workflow_for_current_organism.datamap[PARAM_LOAD_FILE2_INTO_HISTORY] = {"src": "hda", "id": run_workflow_for_current_organism.datasets["gff_file"]}
-        run_workflow_for_current_organism.datamap[PARAM_LOAD_FILE3_INTO_HISTORY] = {"src": "hda", "id": run_workflow_for_current_organism.datasets["proteins_file"]}
-        run_workflow_for_current_organism.datamap[PARAM_LOAD_FILE4_INTO_HISTORY] = {"src": "hda", "id": run_workflow_for_current_organism.datasets["transcripts_file"]}
+        run_workflow_for_current_organism.datamap[PARAM_LOAD_FASTA_IN_HISTORY] = {"src": "hda", "id": run_workflow_for_current_organism.datasets["genome_file"]}
+
+
+        """COMMENTED FOR THE DEMO"""
+        # # Base worflow (loading data in chado and first sync into tripal)
+        # PARAM_LOAD_FILE1_INTO_HISTORY, PARAM_LOAD_FILE2_INTO_HISTORY, PARAM_LOAD_FILE3_INTO_HISTORY, PARAM_LOAD_FILE4_INTO_HISTORY = "0", "1", "2", "3"
+        # PARAM_LOAD_FASTA_IN_CHADO = "4"
+        # PARAM_LOAD_GFF_IN_CHADO = "5"
+        # PARAM_SYNC_ORGANISM_INTO_TRIPAL = "6"
+        # PARAM_SYNC_GENOME_ANALYSIS_INTO_TRIPAL = "7"
+        # PARAM_SYNC_OGS_ANALYSIS_INTO_TRIPAL = "8"
+        # PARAM_SYNC_FEATURES_INTO_TRIPAL = "9"
+
+
+        # workflow_parameters[PARAM_LOAD_FILE1_INTO_HISTORY] = {}
+        # workflow_parameters[PARAM_LOAD_FILE2_INTO_HISTORY] = {}
+        # workflow_parameters[PARAM_LOAD_FILE3_INTO_HISTORY] = {}
+        # workflow_parameters[PARAM_LOAD_FILE4_INTO_HISTORY] = {}
+        # workflow_parameters[PARAM_LOAD_FASTA_IN_CHADO] = {"organism": run_workflow_for_current_organism.org_id,
+        #                             "analysis_id": run_workflow_for_current_organism.genome_analysis_id,
+        #                             "do_update": "true"}
+        # workflow_parameters[PARAM_LOAD_GFF_IN_CHADO] = {"organism": run_workflow_for_current_organism.org_id,
+        #                             "analysis_id": run_workflow_for_current_organism.ogs_analysis_id}
+        # workflow_parameters[PARAM_SYNC_ORGANISM_INTO_TRIPAL] = {"organism_id": run_workflow_for_current_organism.org_id}
+        # workflow_parameters[PARAM_SYNC_GENOME_ANALYSIS_INTO_TRIPAL] = {"analysis_id": run_workflow_for_current_organism.ogs_analysis_id}
+        # workflow_parameters[PARAM_SYNC_OGS_ANALYSIS_INTO_TRIPAL] = {"analysis_id": run_workflow_for_current_organism.genome_analysis_id}
+        # workflow_parameters[PARAM_SYNC_FEATURES_INTO_TRIPAL] = {"organism_id": run_workflow_for_current_organism.org_id}
+
+        # # Loading files into history works a bit different than the others as it's not a GMOD tool but a standard Galaxy tool
+        # # It requires this additional "datamap" (conveniently named "datamap" here), requiring the source type of the file and its corresponding ID (unique)
+        # run_workflow_for_current_organism.datamap = dict()
+        # run_workflow_for_current_organism.datamap[PARAM_LOAD_FILE1_INTO_HISTORY] = {"src": "hda", "id": run_workflow_for_current_organism.datasets["genome_file"]}
+        # run_workflow_for_current_organism.datamap[PARAM_LOAD_FILE2_INTO_HISTORY] = {"src": "hda", "id": run_workflow_for_current_organism.datasets["gff_file"]}
+        # run_workflow_for_current_organism.datamap[PARAM_LOAD_FILE3_INTO_HISTORY] = {"src": "hda", "id": run_workflow_for_current_organism.datasets["proteins_file"]}
+        # run_workflow_for_current_organism.datamap[PARAM_LOAD_FILE4_INTO_HISTORY] = {"src": "hda", "id": run_workflow_for_current_organism.datasets["transcripts_file"]}
 
         # Run the workflow with the parameters set above
         run_workflow_for_current_organism.run_workflow(workflow_path=workflow,
diff --git a/workflows/Galaxy-Workflow-demo.ga b/workflows/Galaxy-Workflow-demo.ga
new file mode 100644
index 0000000..c59f6ee
--- /dev/null
+++ b/workflows/Galaxy-Workflow-demo.ga
@@ -0,0 +1,91 @@
+{
+    "a_galaxy_workflow": "true",
+    "annotation": "",
+    "format-version": "0.1",
+    "name": "demo",
+    "steps": {
+        "0": {
+            "annotation": "",
+            "content_id": null,
+            "errors": null,
+            "id": 0,
+            "input_connections": {},
+            "inputs": [],
+            "label": null,
+            "name": "Input dataset",
+            "outputs": [],
+            "position": {
+                "left": 222,
+                "top": 286.8500061035156
+            },
+            "tool_id": null,
+            "tool_state": "{\"optional\": false}",
+            "tool_version": null,
+            "type": "data_input",
+            "uuid": "74f22d9b-e764-45e4-b0eb-579c9b647ea0",
+            "workflow_outputs": []
+        },
+        "1": {
+            "annotation": "",
+            "content_id": "toolshed.g2.bx.psu.edu/repos/gga/chado_feature_load_fasta/feature_load_fasta/2.3.3",
+            "errors": null,
+            "id": 1,
+            "input_connections": {
+                "fasta": {
+                    "id": 0,
+                    "output_name": "output"
+                },
+                "wait_for": {
+                    "id": 0,
+                    "output_name": "output"
+                }
+            },
+            "inputs": [
+                {
+                    "description": "runtime parameter for tool Chado load fasta",
+                    "name": "analysis_id"
+                },
+                {
+                    "description": "runtime parameter for tool Chado load fasta",
+                    "name": "fasta"
+                },
+                {
+                    "description": "runtime parameter for tool Chado load fasta",
+                    "name": "organism"
+                },
+                {
+                    "description": "runtime parameter for tool Chado load fasta",
+                    "name": "wait_for"
+                }
+            ],
+            "label": null,
+            "name": "Chado load fasta",
+            "outputs": [
+                {
+                    "name": "results",
+                    "type": "json"
+                }
+            ],
+            "position": {
+                "left": 509.9000244140625,
+                "top": 271
+            },
+            "post_job_actions": {},
+            "tool_id": "toolshed.g2.bx.psu.edu/repos/gga/chado_feature_load_fasta/feature_load_fasta/2.3.3",
+            "tool_shed_repository": {
+                "changeset_revision": "a7ab30ded37d",
+                "name": "chado_feature_load_fasta",
+                "owner": "gga",
+                "tool_shed": "toolshed.g2.bx.psu.edu"
+            },
+            "tool_state": "{\"analysis_id\": {\"__class__\": \"RuntimeValue\"}, \"do_update\": \"false\", \"ext_db\": {\"db\": \"\", \"re_db_accession\": \"\"}, \"fasta\": {\"__class__\": \"RuntimeValue\"}, \"match_on_name\": \"false\", \"organism\": {\"__class__\": \"RuntimeValue\"}, \"psql_target\": {\"method\": \"remote\", \"__current_case__\": 0}, \"re_name\": \"\", \"re_uniquename\": \"\", \"relationships\": {\"rel_type\": \"none\", \"__current_case__\": 0}, \"sequence_type\": \"contig\", \"wait_for\": {\"__class__\": \"RuntimeValue\"}, \"__page__\": null, \"__rerun_remap_job_id__\": null}",
+            "tool_version": "2.3.3",
+            "type": "tool",
+            "uuid": "f3655d26-08b8-408e-bfef-6e8a4aaab355",
+            "workflow_outputs": []
+        }
+    },
+    "tags": [],
+    "uuid": "ca4cf11f-76c0-40dd-925b-b20284bcc857",
+    "version": 3
+}
\ No newline at end of file
-- 
GitLab