From b68391725751a363c45f14d423472d2b4a9576db Mon Sep 17 00:00:00 2001
From: George Marchment <georgemarchment@yahoo.fr>
Date: Thu, 7 Mar 2024 09:48:54 +0100
Subject: [PATCH] update

---
 README.md                                     |  90 +++++++++---------
 ...ch_operations.png => dependency_graph.png} | Bin
 src/graph.py                                  |  24 ++---
 src/nextflow_file.py                          |  10 +-
 4 files changed, 63 insertions(+), 61 deletions(-)
 rename img/{dependency_graph_wo_branch_operations.png => dependency_graph.png} (100%)

diff --git a/README.md b/README.md
index 2fa1868..4d6c5bb 100644
--- a/README.md
+++ b/README.md
@@ -1,16 +1,15 @@
 # BioFlow-Insight
 
 
-[![MIT licensed](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE) [![Version 0.1](https://img.shields.io/badge/version-v0.1-yellow)]()
+[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-green.svg)](https://www.gnu.org/licenses/gpl-3.0) 
+[![Version 0.1](https://img.shields.io/badge/version-v0.0.11-yellow)]()
 
 ## Description
 
-This repository contains **BioFlow-Insight**, a Python software tool. **BioFlow-Insight** automatically analyses Nextflow workflow code, extracting useful information, notably in the form of visual graphs illustrating the workflow's structure and its various steps.
+**BioFlow-Insight** is a Python-based open-source command-line tool designed to automatically analyse Nextflow workflow code, gathering useful information, particularly in the form of visual graphs that illustrate the workflow's structure and its various steps. Additionally, it is capable of detecting certain programming errors and generates a RO-Crate JSON-LD file that describes the workflow.
 
+**BioFlow-Insight** is easily installable as a CLI (see [here](#installing-via-pip)). It is also freely accessible as a free [web service](https://bioflow-insight.pasteur.cloud/). For more information and to start using BioFlow-Insight, visit [here](https://bioflow-insight.pasteur.cloud/) (https://bioflow-insight.pasteur.cloud/).
 
-**BioFlow-Insight** is easily installable as a Python package (see here). It is also accessible as a free web service. For more information and to start using BioFlow-Insight, visit [here](https://bioflow-insight.pasteur.cloud/) (https://bioflow-insight.pasteur.cloud/).
-
-<!--The outputs of **BioFlow-Insight** are saved in the results folder.-->
 
 ## Table of Contents
 
@@ -18,8 +17,8 @@ This repository contains **BioFlow-Insight**, a Python software tool. **BioFlow-
   - [Description](#description)
   - [Table of Contents](#table-of-contents)
   - [Installation](#installation)
+    - [Installing via pip](#installing-via-pip)
     - [Using from source](#using-from-source)
-    - [Using the Python package](#using-the-python-package)
   - [Usage](#usage)
     - [Input](#input)
     - [Output](#output)
@@ -28,16 +27,9 @@ This repository contains **BioFlow-Insight**, a Python software tool. **BioFlow-
 
 ## Installation
 
-### Using from source
-
-BioFlow-Insight's dependencies are given in the `requirements.txt` file.
-
-> Note : To install graphviz, in linux you might need to execute this command `sudo apt install graphviz`
-
+### Installing via pip
 
-### Using the Python package
-
-**BioFlow-Insight** is easily installable as a [Python package]()<!--TODO : Add LINK-->.
+**BioFlow-Insight** is easily installable as a CLI.
 
 To install it using *pip*, use the following command :
 
@@ -45,21 +37,32 @@ To install it using *pip*, use the following command :
 pip install bioflow-insight
 ```
 
-TODO
+
+### Using from source
+
+To access its source code, simply clone its GitLab repository. **BioFlow-Insight** is developed using Python 3
+
+**BioFlow-Insight**'s dependencies are given in the `requirements.txt` file.
+
+> Note : To install graphviz, in linux you might need to execute this command `sudo apt install graphviz`
+
 
 ## Usage
 
-**BioFlow-Insight** automatically analyses the code of Nextflow workflows and extracts useful information, particularly in the form of visual graphs depicting the workflow's structure and representing its different steps. 
+**BioFlow-Insight** is a Python-based open-source command-line tool designed to automatically analyse Nextflow workflow code, gathering useful information, particularly in the form of visual graphs that illustrate the workflow's structure and its various steps. Additionally, it is capable of detecting certain programming errors and generates a RO-Crate JSON-LD file that describes the workflow.
+
 
 For an explanation of the different elements composing a Nextflow workflow, see [its documentation](https://www.nextflow.io/docs/latest/index.html).
 
 The 3 different graphs generated by **BioFlow-Insight** are : 
 
-1. The *specification graph* which represents all elements of the workflow, including processes and operations, and their interactions through channels. Within the specification graph, we define two types of operations: those without inputs and those with inputs (called branch operations).
-2. The second graph represents operations without any inputs, along with processes and their dependencies. This graph, called the *dependency graph without branch operations*, is obtained by removing the branch operations and linking the remaining elements if a path exists between them in the original specification graph.
-3. The final graph, called the *process dependency graph*, represents only processes and their dependencies. Similar to the latter, this graph is constructed by removing all operations, leaving only processes, and linking them based on their dependencies in the original specification graph.
+* *Specification graph:* **BioFlow-Insight** reconstructs the workflow’s specification graph from its source code without having to execute it. The specification graph is defined as a directed graph where nodes are processes and operations, and edges are channels that are directed from one vertex to another (steps of the workflow are ordered). This graph **represents all the possible interactions between processes and operations through channels** that are defined in the workflow code. Within the specification graph, we define two types of operations: operations are categorised in two groups: the *following operations* defined as operations that have at least one input, and the *starting operations* defined as operations without any inputs.
+  
+* *Dependency graph:* From the specification graph, **BioFlow-Insight** also generates the dependency graph which **represents starting operations, along with processes (as nodes) and their dependencies (edges)**. This graph is obtained by removing the following operations and linking the remaining elements if a path exists between them in the original specification graph. In this representation, **the edges no longer represent interaction between its elements, but their dependencies**.  
+
+* *Process dependency graph:* Finally **BioFlow-Insight** also generates the process dependency graph which represents only **processes (nodes) and their dependencies (edges)**. Similar to the dependency graph, this graph is constructed by removing all operations, leaving only processes, and linking them based on their dependencies in the original specification graph. Again in this representation, **the edges no longer represent interaction between its elements, but their dependencies**.
 
-> For a more in-depth explanation of BioFlow-Insight functionnalities, visit its webpage [here](https://bioflow-insight.pasteur.cloud/) (https://bioflow-insight.pasteur.cloud/).
+> For a more in-depth explanation of BioFlow-Insight functionnalities, visit its webpage [here](https://bioflow-insight.pasteur.cloud/specification/) (https://bioflow-insight.pasteur.cloud/specification/).
 
 > To examplify **BioFlow-Insight** utilisation, let's use the rnaseq-nf workflow proposed by Nextflow (its source code can be found [here](https://github.com/nextflow-io/rnaseq-nf/tree/8253a586cc5a9679d37544ac54f72167cced324b)). Examples of the output are given below. 
 
@@ -102,20 +105,20 @@ The structure of this folder is organised as such :
 │   ├── operations_in_call.nf
 │   └── operations.nf
 ├── graphs
-│   ├── dependency_graph_wo_branch_operations.dot
-│   ├── dependency_graph_wo_branch_operations.json
-│   ├── dependency_graph_wo_branch_operations.mmd
-│   ├── dependency_graph_wo_branch_operations.png
-│   ├── dependency_graph_wo_branch_operations_wo_lables.dot
-│   ├── dependency_graph_wo_branch_operations_wo_lables.mmd
-│   ├── dependency_graph_wo_branch_operations_wo_lables.png
-│   ├── dependency_graph_wo_branch_operations_wo_orphan_operations.dot
-│   ├── dependency_graph_wo_branch_operations_wo_orphan_operations.mmd
-│   ├── dependency_graph_wo_branch_operations_wo_orphan_operations.png
-│   ├── dependency_graph_wo_branch_operations_wo_orphan_operations_wo_lables.dot
-│   ├── dependency_graph_wo_branch_operations_wo_orphan_operations_wo_lables.mmd
-│   ├── dependency_graph_wo_branch_operations_wo_orphan_operations_wo_lables.png
-│   ├── metadata_dependency_graph_wo_branch_operations.json
+│   ├── dependency_graph.dot
+│   ├── dependency_graph.json
+│   ├── dependency_graph.mmd
+│   ├── dependency_graph.png
+│   ├── dependency_graph_wo_lables.dot
+│   ├── dependency_graph_wo_lables.mmd
+│   ├── dependency_graph_wo_lables.png
+│   ├── dependency_graph_wo_orphan_operations.dot
+│   ├── dependency_graph_wo_orphan_operations.mmd
+│   ├── dependency_graph_wo_orphan_operations.png
+│   ├── dependency_graph_wo_orphan_operations_wo_lables.dot
+│   ├── dependency_graph_wo_orphan_operations_wo_lables.mmd
+│   ├── dependency_graph_wo_orphan_operations_wo_lables.png
+│   ├── metadata_dependency_graph.json
 │   ├── metadata_process_dependency_graph.json
 │   ├── metadata_specification_graph.json
 │   ├── process_dependency_graph.dot
@@ -149,16 +152,15 @@ The structure of this folder is organised as such :
 
 Here are some of the graphs which are generated by **BioFlow-Insight**, they are rendered using Graphviz (png).
 
-| <img align="center" src="img/specification_graph.png" >  | <img align="center" src="img/dependency_graph_wo_branch_operations.png">   | <img align="center" src="img/process_dependency_graph.png" >   |
+| <img align="center" src="https://gitlab.liris.cnrs.fr/sharefair/bioflow-insight/-/raw/main/img/specification_graph.png" >  | <img align="center" src="https://gitlab.liris.cnrs.fr/sharefair/bioflow-insight/-/raw/main/img/dependency_graph.png">   | <img align="center" src="https://gitlab.liris.cnrs.fr/sharefair/bioflow-insight/-/raw/main/img/process_dependency_graph.png" >   |
 |:-:|:-:|---|
-| Specification Graph  |  Dependency Graph without branch operations | Process Dependency Graph  |
+| Specification Graph  |  Dependency Graph | Process Dependency Graph  |
 
 
 ## License
 
 This project is licensed under the [GNU Affero General Public License](https://www.gnu.org/licenses/agpl-3.0.en.html).
 
-TODO -> add license to git repo
 
 ## Funding
 
@@ -166,12 +168,12 @@ This work received support from the National Research Agency under the France 20
 
 ___
 
-<img align="left" src="img/logo.png" width="16%">
-<img align="left" src="img/paris_saclay.png" width="16%">
-<img align="left" src="img/lisn.png" width="16%">
-<img align="left" src="img/pasteur.png" width="16%">
-<img align="left" src="img/sharefair.png" width="16%">
-<img align="left" src="img/france2030.png" width="16%">
+<img align="left" src="https://gitlab.liris.cnrs.fr/sharefair/bioflow-insight/-/raw/main/img/logo.png" width="16%">
+<img align="left" src="https://gitlab.liris.cnrs.fr/sharefair/bioflow-insight/-/raw/main/img/paris_saclay.png" width="16%">
+<img align="left" src="https://gitlab.liris.cnrs.fr/sharefair/bioflow-insight/-/raw/main/img/lisn.png" width="16%">
+<img align="left" src="https://gitlab.liris.cnrs.fr/sharefair/bioflow-insight/-/raw/main/img/pasteur.png" width="16%">
+<img align="left" src="https://gitlab.liris.cnrs.fr/sharefair/bioflow-insight/-/raw/main/img/sharefair.png" width="16%">
+<img align="left" src="https://gitlab.liris.cnrs.fr/sharefair/bioflow-insight/-/raw/main/img/france2030.png" width="16%">
 
 <br/><br/>
 <br/><br/>
diff --git a/img/dependency_graph_wo_branch_operations.png b/img/dependency_graph.png
similarity index 100%
rename from img/dependency_graph_wo_branch_operations.png
rename to img/dependency_graph.png
diff --git a/src/graph.py b/src/graph.py
index 813e2ba..8001086 100644
--- a/src/graph.py
+++ b/src/graph.py
@@ -65,7 +65,7 @@ class Graph():
             remove_node(self.full_dico, node_id)
 
 
-        self.get_dependency_graph_wo_branch_operations()
+        self.get_dependency_graph()
         self.get_process_dependency_graph()
 
         
@@ -200,12 +200,12 @@ class Graph():
         generate_graph(self.get_output_dir()/'graphs'/filename, self.dico_wo_operation, render_graphs = render_graphs, label_edge=False, label_node=False)
     
 
-    def get_dependency_graph_wo_branch_operations(self):
+    def get_dependency_graph(self):
         self.intia_link_dico()
         nodes_in_graph = []
         branch_operation_ids = []
         #Function that replicates the workflow's structure wo the operations in the nodes
-        def replicate_dico_wo_branch_operations(dico_struct):
+        def replicate_dico(dico_struct):
             dico = {}
             dico['nodes'] = []
             dico['edges'] = []
@@ -215,10 +215,10 @@ class Graph():
                     dico['nodes'].append(node)
                     nodes_in_graph.append(node['id'])
             for sub in dico_struct['subworkflows']:
-                dico['subworkflows'][sub] = replicate_dico_wo_branch_operations(dico_struct['subworkflows'][sub])
+                dico['subworkflows'][sub] = replicate_dico(dico_struct['subworkflows'][sub])
             return dico
         
-        dico = replicate_dico_wo_branch_operations(self.full_dico)
+        dico = replicate_dico(self.full_dico)
 
         #This is a dictionnary which links every node to it's connected process
         node_2_none_branch = copy.deepcopy(self.link_dico)
@@ -261,20 +261,20 @@ class Graph():
         add_edges(dico)
         self.dico_wo_branch_operation = dico
 
-        with open(f"{self.get_output_dir()}/graphs/dependency_graph_wo_branch_operations.json", 'w') as output_file :
+        with open(f"{self.get_output_dir()}/graphs/dependency_graph.json", 'w') as output_file :
             json.dump(self.dico_wo_branch_operation, output_file, indent=4)
     
 
-    def render_dependency_graph_wo_branch_operations(self, filename = "dependency_graph_wo_branch_operations", render_graphs = True):
+    def render_dependency_graph(self, filename = "dependency_graph", render_graphs = True):
         generate_graph(self.get_output_dir()/'graphs'/filename, self.dico_wo_branch_operation, render_graphs = render_graphs)
     
-    def get_dependency_graph_wo_branch_operations_wo_lables(self, filename = "dependency_graph_wo_branch_operations_wo_lables", render_graphs = True):
+    def get_dependency_graph_wo_lables(self, filename = "dependency_graph_wo_lables", render_graphs = True):
         generate_graph(self.get_output_dir()/'graphs'/filename, self.dico_wo_branch_operation, label_edge=False, label_node=False, render_graphs = render_graphs)
 
-    def get_dependency_graph_wo_branch_operations_wo_orphan_operations(self, filename = "dependency_graph_wo_branch_operations_wo_orphan_operations", render_graphs = True):
+    def get_dependency_graph_wo_orphan_operations(self, filename = "dependency_graph_wo_orphan_operations", render_graphs = True):
         generate_graph(self.get_output_dir()/'graphs'/filename, graph_dico_wo_orphan_operations(self.dico_wo_branch_operation), render_graphs = render_graphs)
     
-    def get_dependency_graph_wo_branch_operations_wo_orphan_operations_wo_lables(self, filename = "dependency_graph_wo_branch_operations_wo_orphan_operations_wo_lables", render_graphs = True):
+    def get_dependency_graph_wo_orphan_operations_wo_lables(self, filename = "dependency_graph_wo_orphan_operations_wo_lables", render_graphs = True):
         generate_graph(self.get_output_dir()/'graphs'/filename, graph_dico_wo_orphan_operations(self.dico_wo_branch_operation), label_edge=False, label_node=False, render_graphs = render_graphs)
 
 
@@ -431,10 +431,10 @@ class Graph():
         with open(self.get_output_dir()/ "graphs/metadata_specification_graph.json", 'w') as output_file :
             json.dump(dico, output_file, indent=4)
 
-    def get_metadata_dependency_graph_wo_branch_operations(self):
+    def get_metadata_dependency_graph(self):
 
         dico = self.get_metadata(self.dico_wo_branch_operation)
-        with open(self.get_output_dir()/ "graphs/metadata_dependency_graph_wo_branch_operations.json", 'w') as output_file :
+        with open(self.get_output_dir()/ "graphs/metadata_dependency_graph.json", 'w') as output_file :
             json.dump(dico, output_file, indent=4)
 
     def get_metadata_process_dependency_graph(self):
diff --git a/src/nextflow_file.py b/src/nextflow_file.py
index 234614b..08f37ea 100644
--- a/src/nextflow_file.py
+++ b/src/nextflow_file.py
@@ -643,15 +643,15 @@ class Nextflow_File(Nextflow_Building_Blocks):
         self.graph.render_graph_wo_operations(render_graphs = render_graphs)
         self.graph.get_specification_graph_wo_orphan_operations(render_graphs = render_graphs)
         self.graph.get_specification_graph_wo_orphan_operations_wo_lables(render_graphs = render_graphs)
-        self.graph.render_dependency_graph_wo_branch_operations(render_graphs = render_graphs)
-        self.graph.get_dependency_graph_wo_branch_operations_wo_lables(render_graphs = render_graphs)
-        self.graph.get_dependency_graph_wo_branch_operations_wo_orphan_operations(render_graphs = render_graphs)
-        self.graph.get_dependency_graph_wo_branch_operations_wo_orphan_operations_wo_lables(render_graphs = render_graphs)
+        self.graph.render_dependency_graph(render_graphs = render_graphs)
+        self.graph.get_dependency_graph_wo_lables(render_graphs = render_graphs)
+        self.graph.get_dependency_graph_wo_orphan_operations(render_graphs = render_graphs)
+        self.graph.get_dependency_graph_wo_orphan_operations_wo_lables(render_graphs = render_graphs)
 
         
         #Generate the different metadata associated with the graphs
         self.graph.get_metadata_specification_graph()
-        self.graph.get_metadata_dependency_graph_wo_branch_operations()
+        self.graph.get_metadata_dependency_graph()
         self.graph.get_metadata_process_dependency_graph()
 
     #def get_metadata_graph_wo_operations(self):
-- 
GitLab