From c483399a4ee7ea5d6caba204b45cbb274eee16f5 Mon Sep 17 00:00:00 2001
From: lcottret <ludovic.cottret@inrae.fr>
Date: Thu, 2 Jan 2025 15:40:11 +0100
Subject: [PATCH 01/74] remove *.versionsBackup

---
 .gitignore                                  |   2 +
 coverage/pom.xml.versionsBackup             | 121 ------------
 met4j-chemUtils/pom.xml.versionsBackup      |  72 -------
 met4j-core/pom.xml.versionsBackup           |  66 -------
 met4j-graph/pom.xml.versionsBackup          |  85 --------
 met4j-io/pom.xml.versionsBackup             |  90 ---------
 met4j-mapping/pom.xml.versionsBackup        |  66 -------
 met4j-mathUtils/pom.xml.versionsBackup      |  65 -------
 met4j-reconstruction/pom.xml.versionsBackup | 101 ----------
 met4j-toolbox/pom.xml.versionsBackup        | 169 ----------------
 pom.xml.versionsBackup                      | 203 --------------------
 11 files changed, 2 insertions(+), 1038 deletions(-)
 delete mode 100644 coverage/pom.xml.versionsBackup
 delete mode 100644 met4j-chemUtils/pom.xml.versionsBackup
 delete mode 100644 met4j-core/pom.xml.versionsBackup
 delete mode 100644 met4j-graph/pom.xml.versionsBackup
 delete mode 100644 met4j-io/pom.xml.versionsBackup
 delete mode 100644 met4j-mapping/pom.xml.versionsBackup
 delete mode 100644 met4j-mathUtils/pom.xml.versionsBackup
 delete mode 100644 met4j-reconstruction/pom.xml.versionsBackup
 delete mode 100644 met4j-toolbox/pom.xml.versionsBackup
 delete mode 100644 pom.xml.versionsBackup

diff --git a/.gitignore b/.gitignore
index c121512a9..4ec297b32 100644
--- a/.gitignore
+++ b/.gitignore
@@ -20,3 +20,5 @@ met4j-core/src/main/java/fr/inra/toulouse/metexplore/met4j_core/Test\.java
 
 dependency-reduced-pom.xml
 *.sif
+
+*.versionsBackup
diff --git a/coverage/pom.xml.versionsBackup b/coverage/pom.xml.versionsBackup
deleted file mode 100644
index 61a11c13d..000000000
--- a/coverage/pom.xml.versionsBackup
+++ /dev/null
@@ -1,121 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  ~ Copyright INRAE (2021)
-  ~
-  ~ contact-metexplore@inrae.fr
-  ~
-  ~ This software is a computer program whose purpose is to [describe
-  ~ functionalities and technical features of your software].
-  ~
-  ~ This software is governed by the CeCILL license under French law and
-  ~ abiding by the rules of distribution of free software.  You can  use,
-  ~ modify and/ or redistribute the software under the terms of the CeCILL
-  ~ license as circulated by CEA, CNRS and INRIA at the following URL
-  ~ "https://cecill.info/licences/Licence_CeCILL_V2.1-en.html".
-  ~
-  ~ As a counterpart to the access to the source code and  rights to copy,
-  ~ modify and redistribute granted by the license, users are provided only
-  ~ with a limited warranty  and the software's author,  the holder of the
-  ~ economic rights,  and the successive licensors  have only  limited
-  ~ liability.
-  ~
-  ~ In this respect, the user's attention is drawn to the risks associated
-  ~ with loading,  using,  modifying and/or developing or reproducing the
-  ~ software by the user in light of its specific status of free software,
-  ~ that may mean  that it is complicated to manipulate,  and  that  also
-  ~ therefore means  that it is reserved for developers  and  experienced
-  ~ professionals having in-depth computer knowledge. Users are therefore
-  ~ encouraged to load and test the software's suitability as regards their
-  ~ requirements in conditions enabling the security of their systems and/or
-  ~ data to be ensured and,  more generally, to use and operate it in the
-  ~ same conditions as regards security.
-  ~
-  ~ The fact that you are presently reading this means that you have had
-  ~ knowledge of the CeCILL license and that you accept its terms.
-  ~
-  -->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0"
-         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
-    http://maven.apache.org/maven-v4_0_0.xsd">
-    <modelVersion>4.0.0</modelVersion>
-
-    <parent>
-        <groupId>fr.inrae.toulouse.metexplore</groupId>
-        <artifactId>met4j</artifactId>
-        <version>1.5.4-SNAPSHOT</version>
-        <relativePath>../pom.xml</relativePath>
-    </parent>
-
-    <artifactId>coverage</artifactId>
-    <name>coverage</name>
-    <description>Compute aggregated test code coverage</description>
-
-    <properties>
-        <maven.deploy.skip>true</maven.deploy.skip>
-        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-        <maven.compiler.source>17</maven.compiler.source>
-        <maven.compiler.target>17</maven.compiler.target>
-    </properties>
-
-    <dependencies>
-        <dependency>
-            <groupId>${project.groupId}</groupId>
-            <artifactId>met4j-core</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-
-        <dependency>
-            <groupId>${project.groupId}</groupId>
-            <artifactId>met4j-io</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-
-        <dependency>
-            <groupId>${project.groupId}</groupId>
-            <artifactId>met4j-graph</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-
-        <dependency>
-            <groupId>${project.groupId}</groupId>
-            <artifactId>met4j-mapping</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-
-        <dependency>
-            <groupId>${project.groupId}</groupId>
-            <artifactId>met4j-reconstruction</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-    </dependencies>
-
-    <build>
-        <plugins>
-            <plugin>
-                <groupId>org.jacoco</groupId>
-                <artifactId>jacoco-maven-plugin</artifactId>
-                <version>0.8.11</version>
-                <executions>
-                    <execution>
-                        <id>report-aggregate</id>
-                        <phase>test</phase>
-                        <goals>
-                            <goal>report-aggregate</goal>
-                        </goals>
-                    </execution>
-                </executions>
-            </plugin>
-            <plugin>
-                <groupId>org.sonatype.plugins</groupId>
-                <artifactId>nexus-staging-maven-plugin</artifactId>
-                <extensions>true</extensions>
-                <configuration>
-                    <skipNexusStagingDeployMojo>true</skipNexusStagingDeployMojo>
-                </configuration>
-            </plugin>
-        </plugins>
-    </build>
-
-</project>
\ No newline at end of file
diff --git a/met4j-chemUtils/pom.xml.versionsBackup b/met4j-chemUtils/pom.xml.versionsBackup
deleted file mode 100644
index 83fc4c0f9..000000000
--- a/met4j-chemUtils/pom.xml.versionsBackup
+++ /dev/null
@@ -1,72 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-    <modelVersion>4.0.0</modelVersion>
-
-  <parent>
-    <groupId>fr.inrae.toulouse.metexplore</groupId>
-    <artifactId>met4j</artifactId>
-    <version>1.5.4-SNAPSHOT</version>
-  </parent>
-
-    <properties>
-        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-        <maven.compiler.source>17</maven.compiler.source>
-        <maven.compiler.target>17</maven.compiler.target>
-    </properties>
-
-    <artifactId>met4j-chemUtils</artifactId>
-    <packaging>jar</packaging>
-
-    <name>met4j-chemUtils</name>
-    <url>http://maven.apache.org</url>
-
-    <dependencies>
-        <dependency>
-            <groupId>org.openscience.cdk</groupId>
-            <artifactId>cdk-bundle</artifactId>
-            <version>2.9</version>
-        </dependency>
-        <dependency>
-            <groupId>fr.inrae.toulouse.metexplore</groupId>
-            <artifactId>met4j-core</artifactId>
-            <version>1.5.4-SNAPSHOT</version>
-        </dependency>
-        <!-- https://mvnrepository.com/artifact/org.mockito/mockito-all -->
-        <dependency>
-            <groupId>org.mockito</groupId>
-            <artifactId>mockito-core</artifactId>
-            <version>5.7.0</version>
-            <scope>test</scope>
-        </dependency>
-    </dependencies>
-
-
-    <build>
-        <plugins>
-            <plugin>
-                <groupId>org.jacoco</groupId>
-                <artifactId>jacoco-maven-plugin</artifactId>
-                <version>0.8.11</version>
-                <executions>
-                    <!-- to avoid bugs in some situations -->
-                    <execution>
-                        <id>default-prepare-agent</id>
-                        <goals>
-                            <goal>prepare-agent</goal>
-                        </goals>
-                    </execution>
-
-                    <!-- create report during maven verify phase -->
-                    <execution>
-                        <id>report</id>
-                        <phase>verify</phase>
-                        <goals>
-                            <goal>report</goal>
-                        </goals>
-                    </execution>
-                </executions>
-            </plugin>
-        </plugins>
-    </build>
-
-</project>
diff --git a/met4j-core/pom.xml.versionsBackup b/met4j-core/pom.xml.versionsBackup
deleted file mode 100644
index c9c4d72b3..000000000
--- a/met4j-core/pom.xml.versionsBackup
+++ /dev/null
@@ -1,66 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-    <modelVersion>4.0.0</modelVersion>
-
-  <parent>
-    <groupId>fr.inrae.toulouse.metexplore</groupId>
-    <artifactId>met4j</artifactId>
-    <version>1.5.4-SNAPSHOT</version>
-  </parent>
-
-    <scm>
-        <developerConnection>scm:git:ssh://git@forgemia.inra.fr/metexplore/met4j.git</developerConnection>
-        <tag>met4j-0.1.2</tag>
-        <url>https://forgemia.inra.fr/metexplore/met4j/-/tree/master</url>
-    </scm>
-
-    <artifactId>met4j-core</artifactId>
-    <packaging>jar</packaging>
-
-    <name>met4j-core</name>
-    <url>http://maven.apache.org</url>
-
-    <properties>
-        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-        <maven.compiler.source>17</maven.compiler.source>
-        <maven.compiler.target>17</maven.compiler.target>
-    </properties>
-
-    <dependencies>
-
-        <dependency>
-            <groupId>org.apache.commons</groupId>
-            <artifactId>commons-lang3</artifactId>
-            <version>3.13.0</version>
-        </dependency>
-    </dependencies>
-
-    <build>
-        <plugins>
-            <plugin>
-                <groupId>org.jacoco</groupId>
-                <artifactId>jacoco-maven-plugin</artifactId>
-                <version>0.8.11</version>
-                <executions>
-                    <!-- to avoid bugs in some situations -->
-                    <execution>
-                        <id>default-prepare-agent</id>
-                        <goals>
-                            <goal>prepare-agent</goal>
-                        </goals>
-                    </execution>
-
-                    <!-- create report during maven verify phase -->
-                    <execution>
-                        <id>report</id>
-                        <phase>verify</phase>
-                        <goals>
-                            <goal>report</goal>
-                        </goals>
-                    </execution>
-                </executions>
-            </plugin>
-        </plugins>
-    </build>
-
-</project>
diff --git a/met4j-graph/pom.xml.versionsBackup b/met4j-graph/pom.xml.versionsBackup
deleted file mode 100644
index 9b349e4cc..000000000
--- a/met4j-graph/pom.xml.versionsBackup
+++ /dev/null
@@ -1,85 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-    <modelVersion>4.0.0</modelVersion>
-
-    <parent>
-        <groupId>fr.inrae.toulouse.metexplore</groupId>
-        <artifactId>met4j</artifactId>
-        <version>1.5.4-SNAPSHOT</version>
-    </parent>
-
-    <artifactId>met4j-graph</artifactId>
-    <packaging>jar</packaging>
-
-    <name>met4j-graph</name>
-    <url>http://maven.apache.org</url>
-
-    <properties>
-        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-        <maven.compiler.source>17</maven.compiler.source>
-        <maven.compiler.target>17</maven.compiler.target>
-    </properties>
-
-    <dependencies>
-        <dependency>
-            <groupId>org.jgrapht</groupId>
-            <artifactId>jgrapht-core</artifactId>
-            <version>1.5.2</version>
-            <!--memo: once 1.5.2 is available, remove quick-fix in graph.connect.ShortestPath$getShortestPathsUnionList-->
-        </dependency>
-        <dependency>
-            <groupId>org.jgrapht</groupId>
-            <artifactId>jgrapht-io</artifactId>
-            <version>1.5.2</version>
-        </dependency>
-        <dependency>
-            <groupId>fr.inrae.toulouse.metexplore</groupId>
-            <artifactId>met4j-core</artifactId>
-            <version>1.5.4-SNAPSHOT</version>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.commons</groupId>
-            <artifactId>commons-math3</artifactId>
-            <version>3.6.1</version>
-        </dependency>
-        <dependency>
-            <groupId>fr.inrae.toulouse.metexplore</groupId>
-            <artifactId>met4j-mathUtils</artifactId>
-            <version>1.5.4-SNAPSHOT</version>
-        </dependency>
-        <dependency>
-            <groupId>fr.inrae.toulouse.metexplore</groupId>
-            <artifactId>met4j-chemUtils</artifactId>
-            <version>1.5.4-SNAPSHOT</version>
-        </dependency>
-    </dependencies>
-
-    <build>
-        <plugins>
-            <plugin>
-                <groupId>org.jacoco</groupId>
-                <artifactId>jacoco-maven-plugin</artifactId>
-                <version>0.8.11</version>
-                <executions>
-                    <!-- to avoid bugs in some situations -->
-                    <execution>
-                        <id>default-prepare-agent</id>
-                        <goals>
-                            <goal>prepare-agent</goal>
-                        </goals>
-                    </execution>
-
-                    <!-- create report during maven verify phase -->
-                    <execution>
-                        <id>report</id>
-                        <phase>verify</phase>
-                        <goals>
-                            <goal>report</goal>
-                        </goals>
-                    </execution>
-                </executions>
-            </plugin>
-        </plugins>
-    </build>
-
-</project>
diff --git a/met4j-io/pom.xml.versionsBackup b/met4j-io/pom.xml.versionsBackup
deleted file mode 100644
index fdb52ef62..000000000
--- a/met4j-io/pom.xml.versionsBackup
+++ /dev/null
@@ -1,90 +0,0 @@
-<?xml version="1.0"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-    <modelVersion>4.0.0</modelVersion>
-
-    <parent>
-        <groupId>fr.inrae.toulouse.metexplore</groupId>
-        <artifactId>met4j</artifactId>
-        <version>1.5.4-SNAPSHOT</version>
-    </parent>
-
-    <artifactId>met4j-io</artifactId>
-    <packaging>jar</packaging>
-
-    <name>met4j-io</name>
-    <url>http://maven.apache.org</url>
-
-    <properties>
-        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-        <maven.compiler.source>17</maven.compiler.source>
-        <maven.compiler.target>17</maven.compiler.target>
-    </properties>
-
-    <dependencies>
-        <dependency>
-            <groupId>fr.inrae.toulouse.metexplore</groupId>
-            <artifactId>met4j-core</artifactId>
-            <version>1.5.4-SNAPSHOT</version>
-        </dependency>
-        <dependency>
-            <groupId>org.sbml.jsbml</groupId>
-            <artifactId>jsbml</artifactId>
-            <version>1.6.1</version>
-        </dependency>
-        <dependency>
-            <groupId>xerces</groupId>
-            <artifactId>xercesImpl</artifactId>
-            <version>2.12.2</version>
-        </dependency>
-        <!-- https://mvnrepository.com/artifact/xom/xom -->
-        <dependency>
-            <groupId>xom</groupId>
-            <artifactId>xom</artifactId>
-            <version>1.3.9</version>
-        </dependency>
-        <dependency>
-            <groupId>com.sun.jersey</groupId>
-            <artifactId>jersey-client</artifactId>
-            <version>1.19.4</version>
-        </dependency>
-        <dependency>
-            <groupId>com.google.guava</groupId>
-            <artifactId>guava</artifactId>
-            <version>32.1.3-jre</version>
-        </dependency>
-        <dependency>
-            <groupId>org.mockito</groupId>
-            <artifactId>mockito-core</artifactId>
-            <version>5.7.0</version>
-        </dependency>
-    </dependencies>
-    <build>
-        <plugins>
-            <plugin>
-                <groupId>org.jacoco</groupId>
-                <artifactId>jacoco-maven-plugin</artifactId>
-                <version>0.8.11</version>
-                <executions>
-                    <!-- to avoid bugs in some situations -->
-                    <execution>
-                        <id>default-prepare-agent</id>
-                        <goals>
-                            <goal>prepare-agent</goal>
-                        </goals>
-                    </execution>
-
-                    <!-- create report during maven verify phase -->
-                    <execution>
-                        <id>report</id>
-                        <phase>verify</phase>
-                        <goals>
-                            <goal>report</goal>
-                        </goals>
-                    </execution>
-                </executions>
-            </plugin>
-        </plugins>
-    </build>
-
-</project>
diff --git a/met4j-mapping/pom.xml.versionsBackup b/met4j-mapping/pom.xml.versionsBackup
deleted file mode 100644
index cdee7d812..000000000
--- a/met4j-mapping/pom.xml.versionsBackup
+++ /dev/null
@@ -1,66 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-    <parent>
-        <artifactId>met4j</artifactId>
-        <groupId>fr.inrae.toulouse.metexplore</groupId>
-        <version>1.5.4-SNAPSHOT</version>
-    </parent>
-    <modelVersion>4.0.0</modelVersion>
-
-    <properties>
-        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-        <maven.compiler.source>17</maven.compiler.source>
-        <maven.compiler.target>17</maven.compiler.target>
-    </properties>
-
-    <artifactId>met4j-mapping</artifactId>
-    <dependencies>
-        <dependency>
-            <groupId>fr.inrae.toulouse.metexplore</groupId>
-            <artifactId>met4j-core</artifactId>
-            <version>1.5.4-SNAPSHOT</version>
-        </dependency>
-        <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <version>4.13.2</version>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.commons</groupId>
-            <artifactId>commons-text</artifactId>
-            <version>1.11.0</version>
-            <scope>compile</scope>
-        </dependency>
-    </dependencies>
-
-    <build>
-        <plugins>
-            <plugin>
-                <groupId>org.jacoco</groupId>
-                <artifactId>jacoco-maven-plugin</artifactId>
-                <version>0.8.11</version>
-                <executions>
-                    <!-- to avoid bugs in some situations -->
-                    <execution>
-                        <id>default-prepare-agent</id>
-                        <goals>
-                            <goal>prepare-agent</goal>
-                        </goals>
-                    </execution>
-
-                    <!-- create report during maven verify phase -->
-                    <execution>
-                        <id>report</id>
-                        <phase>verify</phase>
-                        <goals>
-                            <goal>report</goal>
-                        </goals>
-                    </execution>
-                </executions>
-            </plugin>
-        </plugins>
-    </build>
-
-
-</project>
\ No newline at end of file
diff --git a/met4j-mathUtils/pom.xml.versionsBackup b/met4j-mathUtils/pom.xml.versionsBackup
deleted file mode 100644
index ee5da391d..000000000
--- a/met4j-mathUtils/pom.xml.versionsBackup
+++ /dev/null
@@ -1,65 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-    <modelVersion>4.0.0</modelVersion>
-
-    <parent>
-        <groupId>fr.inrae.toulouse.metexplore</groupId>
-        <artifactId>met4j</artifactId>
-        <version>1.5.4-SNAPSHOT</version>
-    </parent>
-
-
-    <artifactId>met4j-mathUtils</artifactId>
-    <packaging>jar</packaging>
-
-    <name>met4j-mathUtils</name>
-    <url>http://maven.apache.org</url>
-
-    <properties>
-        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-        <maven.compiler.source>17</maven.compiler.source>
-        <maven.compiler.target>17</maven.compiler.target>
-    </properties>
-
-    <dependencies>
-        <dependency>
-            <groupId>org.ejml</groupId>
-            <artifactId>all</artifactId>
-            <version>0.30</version>
-        </dependency>
-        <dependency>
-            <groupId>com.googlecode.matrix-toolkits-java</groupId>
-            <artifactId>mtj</artifactId>
-            <version>1.0.4</version>
-        </dependency>
-    </dependencies>
-
-    <build>
-        <plugins>
-            <plugin>
-                <groupId>org.jacoco</groupId>
-                <artifactId>jacoco-maven-plugin</artifactId>
-                <version>0.8.11</version>
-                <executions>
-                    <!-- to avoid bugs in some situations -->
-                    <execution>
-                        <id>default-prepare-agent</id>
-                        <goals>
-                            <goal>prepare-agent</goal>
-                        </goals>
-                    </execution>
-
-                    <!-- create report during maven verify phase -->
-                    <execution>
-                        <id>report</id>
-                        <phase>verify</phase>
-                        <goals>
-                            <goal>report</goal>
-                        </goals>
-                    </execution>
-                </executions>
-            </plugin>
-        </plugins>
-    </build>
-
-</project>
diff --git a/met4j-reconstruction/pom.xml.versionsBackup b/met4j-reconstruction/pom.xml.versionsBackup
deleted file mode 100644
index dffc61489..000000000
--- a/met4j-reconstruction/pom.xml.versionsBackup
+++ /dev/null
@@ -1,101 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  ~ Copyright INRAE (2022)
-  ~
-  ~ contact-metexplore@inrae.fr
-  ~
-  ~ This software is a computer program whose purpose is to [describe
-  ~ functionalities and technical features of your software].
-  ~
-  ~ This software is governed by the CeCILL license under French law and
-  ~ abiding by the rules of distribution of free software.  You can  use,
-  ~ modify and/ or redistribute the software under the terms of the CeCILL
-  ~ license as circulated by CEA, CNRS and INRIA at the following URL
-  ~ "https://cecill.info/licences/Licence_CeCILL_V2.1-en.html".
-  ~
-  ~ As a counterpart to the access to the source code and  rights to copy,
-  ~ modify and redistribute granted by the license, users are provided only
-  ~ with a limited warranty  and the software's author,  the holder of the
-  ~ economic rights,  and the successive licensors  have only  limited
-  ~ liability.
-  ~
-  ~ In this respect, the user's attention is drawn to the risks associated
-  ~ with loading,  using,  modifying and/or developing or reproducing the
-  ~ software by the user in light of its specific status of free software,
-  ~ that may mean  that it is complicated to manipulate,  and  that  also
-  ~ therefore means  that it is reserved for developers  and  experienced
-  ~ professionals having in-depth computer knowledge. Users are therefore
-  ~ encouraged to load and test the software's suitability as regards their
-  ~ requirements in conditions enabling the security of their systems and/or
-  ~ data to be ensured and,  more generally, to use and operate it in the
-  ~ same conditions as regards security.
-  ~
-  ~ The fact that you are presently reading this means that you have had
-  ~ knowledge of the CeCILL license and that you accept its terms.
-  ~
-  -->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0"
-         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-    <parent>
-        <artifactId>met4j</artifactId>
-        <groupId>fr.inrae.toulouse.metexplore</groupId>
-        <version>1.5.4-SNAPSHOT</version>
-    </parent>
-    <modelVersion>4.0.0</modelVersion>
-
-    <artifactId>met4j-reconstruction</artifactId>
-    <packaging>jar</packaging>
-
-    <name>met4j-reconstruction</name>
-    <url>http://maven.apache.org</url>
-
-    <properties>
-        <maven.compiler.source>17</maven.compiler.source>
-        <maven.compiler.target>17</maven.compiler.target>
-        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-    </properties>
-
-    <dependencies>
-        <dependency>
-            <groupId>fr.inrae.toulouse.metexplore</groupId>
-            <artifactId>met4j-io</artifactId>
-            <version>1.5.4-SNAPSHOT</version>
-        </dependency>
-        <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <version>4.13.2</version>
-        </dependency>
-    </dependencies>
-
-    <build>
-        <plugins>
-            <plugin>
-                <groupId>org.jacoco</groupId>
-                <artifactId>jacoco-maven-plugin</artifactId>
-                <version>0.8.11</version>
-                <executions>
-                    <!-- to avoid bugs in some situations -->
-                    <execution>
-                        <id>default-prepare-agent</id>
-                        <goals>
-                            <goal>prepare-agent</goal>
-                        </goals>
-                    </execution>
-
-                    <!-- create report during maven verify phase -->
-                    <execution>
-                        <id>report</id>
-                        <phase>verify</phase>
-                        <goals>
-                            <goal>report</goal>
-                        </goals>
-                    </execution>
-                </executions>
-            </plugin>
-        </plugins>
-    </build>
-
-</project>
\ No newline at end of file
diff --git a/met4j-toolbox/pom.xml.versionsBackup b/met4j-toolbox/pom.xml.versionsBackup
deleted file mode 100644
index 5d5edc96b..000000000
--- a/met4j-toolbox/pom.xml.versionsBackup
+++ /dev/null
@@ -1,169 +0,0 @@
-<?xml version="1.0"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-    <modelVersion>4.0.0</modelVersion>
-    <parent>
-        <groupId>fr.inrae.toulouse.metexplore</groupId>
-        <artifactId>met4j</artifactId>
-        <version>1.5.4-SNAPSHOT</version>
-    </parent>
-
-    <artifactId>met4j-toolbox</artifactId>
-    <name>met4j-toolbox</name>
-    <url>http://maven.apache.org</url>
-
-    <properties>
-        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-        <maven.compiler.source>17</maven.compiler.source>
-        <maven.compiler.target>17</maven.compiler.target>
-    </properties>
-
-    <dependencies>
-        <dependency>
-            <groupId>args4j</groupId>
-            <artifactId>args4j</artifactId>
-            <version>2.33</version>
-        </dependency>
-        <dependency>
-            <groupId>fr.inrae.toulouse.metexplore</groupId>
-            <artifactId>met4j-chemUtils</artifactId>
-            <version>1.5.4-SNAPSHOT</version>
-        </dependency>
-        <dependency>
-            <groupId>fr.inrae.toulouse.metexplore</groupId>
-            <artifactId>met4j-io</artifactId>
-            <version>1.5.4-SNAPSHOT</version>
-        </dependency>
-        <dependency>
-            <groupId>fr.inrae.toulouse.metexplore</groupId>
-            <artifactId>met4j-core</artifactId>
-            <version>1.5.4-SNAPSHOT</version>
-        </dependency>
-        <dependency>
-            <groupId>fr.inrae.toulouse.metexplore</groupId>
-            <artifactId>met4j-mathUtils</artifactId>
-            <version>1.5.4-SNAPSHOT</version>
-        </dependency>
-        <dependency>
-            <groupId>fr.inrae.toulouse.metexplore</groupId>
-            <artifactId>met4j-graph</artifactId>
-            <version>1.5.4-SNAPSHOT</version>
-        </dependency>
-        <dependency>
-            <groupId>fr.inrae.toulouse.metexplore</groupId>
-            <artifactId>met4j-mapping</artifactId>
-            <version>1.5.4-SNAPSHOT</version>
-        </dependency>
-        <dependency>
-            <groupId>fr.inrae.toulouse.metexplore</groupId>
-            <artifactId>met4j-reconstruction</artifactId>
-            <version>1.5.4-SNAPSHOT</version>
-        </dependency>
-        <!-- https://mvnrepository.com/artifact/com.googlecode.json-simple/json-simple -->
-        <dependency>
-            <groupId>com.googlecode.json-simple</groupId>
-            <artifactId>json-simple</artifactId>
-            <version>1.1.1</version>
-        </dependency>
-        <dependency>
-            <groupId>org.hibernate.validator</groupId>
-            <artifactId>hibernate-validator</artifactId>
-            <version>8.0.1.Final</version>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.maven</groupId>
-            <artifactId>maven-model</artifactId>
-            <version>4.0.0-alpha-8</version>
-        </dependency>
-    </dependencies>
-
-    <description>Bundle of all met4j modules and api</description>
-
-    <build>
-        <plugins>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-shade-plugin</artifactId>
-                <version>3.2.4</version>
-                <executions>
-                    <execution>
-                        <phase>package</phase>
-                        <goals>
-                            <goal>shade</goal>
-                        </goals>
-                        <configuration>
-                            <filters>
-                                <filter>
-                                    <artifact>*:*</artifact>
-                                    <excludes>
-                                        <exclude>META-INF/*.SF</exclude>
-                                        <exclude>META-INF/*.DSA</exclude>
-                                        <exclude>META-INF/*.RSA</exclude>
-                                    </excludes>
-                                </filter>
-                            </filters>
-                            <transformers>
-                                <transformer
-                                        implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
-                                    <mainClass>
-                                        fr.inrae.toulouse.metexplore.met4j_toolbox.Main
-                                    </mainClass>
-                                    <manifestEntries>
-                                        <Multi-Release>true</Multi-Release>
-                                        <Implementation-Version>${project.version}</Implementation-Version>
-                                    </manifestEntries>
-                                </transformer>
-                                <transformer
-                                        implementation="com.github.edwgiz.mavenShadePlugin.log4j2CacheTransformer.PluginsCacheFileTransformer"/>
-                            </transformers>
-                            <createDependencyReducedPom>
-                                false
-                            </createDependencyReducedPom>
-                        </configuration>
-                    </execution>
-                </executions>
-                <dependencies>
-                    <dependency>
-                        <groupId>com.github.edwgiz</groupId>
-                        <artifactId>maven-shade-plugin.log4j2-cachefile-transformer</artifactId>
-                        <version>2.6.2</version>
-                    </dependency>
-                </dependencies>
-            </plugin>
-            <plugin>
-                <groupId>org.jacoco</groupId>
-                <artifactId>jacoco-maven-plugin</artifactId>
-                <version>0.8.11</version>
-                <executions>
-                    <!-- to avoid bugs in some situations -->
-                    <execution>
-                        <id>default-prepare-agent</id>
-                        <goals>
-                            <goal>prepare-agent</goal>
-                        </goals>
-                    </execution>
-                    <!-- create report during maven verify phase -->
-                    <execution>
-                        <id>report</id>
-                        <phase>verify</phase>
-                        <goals>
-                            <goal>report</goal>
-                        </goals>
-                    </execution>
-                </executions>
-            </plugin>
-            <plugin>
-                <groupId>org.codehaus.mojo</groupId>
-                <artifactId>exec-maven-plugin</artifactId>
-                <version>3.0.0</version>
-                <configuration>
-                    <mainClass>fr.inrae.toulouse.metexplore.met4j_toolbox.GenerateDoc</mainClass>
-                    <arguments>
-                        <argument>README.md</argument>
-                    </arguments>
-                </configuration>
-            </plugin>
-        </plugins>
-    </build>
-
-</project>
diff --git a/pom.xml.versionsBackup b/pom.xml.versionsBackup
deleted file mode 100644
index dbbf69abc..000000000
--- a/pom.xml.versionsBackup
+++ /dev/null
@@ -1,203 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-    <modelVersion>4.0.0</modelVersion>
-
-    <groupId>fr.inrae.toulouse.metexplore</groupId>
-    <artifactId>met4j</artifactId>
-    <version>1.5.4-SNAPSHOT</version>
-    <packaging>pom</packaging>
-
-    <name>met4j</name>
-    <description>A java library dedicated to metabolic network analysis</description>
-    <url>https://metexplore.toulouse.inrae.fr/met4j</url>
-
-    <organization>
-        <url>www.inrae.fr</url>
-        <name>Institut national de recherche pour l’agriculture, l’alimentation et l’environnement</name>
-    </organization>
-
-    <issueManagement>
-        <url>https://forgemia.inra.fr/metexplore/met4j/issues</url>
-        <system>GitLab</system>
-    </issueManagement>
-
-    <licenses>
-        <license>
-            <name>CeCILL License, version 2.1</name>
-            <url>https://cecill.info/licences/Licence_CeCILL_V2.1-en.html</url>
-        </license>
-
-    </licenses>
-
-    <developers>
-        <developer>
-            <name>Ludovic Cottret</name>
-            <email>ludovic.cottret@inrae.fr</email>
-            <organization>INRAE</organization>
-            <organizationUrl>https://www.inrae.fr/</organizationUrl>
-        </developer>
-        <developer>
-            <name>Clément Frainay</name>
-            <email>clement.frainay@inrae.fr</email>
-            <organization>INRAE</organization>
-            <organizationUrl>https://www.inrae.fr/</organizationUrl>
-        </developer>
-    </developers>
-
-    <scm>
-        <developerConnection>scm:git:ssh://git@forgemia.inra.fr/metexplore/met4j.git</developerConnection>
-        <tag>met4j-0.1.2</tag>
-        <url>https://forgemia.inra.fr/metexplore/met4j/-/tree/master</url>
-    </scm>
-
-    <distributionManagement>
-        <snapshotRepository>
-            <id>ossrh</id>
-            <url>https://oss.sonatype.org/content/repositories/snapshots</url>
-        </snapshotRepository>
-        <repository>
-            <id>ossrh</id>
-            <url>https://oss.sonatype.org/service/local/staging/deploy/maven2</url>
-        </repository>
-    </distributionManagement>
-
-    <properties>
-        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-        <maven.compiler.source>17</maven.compiler.source>
-        <maven.compiler.target>17</maven.compiler.target>
-        <project.scm.id>forgemia</project.scm.id>
-    </properties>
-
-    <build>
-        <plugins>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-release-plugin</artifactId>
-                <version>3.0.0-M1</version>
-                <configuration>
-                    <!--
-                      During release:perform, enable the "release" profile
-                     -->
-                    <releaseProfiles>release</releaseProfiles>
-                </configuration>
-            </plugin>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-compiler-plugin</artifactId>
-                <version>3.8.1</version>
-                <configuration>
-                    <source>17</source>
-                    <target>17</target>
-                </configuration>
-            </plugin>
-            <plugin>
-                <groupId>org.sonatype.plugins</groupId>
-                <artifactId>nexus-staging-maven-plugin</artifactId>
-                <version>1.6.13</version>
-                <extensions>true</extensions>
-                <configuration>
-                    <serverId>ossrh</serverId>
-                    <nexusUrl>https://oss.sonatype.org/</nexusUrl>
-                    <autoReleaseAfterClose>true</autoReleaseAfterClose>
-                </configuration>
-            </plugin>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-surefire-plugin</artifactId>
-                <version>3.0.0-M5</version>
-            </plugin>
-        </plugins>
-    </build>
-    <profiles>
-        <profile>
-            <id>release</id>
-            <build>
-                <plugins>
-                    <plugin>
-                        <groupId>org.apache.maven.plugins</groupId>
-                        <artifactId>maven-gpg-plugin</artifactId>
-                        <executions>
-                            <execution>
-                                <id>sign-artifacts</id>
-                                <phase>verify</phase>
-                                <goals>
-                                    <goal>sign</goal>
-                                </goals>
-                                <configuration>
-                                    <gpgArguments>
-                                        <arg>--pinentry-mode</arg>
-                                        <arg>loopback</arg>
-                                    </gpgArguments>
-                                </configuration>
-                            </execution>
-                        </executions>
-                    </plugin>
-                    <plugin>
-                        <groupId>org.apache.maven.plugins</groupId>
-                        <artifactId>maven-javadoc-plugin</artifactId>
-                        <version>3.1.1</version>
-                        <executions>
-                            <execution>
-                                <id>attach-javadocs</id>
-                                <goals>
-                                    <goal>jar</goal>
-                                </goals>
-                            </execution>
-                        </executions>
-                        <configuration>
-                            <javadocExecutable>${java.home}/bin/javadoc</javadocExecutable>
-                            <doclint>none</doclint>
-                        </configuration>
-
-                    </plugin>
-                    <plugin>
-                        <groupId>org.apache.maven.plugins</groupId>
-                        <artifactId>maven-source-plugin</artifactId>
-                        <version>3.2.1</version>
-                        <executions>
-                            <execution>
-                                <id>attach-sources</id>
-                                <goals>
-                                    <goal>jar</goal>
-                                </goals>
-                            </execution>
-                        </executions>
-                    </plugin>
-                </plugins>
-            </build>
-        </profile>
-    </profiles>
-    <modules>
-        <module>met4j-core</module>
-        <module>met4j-io</module>
-        <module>met4j-chemUtils</module>
-        <module>met4j-mathUtils</module>
-        <module>met4j-graph</module>
-        <module>met4j-mapping</module>
-        <module>met4j-reconstruction</module>
-        <module>coverage</module>
-        <module>met4j-toolbox</module>
-    </modules>
-
-    <dependencies>
-        <dependency>
-            <groupId>org.codehaus.mojo</groupId>
-            <artifactId>build-helper-maven-plugin</artifactId>
-            <version>3.4.0</version>
-            <type>maven-plugin</type>
-        </dependency>
-        <dependency>
-            <groupId>org.projectlombok</groupId>
-            <artifactId>lombok</artifactId>
-            <version>1.18.30</version>
-            <scope>provided</scope>
-        </dependency>
-        <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <version>4.13.2</version>
-            <scope>test</scope>
-        </dependency>
-    </dependencies>
-</project>
\ No newline at end of file
-- 
GitLab


From 6cf3f60e53c8476ccfb5a355818f16fc4ce79988 Mon Sep 17 00:00:00 2001
From: lcottret <ludovic.cottret@inrae.fr>
Date: Thu, 2 Jan 2025 16:44:41 +0100
Subject: [PATCH 02/74] Rename DecomposeSbml to GetSbmlEntities and fix doc

---
 .../{DecomposeSBML.java => GetSbmlEntities.java} | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
 rename met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/{DecomposeSBML.java => GetSbmlEntities.java} (89%)

diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/DecomposeSBML.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/GetSbmlEntities.java
similarity index 89%
rename from met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/DecomposeSBML.java
rename to met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/GetSbmlEntities.java
index 613f08b24..f865a8694 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/DecomposeSBML.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/GetSbmlEntities.java
@@ -16,7 +16,7 @@ import java.io.IOException;
 import java.io.PrintWriter;
 import java.util.Set;
 
-public class DecomposeSBML extends AbstractMet4jApplication {
+public class GetSbmlEntities extends AbstractMet4jApplication {
 
 
     @ParameterType(name= EnumParameterTypes.InputFile)
@@ -41,7 +41,7 @@ public class DecomposeSBML extends AbstractMet4jApplication {
     public Boolean printGenes = false;
 
     @ParameterType(name= EnumParameterTypes.Boolean)
-    @Option(name = "-nt", aliases = {"--noTypeCol"}, usage = "Do not output type column", required = false)
+    @Option(name = "-nt", aliases = {"--noTypeCol"}, usage = "Do not write type column", required = false)
     public Boolean noTypeCol = false;
 
     @ParameterType(name= EnumParameterTypes.OutputFile)
@@ -55,7 +55,7 @@ public class DecomposeSBML extends AbstractMet4jApplication {
      * @param args an array of {@link java.lang.String} objects.
      */
     public static void main(String[] args) {
-        DecomposeSBML app = new DecomposeSBML();
+        GetSbmlEntities app = new GetSbmlEntities();
         app.parseArguments(args);
         app.run();
     }
@@ -123,15 +123,15 @@ public class DecomposeSBML extends AbstractMet4jApplication {
 
     @Override
     public String getLongDescription() {
-        return "Parse SBML to render list of composing entities: metabolites, reactions, genes, pathways and compartments. " +
-                "The output file is a tsv with two columns, one with entities identifiers, and one with the entity type. " +
-                "If no entity type is selected, by default all of them are taken into account. " +
-                "Only identifiers are written, attributes can be extracted from dedicated apps or from the SBML2Tab.";
+        return this.getShortDescription() +
+                "The output file is a tsv with two columns, one with entity identifiers, and one with the entity type. " +
+                "If no entity type is selected, all of them are returned by default. " +
+                "Only identifiers are written, attributes can be extracted from dedicated apps or from the Sbml2Tab app.";
     }
 
     @Override
     public String getShortDescription() {
-        return "Parse SBML to render list of composing entities: metabolites, reactions, genes and others.";
+        return "Parse a SBML file to return a list of entities composing the network: metabolites, reactions, genes and others.";
     }
 
     @Override
-- 
GitLab


From 3ae58a567e40a18bc4a0404374f6f61c8a9c4086 Mon Sep 17 00:00:00 2001
From: lcottret <ludovic.cottret@inrae.fr>
Date: Fri, 3 Jan 2025 13:52:26 +0100
Subject: [PATCH 03/74] add static methods to read and write SBML in toolbox
 apps

---
 .../met4j_toolbox/utils/IOUtils.java          | 87 +++++++++++++++++++
 1 file changed, 87 insertions(+)
 create mode 100644 met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/utils/IOUtils.java

diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/utils/IOUtils.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/utils/IOUtils.java
new file mode 100644
index 000000000..2a8c1ea26
--- /dev/null
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/utils/IOUtils.java
@@ -0,0 +1,87 @@
+/*
+ * Copyright INRAE (2025)
+ *
+ * contact-metexplore@inrae.fr
+ *
+ * This software is a computer program whose purpose is to [describe
+ * functionalities and technical features of your software].
+ *
+ * This software is governed by the CeCILL license under French law and
+ * abiding by the rules of distribution of free software.  You can  use,
+ * modify and/ or redistribute the software under the terms of the CeCILL
+ * license as circulated by CEA, CNRS and INRIA at the following URL
+ * "https://cecill.info/licences/Licence_CeCILL_V2.1-en.html".
+ *
+ * As a counterpart to the access to the source code and  rights to copy,
+ * modify and redistribute granted by the license, users are provided only
+ * with a limited warranty  and the software's author,  the holder of the
+ * economic rights,  and the successive licensors  have only  limited
+ * liability.
+ *
+ * In this respect, the user's attention is drawn to the risks associated
+ * with loading,  using,  modifying and/or developing or reproducing the
+ * software by the user in light of its specific status of free software,
+ * that may mean  that it is complicated to manipulate,  and  that  also
+ * therefore means  that it is reserved for developers  and  experienced
+ * professionals having in-depth computer knowledge. Users are therefore
+ * encouraged to load and test the software's suitability as regards their
+ * requirements in conditions enabling the security of their systems and/or
+ * data to be ensured and,  more generally, to use and operate it in the
+ * same conditions as regards security.
+ *
+ * The fact that you are presently reading this means that you have had
+ * knowledge of the CeCILL license and that you accept its terms.
+ *
+ */
+
+package fr.inrae.toulouse.metexplore.met4j_toolbox.utils;
+
+import fr.inrae.toulouse.metexplore.met4j_core.biodata.BioNetwork;
+import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.JsbmlReader;
+import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.Met4jSbmlReaderException;
+import fr.inrae.toulouse.metexplore.met4j_io.jsbml.writer.JsbmlWriter;
+
+public class IOUtils {
+
+    /**
+     * Reads an SBML file and returns a BioNetwork object.
+     *
+     * @param sbmlPath the path to the SBML file
+     * @return the BioNetwork object read from the SBML file
+     */
+    public static BioNetwork readSbml(String sbmlPath) {
+        JsbmlReader reader = new JsbmlReader(sbmlPath);
+
+        BioNetwork bn = null;
+        try {
+            bn = reader.read();
+        } catch (Met4jSbmlReaderException e) {
+            e.printStackTrace();
+            System.err.println("Problem while reading the sbml file " + sbmlPath);
+            System.exit(1);
+        }
+
+        return bn;
+
+    }
+
+    /**
+     * Writes a BioNetwork object to an SBML file.
+     *
+     * @param network the BioNetwork object to be written
+     * @param pathOut the path to the output SBML file
+     */
+    public static void writeSbml(BioNetwork network, String pathOut) {
+        JsbmlWriter writer = new JsbmlWriter(pathOut, network);
+
+        try {
+            writer.write();
+        } catch (Exception e) {
+            e.printStackTrace();
+            System.err.println("Error in writing the sbml file");
+            System.exit(1);
+        }
+    }
+
+
+}
-- 
GitLab


From 0398e9d0b4341ba11702c3130f56c9e4cfeb11e9 Mon Sep 17 00:00:00 2001
From: lcottret <ludovic.cottret@inrae.fr>
Date: Fri, 3 Jan 2025 13:52:50 +0100
Subject: [PATCH 04/74] use readSbml and writeSbml static methods

---
 .../attributes/AbstractSbmlSet.java           | 30 ++-----------------
 1 file changed, 3 insertions(+), 27 deletions(-)

diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/AbstractSbmlSet.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/AbstractSbmlSet.java
index eb0e8bac0..f61ccdbfb 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/AbstractSbmlSet.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/AbstractSbmlSet.java
@@ -37,14 +37,10 @@
 package fr.inrae.toulouse.metexplore.met4j_toolbox.attributes;
 
 import fr.inrae.toulouse.metexplore.met4j_core.biodata.BioNetwork;
-import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.JsbmlReader;
-import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.Met4jSbmlReaderException;
-import fr.inrae.toulouse.metexplore.met4j_io.jsbml.writer.JsbmlWriter;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.AbstractMet4jApplication;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.*;
 import org.kohsuke.args4j.Option;
-
-import java.io.IOException;
+import fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils;
 
 import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumFormats.*;
 import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumParameterTypes.*;
@@ -91,19 +87,7 @@ public abstract class AbstractSbmlSet extends AbstractMet4jApplication {
      * @return a {@link fr.inrae.toulouse.metexplore.met4j_core.biodata.BioNetwork} object.
      */
     protected BioNetwork readSbml() {
-        JsbmlReader reader = new JsbmlReader(this.sbml);
-
-        BioNetwork bn = null;
-        try {
-            bn = reader.read();
-        } catch (Met4jSbmlReaderException e) {
-            e.printStackTrace();
-            System.err.println("Problem while reading the sbml file " + this.sbml);
-            System.exit(1);
-        }
-
-        return bn;
-
+        return IOUtils.readSbml(this.sbml);
     }
 
     /**
@@ -112,15 +96,7 @@ public abstract class AbstractSbmlSet extends AbstractMet4jApplication {
      * @param network a {@link fr.inrae.toulouse.metexplore.met4j_core.biodata.BioNetwork} object.
      */
     protected void writeSbml(BioNetwork network) {
-        JsbmlWriter writer = new JsbmlWriter(this.out, network);
-
-        try {
-            writer.write();
-        } catch (Exception e) {
-            e.printStackTrace();
-            System.err.println("Error in writing the sbml file");
-            System.exit(1);
-        }
+        IOUtils.writeSbml(network, this.out);
     }
 
 
-- 
GitLab


From 82807b6294731efbef74b6235201be3a46877c48 Mon Sep 17 00:00:00 2001
From: lcottret <ludovic.cottret@inrae.fr>
Date: Fri, 3 Jan 2025 13:54:46 +0100
Subject: [PATCH 05/74] small refactoring

---
 .../attributes/ExtractPathways.java           | 38 ++++++-------------
 1 file changed, 12 insertions(+), 26 deletions(-)

diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/ExtractPathways.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/ExtractPathways.java
index d921bbdf1..f3207d86f 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/ExtractPathways.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/ExtractPathways.java
@@ -12,6 +12,7 @@ import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumParame
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.Format;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.ParameterType;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.utils.Doi;
+import fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils;
 import org.kohsuke.args4j.Option;
 
 import java.io.IOException;
@@ -44,27 +45,19 @@ public class ExtractPathways extends AbstractMet4jApplication {
 
 
     public void run() {
-        //read smbl
-        JsbmlReader reader = new JsbmlReader(this.inputPath);
-        BioNetwork network = null;
-        try {
-            network = reader.read();
-        } catch (Met4jSbmlReaderException e) {
-            System.err.println("Error while converting the SBML file");
-            System.err.println(e.getMessage());
-            System.exit(1);
-        }
+        // read smbl
+        BioNetwork network = IOUtils.readSbml(this.inputPath);
+
         System.out.println("Number of reactions in original network: "+network.getReactionsView().size());
         System.out.println("Number of species in original network: "+network.getMetabolitesView().size());
         System.out.println("Number of genes in original network: "+network.getGenesView().size());
 
-
-        //get all reactions & metabolites
+        // get all reactions & metabolites
         BioCollection<BioReaction> reactions = new BioCollection<>(network.getReactionsView());
         BioCollection<BioMetabolite> metabolites = new BioCollection<>(network.getMetabolitesView());
         BioCollection<BioGene> genes = new BioCollection<>(network.getGenesView());
 
-        //get pathways
+        // get pathways
         BioCollection<BioPathway> pathways = new BioCollection<>();
         for(String id : pathwayId.split("\\+")){
             BioPathway pathway = network.getPathwaysView().get(id);
@@ -78,13 +71,13 @@ public class ExtractPathways extends AbstractMet4jApplication {
             }
         }
 
-        //remove pathway's reactions and metabolites from list
+        // remove pathway's reactions and metabolites from list
         BioCollection<BioReaction> pathwaysReactions = network.getReactionsFromPathways(pathways);
         reactions.removeAll(pathwaysReactions);
         metabolites.removeAll(network.getMetabolitesFromReactions(pathwaysReactions));
         genes.removeAll(network.getGenesFromReactions(pathwaysReactions));
 
-        //remove remaining reactions
+        // remove remaining reactions
         network.removeOnCascade(reactions);
         network.removeOnCascade(metabolites);
         network.removeOnCascade(genes);
@@ -92,16 +85,9 @@ public class ExtractPathways extends AbstractMet4jApplication {
         System.out.println("Number of species in network: "+network.getMetabolitesView().size());
         System.out.println("Number of genes in network: "+network.getGenesView().size());
 
-        //export network
-        JsbmlWriter w = new JsbmlWriter(outputPath, network);
+        // export network
+        IOUtils.writeSbml(network, this.outputPath);
 
-        try {
-            w.write();
-        } catch (Met4jSbmlWriterException e) {
-            System.err.println("Error while writing the SBML file");
-            System.err.println(e.getMessage());
-            System.exit(1);
-        }
         System.err.println("network exported.");
         return;
     }
@@ -113,12 +99,12 @@ public class ExtractPathways extends AbstractMet4jApplication {
 
     @Override
     public String getLongDescription() {
-        return "\"Extract pathway(s) from GSMN: From a SBML file, Create a sub-network SBML file including only a selection of pathways";
+        return this.getShortDescription();
     }
 
     @Override
     public String getShortDescription() {
-        return "Extract pathway(s) from GSMN";
+        return "Extract pathway(s) from a SBML file and create a sub-network SBML file";
     }
 
     @Override
-- 
GitLab


From 4ef052bd15f218a86ee7279d581eba081d2181ec Mon Sep 17 00:00:00 2001
From: lcottret <ludovic.cottret@inrae.fr>
Date: Fri, 3 Jan 2025 13:58:03 +0100
Subject: [PATCH 06/74] only typo

---
 .../met4j_toolbox/attributes/ExtractSbmlAnnot.java | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)

diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/ExtractSbmlAnnot.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/ExtractSbmlAnnot.java
index 722e60a6b..8b3cad000 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/ExtractSbmlAnnot.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/ExtractSbmlAnnot.java
@@ -12,6 +12,7 @@ import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumParame
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.Format;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.ParameterType;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.utils.Doi;
+import fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils;
 import org.kohsuke.args4j.Option;
 
 import java.io.FileWriter;
@@ -65,16 +66,7 @@ public class ExtractSbmlAnnot extends AbstractMet4jApplication {
             fw = new FileWriter(outputPath);
 
             //read smbl
-            JsbmlReader reader = new JsbmlReader(this.inputPath);
-
-            BioNetwork network = null;
-            try {
-                network = reader.read();
-            } catch (Met4jSbmlReaderException e) {
-                System.err.println("Error while reading the sbml file");
-                System.err.println(e.getMessage());
-                System.exit(1);
-            }
+            BioNetwork network = IOUtils.readSbml(this.inputPath);
 
             BioCollection<? extends BioEntity> entities = new BioCollection<>();
             if (export == entity.METABOLITE) {
@@ -139,7 +131,7 @@ public class ExtractSbmlAnnot extends AbstractMet4jApplication {
                 "The references are exported as a tabulated file with one column with the SBML compound, " +
                 "reaction or gene identifiers, and one column with the corresponding database identifier." +
                 "The name of the targeted database need to be provided under the same form than the one used " +
-                "in the notes field or the identifiers.org uri";
+                "in the notes field or the identifiers.org uri.";
     }
 
     @Override
-- 
GitLab


From 2109d6c1a64a247c4ec2288e1dd0fb9cad5ea90d Mon Sep 17 00:00:00 2001
From: lcottret <ludovic.cottret@inrae.fr>
Date: Fri, 3 Jan 2025 13:59:59 +0100
Subject: [PATCH 07/74] move ExtractSbmlAnnot to ExtractAnnotations

---
 .../{ExtractSbmlAnnot.java => ExtractAnnotations.java}       | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
 rename met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/{ExtractSbmlAnnot.java => ExtractAnnotations.java} (96%)

diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/ExtractSbmlAnnot.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/ExtractAnnotations.java
similarity index 96%
rename from met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/ExtractSbmlAnnot.java
rename to met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/ExtractAnnotations.java
index 8b3cad000..51c1cd20f 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/ExtractSbmlAnnot.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/ExtractAnnotations.java
@@ -4,7 +4,6 @@ import fr.inrae.toulouse.metexplore.met4j_core.biodata.BioEntity;
 import fr.inrae.toulouse.metexplore.met4j_core.biodata.BioNetwork;
 import fr.inrae.toulouse.metexplore.met4j_core.biodata.BioRef;
 import fr.inrae.toulouse.metexplore.met4j_core.biodata.collection.BioCollection;
-import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.JsbmlReader;
 import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.Met4jSbmlReaderException;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.AbstractMet4jApplication;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumFormats;
@@ -19,7 +18,7 @@ import java.io.FileWriter;
 import java.io.IOException;
 import java.util.*;
 
-public class ExtractSbmlAnnot extends AbstractMet4jApplication {
+public class ExtractAnnotations extends AbstractMet4jApplication {
 
     @Format(name = EnumFormats.Sbml)
     @ParameterType(name = EnumParameterTypes.InputFile)
@@ -50,7 +49,7 @@ public class ExtractSbmlAnnot extends AbstractMet4jApplication {
 
     public static void main(String[] args) throws IOException, Met4jSbmlReaderException {
 
-        ExtractSbmlAnnot app = new ExtractSbmlAnnot();
+        ExtractAnnotations app = new ExtractAnnotations();
 
         app.parseArguments(args);
 
-- 
GitLab


From b687e9dc73309d29009c31684248ad74813f8662 Mon Sep 17 00:00:00 2001
From: lcottret <ludovic.cottret@inrae.fr>
Date: Fri, 3 Jan 2025 14:01:30 +0100
Subject: [PATCH 08/74] change parameter names

---
 .../met4j_toolbox/attributes/AbstractSbmlSet.java           | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/AbstractSbmlSet.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/AbstractSbmlSet.java
index f61ccdbfb..5cc833234 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/AbstractSbmlSet.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/AbstractSbmlSet.java
@@ -58,17 +58,17 @@ public abstract class AbstractSbmlSet extends AbstractMet4jApplication {
 
     @Format(name = Sbml)
     @ParameterType(name = OutputFile)
-    @Option(name = "-out", usage = "[out.sbml] Out sbml file")
+    @Option(name = "-o", usage = "[out.sbml] SBML output file")
     public String out = "out.sbml";
 
     @Format(name = Sbml)
     @ParameterType(name = InputFile)
-    @Option(name = "-sbml", usage = "Original sbml file", required = true)
+    @Option(name = "-i", usage = "Original SBML file", required = true)
     public String sbml;
 
     @ParameterType(name = InputFile)
     @Format(name = Tsv)
-    @Option(name = "-tab", usage = "Tabulated file")
+    @Option(name = "-tab", usage = "Input Tabulated file")
     public String tab;
 
     @ParameterType(name = EnumParameterTypes.Text)
-- 
GitLab


From 04be73e042436f6afba40e00fec5d01c1fd4cf12 Mon Sep 17 00:00:00 2001
From: lcottret <ludovic.cottret@inrae.fr>
Date: Fri, 3 Jan 2025 14:04:38 +0100
Subject: [PATCH 09/74] doc and refactoring

---
 .../attributes/GetGenesFromReactions.java     | 31 +++++++------------
 1 file changed, 12 insertions(+), 19 deletions(-)

diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/GetGenesFromReactions.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/GetGenesFromReactions.java
index d2c8e52a0..ef011f764 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/GetGenesFromReactions.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/GetGenesFromReactions.java
@@ -14,6 +14,7 @@ import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumParame
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.Format;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.ParameterType;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.utils.Doi;
+import fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils;
 import org.kohsuke.args4j.Option;
 
 import java.io.FileWriter;
@@ -35,13 +36,15 @@ public class GetGenesFromReactions extends AbstractMet4jApplication {
     public String reactionFile;
 
     @ParameterType(name= EnumParameterTypes.Text)
-    @Option(name = "-sep", usage = "Separator in reaction file", required = false)
+    @Option(name = "-sep", usage = "Separator in reaction file")
     public String sep = "\t";
+
     @ParameterType(name= EnumParameterTypes.Boolean)
-    @Option(name = "-header", usage = "Skip reaction file header", required = false)
+    @Option(name = "-header", usage = "Skip reaction file header")
     public boolean hasHeader = false;
+
     @ParameterType(name= EnumParameterTypes.Integer)
-    @Option(name = "-col", usage = "Column number in reaction file (first as 1)", required = false)
+    @Option(name = "-col", usage = "Column number in reaction file (first as 1)")
     public int i=1;
 
     @ParameterType(name= EnumParameterTypes.OutputFile)
@@ -68,30 +71,20 @@ public class GetGenesFromReactions extends AbstractMet4jApplication {
 
         //read SBML, create bionetwork
         String fileIn = this.sbml;
-        JsbmlReader reader = new JsbmlReader(fileIn);
-        BioNetwork network = null;
-        try {
-            network = reader.read();
-        } catch (Met4jSbmlReaderException e) {
-            System.err.println("Error while reading the SBML file");
-            System.err.println(e.getMessage());
-            System.exit(1);
-        }
+        BioNetwork network = IOUtils.readSbml(fileIn);
 
         //Import Reaction File
         BioCollection<BioReaction> input = new BioCollection<>();
         try {
             BioNetwork finalNetwork = network;
-            Mapper map = new Mapper(finalNetwork, bioNetwork -> {
-                return finalNetwork.getReactionsView();
-            })
+            Mapper map = new Mapper(finalNetwork, bioNetwork -> finalNetwork.getReactionsView())
                     .columnSeparator(sep)
                     .idColumn(i)
                     .skipIfNotFound();
             if(hasHeader) map = map.skipHeader();
             input = map.map(reactionFile);
-            System.err.println(input.size()+" reactions mapped");
-            System.err.println(map.getNumberOfSkippedEntries()+" reactions not found in model");
+            System.out.println(input.size()+" reactions mapped");
+            System.out.println(map.getNumberOfSkippedEntries()+" reactions not found in model");
         } catch (IOException e) {
             System.err.println("Error while reading the Reaction file");
             System.err.println(e.getMessage());
@@ -119,13 +112,13 @@ public class GetGenesFromReactions extends AbstractMet4jApplication {
 
     @Override
     public String getLongDescription() {
-        return "Get associated gene list from a list of reactions and a GSMN. Parse GSMN GPR annotations and output a tab-separated file " +
+        return "Get associated gene list from a list of reactions and a SBML file. Parse SBML GPR annotations and output a tab-separated file " +
                 "with one row per gene, associated reaction identifiers from input file in first column, gene identifiers in second column.";
     }
 
     @Override
     public String getShortDescription() {
-        return "Get gene lists from a list of reactions and a GSMN.";
+        return "Get gene lists from a list of reactions and a SBML file.";
     }
 
     @Override
-- 
GitLab


From 4f30401de9a9bd8f66db0159fd4925e2cc94b184 Mon Sep 17 00:00:00 2001
From: lcottret <ludovic.cottret@inrae.fr>
Date: Fri, 3 Jan 2025 14:08:47 +0100
Subject: [PATCH 10/74] doc and refactoring

---
 .../attributes/GetReactantsFromReactions.java | 33 ++++++++-----------
 1 file changed, 13 insertions(+), 20 deletions(-)

diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/GetReactantsFromReactions.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/GetReactantsFromReactions.java
index 592cd036d..fadae7fb1 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/GetReactantsFromReactions.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/GetReactantsFromReactions.java
@@ -11,6 +11,7 @@ import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumParame
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.Format;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.ParameterType;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.utils.Doi;
+import fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils;
 import org.kohsuke.args4j.Option;
 
 import java.io.FileWriter;
@@ -32,20 +33,22 @@ public class GetReactantsFromReactions extends AbstractMet4jApplication {
     public String reactionFile;
 
     @ParameterType(name= EnumParameterTypes.Text)
-    @Option(name = "-sep", usage = "Separator in reaction file", required = false)
+    @Option(name = "-sep", usage = "Separator in reaction file")
     public String sep = "\t";
+
     @ParameterType(name= EnumParameterTypes.Boolean)
-    @Option(name = "-header", usage = "Skip reaction file header", required = false)
+    @Option(name = "-header", usage = "Skip reaction file header")
     public boolean hasHeader = false;
+
     @ParameterType(name= EnumParameterTypes.Integer)
-    @Option(name = "-col", usage = "Column number in reaction file (first as 1)", required = false)
+    @Option(name = "-col", usage = "Column number in reaction file (first as 1)")
     public int i=1;
 
     @ParameterType(name= EnumParameterTypes.Boolean)
-    @Option(name = "-s", aliases = {"--substrates"}, usage = "Extract substrates only", required = false)
+    @Option(name = "-s", aliases = {"--substrates"}, usage = "Extract substrates only")
     public Boolean printSubstrates = false;
     @ParameterType(name= EnumParameterTypes.Boolean)
-    @Option(name = "-p", aliases = {"--products"}, usage = "Extract products only", required = false)
+    @Option(name = "-p", aliases = {"--products"}, usage = "Extract products only")
     public Boolean printProducts = false;
 
     @ParameterType(name= EnumParameterTypes.OutputFile)
@@ -72,23 +75,13 @@ public class GetReactantsFromReactions extends AbstractMet4jApplication {
 
         //read SBML, create bionetwork
         String fileIn = this.sbml;
-        JsbmlReader reader = new JsbmlReader(fileIn);
-        BioNetwork network = null;
-        try {
-            network = reader.read();
-        } catch (Met4jSbmlReaderException e) {
-            System.err.println("Error while reading the SBML file");
-            System.err.println(e.getMessage());
-            System.exit(1);
-        }
+        BioNetwork network = IOUtils.readSbml(fileIn);
 
         //Import Reaction File
         BioCollection<BioReaction> input = new BioCollection<>();
         try {
             BioNetwork finalNetwork = network;
-            Mapper map = new Mapper(finalNetwork, bioNetwork -> {
-                return finalNetwork.getReactionsView();
-            })
+            Mapper map = new Mapper(finalNetwork, bioNetwork -> finalNetwork.getReactionsView())
                     .columnSeparator(sep)
                     .idColumn(i)
                     .skipIfNotFound();
@@ -130,15 +123,15 @@ public class GetReactantsFromReactions extends AbstractMet4jApplication {
 
     @Override
     public String getLongDescription() {
-        return "Get reactants lists from a list of reactions and a GSMN. Output a tab-separated file " +
+        return "Get reactant lists from a list of reactions and a Sbml file. Output a tab-separated file " +
                 "with one row per reactant, reaction identifiers in first column, reactant identifiers in second column. " +
                 "It can provides substrates, products, or both (by default). In the case of reversible reactions, " +
-                "all reactants are considered both substrates and products";
+                "all reactants are considered as both substrates and products";
     }
 
     @Override
     public String getShortDescription() {
-        return "Get reactants lists from a list of reactions and a GSMN.";
+        return "Get reactant lists from a list of reactions and a SBML file.";
     }
 
     @Override
-- 
GitLab


From 6beda1917fb3ba0cf65afd911855e244d40f5324 Mon Sep 17 00:00:00 2001
From: lcottret <ludovic.cottret@inrae.fr>
Date: Fri, 3 Jan 2025 14:13:07 +0100
Subject: [PATCH 11/74] doc and refactoring

---
 ...{GetSbmlEntities.java => GetEntities.java} | 35 ++++++++-----------
 .../attributes/GetReactantsFromReactions.java |  4 +--
 2 files changed, 17 insertions(+), 22 deletions(-)
 rename met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/{GetSbmlEntities.java => GetEntities.java} (83%)

diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/GetSbmlEntities.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/GetEntities.java
similarity index 83%
rename from met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/GetSbmlEntities.java
rename to met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/GetEntities.java
index f865a8694..e92e44c95 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/GetSbmlEntities.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/GetEntities.java
@@ -1,14 +1,13 @@
 package fr.inrae.toulouse.metexplore.met4j_toolbox.attributes;
 
 import fr.inrae.toulouse.metexplore.met4j_core.biodata.*;
-import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.JsbmlReader;
-import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.Met4jSbmlReaderException;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.AbstractMet4jApplication;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumFormats;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumParameterTypes;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.Format;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.ParameterType;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.utils.Doi;
+import fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils;
 import org.kohsuke.args4j.Option;
 
 import java.io.FileWriter;
@@ -16,7 +15,7 @@ import java.io.IOException;
 import java.io.PrintWriter;
 import java.util.Set;
 
-public class GetSbmlEntities extends AbstractMet4jApplication {
+public class GetEntities extends AbstractMet4jApplication {
 
 
     @ParameterType(name= EnumParameterTypes.InputFile)
@@ -25,23 +24,27 @@ public class GetSbmlEntities extends AbstractMet4jApplication {
     public String sbml;
 
     @ParameterType(name= EnumParameterTypes.Boolean)
-    @Option(name = "-m", aliases = {"--metabolites"}, usage = "Extract Metabolites", required = false)
+    @Option(name = "-m", aliases = {"--metabolites"}, usage = "Extract Metabolites")
     public Boolean printMetabolites = false;
+    
     @ParameterType(name= EnumParameterTypes.Boolean)
-    @Option(name = "-r", aliases = {"--reactions"}, usage = "Extract Reactions", required = false)
+    @Option(name = "-r", aliases = {"--reactions"}, usage = "Extract Reactions")
     public Boolean printReactions = false;
+
     @ParameterType(name= EnumParameterTypes.Boolean)
-    @Option(name = "-c", aliases = {"--compartments"}, usage = "Extract Compartments", required = false)
+    @Option(name = "-c", aliases = {"--compartments"}, usage = "Extract Compartments")
     public Boolean printCompartments = false;
+
     @ParameterType(name= EnumParameterTypes.Boolean)
-    @Option(name = "-p", aliases = {"--pathways"}, usage = "Extract Pathways", required = false)
+    @Option(name = "-p", aliases = {"--pathways"}, usage = "Extract Pathways")
     public Boolean printPathways = false;
+
     @ParameterType(name= EnumParameterTypes.Boolean)
-    @Option(name = "-g", aliases = {"--genes"}, usage = "Extract Genes", required = false)
+    @Option(name = "-g", aliases = {"--genes"}, usage = "Extract Genes")
     public Boolean printGenes = false;
 
     @ParameterType(name= EnumParameterTypes.Boolean)
-    @Option(name = "-nt", aliases = {"--noTypeCol"}, usage = "Do not write type column", required = false)
+    @Option(name = "-nt", aliases = {"--noTypeCol"}, usage = "Do not write type column")
     public Boolean noTypeCol = false;
 
     @ParameterType(name= EnumParameterTypes.OutputFile)
@@ -55,7 +58,7 @@ public class GetSbmlEntities extends AbstractMet4jApplication {
      * @param args an array of {@link java.lang.String} objects.
      */
     public static void main(String[] args) {
-        GetSbmlEntities app = new GetSbmlEntities();
+        GetEntities app = new GetEntities();
         app.parseArguments(args);
         app.run();
     }
@@ -66,15 +69,7 @@ public class GetSbmlEntities extends AbstractMet4jApplication {
     public void run() {
 
         String fileIn = this.sbml;
-        JsbmlReader reader = new JsbmlReader(fileIn);
-        BioNetwork network = null;
-        try {
-            network = reader.read();
-        } catch (Met4jSbmlReaderException e) {
-            System.err.println("Error while reading the SBML file");
-            System.err.println(e.getMessage());
-            System.exit(1);
-        }
+        BioNetwork network = IOUtils.readSbml(fileIn);
 
         //default case: everything printed
         if(!(printMetabolites|printReactions|printPathways|printGenes|printCompartments)){
@@ -124,7 +119,7 @@ public class GetSbmlEntities extends AbstractMet4jApplication {
     @Override
     public String getLongDescription() {
         return this.getShortDescription() +
-                "The output file is a tsv with two columns, one with entity identifiers, and one with the entity type. " +
+                "The output file is a tabulated file with two columns, one with entity identifiers, and one with the entity type. " +
                 "If no entity type is selected, all of them are returned by default. " +
                 "Only identifiers are written, attributes can be extracted from dedicated apps or from the Sbml2Tab app.";
     }
diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/GetReactantsFromReactions.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/GetReactantsFromReactions.java
index fadae7fb1..758fbb541 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/GetReactantsFromReactions.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/GetReactantsFromReactions.java
@@ -87,8 +87,8 @@ public class GetReactantsFromReactions extends AbstractMet4jApplication {
                     .skipIfNotFound();
             if(hasHeader) map = map.skipHeader();
             input = map.map(reactionFile);
-            System.err.println(input.size()+" reactions mapped");
-            System.err.println(map.getNumberOfSkippedEntries()+" reactions not found in model");
+            System.out.println(input.size()+" reactions mapped");
+            System.out.println(map.getNumberOfSkippedEntries()+" reactions not found in model");
         } catch (IOException e) {
             System.err.println("Error while reading the Reaction file");
             System.err.println(e.getMessage());
-- 
GitLab


From c4da07cba0b60ee6b1f067fa339d45bf9cccfb94 Mon Sep 17 00:00:00 2001
From: lcottret <ludovic.cottret@inrae.fr>
Date: Fri, 3 Jan 2025 14:17:29 +0100
Subject: [PATCH 12/74] doc and refactoring

---
 .../tabulated/attributes/SetChargesFromFile.java       |  2 +-
 .../{SbmlSetChargesFromFile.java => SetCharges.java}   | 10 +++++-----
 2 files changed, 6 insertions(+), 6 deletions(-)
 rename met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/{SbmlSetChargesFromFile.java => SetCharges.java} (92%)

diff --git a/met4j-io/src/main/java/fr/inrae/toulouse/metexplore/met4j_io/tabulated/attributes/SetChargesFromFile.java b/met4j-io/src/main/java/fr/inrae/toulouse/metexplore/met4j_io/tabulated/attributes/SetChargesFromFile.java
index a1df10bb9..773cf8322 100644
--- a/met4j-io/src/main/java/fr/inrae/toulouse/metexplore/met4j_io/tabulated/attributes/SetChargesFromFile.java
+++ b/met4j-io/src/main/java/fr/inrae/toulouse/metexplore/met4j_io/tabulated/attributes/SetChargesFromFile.java
@@ -129,7 +129,7 @@ public class SetChargesFromFile extends AbstractSetAttributesFromFile {
         }
 
 
-        System.err.println(n + " attributions");
+        System.out.println(n + " attributions");
 
         return flag;
 
diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/SbmlSetChargesFromFile.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/SetCharges.java
similarity index 92%
rename from met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/SbmlSetChargesFromFile.java
rename to met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/SetCharges.java
index 884a46140..044495e4d 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/SbmlSetChargesFromFile.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/SetCharges.java
@@ -51,7 +51,7 @@ import java.util.Set;
  * @author lcottret
  * @version $Id: $Id
  */
-public class SbmlSetChargesFromFile extends AbstractSbmlSetMetabolite {
+public class SetCharges extends AbstractSbmlSetMetabolite {
 
     @ParameterType(name= EnumParameterTypes.Integer)
     @Option(name="-cc", usage="[2] number of the column where are the charges")
@@ -76,8 +76,8 @@ public class SbmlSetChargesFromFile extends AbstractSbmlSetMetabolite {
     /** {@inheritDoc} */
     @Override
     public String getShortDescription() {
-        return "Set charge to network metabolites from a tabulated file " +
-                "containing the metabolite ids and the formulas";
+        return "Set charge to metabolites in a SBML file from a tabulated file " +
+                "containing the metabolite ids and the charges";
     }
 
     @Override
@@ -92,7 +92,7 @@ public class SbmlSetChargesFromFile extends AbstractSbmlSetMetabolite {
      */
     public static void main(String[] args) {
 
-        SbmlSetChargesFromFile app = new SbmlSetChargesFromFile();
+        SetCharges app = new SetCharges();
 
         app.parseArguments(args);
 
@@ -107,7 +107,7 @@ public class SbmlSetChargesFromFile extends AbstractSbmlSetMetabolite {
         SetChargesFromFile sgff = new SetChargesFromFile(this.colid-1, this.colcharge-1,
                 bn, this.tab, this.c, this.nSkip, this.p, this.s);
 
-        Boolean flag = true;
+        Boolean flag;
 
         try {
             flag = sgff.setAttributes();
-- 
GitLab


From d1e5b6921e186e760a012d84d9917daa7bcfb267 Mon Sep 17 00:00:00 2001
From: lcottret <ludovic.cottret@inrae.fr>
Date: Fri, 3 Jan 2025 14:18:57 +0100
Subject: [PATCH 13/74] doc and refactoring

---
 .../met4j_io/tabulated/attributes/SetEcsFromFile.java     | 2 +-
 .../{SbmlSetEcsFromFile.java => SetEcNumbers.java}        | 8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)
 rename met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/{SbmlSetEcsFromFile.java => SetEcNumbers.java} (93%)

diff --git a/met4j-io/src/main/java/fr/inrae/toulouse/metexplore/met4j_io/tabulated/attributes/SetEcsFromFile.java b/met4j-io/src/main/java/fr/inrae/toulouse/metexplore/met4j_io/tabulated/attributes/SetEcsFromFile.java
index b727d3c71..2de5ab312 100644
--- a/met4j-io/src/main/java/fr/inrae/toulouse/metexplore/met4j_io/tabulated/attributes/SetEcsFromFile.java
+++ b/met4j-io/src/main/java/fr/inrae/toulouse/metexplore/met4j_io/tabulated/attributes/SetEcsFromFile.java
@@ -126,7 +126,7 @@ public class SetEcsFromFile extends AbstractSetAttributesFromFile {
 
         }
 
-        System.err.println(n + " reactions processed");
+        System.out.println(n + " reactions processed");
 
         return flag;
 
diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/SbmlSetEcsFromFile.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/SetEcNumbers.java
similarity index 93%
rename from met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/SbmlSetEcsFromFile.java
rename to met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/SetEcNumbers.java
index ae6c9ed3f..2d7f237dd 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/SbmlSetEcsFromFile.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/SetEcNumbers.java
@@ -51,7 +51,7 @@ import java.util.Set;
  * @author lcottret
  * @version $Id: $Id
  */
-public class SbmlSetEcsFromFile extends AbstractSbmlSetReaction {
+public class SetEcNumbers extends AbstractSbmlSetReaction {
 
     @ParameterType(name= EnumParameterTypes.Integer)
     @Option(name="-cec", usage="[2] number of the column where are the ecs")
@@ -75,7 +75,7 @@ public class SbmlSetEcsFromFile extends AbstractSbmlSetReaction {
 
     @Override
     public String getShortDescription() {
-        return "Set EC numbers to reactions from a tabulated file containing the reaction ids and the EC";
+        return "Set EC numbers to reactions in a SBML file from a tabulated file containing the reaction ids and the EC";
     }
 
     @Override
@@ -89,7 +89,7 @@ public class SbmlSetEcsFromFile extends AbstractSbmlSetReaction {
      * @param args an array of {@link java.lang.String} objects.
      */
     public static void main(String[] args) {
-        SbmlSetEcsFromFile app = new SbmlSetEcsFromFile();
+        SetEcNumbers app = new SetEcNumbers();
 
         app.parseArguments(args);
 
@@ -102,7 +102,7 @@ public class SbmlSetEcsFromFile extends AbstractSbmlSetReaction {
         SetEcsFromFile sgff = new SetEcsFromFile(this.colid-1, this.colec-1, bn, this.tab,
                 this.c, this.nSkip, this.p, false);
 
-        Boolean flag = true;
+        Boolean flag ;
 
         try {
             flag = sgff.setAttributes();
-- 
GitLab


From cf19443b66bb22554b7140594c5939231d0952a8 Mon Sep 17 00:00:00 2001
From: lcottret <ludovic.cottret@inrae.fr>
Date: Fri, 3 Jan 2025 14:21:27 +0100
Subject: [PATCH 14/74] doc and refactoring

---
 .../met4j_io/tabulated/attributes/SetFormulasFromFile.java  | 2 +-
 ...bmlSetFormulasFromFile.java => SetChemicalFormulas.java} | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)
 rename met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/{SbmlSetFormulasFromFile.java => SetChemicalFormulas.java} (95%)

diff --git a/met4j-io/src/main/java/fr/inrae/toulouse/metexplore/met4j_io/tabulated/attributes/SetFormulasFromFile.java b/met4j-io/src/main/java/fr/inrae/toulouse/metexplore/met4j_io/tabulated/attributes/SetFormulasFromFile.java
index 4735dfeb0..8e29a5b59 100644
--- a/met4j-io/src/main/java/fr/inrae/toulouse/metexplore/met4j_io/tabulated/attributes/SetFormulasFromFile.java
+++ b/met4j-io/src/main/java/fr/inrae/toulouse/metexplore/met4j_io/tabulated/attributes/SetFormulasFromFile.java
@@ -113,7 +113,7 @@ public class SetFormulasFromFile extends AbstractSetAttributesFromFile {
         }
 
 
-        System.err.println(n+" attributions");
+        System.out.println(n+" attributions");
 
         return flag;
 
diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/SbmlSetFormulasFromFile.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/SetChemicalFormulas.java
similarity index 95%
rename from met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/SbmlSetFormulasFromFile.java
rename to met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/SetChemicalFormulas.java
index 2e0b5cc92..37a8ddeda 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/SbmlSetFormulasFromFile.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/SetChemicalFormulas.java
@@ -51,7 +51,7 @@ import java.util.Set;
  * @author lcottret
  * @version $Id: $Id
  */
-public class SbmlSetFormulasFromFile extends AbstractSbmlSetMetabolite {
+public class SetChemicalFormulas extends AbstractSbmlSetMetabolite {
 
     @ParameterType(name= EnumParameterTypes.Integer)
     @Option(name="-cf", usage="[2] number of the column where are the formulas")
@@ -90,7 +90,7 @@ public class SbmlSetFormulasFromFile extends AbstractSbmlSetMetabolite {
      */
     public static void main(String[] args) {
 
-        SbmlSetFormulasFromFile app = new SbmlSetFormulasFromFile();
+        SetChemicalFormulas app = new SetChemicalFormulas();
 
         app.parseArguments(args);
 
@@ -115,7 +115,7 @@ public class SbmlSetFormulasFromFile extends AbstractSbmlSetMetabolite {
         }
 
         if(!flag) {
-            System.err.println("Error in SbmlSetFormula");
+            System.err.println("Error while setting formulas");
             System.exit(1);
         }
 
-- 
GitLab


From 3ec5649ab2d7d9e0833851b5c6228baac1c7534c Mon Sep 17 00:00:00 2001
From: lcottret <ludovic.cottret@inrae.fr>
Date: Fri, 3 Jan 2025 14:51:45 +0100
Subject: [PATCH 15/74] refactoring and doc

---
 .../tabulated/attributes/SetGprsFromFile.java  |  4 ++--
 .../attributes/AbstractSbmlSetAny.java         |  2 +-
 .../{SbmlSetGprsFromFile.java => SetGprs.java} | 18 ++++++------------
 3 files changed, 9 insertions(+), 15 deletions(-)
 rename met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/{SbmlSetGprsFromFile.java => SetGprs.java} (86%)

diff --git a/met4j-io/src/main/java/fr/inrae/toulouse/metexplore/met4j_io/tabulated/attributes/SetGprsFromFile.java b/met4j-io/src/main/java/fr/inrae/toulouse/metexplore/met4j_io/tabulated/attributes/SetGprsFromFile.java
index 26e4ff946..b61bce5b5 100644
--- a/met4j-io/src/main/java/fr/inrae/toulouse/metexplore/met4j_io/tabulated/attributes/SetGprsFromFile.java
+++ b/met4j-io/src/main/java/fr/inrae/toulouse/metexplore/met4j_io/tabulated/attributes/SetGprsFromFile.java
@@ -88,7 +88,7 @@ public class SetGprsFromFile extends AbstractSetAttributesFromFile {
      */
     public Boolean setAttributes() throws IOException {
 
-        Boolean flag = true;
+        Boolean flag;
 
         try {
             flag = this.parseAttributeFile();
@@ -118,7 +118,7 @@ public class SetGprsFromFile extends AbstractSetAttributesFromFile {
             }
         }
 
-        System.err.println(this.getIdAttributeMap().size()+" gene associations created");
+        System.out.println(this.getIdAttributeMap().size()+" gene associations created");
 
         return flag;
 
diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/AbstractSbmlSetAny.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/AbstractSbmlSetAny.java
index a69383187..102e2d91a 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/AbstractSbmlSetAny.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/AbstractSbmlSetAny.java
@@ -65,7 +65,7 @@ public abstract class AbstractSbmlSetAny extends AbstractSbmlSet {
     public Boolean s=false;
 
     @ParameterType(name=Text)
-    @Option(name="-o", usage="[REACTION] Object type in the column id : REACTION;METABOLITE;GENE;PATHWAY")
+    @Option(name="-t", usage="[REACTION] Object type in the column id : REACTION;METABOLITE;GENE;PATHWAY")
     public EntityType o= EntityType.REACTION;
 
     /**
diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/SbmlSetGprsFromFile.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/SetGprs.java
similarity index 86%
rename from met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/SbmlSetGprsFromFile.java
rename to met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/SetGprs.java
index fb93771f5..efa34f02a 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/SbmlSetGprsFromFile.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/SetGprs.java
@@ -52,7 +52,7 @@ import java.util.Set;
  * @author lcottret
  * @version $Id: $Id
  */
-public class SbmlSetGprsFromFile  extends AbstractSbmlSetReaction {
+public class SetGprs extends AbstractSbmlSetReaction {
 
     @ParameterType(name= EnumParameterTypes.Integer)
     @Option(name="-cgpr", usage="[2] number of the column where are the gprs")
@@ -71,14 +71,8 @@ public class SbmlSetGprsFromFile  extends AbstractSbmlSetReaction {
                 this.setDescription +"\n" +
                 "GPR must be written in a cobra way in the tabulated file as described in Schellenberger et al 2011 Nature Protocols 6(9):1290-307\n"+
                 "(The GPR will be written in the SBML file in two locations:\n" +
-                "- in the reaction notes <p>GENE_ASSOCIATION: ( XC_0401 ) OR ( XC_3282 )</p>" +"\n" +
-                "- as fbc gene product association :" +
-                "<fbc:geneProductAssociation>\n" +
-                " <fbc:or>\n" +
-                "  <fbc:geneProductRef fbc:geneProduct=\"XC_3282\"/>\n" +
-                "  <fbc:geneProductRef fbc:geneProduct=\"XC_0401\"/>\n" +
-                " </fbc:or>\n" +
-                "</fbc:geneProductAssociation>\n";
+                "- in the reaction html notes (GENE_ASSOCIATION: ( XC_0401 ) OR ( XC_3282 ))" +"\n" +
+                "- as fbc gene product association (see FBC package specifications: https://doi.org/10.1515/jib-2017-0082)";
     }
 
     /** {@inheritDoc} */
@@ -89,7 +83,7 @@ public class SbmlSetGprsFromFile  extends AbstractSbmlSetReaction {
 
     @Override
     public Set<Doi> getDois() {
-        return Set.of();
+        return Set.of(new Doi("https://doi.org/10.1515/jib-2017-0082"), new Doi("10.1038/nprot.2011.308"));
     }
 
     /**
@@ -100,7 +94,7 @@ public class SbmlSetGprsFromFile  extends AbstractSbmlSetReaction {
      */
     public static void main(String[] args) throws IOException {
 
-        SbmlSetGprsFromFile s = new SbmlSetGprsFromFile();
+        SetGprs s = new SetGprs();
 
         s.parseArguments(args);
 
@@ -113,7 +107,7 @@ public class SbmlSetGprsFromFile  extends AbstractSbmlSetReaction {
 
         SetGprsFromFile sgff = new SetGprsFromFile(this.colid-1, this.colgpr-1, bn, this.tab, this.c, this.nSkip, this.p, false);
 
-        Boolean flag = true;
+        Boolean flag;
 
         try {
             flag = sgff.setAttributes();
-- 
GitLab


From 6ec6e384dda364035d3a3706449c8642f2a688e8 Mon Sep 17 00:00:00 2001
From: lcottret <ludovic.cottret@inrae.fr>
Date: Fri, 3 Jan 2025 14:58:43 +0100
Subject: [PATCH 16/74] doc

---
 .../metexplore/met4j_toolbox/attributes/SetEcNumbers.java | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/SetEcNumbers.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/SetEcNumbers.java
index 2d7f237dd..ef1b1cc7f 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/SetEcNumbers.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/SetEcNumbers.java
@@ -69,18 +69,18 @@ public class SetEcNumbers extends AbstractSbmlSetReaction {
     public String getLongDescription() {
         return this.getShortDescription()+"\n"+this.setDescription+"\n" +
                 "The EC will be written in the SBML file in two locations:\n" +
-                "- in the reaction notes (e.g. <p>EC_NUMBER: 2.4.2.14</p>)\n" +
-                "- as a reaction annotation (e.g. <rdf:li rdf:resource=\"http://identifiers.org/ec-code/2.4.2.14\"/>)";
+                "- in the reaction HTML notes (e.g. EC_NUMBER: 2.4.2.14)\n" +
+                "- as a reaction MIRIAM annotation (see https://pubmed.ncbi.nlm.nih.gov/16333295/) with ec-code identifiers link (https://registry.identifiers.org/registry/ec-code)";
     }
 
     @Override
     public String getShortDescription() {
-        return "Set EC numbers to reactions in a SBML file from a tabulated file containing the reaction ids and the EC";
+        return "Set EC numbers to reactions in a SBML file from a tabulated file containing the reaction ids and the EC numbers";
     }
 
     @Override
     public Set<Doi> getDois() {
-        return Set.of();
+        return Set.of(new Doi("https://doi.org/10.1038/nbt1156"));
     }
 
     /**
-- 
GitLab


From 317874f02047a323e980c70ed1525c603e7ec2c6 Mon Sep 17 00:00:00 2001
From: lcottret <ludovic.cottret@inrae.fr>
Date: Fri, 3 Jan 2025 15:00:30 +0100
Subject: [PATCH 17/74] doc

---
 .../met4j_toolbox/attributes/SetChemicalFormulas.java         | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/SetChemicalFormulas.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/SetChemicalFormulas.java
index 37a8ddeda..d3393ba45 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/SetChemicalFormulas.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/SetChemicalFormulas.java
@@ -68,7 +68,7 @@ public class SetChemicalFormulas extends AbstractSbmlSetMetabolite {
     public String getLongDescription() {
         return this.getShortDescription()+"\n"+this.setDescription+"\n" +
                 "The formula will be written in the SBML file in two locations:+\n" +
-                "- in the metabolite notes (e.g. <p>formula: C16H29O2</p>\n\n" +
+                "- in the metabolite HTML notes (e.g. formula: C16H29O2)\n" +
                 "- as a fbc attribute (e.g. fbc:chemicalFormula=\"C16H29O2\")";
     }
 
@@ -80,7 +80,7 @@ public class SetChemicalFormulas extends AbstractSbmlSetMetabolite {
 
     @Override
     public Set<Doi> getDois() {
-        return Set.of();
+        return Set.of(new Doi("https://doi.org/10.1515/jib-2017-0082"));
     }
 
     /**
-- 
GitLab


From b9c7b921c355e8d8a6338afc17637bc9926aa7aa Mon Sep 17 00:00:00 2001
From: lcottret <ludovic.cottret@inrae.fr>
Date: Fri, 3 Jan 2025 15:01:09 +0100
Subject: [PATCH 18/74] doc

---
 .../metexplore/met4j_toolbox/attributes/SetCharges.java       | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/SetCharges.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/SetCharges.java
index 044495e4d..93fc16b5c 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/SetCharges.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/SetCharges.java
@@ -69,7 +69,7 @@ public class SetCharges extends AbstractSbmlSetMetabolite {
         return this.getShortDescription()+"\n"+
                 "The charge must be a number. "+ this.setDescription+"\n" +
                 "The charge will be written in the SBML file in two locations:+\n" +
-                "- in the reaction notes (e.g. <p>charge: -1</p>)\n" +
+                "- in the reaction notes (e.g. charge: -1)\n" +
                 "- as fbc attribute (e.g. fbc:charge=\"1\")";
     }
 
@@ -82,7 +82,7 @@ public class SetCharges extends AbstractSbmlSetMetabolite {
 
     @Override
     public Set<Doi> getDois() {
-        return Set.of();
+        return Set.of(new Doi("https://doi.org/10.1515/jib-2017-0082"));
     }
 
     /**
-- 
GitLab


From 69f53003dcdf892374cdbb34fb7230ee672d9d82 Mon Sep 17 00:00:00 2001
From: lcottret <ludovic.cottret@inrae.fr>
Date: Fri, 3 Jan 2025 15:15:40 +0100
Subject: [PATCH 19/74] small refactoring

---
 .../met4j_io/tabulated/attributes/SetIdsFromFile.java         | 2 +-
 .../met4j_toolbox/attributes/SbmlSetIdsFromFile.java          | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/met4j-io/src/main/java/fr/inrae/toulouse/metexplore/met4j_io/tabulated/attributes/SetIdsFromFile.java b/met4j-io/src/main/java/fr/inrae/toulouse/metexplore/met4j_io/tabulated/attributes/SetIdsFromFile.java
index 78a46d598..2da020062 100644
--- a/met4j-io/src/main/java/fr/inrae/toulouse/metexplore/met4j_io/tabulated/attributes/SetIdsFromFile.java
+++ b/met4j-io/src/main/java/fr/inrae/toulouse/metexplore/met4j_io/tabulated/attributes/SetIdsFromFile.java
@@ -117,7 +117,7 @@ public class SetIdsFromFile extends AbstractSetAttributesFromFile {
             }
         }
 
-        System.err.println(n + " entities processed");
+        System.out.println(n + " entities processed");
 
         return true;
     }
diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/SbmlSetIdsFromFile.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/SbmlSetIdsFromFile.java
index 0ce64ca8a..247f2c519 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/SbmlSetIdsFromFile.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/SbmlSetIdsFromFile.java
@@ -67,7 +67,7 @@ public class SbmlSetIdsFromFile extends AbstractSbmlSetAny {
     /** {@inheritDoc} */
     @Override
     public String getShortDescription() {
-        return "Set new ids to network objects from a tabulated file containing the old ids and the new ids";
+        return "Set new ids to network objects in a SBML file from a tabulated file containing the old ids and the new ids";
     }
 
     @Override
@@ -97,7 +97,7 @@ public class SbmlSetIdsFromFile extends AbstractSbmlSetAny {
         SetIdsFromFile setter = new SetIdsFromFile(this.colid-1, this.colname-1,
                 bn, this.tab, this.c, this.nSkip, this.o, this.p, this.s);
 
-        Boolean flag = true;
+        Boolean flag;
 
         try {
             flag = setter.setAttributes();
-- 
GitLab


From 81daa2e81b27e9f9611b1f66b48e9ba851a50037 Mon Sep 17 00:00:00 2001
From: lcottret <ludovic.cottret@inrae.fr>
Date: Fri, 3 Jan 2025 15:16:16 +0100
Subject: [PATCH 20/74] move SbmlSetIds to SetIds

---
 .../attributes/{SbmlSetIdsFromFile.java => SetIds.java}      | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
 rename met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/{SbmlSetIdsFromFile.java => SetIds.java} (94%)

diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/SbmlSetIdsFromFile.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/SetIds.java
similarity index 94%
rename from met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/SbmlSetIdsFromFile.java
rename to met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/SetIds.java
index 247f2c519..36000a8ad 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/SbmlSetIdsFromFile.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/SetIds.java
@@ -37,7 +37,6 @@ package fr.inrae.toulouse.metexplore.met4j_toolbox.attributes;
 
 import fr.inrae.toulouse.metexplore.met4j_core.biodata.BioNetwork;
 import fr.inrae.toulouse.metexplore.met4j_io.tabulated.attributes.SetIdsFromFile;
-import fr.inrae.toulouse.metexplore.met4j_io.tabulated.attributes.SetNamesFromFile;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumParameterTypes;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.ParameterType;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.utils.Doi;
@@ -45,7 +44,7 @@ import org.kohsuke.args4j.Option;
 
 import java.util.Set;
 
-public class SbmlSetIdsFromFile extends AbstractSbmlSetAny {
+public class SetIds extends AbstractSbmlSetAny {
 
     @ParameterType(name= EnumParameterTypes.Integer)
     @Option(name="-cnew", usage="[2] number of the column where are the new ids")
@@ -82,7 +81,7 @@ public class SbmlSetIdsFromFile extends AbstractSbmlSetAny {
      */
     public static void main(String[] args) {
 
-        SbmlSetIdsFromFile app = new SbmlSetIdsFromFile();
+        SetIds app = new SetIds();
 
         app.parseArguments(args);
 
-- 
GitLab


From 0ae12a99b7ea646813f2acd353429a43619d5883 Mon Sep 17 00:00:00 2001
From: lcottret <ludovic.cottret@inrae.fr>
Date: Fri, 3 Jan 2025 15:17:19 +0100
Subject: [PATCH 21/74] refactoring

---
 .../met4j_io/tabulated/attributes/SetNamesFromFile.java  | 2 +-
 .../{SbmlSetNamesFromFile.java => SetNames.java}         | 9 ++++-----
 2 files changed, 5 insertions(+), 6 deletions(-)
 rename met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/{SbmlSetNamesFromFile.java => SetNames.java} (91%)

diff --git a/met4j-io/src/main/java/fr/inrae/toulouse/metexplore/met4j_io/tabulated/attributes/SetNamesFromFile.java b/met4j-io/src/main/java/fr/inrae/toulouse/metexplore/met4j_io/tabulated/attributes/SetNamesFromFile.java
index e0dde0f5a..c0d78e244 100644
--- a/met4j-io/src/main/java/fr/inrae/toulouse/metexplore/met4j_io/tabulated/attributes/SetNamesFromFile.java
+++ b/met4j-io/src/main/java/fr/inrae/toulouse/metexplore/met4j_io/tabulated/attributes/SetNamesFromFile.java
@@ -142,7 +142,7 @@ public class SetNamesFromFile extends AbstractSetAttributesFromFile {
             object.setName(name);
         }
 
-        System.err.println(n+" attributions");
+        System.out.println(n+" attributions");
 
         return flag;
 
diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/SbmlSetNamesFromFile.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/SetNames.java
similarity index 91%
rename from met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/SbmlSetNamesFromFile.java
rename to met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/SetNames.java
index cae147f53..956752a12 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/SbmlSetNamesFromFile.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/SetNames.java
@@ -37,7 +37,6 @@
 package fr.inrae.toulouse.metexplore.met4j_toolbox.attributes;
 
 import fr.inrae.toulouse.metexplore.met4j_core.biodata.BioNetwork;
-import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.JsbmlReader;
 import fr.inrae.toulouse.metexplore.met4j_io.tabulated.attributes.SetNamesFromFile;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumParameterTypes;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.ParameterType;
@@ -52,7 +51,7 @@ import java.util.Set;
  * @author lcottret
  * @version $Id: $Id
  */
-public class SbmlSetNamesFromFile extends AbstractSbmlSetAny {
+public class SetNames extends AbstractSbmlSetAny {
 
     @ParameterType(name= EnumParameterTypes.Integer)
     @Option(name="-cname", usage="[2] number of the column where are the names")
@@ -74,7 +73,7 @@ public class SbmlSetNamesFromFile extends AbstractSbmlSetAny {
     /** {@inheritDoc} */
     @Override
     public String getShortDescription() {
-        return "Set names to network objects from a tabulated file containing the object ids and the names";
+        return "Set names to network objects in a SBML file from a tabulated file containing the object ids and the names";
     }
 
     @Override
@@ -89,7 +88,7 @@ public class SbmlSetNamesFromFile extends AbstractSbmlSetAny {
      */
     public static void main(String[] args) {
 
-        SbmlSetNamesFromFile app = new SbmlSetNamesFromFile();
+        SetNames app = new SetNames();
 
         app.parseArguments(args);
 
@@ -104,7 +103,7 @@ public class SbmlSetNamesFromFile extends AbstractSbmlSetAny {
         SetNamesFromFile sgff = new SetNamesFromFile(this.colid-1, this.colname-1,
                 bn, this.tab, this.c, this.nSkip, this.p, this.s, this.o);
 
-        Boolean flag = true;
+        Boolean flag;
 
         try {
             flag = sgff.setAttributes();
-- 
GitLab


From 41ad815209c2a99ac2833990047e62a4515c226b Mon Sep 17 00:00:00 2001
From: lcottret <ludovic.cottret@inrae.fr>
Date: Fri, 3 Jan 2025 15:20:01 +0100
Subject: [PATCH 22/74] refactoring

---
 .../attributes/SetPathwaysFromFile.java          |  4 ++--
 ...SetPathwaysFromFile.java => SetPathways.java} | 16 ++++++----------
 2 files changed, 8 insertions(+), 12 deletions(-)
 rename met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/{SbmlSetPathwaysFromFile.java => SetPathways.java} (85%)

diff --git a/met4j-io/src/main/java/fr/inrae/toulouse/metexplore/met4j_io/tabulated/attributes/SetPathwaysFromFile.java b/met4j-io/src/main/java/fr/inrae/toulouse/metexplore/met4j_io/tabulated/attributes/SetPathwaysFromFile.java
index a4a950eb9..cde676f4f 100644
--- a/met4j-io/src/main/java/fr/inrae/toulouse/metexplore/met4j_io/tabulated/attributes/SetPathwaysFromFile.java
+++ b/met4j-io/src/main/java/fr/inrae/toulouse/metexplore/met4j_io/tabulated/attributes/SetPathwaysFromFile.java
@@ -104,7 +104,7 @@ public class SetPathwaysFromFile extends AbstractSetAttributesFromFile {
      */
     public Boolean setAttributes() throws IOException {
 
-        Boolean flag = true;
+        Boolean flag;
 
         try {
             flag = this.parseAttributeFile();
@@ -169,7 +169,7 @@ public class SetPathwaysFromFile extends AbstractSetAttributesFromFile {
                 filter(bioPathway -> this.bn.getReactionsFromPathways(bioPathway).isEmpty())
                 .forEach(emptyPathway -> this.bn.removeOnCascade(emptyPathway));
 
-        System.err.println(n + " reactions processed");
+        System.out.println(n + " reactions processed");
 
         return flag;
 
diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/SbmlSetPathwaysFromFile.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/SetPathways.java
similarity index 85%
rename from met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/SbmlSetPathwaysFromFile.java
rename to met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/SetPathways.java
index 058779511..396f5b58e 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/SbmlSetPathwaysFromFile.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/SetPathways.java
@@ -51,7 +51,7 @@ import java.util.Set;
  * @author lcottret
  * @version $Id: $Id
  */
-public class SbmlSetPathwaysFromFile extends AbstractSbmlSetReaction {
+public class SetPathways extends AbstractSbmlSetReaction {
 
     @ParameterType(name= EnumParameterTypes.Integer)
     @Option(name="-cp", usage="[2] number of the column where are the pathways")
@@ -73,12 +73,8 @@ public class SbmlSetPathwaysFromFile extends AbstractSbmlSetReaction {
         return this.getShortDescription()+"\n" +
                 this.setDescription+"\n" +
                 "Pathways will be written in the SBML file in two ways:" +
-                "- as reaction note (e.g. <p>SUBSYSTEM: purine_biosynthesis</p>)" +
-                "- as SBML group:\n" +
-                        "<groups:group groups:id=\"purine_biosynthesis\" groups:kind=\"classification\" groups:name=\"purine_biosynthesis\">\n" +
-                        " <groups:listOfMembers>\n" +
-                        "  <groups:member groups:idRef=\"R_GLUPRT\"/>\n" +
-                        "  <groups:member groups:idRef=\"R_RNDR1b\"/>\n...\n";
+                "- as reaction note (e.g. SUBSYSTEM: purine_biosynthesis)" +
+                "- as SBML group (see Group package specifications: https://pmc.ncbi.nlm.nih.gov/articles/PMC5451322/)";
     }
 
     /** {@inheritDoc} */
@@ -89,7 +85,7 @@ public class SbmlSetPathwaysFromFile extends AbstractSbmlSetReaction {
 
     @Override
     public Set<Doi> getDois() {
-        return Set.of();
+        return Set.of(new Doi("10.2390/biecoll-jib-2016-290"));
     }
 
     /**
@@ -99,7 +95,7 @@ public class SbmlSetPathwaysFromFile extends AbstractSbmlSetReaction {
      */
     public static void main(String[] args) {
 
-        SbmlSetPathwaysFromFile app = new SbmlSetPathwaysFromFile();
+        SetPathways app = new SetPathways();
 
         app.parseArguments(args);
 
@@ -114,7 +110,7 @@ public class SbmlSetPathwaysFromFile extends AbstractSbmlSetReaction {
         SetPathwaysFromFile sgff = new SetPathwaysFromFile(this.colid-1, this.colp-1, bn, this.tab,
                 this.c, this.nSkip, this.p, false, this.sep);
 
-        Boolean flag = true;
+        Boolean flag;
 
         try {
             flag = sgff.setAttributes();
-- 
GitLab


From e376040207d93d4f90228c94eab348c5b194d754 Mon Sep 17 00:00:00 2001
From: lcottret <ludovic.cottret@inrae.fr>
Date: Fri, 3 Jan 2025 15:24:10 +0100
Subject: [PATCH 23/74] refactoring and doc

---
 .../tabulated/attributes/SetRefsFromFile.java |  4 ++--
 ...etRefsFromFile.java => SetReferences.java} | 19 +++++++++----------
 2 files changed, 11 insertions(+), 12 deletions(-)
 rename met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/{SbmlSetRefsFromFile.java => SetReferences.java} (84%)

diff --git a/met4j-io/src/main/java/fr/inrae/toulouse/metexplore/met4j_io/tabulated/attributes/SetRefsFromFile.java b/met4j-io/src/main/java/fr/inrae/toulouse/metexplore/met4j_io/tabulated/attributes/SetRefsFromFile.java
index 6f6bd05bf..eb4f0440a 100644
--- a/met4j-io/src/main/java/fr/inrae/toulouse/metexplore/met4j_io/tabulated/attributes/SetRefsFromFile.java
+++ b/met4j-io/src/main/java/fr/inrae/toulouse/metexplore/met4j_io/tabulated/attributes/SetRefsFromFile.java
@@ -87,7 +87,7 @@ public class SetRefsFromFile extends AbstractSetAttributesFromFile {
      */
     public Boolean setAttributes() throws IOException {
 
-        Boolean flag = true;
+        Boolean flag;
 
         try {
             flag = this.parseAttributeFile();
@@ -144,7 +144,7 @@ public class SetRefsFromFile extends AbstractSetAttributesFromFile {
             object.addRef(new BioRef("attributesTable", this.ref, this.getIdAttributeMap().get(id), 1));
         }
 
-        System.err.println(n+" attributions");
+        System.out.println(n+" attributions");
 
         return flag;
 
diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/SbmlSetRefsFromFile.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/SetReferences.java
similarity index 84%
rename from met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/SbmlSetRefsFromFile.java
rename to met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/SetReferences.java
index e7acbb4d7..4a968e4b5 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/SbmlSetRefsFromFile.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/SetReferences.java
@@ -37,7 +37,6 @@
 package fr.inrae.toulouse.metexplore.met4j_toolbox.attributes;
 
 import fr.inrae.toulouse.metexplore.met4j_core.biodata.BioNetwork;
-import fr.inrae.toulouse.metexplore.met4j_io.tabulated.attributes.SetChargesFromFile;
 import fr.inrae.toulouse.metexplore.met4j_io.tabulated.attributes.SetRefsFromFile;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumParameterTypes;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.ParameterType;
@@ -52,13 +51,13 @@ import java.util.Set;
  * @author lcottret
  * @version $Id: $Id
  */
-public class SbmlSetRefsFromFile extends AbstractSbmlSetAny {
+public class SetReferences extends AbstractSbmlSetAny {
 
     @ParameterType(name= EnumParameterTypes.Integer)
     @Option(name="-cr", usage="[2] number of the column where are the references")
     public int colRef=2;
 
-    @Option(name="-ref", usage="Name of the ref. Must exist in identifiers.org", required = true)
+    @Option(name="-ref", usage="Name of the reference. Must exist in identifiers.org (https://registry.identifiers.org/registry)", required = true)
     public String ref=null;
 
     /** {@inheritDoc} */
@@ -71,20 +70,20 @@ public class SbmlSetRefsFromFile extends AbstractSbmlSetAny {
     @Override
     public String getLongDescription() {
         return this.getShortDescription()+"\n" +
-                "Reference name given as parameter (-ref) must correspond to an existing id the " +
-                "registry of  identifiers.org (https://registry.identifiers.org/registry)\n" +
-                "The corresponding key:value pair will be written as metabolite or reaction annotation";
+                "Reference name given as parameter (-ref) must correspond to an existing id in the " +
+                "registry of identifiers.org (https://registry.identifiers.org/registry)\n" +
+                "The corresponding key:value pair will be written as metabolite or reaction MIRIAM annotation (see https://pubmed.ncbi.nlm.nih.gov/16333295/)";
     }
 
     /** {@inheritDoc} */
     @Override
     public String getShortDescription() {
-        return "Add refs to network objects from a tabulated file containing the metabolite ids and the formulas";
+        return "Add references to network objects in a SBML file from a tabulated file containing the metabolite ids and the references";
     }
 
     @Override
     public Set<Doi> getDois() {
-        return Set.of();
+        return Set.of(new Doi("https://doi.org/10.1038/nbt1156"));
     }
 
     /**
@@ -94,7 +93,7 @@ public class SbmlSetRefsFromFile extends AbstractSbmlSetAny {
      */
     public static void main(String[] args) {
 
-        SbmlSetRefsFromFile app = new SbmlSetRefsFromFile();
+        SetReferences app = new SetReferences();
 
         app.parseArguments(args);
 
@@ -108,7 +107,7 @@ public class SbmlSetRefsFromFile extends AbstractSbmlSetAny {
         SetRefsFromFile s = new SetRefsFromFile(this.colid-1, this.colRef-1,
                 bn, this.tab, this.c, this.nSkip, this.p, this.s, this.ref, this.o);
 
-        Boolean flag = true;
+        Boolean flag;
 
         try {
             flag = s.setAttributes();
-- 
GitLab


From 3c99763f538ca41d6588fff9eb97a32ab0df65fd Mon Sep 17 00:00:00 2001
From: lcottret <ludovic.cottret@inrae.fr>
Date: Fri, 3 Jan 2025 15:26:14 +0100
Subject: [PATCH 24/74] refactoring and doc

---
 ...able.java => GetMetaboliteAttributes.java} | 23 ++++---------------
 1 file changed, 5 insertions(+), 18 deletions(-)
 rename met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/{SbmlToMetaboliteTable.java => GetMetaboliteAttributes.java} (86%)

diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/SbmlToMetaboliteTable.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/GetMetaboliteAttributes.java
similarity index 86%
rename from met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/SbmlToMetaboliteTable.java
rename to met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/GetMetaboliteAttributes.java
index 7ee464c1f..c17a8bf7b 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/SbmlToMetaboliteTable.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/GetMetaboliteAttributes.java
@@ -38,14 +38,13 @@ package fr.inrae.toulouse.metexplore.met4j_toolbox.attributes;
 
 import fr.inrae.toulouse.metexplore.met4j_core.biodata.BioMetabolite;
 import fr.inrae.toulouse.metexplore.met4j_core.biodata.BioNetwork;
-import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.JsbmlReader;
-import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.Met4jSbmlReaderException;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.AbstractMet4jApplication;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumFormats;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumParameterTypes;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.Format;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.ParameterType;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.utils.Doi;
+import fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils;
 import org.kohsuke.args4j.Option;
 
 import java.io.FileWriter;
@@ -59,11 +58,11 @@ import java.util.Set;
  * @author lcottret
  * @version $Id: $Id
  */
-public class SbmlToMetaboliteTable extends AbstractMet4jApplication {
+public class GetMetaboliteAttributes extends AbstractMet4jApplication {
 
     @ParameterType(name= EnumParameterTypes.InputFile)
     @Format(name= EnumFormats.Sbml)
-    @Option(name = "-s", usage = "Sbml file", required = true)
+    @Option(name = "-i", usage = "Input SBML file", required = true)
     public String sbml;
 
     @ParameterType(name= EnumParameterTypes.OutputFile)
@@ -77,7 +76,7 @@ public class SbmlToMetaboliteTable extends AbstractMet4jApplication {
      * @param args an array of {@link java.lang.String} objects.
      */
     public static void main(String[] args) {
-        SbmlToMetaboliteTable app = new SbmlToMetaboliteTable();
+        GetMetaboliteAttributes app = new GetMetaboliteAttributes();
 
         app.parseArguments(args);
 
@@ -109,19 +108,7 @@ public class SbmlToMetaboliteTable extends AbstractMet4jApplication {
     }
 
     BioNetwork readSbml() {
-        JsbmlReader reader = new JsbmlReader(this.sbml);
-
-        BioNetwork bn = null;
-        try {
-            bn = reader.read();
-        } catch (Met4jSbmlReaderException e) {
-            e.printStackTrace();
-            System.err.println("Problem while reading the sbml file " + this.sbml);
-            System.exit(1);
-        }
-
-        return bn;
-
+        return IOUtils.readSbml(this.sbml);
     }
 
 
-- 
GitLab


From a481dd9b14f6e2c37564fbf7993c9828cdc31e2a Mon Sep 17 00:00:00 2001
From: lcottret <ludovic.cottret@inrae.fr>
Date: Fri, 3 Jan 2025 15:29:20 +0100
Subject: [PATCH 25/74] refactoring and doc

---
 ...ModelProteome.java => GetBiggModelProteome.java} | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)
 rename met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/bigg/{GetModelProteome.java => GetBiggModelProteome.java} (97%)

diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/bigg/GetModelProteome.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/bigg/GetBiggModelProteome.java
similarity index 97%
rename from met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/bigg/GetModelProteome.java
rename to met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/bigg/GetBiggModelProteome.java
index 7e144df98..78742f9c4 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/bigg/GetModelProteome.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/bigg/GetBiggModelProteome.java
@@ -67,9 +67,9 @@ import java.util.Set;
  * @author lcottret
  * @version $Id: $Id
  */
-public class GetModelProteome extends AbstractMet4jApplication {
+public class GetBiggModelProteome extends AbstractMet4jApplication {
 
-    public String description = "Get proteome in fasta format of a model present in BIGG";
+    public String description = "Get proteome in fasta format of a model present in the BIGG database";
 
     @Option(name = "-m", usage = "[ex: iMM904] id of the BIGG model", required = true)
     public String modelId = "iMM904";
@@ -89,7 +89,7 @@ public class GetModelProteome extends AbstractMet4jApplication {
      */
     public static void main(String[] args)  {
 
-        GetModelProteome f = new GetModelProteome();
+        GetBiggModelProteome f = new GetBiggModelProteome();
         CmdLineParser parser = new CmdLineParser(f);
 
         try {
@@ -159,8 +159,6 @@ public class GetModelProteome extends AbstractMet4jApplication {
             System.exit(1);
         }
 
-
-        return;
     }
 
 
@@ -330,9 +328,6 @@ public class GetModelProteome extends AbstractMet4jApplication {
 
         writer.close();
 
-        return;
-
-
     }
 
 
@@ -356,6 +351,6 @@ public class GetModelProteome extends AbstractMet4jApplication {
 
     @Override
     public Set<Doi> getDois() {
-        return Set.of();
+        return Set.of(new Doi("doi:10.1093/nar/gkv1049"));
     }
 }
-- 
GitLab


From 46e1f97be80c9c6ddcd9b80fdcc91f70bad5cf5e Mon Sep 17 00:00:00 2001
From: lcottret <ludovic.cottret@inrae.fr>
Date: Fri, 3 Jan 2025 15:31:51 +0100
Subject: [PATCH 26/74] doc

---
 .../met4j_toolbox/convert/FbcToNotes.java     | 22 ++++++-------------
 1 file changed, 7 insertions(+), 15 deletions(-)

diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/convert/FbcToNotes.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/convert/FbcToNotes.java
index b6af1f7ef..b721287db 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/convert/FbcToNotes.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/convert/FbcToNotes.java
@@ -50,6 +50,7 @@ import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumFormat
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.Format;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.ParameterType;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.utils.Doi;
+import fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils;
 import org.kohsuke.args4j.CmdLineException;
 import org.kohsuke.args4j.CmdLineParser;
 import org.kohsuke.args4j.Option;
@@ -72,12 +73,12 @@ public class FbcToNotes extends AbstractMet4jApplication {
 
     @Format(name= Sbml)
     @ParameterType(name = InputFile)
-    @Option(name = "-i", usage = "input file", required = true)
+    @Option(name = "-i", usage = "input SBML file", required = true)
     public String inputPath = null;
 
     @Format(name= Sbml)
     @ParameterType(name = OutputFile)
-    @Option(name = "-o", usage = "output file", required = true)
+    @Option(name = "-o", usage = "output SBML file", required = true)
     public String outputPath = null;
 
     /**
@@ -108,16 +109,7 @@ public class FbcToNotes extends AbstractMet4jApplication {
 
     private void run() {
 
-        JsbmlReader reader = new JsbmlReader(this.inputPath);
-
-        BioNetwork network = null;
-        try {
-            network = reader.read();
-        } catch (Met4jSbmlReaderException e) {
-            System.err.println("Error while reading the SBML file");
-            System.err.println(e.getMessage());
-            System.exit(1);
-        }
+        BioNetwork network = IOUtils.readSbml(this.inputPath);
 
         JsbmlWriter writer = new JsbmlWriter(this.outputPath, network, 3, 1, false );
 
@@ -146,18 +138,18 @@ public class FbcToNotes extends AbstractMet4jApplication {
     /** {@inheritDoc} */
     @Override
     public String getLongDescription() {
-        return this.getShortDescription();
+        return this.getShortDescription() + " (see https://www.degruyter.com/document/doi/10.1515/jib-2017-0082/html)";
     }
 
     /** {@inheritDoc} */
     @Override
     public String getShortDescription() {
-        return "Convert FBC package annotations to sbml notes";
+        return "Convert FBC package annotations to sbml html notes";
     }
 
     @Override
     public Set<Doi> getDois() {
-        return Set.of();
+        return Set.of(new Doi("https://doi.org/10.1515/jib-2017-0082"));
     }
 
 
-- 
GitLab


From 7d9c53e34ae5658f007d20f85a1a42f91571e2c6 Mon Sep 17 00:00:00 2001
From: lcottret <ludovic.cottret@inrae.fr>
Date: Fri, 3 Jan 2025 15:33:32 +0100
Subject: [PATCH 27/74] doc and refactoring

---
 .../metexplore/met4j_toolbox/convert/Kegg2Sbml.java | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/convert/Kegg2Sbml.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/convert/Kegg2Sbml.java
index cf498a57e..d5cf11daf 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/convert/Kegg2Sbml.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/convert/Kegg2Sbml.java
@@ -43,6 +43,7 @@ import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.AbstractMet4jApplicati
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.Format;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.ParameterType;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.utils.Doi;
+import fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils;
 import org.kohsuke.args4j.Option;
 
 import java.util.Set;
@@ -57,7 +58,7 @@ public class Kegg2Sbml  extends AbstractMet4jApplication  {
 
     @Format(name= Sbml)
     @ParameterType(name = OutputFile)
-    @Option(name="-sbml", usage="[out.sbml] Out sbml file")
+    @Option(name="-o", usage="[out.sbml] Out sbml file")
     public String sbml = "out.sbml";
 
     @Override
@@ -106,15 +107,7 @@ public class Kegg2Sbml  extends AbstractMet4jApplication  {
 
         BioNetwork network = k.getNetwork();
 
-        JsbmlWriter writer = new JsbmlWriter(this.sbml, network);
-
-        try {
-            writer.write();
-        } catch (Met4jSbmlWriterException e) {
-            System.err.println("Error while writing the SBML file");
-            System.err.println(e.getMessage());
-            System.exit(1);
-        }
+        IOUtils.writeSbml(network, this.sbml);
 
     }
 }
-- 
GitLab


From f066988ea4688f04749e4aaf345556997abe4c35 Mon Sep 17 00:00:00 2001
From: lcottret <ludovic.cottret@inrae.fr>
Date: Fri, 3 Jan 2025 15:36:34 +0100
Subject: [PATCH 28/74] doc

---
 .../metexplore/met4j_toolbox/convert/Sbml2Graph.java         | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/convert/Sbml2Graph.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/convert/Sbml2Graph.java
index 147d3ab5a..04b7fa0cb 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/convert/Sbml2Graph.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/convert/Sbml2Graph.java
@@ -105,7 +105,6 @@ public class Sbml2Graph extends AbstractMet4jApplication {
                 ExportGraph.toTab(graph, this.outputPath);
             }
         }
-        return;
     }
 
     @Override
@@ -116,7 +115,7 @@ public class Sbml2Graph extends AbstractMet4jApplication {
     @Override
     public String getLongDescription() {
         return this.getShortDescription() + "\n" +
-                "The graph can be either a compound graph or a bipartite graph, and can be exported in gml or tabulated file format.";
+                "The graph can be either a compound graph, a reaction graph or a bipartite graph, and can be exported in gml or tabulated file format.";
     }
 
     @Override
@@ -126,7 +125,7 @@ public class Sbml2Graph extends AbstractMet4jApplication {
 
     @Override
     public Set<Doi> getDois() {
-        return Set.of();
+        return Set.of(new Doi("https://doi.org/10.1109/tcbb.2008.79"));
     }
 
 }
-- 
GitLab


From dccf624ce1a9f38f4d54986b2ece2c1bcbe70d4c Mon Sep 17 00:00:00 2001
From: lcottret <ludovic.cottret@inrae.fr>
Date: Fri, 3 Jan 2025 15:38:32 +0100
Subject: [PATCH 29/74] doc

---
 .../met4j_toolbox/convert/Sbml2Tab.java       | 21 +++++--------------
 1 file changed, 5 insertions(+), 16 deletions(-)

diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/convert/Sbml2Tab.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/convert/Sbml2Tab.java
index d0dfcb9e7..fed8ac959 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/convert/Sbml2Tab.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/convert/Sbml2Tab.java
@@ -46,6 +46,7 @@ import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumParame
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.Format;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.ParameterType;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.utils.Doi;
+import fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils;
 import org.kohsuke.args4j.Option;
 
 import java.io.IOException;
@@ -67,12 +68,12 @@ public class Sbml2Tab extends AbstractMet4jApplication {
 
     @Format(name = EnumFormats.Tsv)
     @ParameterType(name = EnumParameterTypes.OutputFile)
-    @Option(name = "-out", usage = "[out.tsv] Tabulated file")
+    @Option(name = "-o", usage = "[out.tsv] Tabulated file")
     public String out = "out.tsv";
 
     @ParameterType(name = EnumParameterTypes.InputFile)
     @Format(name = EnumFormats.Sbml)
-    @Option(name = "-in", usage = "Sbml file", required = true)
+    @Option(name = "-i", usage = "Sbml file", required = true)
     public String in;
 
 
@@ -97,17 +98,7 @@ public class Sbml2Tab extends AbstractMet4jApplication {
 
         String fileIn = this.in;
 
-        JsbmlReader reader = new JsbmlReader(fileIn);
-
-        BioNetwork network = null;
-        try {
-            network = reader.read();
-        } catch (Met4jSbmlReaderException e) {
-            e.printStackTrace();
-            System.err.println("Error while reading the SBML file");
-            System.err.println(e.getMessage());
-            System.exit(1);
-        }
+        BioNetwork network = IOUtils.readSbml(fileIn);
 
         BioNetwork2Tab bioNetwork2Tab = new BioNetwork2Tab(network, this.out, this.r, this.i);
 
@@ -119,8 +110,6 @@ public class Sbml2Tab extends AbstractMet4jApplication {
             System.exit(1);
         }
 
-        return;
-
     }
 
     /**
@@ -144,7 +133,7 @@ public class Sbml2Tab extends AbstractMet4jApplication {
      */
     @Override
     public String getShortDescription() {
-        return "Create a tabulated file from a SBML file";
+        return "Create a tabulated file listing reaction attributes from a SBML file";
     }
 
     @Override
-- 
GitLab


From f0e51ec60bfb87d102eb3c341f0f55f16e862cf6 Mon Sep 17 00:00:00 2001
From: lcottret <ludovic.cottret@inrae.fr>
Date: Fri, 3 Jan 2025 15:42:18 +0100
Subject: [PATCH 30/74] doc

---
 .../{SBMLwizard.java => SbmlWizard.java}      | 42 +++++--------------
 1 file changed, 11 insertions(+), 31 deletions(-)
 rename met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/convert/{SBMLwizard.java => SbmlWizard.java} (86%)

diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/convert/SBMLwizard.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/convert/SbmlWizard.java
similarity index 86%
rename from met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/convert/SBMLwizard.java
rename to met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/convert/SbmlWizard.java
index 4c3ebbcee..e235357da 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/convert/SBMLwizard.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/convert/SbmlWizard.java
@@ -5,13 +5,6 @@ import fr.inrae.toulouse.metexplore.met4j_core.biodata.collection.BioCollection;
 import fr.inrae.toulouse.metexplore.met4j_core.biodata.utils.BioNetworkUtils;
 import fr.inrae.toulouse.metexplore.met4j_core.biodata.utils.CompartmentMerger;
 import fr.inrae.toulouse.metexplore.met4j_io.annotations.reaction.ReactionAttributes;
-import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.JsbmlReader;
-import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.Met4jSbmlReaderException;
-import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.plugin.FBCParser;
-import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.plugin.GroupPathwayParser;
-import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.plugin.NotesParser;
-import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.plugin.PackageParser;
-import fr.inrae.toulouse.metexplore.met4j_io.jsbml.writer.JsbmlWriter;
 import fr.inrae.toulouse.metexplore.met4j_io.jsbml.writer.Met4jSbmlWriterException;
 import fr.inrae.toulouse.metexplore.met4j_mapping.Mapper;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.AbstractMet4jApplication;
@@ -20,23 +13,22 @@ import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumParame
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.Format;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.ParameterType;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.utils.Doi;
+import fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils;
 import org.kohsuke.args4j.Option;
 
 import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.Set;
 
-public class SBMLwizard extends AbstractMet4jApplication {
+public class SbmlWizard extends AbstractMet4jApplication {
 
     @Format(name = EnumFormats.Sbml)
     @ParameterType(name = EnumParameterTypes.InputFile)
-    @Option(name = "-s", usage = "input SBML file", required = true)
+    @Option(name = "-i", usage = "input SBML file", required = true)
     public String inputPath = null;
 
     @ParameterType(name = EnumParameterTypes.InputFile)
     @Format(name = EnumFormats.Txt)
-    @Option(name = "-rc", usage = "file containing identifiers of compounds to remove from the metabolic network", required = false)
+    @Option(name = "-rc", usage = "file containing identifiers of compounds to remove from the metabolic network")
     public String inputSide = null;
 
     @Option(name = "-ric", aliases = {"--noIsolated"}, usage = "remove isolated compounds (not involved in any reaction)")
@@ -44,7 +36,7 @@ public class SBMLwizard extends AbstractMet4jApplication {
 
     @ParameterType(name = EnumParameterTypes.InputFile)
     @Format(name = EnumFormats.Txt)
-    @Option(name = "-rr", usage = "file containing identifiers of reactions to remove from the metabolic network", required = false)
+    @Option(name = "-rr", usage = "file containing identifiers of reactions to remove from the metabolic network")
     public String inputReactions = null;
 
     @ParameterType(name = EnumParameterTypes.OutputFile)
@@ -65,12 +57,12 @@ public class SBMLwizard extends AbstractMet4jApplication {
     public boolean removeDuplicated;
 
 
-    @Option(name = "-rEX", aliases = {"--removeExchange"}, usage = "remove exchange reactions and species from given exchange compartment identifier", required = false)
+    @Option(name = "-rEX", aliases = {"--removeExchange"}, usage = "remove exchange reactions and species from given exchange compartment identifier")
     public String exchangeCompToRemove;
 
     public static void main(String[] args) throws Met4jSbmlWriterException, IOException {
 
-        SBMLwizard app = new SBMLwizard();
+        SbmlWizard app = new SbmlWizard();
 
         app.parseArguments(args);
 
@@ -81,19 +73,8 @@ public class SBMLwizard extends AbstractMet4jApplication {
 
     public void run() throws Met4jSbmlWriterException, IOException {
         System.out.print("Reading SBML...");
-        JsbmlReader reader = new JsbmlReader(this.inputPath);
-        ArrayList<PackageParser> pkgs = new ArrayList<>(Arrays.asList(
-                new NotesParser(false), new FBCParser(), new GroupPathwayParser()));
-
-        BioNetwork network = null;
-
-        try {
-            network = reader.read(pkgs);
-        } catch (Met4jSbmlReaderException e) {
-            System.err.println("Error while reading the SBML file");
-            System.err.println(e.getMessage());
-            System.exit(1);
-        }
+
+        BioNetwork network = IOUtils.readSbml(inputPath);
         System.out.println(" Done.");
 
         //print info
@@ -151,7 +132,7 @@ public class SBMLwizard extends AbstractMet4jApplication {
 
         //removal of reactions that cannot hold flux in any condition
         if(removeNoFlux){
-            System.out.println("removing reaction with closed flux bound...");
+            System.out.println("removing reaction with null flux bounds...");
             BioCollection<BioReaction> toRemove = new BioCollection<>();
             for(BioReaction r : network.getReactionsView()){
                 if(ReactionAttributes.getLowerBound(r).value==0.0 &&
@@ -226,9 +207,8 @@ public class SBMLwizard extends AbstractMet4jApplication {
 
         //export network
         System.out.print("Exporting...");
-        new JsbmlWriter(outputPath,newNetwork).write();
+        IOUtils.writeSbml(newNetwork, outputPath);
         System.out.println(" Done.");
-        return;
     }
 
     @Override
-- 
GitLab


From 3cfd491f1e2727289b74d932fa1d909de981ed2a Mon Sep 17 00:00:00 2001
From: lcottret <ludovic.cottret@inrae.fr>
Date: Fri, 3 Jan 2025 15:44:20 +0100
Subject: [PATCH 31/74] doc and refactoring

---
 .../tabulated/network/Tab2BioNetwork.java        |  4 ++--
 .../met4j_toolbox/convert/Tab2Sbml.java          | 16 ++++++----------
 2 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/met4j-io/src/main/java/fr/inrae/toulouse/metexplore/met4j_io/tabulated/network/Tab2BioNetwork.java b/met4j-io/src/main/java/fr/inrae/toulouse/metexplore/met4j_io/tabulated/network/Tab2BioNetwork.java
index c4b320e0f..3373bc205 100644
--- a/met4j-io/src/main/java/fr/inrae/toulouse/metexplore/met4j_io/tabulated/network/Tab2BioNetwork.java
+++ b/met4j-io/src/main/java/fr/inrae/toulouse/metexplore/met4j_io/tabulated/network/Tab2BioNetwork.java
@@ -171,7 +171,7 @@ public class Tab2BioNetwork {
         if (flag == false) {
             System.err.println("Input file badly formatted");
         } else {
-            System.err.println("The input file looks good and contains " + reactions.size() + " reactions");
+            System.out.println("The input file looks good and contains " + reactions.size() + " reactions");
         }
 
         in.close();
@@ -492,7 +492,7 @@ public class Tab2BioNetwork {
 
         br.close();
 
-        System.err.println(bioNetwork.getReactionsView().size() + " reactions, " + bioNetwork.getMetabolitesView().size() + " metabolites and " + this.bioNetwork.getCompartmentsView().size() + " compartments created");
+        System.out.println(bioNetwork.getReactionsView().size() + " reactions, " + bioNetwork.getMetabolitesView().size() + " metabolites and " + this.bioNetwork.getCompartmentsView().size() + " compartments created");
 
         return flag;
     }
diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/convert/Tab2Sbml.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/convert/Tab2Sbml.java
index 2dcb43933..e23e1d144 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/convert/Tab2Sbml.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/convert/Tab2Sbml.java
@@ -46,6 +46,7 @@ import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumParame
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.Format;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.ParameterType;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.utils.Doi;
+import fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils;
 import org.kohsuke.args4j.Option;
 
 import java.io.IOException;
@@ -76,20 +77,20 @@ public class Tab2Sbml extends AbstractMet4jApplication {
     @Option(name = "-e", usage = "[_b] flag to assign metabolite as external")
     public String e = "_b";
 
-    @Option(name = "-i", usage = "[-->] String for irreversible reaction")
+    @Option(name = "-irr", usage = "[-->] String for irreversible reaction")
     public String i = "-->";
 
-    @Option(name = "-r", usage = "[<==>] String for reversible reaction")
+    @Option(name = "-rev", usage = "[<==>] String for reversible reaction")
     public String r = "<==>";
 
     @Format(name = EnumFormats.Sbml)
     @ParameterType(name = EnumParameterTypes.OutputFile)
-    @Option(name = "-sbml", usage = "[out.sbml] Out sbml file")
+    @Option(name = "-o", usage = "[out.sbml] Out sbml file")
     public String sbml = "out.sbml";
 
     @Format(name = EnumFormats.Tsv)
     @ParameterType(name = EnumParameterTypes.InputFile)
-    @Option(name = "-in", usage = "Tabulated file", required = true)
+    @Option(name = "-i", usage = "Tabulated file", required = true)
     public String in;
 
     @Option(name = "-id", usage = "[NA] Model id written in the SBML file")
@@ -179,12 +180,7 @@ public class Tab2Sbml extends AbstractMet4jApplication {
 
         BioNetwork bn = tb.getBioNetwork();
 
-        JsbmlWriter writer = new JsbmlWriter(sbmlFile, bn);
-        try {
-            writer.write();
-        } catch (Met4jSbmlWriterException ex) {
-            System.exit(1);
-        }
+        IOUtils.writeSbml(bn, sbmlFile);
 
         return;
 
-- 
GitLab


From c051b8c50322fce3b6717273a048c0463da61f09 Mon Sep 17 00:00:00 2001
From: lcottret <ludovic.cottret@inrae.fr>
Date: Fri, 3 Jan 2025 15:47:10 +0100
Subject: [PATCH 32/74] doc and refactoring

---
 .../met4j_toolbox/mapping/NameMatcher.java      | 17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)

diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/mapping/NameMatcher.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/mapping/NameMatcher.java
index 69317ec07..c6df8df7d 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/mapping/NameMatcher.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/mapping/NameMatcher.java
@@ -11,6 +11,7 @@ import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumParame
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.Format;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.ParameterType;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.utils.Doi;
+import fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils;
 import org.kohsuke.args4j.Option;
 
 import java.io.*;
@@ -23,7 +24,7 @@ import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.Enu
 public class NameMatcher extends AbstractMet4jApplication {
 
 
-    @Option(name = "-nMatch", usage = "[1] Number of match to return per name")
+    @Option(name = "-nMatch", usage = "[1] Number of matchs to return per name")
     public int n = 1;
 
     @Option(name = "-skip", usage = "[0] Number of lines to skip at the beginning of the compound file")
@@ -34,7 +35,7 @@ public class NameMatcher extends AbstractMet4jApplication {
 
     @Format(name = Sbml)
     @ParameterType(name = InputFile)
-    @Option(name = "-sbml", usage = "Original sbml file", required = true)
+    @Option(name = "-i", usage = "Original sbml file", required = true)
     public String sbml;
 
     @ParameterType(name = InputFile)
@@ -44,7 +45,7 @@ public class NameMatcher extends AbstractMet4jApplication {
 
     @ParameterType(name= EnumParameterTypes.OutputFile)
     @Format(name= EnumFormats.Tsv)
-    @Option(name = "-o", usage = "Output file", required=true)
+    @Option(name = "-o", usage = "Output tabulated file", required=true)
     public String outputFile;
 
     @ParameterType(name = EnumParameterTypes.Text)
@@ -65,17 +66,9 @@ public class NameMatcher extends AbstractMet4jApplication {
      * @return a {@link fr.inrae.toulouse.metexplore.met4j_core.biodata.BioNetwork} object.
      */
     protected Map<String,List<String>> readSbml() {
-        JsbmlReader reader = new JsbmlReader(this.sbml);
 
-        BioNetwork bn = null;
+        BioNetwork bn = IOUtils.readSbml(this.sbml);
         Map<String,List<String>> names = new HashMap<>();
-        try {
-            bn = reader.read();
-        } catch (Met4jSbmlReaderException e) {
-            e.printStackTrace();
-            System.err.println("Problem while reading the sbml file " + this.sbml);
-            System.exit(1);
-        }
 
         for(BioMetabolite m : bn.getMetabolitesView()){
             names.computeIfAbsent(m.getName(), k -> new ArrayList<>()).add(m.getId());
-- 
GitLab


From d42f7fe35ca330878115956e79eabc647d50be47 Mon Sep 17 00:00:00 2001
From: lcottret <ludovic.cottret@inrae.fr>
Date: Fri, 3 Jan 2025 15:53:46 +0100
Subject: [PATCH 33/74] doc and refactoring

---
 .../mapping/ORApathwayEnrichment.java         | 83 +++++--------------
 1 file changed, 21 insertions(+), 62 deletions(-)

diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/mapping/ORApathwayEnrichment.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/mapping/ORApathwayEnrichment.java
index 78f894aff..cdd055939 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/mapping/ORApathwayEnrichment.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/mapping/ORApathwayEnrichment.java
@@ -3,12 +3,6 @@ package fr.inrae.toulouse.metexplore.met4j_toolbox.mapping;
 import fr.inrae.toulouse.metexplore.met4j_core.biodata.BioMetabolite;
 import fr.inrae.toulouse.metexplore.met4j_core.biodata.BioNetwork;
 import fr.inrae.toulouse.metexplore.met4j_core.biodata.BioPathway;
-import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.JsbmlReader;
-import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.Met4jSbmlReaderException;
-import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.plugin.FBCParser;
-import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.plugin.GroupPathwayParser;
-import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.plugin.NotesParser;
-import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.plugin.PackageParser;
 import fr.inrae.toulouse.metexplore.met4j_mapping.Mapper;
 import fr.inrae.toulouse.metexplore.met4j_mapping.enrichment.PathwayEnrichment;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.AbstractMet4jApplication;
@@ -17,11 +11,14 @@ import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumParame
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.Format;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.ParameterType;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.utils.Doi;
+import fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils;
 import org.kohsuke.args4j.Option;
 
 import java.io.FileWriter;
 import java.io.IOException;
-import java.util.*;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
 import java.util.stream.Collectors;
 
 import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumFormats.Sbml;
@@ -36,49 +33,21 @@ public class ORApathwayEnrichment extends AbstractMet4jApplication {
 
     @Format(name = Sbml)
     @ParameterType(name = InputFile)
-    @Option(name = "-s", aliases = {"--sbml"}, usage = "Input model : SBML file with pathway annotation", required = true)
+    @Option(name = "-i", aliases = {"--sbml"}, usage = "Input model : SBML file with pathway annotation", required = true)
     public String sbml;
 
     @ParameterType(name = InputFile)
     @Format(name = Tsv)
-    @Option(name = "-i", aliases = {"--data"}, usage = "Input data : Compounds of interest file, as one SBML specie identifier per line", required = true)
+    @Option(name = "-d", aliases = {"--data"}, usage = "Input data : Compounds of interest file, as one SBML specie identifier per line", required = true)
     public String input;
 
-    @ParameterType(name= EnumParameterTypes.OutputFile)
-    @Format(name= EnumFormats.Tsv)
-    @Option(name = "-o", aliases = {"--output"}, usage = "Output file : tabulated file with pathway identifier, pathway name, adjusted p-value.", required=true)
+    @ParameterType(name = EnumParameterTypes.OutputFile)
+    @Format(name = EnumFormats.Tsv)
+    @Option(name = "-o", aliases = {"--output"}, usage = "Output file : tabulated file with pathway identifier, pathway name, adjusted p-value.", required = true)
     public String outputFile;
-
-    enum correction {Bonferroni, BenjaminiHochberg, HolmBonferroni}
     @Option(name = "-c", aliases = {"--correction"}, usage = "Method for multiple testing p-value adjustment.")
     public correction corr = correction.BenjaminiHochberg;
 
-
-    /**
-     * <p>readSbml.</p>
-     *
-     * @return a {@link fr.inrae.toulouse.metexplore.met4j_core.biodata.BioNetwork} object.
-     */
-    protected Map<String, List<String>> readSbml() {
-        JsbmlReader reader = new JsbmlReader(this.sbml);
-
-        BioNetwork bn = null;
-        Map<String,List<String>> names = new HashMap<>();
-        try {
-            bn = reader.read();
-        } catch (Met4jSbmlReaderException e) {
-            e.printStackTrace();
-            System.err.println("Problem while reading the sbml file " + this.sbml);
-            System.exit(1);
-        }
-
-        for(BioMetabolite m : bn.getMetabolitesView()){
-            names.computeIfAbsent(m.getName(), k -> new ArrayList<>()).add(m.getId());
-        }
-        return names;
-
-    }
-
     public static void main(String[] args) {
         ORApathwayEnrichment app = new ORApathwayEnrichment();
 
@@ -100,18 +69,7 @@ public class ORApathwayEnrichment extends AbstractMet4jApplication {
 
         //import network
         System.out.print("Reading SBML...");
-        JsbmlReader reader = new JsbmlReader(this.sbml);
-        ArrayList<PackageParser> pkgs = new ArrayList<>(Arrays.asList(
-                new NotesParser(false), new FBCParser(), new GroupPathwayParser()));
-
-        BioNetwork network = null;
-        try {
-            network = reader.read(pkgs);
-        } catch (Met4jSbmlReaderException e) {
-            System.err.println("Error while reading the SBML file");
-            System.err.println(e.getMessage());
-            System.exit(1);
-        }
+        BioNetwork network = IOUtils.readSbml(this.sbml);
         System.out.println(" Done.");
 
         //import data
@@ -127,14 +85,14 @@ public class ORApathwayEnrichment extends AbstractMet4jApplication {
         }
         if (metMapper.getNumberOfSkippedEntries() > 0)
             System.err.println(metMapper.getNumberOfSkippedEntries() + " compounds not found in network.");
+
         System.out.println(noi.size() + " compounds imported.");
         System.out.println(" Done.");
 
         //Run analysis
         System.out.print("Perform Pathway Enrichment...");
         int corrInt;
-        switch(corr)
-        {
+        switch (corr) {
             case BenjaminiHochberg:
                 corrInt = PathwayEnrichment.BENJAMINIHOCHBERG;
                 break;
@@ -148,15 +106,15 @@ public class ORApathwayEnrichment extends AbstractMet4jApplication {
                 corrInt = PathwayEnrichment.BENJAMINIHOCHBERG;
                 break;
         }
-        PathwayEnrichment pe = new PathwayEnrichment(network,noi);
+        PathwayEnrichment pe = new PathwayEnrichment(network, noi);
         Map<BioPathway, Double> pathwayScore = pe.computeEnrichment(corrInt);
         System.out.println(" Done.");
 
         //filter
-        if(th>0.0){
+        if (th > 0.0) {
             System.out.println("Select significant pathways...");
-            pathwayScore = pathwayScore.entrySet().stream().filter(e -> e.getValue()<=th).collect(Collectors.toMap(e->e.getKey(),e->e.getValue()));
-            System.out.println("\t"+pathwayScore.size()+" significant pathways found.");
+            pathwayScore = pathwayScore.entrySet().stream().filter(e -> e.getValue() <= th).collect(Collectors.toMap(e -> e.getKey(), e -> e.getValue()));
+            System.out.println("\t" + pathwayScore.size() + " significant pathways found.");
             System.out.println(" Done.");
         }
 
@@ -178,7 +136,6 @@ public class ORApathwayEnrichment extends AbstractMet4jApplication {
 
     }
 
-
     @Override
     public String getLabel() {
         return this.getClass().getSimpleName();
@@ -197,11 +154,11 @@ public class ORApathwayEnrichment extends AbstractMet4jApplication {
     @Override
     public String getLongDescription() {
         return "Perform Over Representation Analysis for Pathway Enrichment, using one-tailed exact Fisher Test.\n" +
-                "The fisher exact test compute the probability p to randomly get the given set of value. \n" +
-                "This version compute the probability to get at least the given overlap between the given set and the given modality :\n" +
+                "The fisher exact test computes the probability p to randomly get the given set of values. \n" +
+                "This version computes the probability to get at least the given overlap between the given set and the given modality :\n" +
                 "Sum the hypergeometric probability with increasing target/query intersection cardinality.\n\n" +
                 "The hypergeometric probability is computed from the following contingency table entries.\n" +
-                "(value in cells correspond to the marginal totals of each intersection groups)\n" +
+                "(values in cells correspond to the marginal totals of each intersection groups)\n" +
                 "\t\t\t\tQuery\t!Query\n" +
                 "\tTarget\t\ta\t\tb\n" +
                 "\t!Target\t\tc\t\td\n" +
@@ -215,4 +172,6 @@ public class ORApathwayEnrichment extends AbstractMet4jApplication {
                 " - Holm-Bonferroni: adjusted p-value = p*(n+1-k)\n" +
                 "n : number of tests; k : pvalue rank";
     }
+
+    enum correction {Bonferroni, BenjaminiHochberg, HolmBonferroni}
 }
-- 
GitLab


From f1387f4d63a0b8e2d63d187eaee3b54a7420b28c Mon Sep 17 00:00:00 2001
From: lcottret <ludovic.cottret@inrae.fr>
Date: Fri, 3 Jan 2025 15:56:47 +0100
Subject: [PATCH 34/74] rearrange code

---
 .../met4j_toolbox/mapping/NameMatcher.java    | 57 ++++++++-----------
 1 file changed, 24 insertions(+), 33 deletions(-)

diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/mapping/NameMatcher.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/mapping/NameMatcher.java
index c6df8df7d..82f09900e 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/mapping/NameMatcher.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/mapping/NameMatcher.java
@@ -2,8 +2,6 @@ package fr.inrae.toulouse.metexplore.met4j_toolbox.mapping;
 
 import fr.inrae.toulouse.metexplore.met4j_core.biodata.BioMetabolite;
 import fr.inrae.toulouse.metexplore.met4j_core.biodata.BioNetwork;
-import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.JsbmlReader;
-import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.Met4jSbmlReaderException;
 import fr.inrae.toulouse.metexplore.met4j_mapping.fuzzyMatching.ChemicalNameMatcher;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.AbstractMet4jApplication;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumFormats;
@@ -43,9 +41,9 @@ public class NameMatcher extends AbstractMet4jApplication {
     @Option(name = "-compound", usage = "Compound file containing one column with compound names to search among the SBML entries", required = true)
     public String input;
 
-    @ParameterType(name= EnumParameterTypes.OutputFile)
-    @Format(name= EnumFormats.Tsv)
-    @Option(name = "-o", usage = "Output tabulated file", required=true)
+    @ParameterType(name = EnumParameterTypes.OutputFile)
+    @Format(name = EnumFormats.Tsv)
+    @Option(name = "-o", usage = "Output tabulated file", required = true)
     public String outputFile;
 
     @ParameterType(name = EnumParameterTypes.Text)
@@ -56,21 +54,25 @@ public class NameMatcher extends AbstractMet4jApplication {
     @Option(name = "-sep", usage = "[\\t] separator in the compound file to split the colmumns.")
     public String sep = "\t";
 
+    public static void main(String[] args) {
+        NameMatcher app = new NameMatcher();
 
+        app.parseArguments(args);
 
-
+        app.run();
+    }
 
     /**
      * <p>readSbml.</p>
      *
      * @return a {@link fr.inrae.toulouse.metexplore.met4j_core.biodata.BioNetwork} object.
      */
-    protected Map<String,List<String>> readSbml() {
+    protected Map<String, List<String>> readSbml() {
 
         BioNetwork bn = IOUtils.readSbml(this.sbml);
-        Map<String,List<String>> names = new HashMap<>();
+        Map<String, List<String>> names = new HashMap<>();
 
-        for(BioMetabolite m : bn.getMetabolitesView()){
+        for (BioMetabolite m : bn.getMetabolitesView()) {
             names.computeIfAbsent(m.getName(), k -> new ArrayList<>()).add(m.getId());
         }
         return names;
@@ -85,8 +87,8 @@ public class NameMatcher extends AbstractMet4jApplication {
             int i = 0;
             while ((line = fr.readLine()) != null) {
                 i++;
-                if(i>nSkip && !line.startsWith(comment)){
-                    String name = line.trim().split(sep)[col-1];
+                if (i > nSkip && !line.startsWith(comment)) {
+                    String name = line.trim().split(sep)[col - 1];
                     //TODO add check
                     names.add(name);
                 }
@@ -102,16 +104,8 @@ public class NameMatcher extends AbstractMet4jApplication {
 
     }
 
-    public static void main(String[] args) {
-        NameMatcher app = new NameMatcher();
-
-        app.parseArguments(args);
-
-        app.run();
-    }
-
     private void run() {
-        Map<String,List<String>> modelNames = this.readSbml();
+        Map<String, List<String>> modelNames = this.readSbml();
         List<String> queries = this.readFile();
         ChemicalNameMatcher matcher = new ChemicalNameMatcher.Builder(modelNames.keySet())
                 .DefaultProcessing()
@@ -121,19 +115,16 @@ public class NameMatcher extends AbstractMet4jApplication {
 
             writer.println("input Name\tSBML Name\tSBML ID");
 
-            for(String query : queries){
-                List<String> resList= matcher.getMatches(query,Double.valueOf(query.length()),n);
-                if(resList.isEmpty()){
-                    StringBuffer sb = new StringBuffer(query);
-                    sb.append("\tNA\tNA");
-                    writer.println(sb);
-                }else{
-                    for(String res : resList){
-                        StringBuffer sb = new StringBuffer(query);
-                        sb.append("\t");
-                        sb.append(res);
-                        sb.append("\t");
-                        sb.append(String.join(",",modelNames.get(res)));
+            for (String query : queries) {
+                List<String> resList = matcher.getMatches(query, Double.valueOf(query.length()), n);
+                if (resList.isEmpty()) {
+                    writer.println(query + "\tNA\tNA");
+                } else {
+                    for (String res : resList) {
+                        String sb = query + "\t" +
+                                res +
+                                "\t" +
+                                String.join(",", modelNames.get(res));
                         writer.println(sb);
                     }
                 }
-- 
GitLab


From 6d4436b9e5ba2e73077f5b7a26905b7fdd446b75 Mon Sep 17 00:00:00 2001
From: lcottret <ludovic.cottret@inrae.fr>
Date: Fri, 3 Jan 2025 16:00:36 +0100
Subject: [PATCH 35/74] doc and refactoring

---
 .../BipartiteDistanceMatrix.java              | 87 +++++++++----------
 1 file changed, 41 insertions(+), 46 deletions(-)

diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/BipartiteDistanceMatrix.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/BipartiteDistanceMatrix.java
index 1e25be22a..40607fa21 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/BipartiteDistanceMatrix.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/BipartiteDistanceMatrix.java
@@ -12,24 +12,25 @@ import fr.inrae.toulouse.metexplore.met4j_graph.core.WeightingPolicy;
 import fr.inrae.toulouse.metexplore.met4j_graph.core.bipartite.BipartiteEdge;
 import fr.inrae.toulouse.metexplore.met4j_graph.core.bipartite.BipartiteGraph;
 import fr.inrae.toulouse.metexplore.met4j_graph.io.Bionetwork2BioGraph;
-import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.JsbmlReader;
-import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.Met4jSbmlReaderException;
 import fr.inrae.toulouse.metexplore.met4j_mapping.Mapper;
 import fr.inrae.toulouse.metexplore.met4j_mathUtils.matrix.BioMatrix;
 import fr.inrae.toulouse.metexplore.met4j_mathUtils.matrix.ExportMatrix;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.AbstractMet4jApplication;
-import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.*;
+import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumFormats;
+import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.Format;
+import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.ParameterType;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.utils.Doi;
+import fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils;
 import org.kohsuke.args4j.Option;
 
 import java.io.IOException;
 import java.util.HashSet;
 import java.util.Set;
-import java.util.stream.Stream;
 
 import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumFormats.Csv;
 import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumFormats.Sbml;
-import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumParameterTypes.*;
+import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumParameterTypes.InputFile;
+import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumParameterTypes.OutputFile;
 
 public class BipartiteDistanceMatrix extends AbstractMet4jApplication {
 
@@ -88,16 +89,9 @@ public class BipartiteDistanceMatrix extends AbstractMet4jApplication {
 
     public void run() {
         //import network
-        JsbmlReader reader = new JsbmlReader(this.inputPath);
-
-        BioNetwork network = null;
-        try {
-            network = reader.read();
-        } catch (Met4jSbmlReaderException e) {
-            System.err.println("Error while reading the SBML file");
-            System.err.println(e.getMessage());
-            System.exit(1);
-        }
+        System.out.print("Reading SBML...");
+        BioNetwork network = IOUtils.readSbml(this.inputPath);
+        System.out.println(" Done.");
 
         //Create bipartite graph
         Bionetwork2BioGraph builder = new Bionetwork2BioGraph(network);
@@ -110,7 +104,7 @@ public class BipartiteDistanceMatrix extends AbstractMet4jApplication {
 
         //Graph processing: side compound removal [optional]
         if (sideCompoundFile != null) {
-            System.err.println("removing side compounds...");
+            System.out.println("removing side compounds...");
             BioCollection<BioMetabolite> sideCpds = null;
             try {
                 sideCpds = metMapper.map(sideCompoundFile);
@@ -120,29 +114,29 @@ public class BipartiteDistanceMatrix extends AbstractMet4jApplication {
                 System.exit(1);
             }
             boolean removed = graph.removeAllVertices(sideCpds);
-            if(removed) removedNodes.addAll(sideCpds);
+            if (removed) removedNodes.addAll(sideCpds);
             if (metMapper.getNumberOfSkippedEntries() > 0)
-            System.err.println(metMapper.getNumberOfSkippedEntries() + " side compounds not found in network.");
-            System.err.println(sideCpds.size() + " side compounds ignored during graph build.");
+                System.err.println(metMapper.getNumberOfSkippedEntries() + " side compounds not found in network.");
+            System.out.println(sideCpds.size() + " side compounds ignored during graph build.");
         }
 
         //Graph processing: reactions removal [optional]
         if (rExclude != null) {
-          System.err.println("removing reactions to exclude...");
-          BioCollection<BioReaction> rList = null;
-          try {
-            rList = rxnMapper.map(rExclude);
-          } catch (IOException e) {
-              System.err.println("Error while reading the reaction to ignore file");
-              System.err.println(e.getMessage());
-              System.exit(1);
-          }
-          boolean removed = graph.removeAllVertices(rList);
-          if(removed) removedNodes.addAll(rList);
-          if (rxnMapper.getNumberOfSkippedEntries() > 0)
-          System.err.println(rxnMapper.getNumberOfSkippedEntries() + " reactions to exclude not found in network.");
-          System.err.println(rList.size() + " reactions ignored during graph build.");
-      }
+            System.out.println("removing reactions to exclude...");
+            BioCollection<BioReaction> rList = null;
+            try {
+                rList = rxnMapper.map(rExclude);
+            } catch (IOException e) {
+                System.err.println("Error while reading the reaction to ignore file");
+                System.err.println(e.getMessage());
+                System.exit(1);
+            }
+            boolean removed = graph.removeAllVertices(rList);
+            if (removed) removedNodes.addAll(rList);
+            if (rxnMapper.getNumberOfSkippedEntries() > 0)
+                System.err.println(rxnMapper.getNumberOfSkippedEntries() + " reactions to exclude not found in network.");
+            System.out.println(rList.size() + " reactions ignored during graph build.");
+        }
 
         //Graph processing: set weights [optional]
         WeightingPolicy wp = new UnweightedPolicy();
@@ -155,15 +149,15 @@ public class BipartiteDistanceMatrix extends AbstractMet4jApplication {
         BioMatrix distM = null;
         Set<BioEntity> metSeeds = null;
         Set<BioEntity> rxnSeeds = null;
-        
+
         //If both seed files are missing, then compute on complete graphs
         //If metabolite's seed file is missing, use the list of all metabolites nodes
         // If metabolites's reaction file is missing, use the list of all reactions nodes
 
         //Note cannot use mapper because bionetwork is not updated
-        if(metFile == null){
+        if (metFile == null) {
             metSeeds = new HashSet<BioEntity>(graph.compoundVertexSet());
-        }else{
+        } else {
             try {
                 metSeeds = new HashSet<>(metMapper.map(metFile));
             } catch (IOException e) {
@@ -172,9 +166,9 @@ public class BipartiteDistanceMatrix extends AbstractMet4jApplication {
                 System.exit(1);
             }
         }
-        if(rxnFile == null){
+        if (rxnFile == null) {
             rxnSeeds = new HashSet<BioEntity>(graph.reactionVertexSet());
-        }else{ 
+        } else {
             try {
                 rxnSeeds = new HashSet<>(rxnMapper.map(rxnFile));
             } catch (IOException e) {
@@ -184,19 +178,20 @@ public class BipartiteDistanceMatrix extends AbstractMet4jApplication {
             }
         }
         //full == square distance matrix of all pairwise comparisons between seeds
-        if(full){
+        if (full) {
             rxnSeeds.addAll(metSeeds);
             metSeeds.addAll(rxnSeeds);
         }
         //clean metabolites seeds
         boolean removedMets = metSeeds.removeAll(removedNodes);
-        if(removedMets) System.err.println("One or more seed nodes removed due to being in the side compounds list");
+        if (removedMets) System.err.println("One or more seed nodes removed due to being in the side compounds list");
         //clean reactions seeds
         boolean removedRxns = rxnSeeds.removeAll(removedNodes);
-        if(removedRxns) System.err.println("One or more seed nodes removed due to being in the reaction to exclude list");
+        if (removedRxns)
+            System.err.println("One or more seed nodes removed due to being in the reaction to exclude list");
         //compute distance matrix
-        ShortestPath<BioEntity,BipartiteEdge,BipartiteGraph> matrixComputor = new ShortestPath<>(graph, !undirected);
-        distM = matrixComputor.getShortestPathDistanceMatrix(metSeeds,rxnSeeds);
+        ShortestPath<BioEntity, BipartiteEdge, BipartiteGraph> matrixComputor = new ShortestPath<>(graph, !undirected);
+        distM = matrixComputor.getShortestPathDistanceMatrix(metSeeds, rxnSeeds);
         //export results
         ExportMatrix.toCSV(outputPath, distM);
 
@@ -211,8 +206,8 @@ public class BipartiteDistanceMatrix extends AbstractMet4jApplication {
     public String getLongDescription() {
         return this.getShortDescription() + "\n" +
                 "The distance between two nodes (metabolite or reaction) is computed as the length of the shortest path connecting the two in the bipartite graph, " +
-                "Bipartite graph are composed of two distinct sets of nodes and two nodes can be linked only if they are from distinct sets.\n" +
-                "Therefore a metabolite node can be linked to a reaction node if the metabolite is a substrate or product of the reaction.\n" + 
+                "Bipartite graphs are composed of two distinct sets of nodes and two nodes can be linked only if they are from distinct sets.\n" +
+                "Therefore a metabolite node can be linked to a reaction node if the metabolite is a substrate or product of the reaction.\n" +
                 "An optional custom edge weighting can be used, turning the distances into the sum of edge weights in the lightest path, rather than the length of the shortest path." +
                 "Custom weighting can be provided in a file. In that case, edges without weight are ignored during path search.\n" +
                 "If no edge weighting is set, it is recommended to provide a list of side compounds to ignore during network traversal.";
-- 
GitLab


From b12c464b22c13590949da1126088829348d8e234 Mon Sep 17 00:00:00 2001
From: lcottret <ludovic.cottret@inrae.fr>
Date: Fri, 3 Jan 2025 16:06:39 +0100
Subject: [PATCH 36/74] doc and refactoring

---
 .../networkAnalysis/CarbonSkeletonNet.java    | 75 +++++++------------
 1 file changed, 26 insertions(+), 49 deletions(-)

diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/CarbonSkeletonNet.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/CarbonSkeletonNet.java
index 5173dbab4..5509ad73a 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/CarbonSkeletonNet.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/CarbonSkeletonNet.java
@@ -9,39 +9,29 @@ import fr.inrae.toulouse.metexplore.met4j_graph.computation.connect.weighting.Re
 import fr.inrae.toulouse.metexplore.met4j_graph.computation.transform.EdgeMerger;
 import fr.inrae.toulouse.metexplore.met4j_graph.computation.transform.VertexContraction;
 import fr.inrae.toulouse.metexplore.met4j_graph.computation.utils.ComputeAdjacencyMatrix;
-import fr.inrae.toulouse.metexplore.met4j_graph.computation.transform.GraphOperation;
 import fr.inrae.toulouse.metexplore.met4j_graph.core.compound.CompoundGraph;
 import fr.inrae.toulouse.metexplore.met4j_graph.io.Bionetwork2BioGraph;
 import fr.inrae.toulouse.metexplore.met4j_graph.io.ExportGraph;
-import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.JsbmlReader;
-import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.Met4jSbmlReaderException;
-import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.plugin.FBCParser;
-import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.plugin.GroupPathwayParser;
-import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.plugin.NotesParser;
-import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.plugin.PackageParser;
 import fr.inrae.toulouse.metexplore.met4j_mathUtils.matrix.ExportMatrix;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.AbstractMet4jApplication;
-import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.*;
-
+import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.Format;
+import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.ParameterType;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.utils.Doi;
-import org.apache.commons.lang3.StringUtils;
+import fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils;
 import org.kohsuke.args4j.Option;
 
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.HashSet;
 import java.util.Set;
 
 import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumFormats.*;
-import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumFormats.Sbml;
-import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumParameterTypes.*;
+import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumParameterTypes.InputFile;
+import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumParameterTypes.OutputFile;
 
 public class CarbonSkeletonNet extends AbstractMet4jApplication {
 
     @Format(name = Sbml)
     @ParameterType(name = InputFile)
-    @Option(name = "-s", usage = "input SBML file", required = true)
+    @Option(name = "-i", usage = "input SBML file", required = true)
     public String inputPath = null;
 
     @Format(name = Gsam)
@@ -49,39 +39,39 @@ public class CarbonSkeletonNet extends AbstractMet4jApplication {
     @Option(name = "-g", usage = "input GSAM file", required = true)
     public String inputAAM = null;
 
-    @Format(name = Gml)
+    @Format(name = Txt)
     @ParameterType(name = OutputFile)
-    @Option(name = "-o", usage = "output Graph file", required = true)
+    @Option(name = "-o", usage = "output Graph file (Gml or Matrix format, see -am parameter))", required = true)
     public String outputPath = null;
 
-    @Option(name = "-ks", aliases = {"--keepSingleCarbon"}, usage = "keep edges involving single-carbon compounds, such as CO2 (requires formulas in SBML)", required = false)
+    @Option(name = "-ks", aliases = {"--keepSingleCarbon"}, usage = "keep edges involving single-carbon compounds, such as CO2 (requires formulas in SBML)")
     public boolean keepSingleCarbon = false;
 
-    @Option(name = "-mc", aliases = {"--nocomp"}, usage = "merge compartments (requires unique compound names that are consistent across compartments)", required = false)
+    @Option(name = "-mc", aliases = {"--nocomp"}, usage = "merge compartments (requires unique compound names that are consistent across compartments)")
     public boolean mergeComp = false;
 
-    @Option(name = "-me", aliases = {"--simple"}, usage = "merge parallel edges to produce a simple graph", required = false)
+    @Option(name = "-me", aliases = {"--simple"}, usage = "merge parallel edges to produce a simple graph")
     public boolean mergeEdges = false;
 
-    @Option(name = "-ri", aliases = {"--removeIsolatedNodes"}, usage = "remove isolated nodes", required = false)
+    @Option(name = "-ri", aliases = {"--removeIsolatedNodes"}, usage = "remove isolated nodes")
     public boolean removeIsolated = false;
 
-    @Option(name = "-un", aliases = {"--undirected"}, usage = "create as undirected", required = false)
+    @Option(name = "-un", aliases = {"--undirected"}, usage = "create as undirected")
     public boolean undirected = false;
 
-    @Option(name = "-tp", aliases = {"--transitionproba"}, usage = "set transition probability as weight", required = false)
+    @Option(name = "-tp", aliases = {"--transitionproba"}, usage = "set transition probability as weight")
     public boolean computeWeight = false;
 
-    @Option(name = "-am", aliases = {"--asmatrix"}, usage = "export as matrix (implies simple graph conversion). Default export as GML file", required = false)
+    @Option(name = "-am", aliases = {"--asmatrix"}, usage = "export as matrix (implies simple graph conversion). Default export as GML file")
     public boolean asMatrix = false;
 
-    @Option(name = "-main", aliases = {"--onlyMainTransition"}, usage = "Compute RPAIRS-like tags and keep only main transitions for each reaction", required = false)
+    @Option(name = "-main", aliases = {"--onlyMainTransition"}, usage = "Compute RPAIRS-like tags and keep only main transitions for each reaction")
     public boolean main = false;
 
-    @Option(name = "-i", aliases = {"--fromIndexes"}, usage = "Use GSAM output with carbon indexes", required = false)
+    @Option(name = "-i", aliases = {"--fromIndexes"}, usage = "Use GSAM output with carbon indexes")
     public boolean fromIndexes = false;
 
-    public static void main(String[] args)  {
+    public static void main(String[] args) {
 
         CarbonSkeletonNet app = new CarbonSkeletonNet();
 
@@ -92,25 +82,13 @@ public class CarbonSkeletonNet extends AbstractMet4jApplication {
     }
 
 
-    public void run()  {
+    public void run() {
         System.out.print("Reading SBML...");
-        JsbmlReader reader = new JsbmlReader(this.inputPath);
-        ArrayList<PackageParser> pkgs = new ArrayList<>(Arrays.asList(
-                new NotesParser(false), new FBCParser(), new GroupPathwayParser()));
-
-        BioNetwork network = null;
-        try {
-            network = reader.read(pkgs);
-        } catch (Met4jSbmlReaderException e) {
-            System.err.println("Error while reading the SBML file");
-            System.err.println(e.getMessage());
-            System.exit(1);
-        }
-
+        BioNetwork network = IOUtils.readSbml(this.inputPath);
         System.out.println(" Done.");
 
 
-        System.out.print("Buildinig Network...");
+        System.out.print("Building Network...");
         Bionetwork2BioGraph builder = new Bionetwork2BioGraph(network);
         CompoundGraph graph = builder.getCompoundGraph();
         System.out.println(" Done.");
@@ -124,12 +102,12 @@ public class CarbonSkeletonNet extends AbstractMet4jApplication {
                 .removeEdgeWithoutMapping()
                 .removeEdgesWithoutConservedCarbon();
 
-        if(main){
+        if (main) {
             RPAIRSlikePolicy rwp = new RPAIRSlikePolicy(wp)
                     .removeSideTransitions()
                     .removeSpuriousTransitions();
             rwp.setWeight(graph);
-        }else{
+        } else {
             wp.setWeight(graph);
             System.out.println("Done.");
         }
@@ -207,7 +185,6 @@ public class CarbonSkeletonNet extends AbstractMet4jApplication {
             ExportGraph.toGmlWithAttributes(graph, this.outputPath, true);
         }
         System.out.println(" Done.");
-        return;
     }
 
     @Override
@@ -219,9 +196,9 @@ public class CarbonSkeletonNet extends AbstractMet4jApplication {
     public String getLongDescription() {
         return "Metabolic networks used for quantitative analysis often contain links that are irrelevant for graph-based structural analysis. For example, inclusion of side compounds or modelling artifacts such as 'biomass' nodes." +
                 " Focusing on links between compounds that share parts of their carbon skeleton allows to avoid many transitions involving side compounds, and removes entities without defined chemical structure. " +
-                "This app produce a Carbon Skeleton Network relevant for graph-based analysis of metabolism, in GML or matrix format, from a SBML and an GSAM atom mapping file. " +
-                "GSAM (see https://forgemia.inra.fr/metexplore/gsam) perform atom mapping at genome-scale level using the Reaction Decoder Tool (https://github.com/asad/ReactionDecoder) and allows to compute the number of conserved atoms of a given type between reactants." +
-                "This app also enable Markov-chain based analysis of metabolic networks by computing reaction-normalized transition probabilities on the Carbon Skeleton Network.";
+                "This app produces a Carbon Skeleton Network relevant for graph-based analysis of metabolism, in GML or matrix format, from a SBML and an GSAM atom mapping file. " +
+                "GSAM (see https://forgemia.inra.fr/metexplore/gsam) performs atom mapping at genome-scale level using the Reaction Decoder Tool (https://github.com/asad/ReactionDecoder) and allows to compute the number of conserved atoms of a given type between reactants." +
+                "This app also enables Markov-chain based analysis of metabolic networks by computing reaction-normalized transition probabilities on the Carbon Skeleton Network.";
     }
 
     @Override
-- 
GitLab


From 81c63285f3768091eedf8f96832d39549a8a4586 Mon Sep 17 00:00:00 2001
From: lcottret <ludovic.cottret@inrae.fr>
Date: Fri, 3 Jan 2025 16:08:49 +0100
Subject: [PATCH 37/74] doc and refactoring

---
 .../ChemSimilarityWeighting.java              | 28 +++++++++----------
 1 file changed, 13 insertions(+), 15 deletions(-)

diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/ChemSimilarityWeighting.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/ChemSimilarityWeighting.java
index d64997c45..568973d31 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/ChemSimilarityWeighting.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/ChemSimilarityWeighting.java
@@ -25,19 +25,25 @@ import java.util.Set;
  */
 public class ChemSimilarityWeighting extends EdgeWeighting {
 
-    enum strategy {EState, Extended, KlekotaRoth, MACCS, PubChem}
-
     @Option(name = "-f", aliases = {"--fingerprint"}, usage = "The chemical fingerprint to use", required = false)
     public strategy type = strategy.Extended;
-
     @Option(name = "-sm", aliases = {"--smileFile"}, usage = "If not present in SBML's annotations, get structure from a tabulated file with first column as compound id and second column as SMILE string, no header. Ignored if inchi file is provided", required = false)
     public String smileFile;
     @Option(name = "-in", aliases = {"--inchiFile"}, usage = "If not present in SBML's annotations, get structure from a tabulated file with first column as compound id and second column as InChI string, no header.", required = false)
     public String inchiFile;
-
     @Option(name = "-d", aliases = {"--asDist"}, usage = "Use distance rather than similarity", required = false)
     public boolean dist = false;
 
+    public static void main(String[] args) throws Met4jSbmlReaderException, IOException {
+
+        ChemSimilarityWeighting app = new ChemSimilarityWeighting();
+
+        app.parseArguments(args);
+
+        app.run();
+
+    }
+
     @Override
     public WeightingPolicy setWeightingPolicy() {
         SimilarityWeightPolicy wp = new SimilarityWeightPolicy();
@@ -103,16 +109,6 @@ public class ChemSimilarityWeighting extends EdgeWeighting {
         return bn;
     }
 
-    public static void main(String[] args) throws Met4jSbmlReaderException, IOException {
-
-        ChemSimilarityWeighting app = new ChemSimilarityWeighting();
-
-        app.parseArguments(args);
-
-        app.run();
-
-    }
-
     @Override
     public String getLabel() {
         return this.getClass().getSimpleName();
@@ -120,7 +116,7 @@ public class ChemSimilarityWeighting extends EdgeWeighting {
 
     @Override
     public String getLongDescription() {
-        return "Provides tabulated compound graph edge list, with one column with reactant pair's chemical similarity." +
+        return this.getShortDescription() +
                 "Chemical similarity has been proposed as edge weight for finding meaningful paths in metabolic networks," +
                 " using shortest (lightest) path search.";
     }
@@ -138,4 +134,6 @@ public class ChemSimilarityWeighting extends EdgeWeighting {
         dois.add(new Doi("https://doi.org/10.1093/bioinformatics/btu760"));
         return dois;
     }
+
+    enum strategy {EState, Extended, KlekotaRoth, MACCS, PubChem}
 }
-- 
GitLab


From 89bfa265f45b168dc0c640c335d33c90ae4dc1bf Mon Sep 17 00:00:00 2001
From: lcottret <ludovic.cottret@inrae.fr>
Date: Fri, 3 Jan 2025 16:11:33 +0100
Subject: [PATCH 38/74] doc and refactoring

---
 .../networkAnalysis/ChokePoint.java           | 28 ++++++++-----------
 1 file changed, 11 insertions(+), 17 deletions(-)

diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/ChokePoint.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/ChokePoint.java
index 7f3273581..f3f349f9a 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/ChokePoint.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/ChokePoint.java
@@ -15,6 +15,7 @@ import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.AbstractMet4jApplicati
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.Format;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.ParameterType;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.utils.Doi;
+import fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils;
 import org.kohsuke.args4j.Option;
 
 import java.io.BufferedReader;
@@ -24,6 +25,7 @@ import java.io.IOException;
 import java.util.HashSet;
 import java.util.Set;
 
+import static fr.inrae.toulouse.metexplore.met4j_graph.computation.analyze.ChokePoint.getChokePoint;
 import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumFormats.*;
 import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumParameterTypes.InputFile;
 import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumParameterTypes.OutputFile;
@@ -37,7 +39,7 @@ public class ChokePoint extends AbstractMet4jApplication {
 
     @Format(name = Tsv)
     @ParameterType(name = OutputFile)
-    @Option(name = "-o", usage = "output results file", required = true)
+    @Option(name = "-o", usage = "output result file", required = true)
     public String outputPath = null;
 
 
@@ -64,29 +66,21 @@ public class ChokePoint extends AbstractMet4jApplication {
         }
 
         //import network
-        System.err.println("reading SBML...");
-        JsbmlReader reader = new JsbmlReader(this.inputPath);
+        System.out.println("reading SBML...");
+        BioNetwork network = IOUtils.readSbml(this.inputPath);
 
-        BioNetwork network = null;
-        try {
-            network = reader.read();
-        } catch (Met4jSbmlReaderException e) {
-            System.err.println("Error while reading the SBML file");
-            System.err.println(e.getMessage());
-            System.exit(1);
-        }
 
         //Create compound graph
-        System.err.println("Creating network...");
+        System.out.println("Creating network...");
         Bionetwork2BioGraph builder = new Bionetwork2BioGraph(network);
         CompoundGraph graph = builder.getCompoundGraph();
 
         //compute choke points
-        System.err.println("Computing choke points...");
-        HashSet<BioReaction> choke = fr.inrae.toulouse.metexplore.met4j_graph.computation.analyze.ChokePoint.getChokePoint(graph);
+        System.out.println("Computing choke points...");
+        HashSet<BioReaction> choke = getChokePoint(graph);
 
         //export results
-        System.err.println("Export results...");
+        System.out.println("Export results...");
 
         try {
             for (BioReaction r : choke) {
@@ -97,7 +91,7 @@ public class ChokePoint extends AbstractMet4jApplication {
             System.err.println(e.getMessage());
             System.exit(1);
         }
-        System.err.println("done.");
+        System.out.println("done.");
 
         try {
             fw.close();
@@ -116,7 +110,7 @@ public class ChokePoint extends AbstractMet4jApplication {
 
     @Override
     public String getLongDescription() {
-        return this.getShortDescription() + "\nChoke points constitute an indicator of lethality and can help identifying drug target " +
+        return this.getShortDescription() + "\n"+
                 "Choke points are reactions that are required to consume or produce one compound. Targeting of choke point can lead to the accumulation or the loss of some metabolites, thus choke points constitute an indicator of lethality and can help identifying drug target.";
     }
 
-- 
GitLab


From fdae494d6f81a1fd5ce7f6b60cf50aece445047a Mon Sep 17 00:00:00 2001
From: lcottret <ludovic.cottret@inrae.fr>
Date: Fri, 3 Jan 2025 16:21:30 +0100
Subject: [PATCH 39/74] doc and refactoring

---
 .../networkAnalysis/CompoundNet.java          | 66 ++++++++-----------
 1 file changed, 27 insertions(+), 39 deletions(-)

diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/CompoundNet.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/CompoundNet.java
index 5abc5499b..c54c70794 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/CompoundNet.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/CompoundNet.java
@@ -13,12 +13,6 @@ import fr.inrae.toulouse.metexplore.met4j_graph.core.compound.ReactionEdge;
 import fr.inrae.toulouse.metexplore.met4j_graph.io.Bionetwork2BioGraph;
 import fr.inrae.toulouse.metexplore.met4j_graph.io.ExportGraph;
 import fr.inrae.toulouse.metexplore.met4j_graph.io.NodeMapping;
-import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.JsbmlReader;
-import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.Met4jSbmlReaderException;
-import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.plugin.FBCParser;
-import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.plugin.GroupPathwayParser;
-import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.plugin.NotesParser;
-import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.plugin.PackageParser;
 import fr.inrae.toulouse.metexplore.met4j_mathUtils.matrix.ExportMatrix;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.AbstractMet4jApplication;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumFormats;
@@ -26,11 +20,10 @@ import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumParame
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.Format;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.ParameterType;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.utils.Doi;
+import fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils;
 import org.kohsuke.args4j.Option;
 
 import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.HashSet;
 import java.util.Set;
 
@@ -38,37 +31,45 @@ public class CompoundNet extends AbstractMet4jApplication {
 
     @Format(name = EnumFormats.Sbml)
     @ParameterType(name = EnumParameterTypes.InputFile)
-    @Option(name = "-s", usage = "input SBML file", required = true)
+    @Option(name = "-i", usage = "input SBML file", required = true)
     public String inputPath = null;
 
     @ParameterType(name = EnumParameterTypes.InputFile)
     @Format(name = EnumFormats.Txt)
-    @Option(name = "-sc", usage = "input Side compound file", required = false)
+    @Option(name = "-sc", usage = "input Side compound file")
     public String inputSide = null;
 
     @ParameterType(name = EnumParameterTypes.OutputFile)
-    @Format(name = EnumFormats.Gml)
-    @Option(name = "-o", usage = "output Graph file", required = true)
+    @Format(name = EnumFormats.Txt)
+    @Option(name = "-o", usage = "output Graph file (GML or matrix format, see -am parameter)", required = true)
     public String outputPath = null;
+
     @Option(name = "-mc", aliases = {"--mergecomp"}, usage = "merge compartments. " +
             "Use names if consistent and unambiguous across compartments, or identifiers if compartment suffix is present (id in form \"xxx_y\" with xxx as base identifier and y as compartment label).")
     public strategy mergingStrat = strategy.no;
     public String idRegex = "^(\\w+)_\\w$";
-    @Option(name = "-me", aliases = {"--simple"}, usage = "merge parallel edges to produce a simple graph", required = false)
+
+    @Option(name = "-me", aliases = {"--simple"}, usage = "merge parallel edges to produce a simple graph")
     public boolean mergeEdges = false;
-    @Option(name = "-ri", aliases = {"--removeIsolatedNodes"}, usage = "remove isolated nodes", required = false)
+
+    @Option(name = "-ri", aliases = {"--removeIsolatedNodes"}, usage = "remove isolated nodes")
     public boolean removeIsolated = false;
+
     @Option(name = "-dw", aliases = {"--degreeWeights"}, usage = "penalize traversal of hubs by using degree square weighting", forbids = {"-cw"})
     public Boolean degree = false;
+
     @ParameterType(name = EnumParameterTypes.InputFile)
     @Format(name = EnumFormats.Tsv)
     @Option(name = "-cw", aliases = {"--customWeights"}, usage = "an optional file containing weights for compound pairs", forbids = {"-dw"})
     public String weightFile = null;
-    @Option(name = "-un", aliases = {"--undirected"}, usage = "create as undirected", required = false)
+
+    @Option(name = "-un", aliases = {"--undirected"}, usage = "create as undirected")
     public boolean undirected = false;
-    @Option(name = "-tp", aliases = {"--transitionproba"}, usage = "set weight as random walk transition probability, normalized by reaction", required = false)
+
+    @Option(name = "-tp", aliases = {"--transitionproba"}, usage = "set weight as random walk transition probability, normalized by reaction")
     public boolean computeWeight = false;
-    @Option(name = "-am", aliases = {"--asmatrix"}, usage = "export as matrix (implies simple graph conversion). Default export as GML file", required = false)
+
+    @Option(name = "-am", aliases = {"--asmatrix"}, usage = "export as matrix (implies simple graph conversion). Default export as GML file")
     public boolean asMatrix = false;
 
     public static void main(String[] args) {
@@ -83,30 +84,17 @@ public class CompoundNet extends AbstractMet4jApplication {
 
     public void run() {
         System.out.print("Reading SBML...");
-        JsbmlReader reader = new JsbmlReader(this.inputPath);
-        ArrayList<PackageParser> pkgs = new ArrayList<>(Arrays.asList(
-                new NotesParser(false), new FBCParser(), new GroupPathwayParser()));
-
-        BioNetwork network = null;
-
-        try {
-            network = reader.read(pkgs);
-        } catch (Met4jSbmlReaderException e) {
-            System.err.println("Error while reading the SBML file");
-            System.err.println(e.getMessage());
-            System.exit(1);
-        }
+        BioNetwork network = IOUtils.readSbml(inputPath);
         System.out.println(" Done.");
 
-
-        System.out.print("Buildinig Network...");
+        System.out.print("Building Network...");
         Bionetwork2BioGraph builder = new Bionetwork2BioGraph(network);
         CompoundGraph graph = builder.getCompoundGraph();
         System.out.println(" Done.");
 
         //Graph processing: side compound removal [optional]
         if (inputSide != null) {
-            System.err.println("removing side compounds...");
+            System.out.println("Removing side compounds...");
             NodeMapping<BioMetabolite, ReactionEdge, CompoundGraph> mapper = new NodeMapping<>(graph).skipIfNotFound();
             BioCollection<BioMetabolite> sideCpds = null;
             try {
@@ -117,16 +105,16 @@ public class CompoundNet extends AbstractMet4jApplication {
                 System.exit(1);
             }
             boolean removed = graph.removeAllVertices(sideCpds);
-            if (removed) System.err.println(sideCpds.size() + " compounds removed.");
+            if (removed) System.out.println(sideCpds.size() + " compounds removed.");
         }
 
         //Graph processing: set weights [optional]
         WeightingPolicy<BioMetabolite, ReactionEdge, CompoundGraph> wp = new UnweightedPolicy<>();
         if (weightFile != null) {
-            System.err.println("Setting edge weights...");
+            System.out.println("Setting edge weights...");
             wp = new WeightsFromFile(weightFile);
         } else if (degree && !undirected) {
-            System.err.println("Setting edge weights...");
+            System.out.println("Setting edge weights...");
             int pow = 2;
             wp = new DegreeWeightPolicy(pow);
         }
@@ -141,7 +129,7 @@ public class CompoundNet extends AbstractMet4jApplication {
             if (degree) {
                 //since degree weighting policy is not symmetric, for undirected case we create reversed edges, apply
                 //a corrected degree computation for each edge, and treat the graph as normal
-                System.err.println("Setting edge weights (target degree)...");
+                System.out.println("Setting edge weights (target degree)...");
                 int pow = 2;
                 wp = new DegreeWeightPolicy(1);
                 wp.setWeight(graph);
@@ -208,8 +196,8 @@ public class CompoundNet extends AbstractMet4jApplication {
     public String getLongDescription() {
         return "Metabolic networks used for quantitative analysis often contain links that are irrelevant for graph-based structural analysis. For example, inclusion of side compounds or modelling artifacts such as 'biomass' nodes.\n" +
                 "While Carbon Skeleton Graph offer a relevant alternative topology for graph-based analysis, it requires compounds' structure information, usually not provided in model, and difficult to retrieve for model with sparse cross-reference annotations.\n" +
-                "In contrary to the SBML2Graph app that performs a raw conversion of the SBML content, the present app propose a fine-tuned creation of compound graph from predefined list of side compounds and degree² weighting to get relevant structure without structural data." +
-                "This app also enable Markov-chain based analysis of metabolic networks by computing reaction-normalized transition probabilities on the network.";
+                "In contrary to the Sbml2Graph app that performs a raw conversion of the SBML content, the present app propose a fine-tuned creation of compound graph from predefined list of side compounds and degree weighting to get relevant structure without structural data." +
+                "This app also enables Markov-chain based analysis of metabolic networks by computing reaction-normalized transition probabilities on the network.";
     }
 
     @Override
-- 
GitLab


From e13ca17c927925f97c6b63de3116fa5630a0d18d Mon Sep 17 00:00:00 2001
From: lcottret <ludovic.cottret@inrae.fr>
Date: Fri, 3 Jan 2025 16:22:32 +0100
Subject: [PATCH 40/74] doc and refactoring

---
 .../met4j_toolbox/networkAnalysis/DegreeWeighting.java          | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/DegreeWeighting.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/DegreeWeighting.java
index 884799301..f2bb09bb4 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/DegreeWeighting.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/DegreeWeighting.java
@@ -42,7 +42,7 @@ public class DegreeWeighting extends EdgeWeighting {
 
     @Override
     public String getLongDescription() {
-        return "Provides tabulated compound graph edge list, with one column with target's degree." +
+        return this.getShortDescription() +
                 "Degree has been proposed as edge weight for finding meaningful paths in metabolic networks," +
                 " using shortest (lightest) path search.";
     }
-- 
GitLab


From 46df45ccacba6ccba5f10feb4b5cc3eb0bc6100c Mon Sep 17 00:00:00 2001
From: lcottret <ludovic.cottret@inrae.fr>
Date: Fri, 3 Jan 2025 16:24:40 +0100
Subject: [PATCH 41/74] doc and refactoring

---
 .../networkAnalysis/DistanceMatrix.java       | 45 ++++++++-----------
 1 file changed, 19 insertions(+), 26 deletions(-)

diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/DistanceMatrix.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/DistanceMatrix.java
index a87eb0fec..e1e196d1a 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/DistanceMatrix.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/DistanceMatrix.java
@@ -5,21 +5,22 @@ import fr.inrae.toulouse.metexplore.met4j_core.biodata.BioNetwork;
 import fr.inrae.toulouse.metexplore.met4j_core.biodata.collection.BioCollection;
 import fr.inrae.toulouse.metexplore.met4j_graph.computation.connect.ShortestPath;
 import fr.inrae.toulouse.metexplore.met4j_graph.computation.connect.weighting.CustomWeightPolicy;
-import fr.inrae.toulouse.metexplore.met4j_graph.computation.connect.weighting.UnweightedPolicy;
 import fr.inrae.toulouse.metexplore.met4j_graph.computation.connect.weighting.DegreeWeightPolicy;
+import fr.inrae.toulouse.metexplore.met4j_graph.computation.connect.weighting.UnweightedPolicy;
 import fr.inrae.toulouse.metexplore.met4j_graph.computation.connect.weighting.WeightsFromFile;
 import fr.inrae.toulouse.metexplore.met4j_graph.core.WeightingPolicy;
 import fr.inrae.toulouse.metexplore.met4j_graph.core.compound.CompoundGraph;
 import fr.inrae.toulouse.metexplore.met4j_graph.core.compound.ReactionEdge;
 import fr.inrae.toulouse.metexplore.met4j_graph.io.Bionetwork2BioGraph;
 import fr.inrae.toulouse.metexplore.met4j_graph.io.NodeMapping;
-import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.JsbmlReader;
-import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.Met4jSbmlReaderException;
 import fr.inrae.toulouse.metexplore.met4j_mathUtils.matrix.BioMatrix;
 import fr.inrae.toulouse.metexplore.met4j_mathUtils.matrix.ExportMatrix;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.AbstractMet4jApplication;
-import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.*;
+import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumFormats;
+import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.Format;
+import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.ParameterType;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.utils.Doi;
+import fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils;
 import org.kohsuke.args4j.Option;
 
 import java.io.IOException;
@@ -28,7 +29,8 @@ import java.util.Set;
 
 import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumFormats.Csv;
 import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumFormats.Sbml;
-import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumParameterTypes.*;
+import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumParameterTypes.InputFile;
+import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumParameterTypes.OutputFile;
 
 public class DistanceMatrix extends AbstractMet4jApplication {
 
@@ -77,16 +79,7 @@ public class DistanceMatrix extends AbstractMet4jApplication {
 
     public void run() {
         //import network
-        JsbmlReader reader = new JsbmlReader(this.inputPath);
-
-        BioNetwork network = null;
-        try {
-            network = reader.read();
-        } catch (Met4jSbmlReaderException e) {
-            System.err.println("Error while reading the SBML file");
-            System.err.println(e.getMessage());
-            System.exit(1);
-        }
+        BioNetwork network = IOUtils.readSbml(this.inputPath);
 
         //Create compound graph
         Bionetwork2BioGraph builder = new Bionetwork2BioGraph(network);
@@ -94,7 +87,7 @@ public class DistanceMatrix extends AbstractMet4jApplication {
 
         //Graph processing: side compound removal [optional]
         if (sideCompoundFile != null) {
-            System.err.println("removing side compounds...");
+            System.out.println("removing side compounds...");
             NodeMapping mapper = new NodeMapping<>(graph).skipIfNotFound();
             BioCollection<BioMetabolite> sideCpds = null;
             try {
@@ -105,7 +98,7 @@ public class DistanceMatrix extends AbstractMet4jApplication {
                 System.exit(1);
             }
             boolean removed = graph.removeAllVertices(sideCpds);
-            if (removed) System.err.println(sideCpds.size() + " side compounds ignored during graph build.");
+            if (removed) System.out.println(sideCpds.size() + " side compounds ignored during graph build.");
         }
 
         //Graph processing: set weights [optional]
@@ -113,20 +106,20 @@ public class DistanceMatrix extends AbstractMet4jApplication {
         if (weightFile != null) {
             wp = new WeightsFromFile(weightFile, true);
         } else if (degree) {
-            if(!undirected){
+            if (!undirected) {
                 int pow = 2;
                 wp = new DegreeWeightPolicy(pow);
-            }else{
+            } else {
                 //since degree weighting policy is not symmetric, for undirected case we create reversed edges, apply
                 //a corrected degree computation for each edge, and treat the graph as normal
                 graph.asUndirected();
-                undirected=false;
-                wp = new CustomWeightPolicy<BioMetabolite,ReactionEdge,CompoundGraph>(
+                undirected = false;
+                wp = new CustomWeightPolicy<BioMetabolite, ReactionEdge, CompoundGraph>(
                         e -> {
                             Double w = Double.valueOf(graph.inDegreeOf(e.getV2()));
                             w += Double.valueOf(graph.outDegreeOf(e.getV2()));
-                            w = w/2;    //adjust for undirected doubled edges
-                            w = StrictMath.pow(w,2);
+                            w = w / 2;    //adjust for undirected doubled edges
+                            w = StrictMath.pow(w, 2);
                             return w;
                         });
             }
@@ -135,12 +128,12 @@ public class DistanceMatrix extends AbstractMet4jApplication {
 
         //init BioMatrix
         BioMatrix distM = null;
-        if(seedFile == null){
+        if (seedFile == null) {
             //compute distance matrix
             ShortestPath matrixComputor = new ShortestPath<>(graph, !undirected);
             //get All SPs
             distM = matrixComputor.getShortestPathDistanceMatrix();
-        }else{
+        } else {
             System.err.println("filtering matrix...");
             NodeMapping mapper = new NodeMapping<>(graph).skipIfNotFound();
             Set<BioMetabolite> seeds = null;
@@ -154,7 +147,7 @@ public class DistanceMatrix extends AbstractMet4jApplication {
             //compute distance matrix
             ShortestPath<BioMetabolite, ReactionEdge, CompoundGraph> matrixComputor = new ShortestPath<>(graph, !undirected);
             //get SPs
-            distM = matrixComputor.getShortestPathDistanceMatrix(seeds,seeds);
+            distM = matrixComputor.getShortestPathDistanceMatrix(seeds, seeds);
         }
         //export results
         ExportMatrix.toCSV(outputPath, distM);
-- 
GitLab


From 9e032f6c74b383578fa6b5f06814ec482eca1606 Mon Sep 17 00:00:00 2001
From: lcottret <ludovic.cottret@inrae.fr>
Date: Fri, 3 Jan 2025 16:28:12 +0100
Subject: [PATCH 42/74] doc and refactoring

---
 .../networkAnalysis/ExtractSubBipNetwork.java | 48 ++++++++-----------
 1 file changed, 19 insertions(+), 29 deletions(-)

diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/ExtractSubBipNetwork.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/ExtractSubBipNetwork.java
index 0a3b4e6e5..8e4155cda 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/ExtractSubBipNetwork.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/ExtractSubBipNetwork.java
@@ -17,13 +17,12 @@ import fr.inrae.toulouse.metexplore.met4j_graph.core.bipartite.BipartiteEdge;
 import fr.inrae.toulouse.metexplore.met4j_graph.core.bipartite.BipartiteGraph;
 import fr.inrae.toulouse.metexplore.met4j_graph.io.Bionetwork2BioGraph;
 import fr.inrae.toulouse.metexplore.met4j_graph.io.ExportGraph;
-import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.JsbmlReader;
-import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.Met4jSbmlReaderException;
 import fr.inrae.toulouse.metexplore.met4j_mapping.Mapper;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.AbstractMet4jApplication;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.Format;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.ParameterType;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.utils.Doi;
+import fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils;
 import org.kohsuke.args4j.Option;
 
 import java.io.IOException;
@@ -84,22 +83,19 @@ public class ExtractSubBipNetwork extends AbstractMet4jApplication {
     @Option(name = "-st", aliases = {"--steinertree"}, usage = "Extract Steiner Tree", forbids = {"-k"})
     public boolean st = false;
 
+    public static void main(String[] args) {
+        ExtractSubBipNetwork app = new ExtractSubBipNetwork();
+        app.parseArguments(args);
+        app.run();
+    }
 
     public void run() {
         //import network
-        JsbmlReader reader = new JsbmlReader(this.inputPath);
-
-        BioNetwork network = null;
-        try {
-            network = reader.read();
-        } catch (Met4jSbmlReaderException e) {
-            System.err.println("Error while reading the SBML file");
-            System.err.println(e.getMessage());
-            System.exit(1);
-        }
+        System.out.println("reading SBML...");
+        BioNetwork network = IOUtils.readSbml(this.inputPath);
 
         //Graph processing: import side compounds
-        System.err.println("importing side compounds...");
+        System.out.println("importing side compounds...");
         Mapper<BioMetabolite> cmapper = new Mapper<>(network, BioNetwork::getMetabolitesView).skipIfNotFound();
         BioCollection<BioMetabolite> sideCpds = null;
 
@@ -115,8 +111,8 @@ public class ExtractSubBipNetwork extends AbstractMet4jApplication {
 
         //Graph processing: import blocked reactions
         BioCollection<BioReaction> blkdReactions = null;
-        if(blkdReactionFile!=null){
-            System.err.println("importing blocked reactions...");
+        if (blkdReactionFile != null) {
+            System.out.println("importing blocked reactions...");
             Mapper<BioReaction> rmapper = new Mapper<>(network, BioNetwork::getReactionsView).skipIfNotFound();
 
             try {
@@ -131,7 +127,7 @@ public class ExtractSubBipNetwork extends AbstractMet4jApplication {
         }
 
         //get sources and targets
-        System.err.println("extracting sources and targets");
+        System.out.println("extracting sources and targets");
         BioCollection<BioEntity> entities = new BioCollection<>();
         entities.addAll(network.getReactionsView());
         entities.addAll(network.getMetabolitesView());
@@ -156,16 +152,16 @@ public class ExtractSubBipNetwork extends AbstractMet4jApplication {
             System.exit(1);
         }
         if (mapper.getNumberOfSkippedEntries() > 0)
-            System.err.println(mapper.getNumberOfSkippedEntries() + " target not found in network.");
+            System.err.println(mapper.getNumberOfSkippedEntries() + " targets not found in network.");
 
         //Create reaction graph
         Bionetwork2BioGraph builder = new Bionetwork2BioGraph(network);
         BipartiteGraph graph = builder.getBipartiteGraph();
         boolean removed = graph.removeAllVertices(sideCpds);
         if (removed) System.err.println(sideCpds.size() + " side compounds removed.");
-        if(blkdReactionFile!=null){
+        if (blkdReactionFile != null) {
             removed = graph.removeAllVertices(blkdReactions);
-            if (removed) System.err.println(blkdReactions.size() + " blocked reaction removed.");
+            if (removed) System.err.println(blkdReactions.size() + " blocked reactions removed.");
         }
         //Graph processing: set weights [optional]
         WeightingPolicy<BioEntity, BipartiteEdge, BipartiteGraph> wp = new UnweightedPolicy<>();
@@ -197,20 +193,14 @@ public class ExtractSubBipNetwork extends AbstractMet4jApplication {
         }
 
         //export sub-network
-        if(asTable){
+        if (asTable) {
             ExportGraph.toTab(subnet, outputPath);
-        }else{
+        } else {
             ExportGraph.toGml(subnet, outputPath);
         }
 
     }
 
-    public static void main(String[] args) {
-        ExtractSubBipNetwork app = new ExtractSubBipNetwork();
-        app.parseArguments(args);
-        app.run();
-    }
-
     @Override
     public String getLabel() {
         return this.getClass().getSimpleName();
@@ -219,7 +209,7 @@ public class ExtractSubBipNetwork extends AbstractMet4jApplication {
     @Override
     public String getLongDescription() {
         return this.getShortDescription() + "\n" +
-                "The subnetwork corresponds to part of the network that connects reactions and compounds from the first list to reactions and compounds from the second list.\n" +
+                "The subnetwork corresponds to the part of the network that connects reactions and compounds from the first list to reactions and compounds from the second list.\n" +
                 "Sources and targets list can have elements in common. The connecting part can be defined as the union of shortest or k-shortest paths between sources and targets, " +
                 "or the Steiner tree connecting them. Contrary to compound graph, bipartite graph often lacks weighting policy for edge relevance. In order to ensure appropriate " +
                 "network density, a list of side compounds and blocked reactions to ignore during path build must be provided. An optional edge weight file, if available, can also be used.";
@@ -227,7 +217,7 @@ public class ExtractSubBipNetwork extends AbstractMet4jApplication {
 
     @Override
     public String getShortDescription() {
-        return "Create a subnetwork from a GSMN in SBML format, and two files containing lists of compounds and/or reactions of interests ids, one per row, plus one file of the same format containing side compounds ids.";
+        return "Create a subnetwork from a metabolic network in SBML format, and two files containing lists of compounds and/or reactions of interests ids, one per row, plus one file of the same format containing side compounds ids.";
     }
 
     @Override
-- 
GitLab


From c2c914cd1d2608784802b8634bc2c386b8b6205a Mon Sep 17 00:00:00 2001
From: lcottret <ludovic.cottret@inrae.fr>
Date: Fri, 3 Jan 2025 16:30:46 +0100
Subject: [PATCH 43/74] doc and refactoring

---
 .../networkAnalysis/ExtractSubNetwork.java    | 40 +++++++------------
 1 file changed, 15 insertions(+), 25 deletions(-)

diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/ExtractSubNetwork.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/ExtractSubNetwork.java
index 898295a42..c7068bd1f 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/ExtractSubNetwork.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/ExtractSubNetwork.java
@@ -7,9 +7,9 @@ import fr.inrae.toulouse.metexplore.met4j_core.biodata.collection.BioCollection;
 import fr.inrae.toulouse.metexplore.met4j_graph.computation.connect.KShortestPath;
 import fr.inrae.toulouse.metexplore.met4j_graph.computation.connect.ShortestPath;
 import fr.inrae.toulouse.metexplore.met4j_graph.computation.connect.SteinerTreeApprox;
-import fr.inrae.toulouse.metexplore.met4j_graph.computation.connect.weighting.UnweightedPolicy;
 import fr.inrae.toulouse.metexplore.met4j_graph.computation.connect.weighting.DegreeWeightPolicy;
 import fr.inrae.toulouse.metexplore.met4j_graph.computation.connect.weighting.SimilarityWeightPolicy;
+import fr.inrae.toulouse.metexplore.met4j_graph.computation.connect.weighting.UnweightedPolicy;
 import fr.inrae.toulouse.metexplore.met4j_graph.computation.connect.weighting.WeightsFromFile;
 import fr.inrae.toulouse.metexplore.met4j_graph.core.BioPath;
 import fr.inrae.toulouse.metexplore.met4j_graph.core.GraphFactory;
@@ -19,11 +19,11 @@ import fr.inrae.toulouse.metexplore.met4j_graph.core.compound.ReactionEdge;
 import fr.inrae.toulouse.metexplore.met4j_graph.io.Bionetwork2BioGraph;
 import fr.inrae.toulouse.metexplore.met4j_graph.io.ExportGraph;
 import fr.inrae.toulouse.metexplore.met4j_graph.io.NodeMapping;
-import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.JsbmlReader;
-import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.Met4jSbmlReaderException;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.AbstractMet4jApplication;
-import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.*;
+import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.Format;
+import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.ParameterType;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.utils.Doi;
+import fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils;
 import org.kohsuke.args4j.Option;
 
 import java.io.IOException;
@@ -85,19 +85,15 @@ public class ExtractSubNetwork extends AbstractMet4jApplication {
     @Option(name = "-st", aliases = {"--steinertree"}, usage = "Extract Steiner Tree", forbids = {"-k"})
     public boolean st = false;
 
+    public static void main(String[] args) {
+        ExtractSubNetwork app = new ExtractSubNetwork();
+        app.parseArguments(args);
+        app.run();
+    }
 
     public void run() {
         //import network
-        JsbmlReader reader = new JsbmlReader(this.inputPath);
-
-        BioNetwork network = null;
-        try {
-            network = reader.read();
-        } catch (Met4jSbmlReaderException e) {
-            System.err.println("Error while reading the SBML file");
-            System.err.println(e.getMessage());
-            System.exit(1);
-        }
+        BioNetwork network = IOUtils.readSbml(this.inputPath);
 
         //Create compound graph
         Bionetwork2BioGraph builder = new Bionetwork2BioGraph(network);
@@ -162,7 +158,7 @@ public class ExtractSubNetwork extends AbstractMet4jApplication {
         };
         CompoundGraph subnet;
         if (st) {
-            SteinerTreeApprox<BioMetabolite, ReactionEdge, CompoundGraph> stComp = new SteinerTreeApprox<>(graph,(degree || weightFile != null), !undirected, false);
+            SteinerTreeApprox<BioMetabolite, ReactionEdge, CompoundGraph> stComp = new SteinerTreeApprox<>(graph, (degree || weightFile != null), !undirected, false);
             List<ReactionEdge> stEdges = stComp.getLightestUnionOfShortestPaths(sources, targets);
             subnet = factory.createGraphFromEdgeList(stEdges);
         } else if (k > 1) {
@@ -176,20 +172,14 @@ public class ExtractSubNetwork extends AbstractMet4jApplication {
         }
 
         //export sub-network
-        if(asTable){
+        if (asTable) {
             ExportGraph.toTab(subnet, outputPath);
-        }else{
+        } else {
             ExportGraph.toGmlWithAttributes(subnet, outputPath);
         }
 
     }
 
-    public static void main(String[] args) {
-        ExtractSubNetwork app = new ExtractSubNetwork();
-        app.parseArguments(args);
-        app.run();
-    }
-
     @Override
     public String getLabel() {
         return this.getClass().getSimpleName();
@@ -198,7 +188,7 @@ public class ExtractSubNetwork extends AbstractMet4jApplication {
     @Override
     public String getLongDescription() {
         return this.getShortDescription() + "\n" +
-                "The subnetwork correspond to part of the network that connects compounds from the first list to compounds from the second list.\n" +
+                "The subnetwork corresponds to the part of the network that connects compounds from the first list to compounds from the second list.\n" +
                 "Sources and targets list can have elements in common. The connecting part can be defined as the union of shortest or k-shortest paths between sources and targets, " +
                 "or the Steiner tree connecting them. The relevance of considered path can be increased by weighting the edges using degree squared, chemical similarity (require InChI or SMILES annotations) or any provided weighting.\n" +
                 "\nSee previous works on subnetwork extraction for parameters recommendations.";
@@ -206,7 +196,7 @@ public class ExtractSubNetwork extends AbstractMet4jApplication {
 
     @Override
     public String getShortDescription() {
-        return "Create a subnetwork from a GSMN in SBML format, and two files containing lists of compounds of interests ids, one per row.";
+        return "Create a subnetwork from a metabolic network in SBML format, and two files containing lists of compounds of interests ids, one per row.";
     }
 
     @Override
-- 
GitLab


From 16a22af0522613003a780bf24d980eb2298119fe Mon Sep 17 00:00:00 2001
From: lcottret <ludovic.cottret@inrae.fr>
Date: Fri, 3 Jan 2025 16:34:03 +0100
Subject: [PATCH 44/74] doc and refactoring

---
 .../ExtractSubReactionNetwork.java            | 34 ++++++++-----------
 1 file changed, 14 insertions(+), 20 deletions(-)

diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/ExtractSubReactionNetwork.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/ExtractSubReactionNetwork.java
index 9ed45008a..153281c54 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/ExtractSubReactionNetwork.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/ExtractSubReactionNetwork.java
@@ -23,6 +23,7 @@ import fr.inrae.toulouse.metexplore.met4j_mapping.Mapper;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.AbstractMet4jApplication;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.*;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.utils.Doi;
+import fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils;
 import org.kohsuke.args4j.Option;
 
 import java.io.IOException;
@@ -57,9 +58,9 @@ public class ExtractSubReactionNetwork extends AbstractMet4jApplication {
     @Option(name = "-t", usage = "input targets txt file", required = true)
     public String targetPath = null;
 
-    @Format(name = Gml)
+    @Format(name = Txt)
     @ParameterType(name = OutputFile)
-    @Option(name = "-o", usage = "output gml file", required = true)
+    @Option(name = "-o", usage = "output gml or tabulated file (see -tab option)", required = true)
     public String outputPath = null;
 
     @Format(name = Txt)
@@ -86,15 +87,8 @@ public class ExtractSubReactionNetwork extends AbstractMet4jApplication {
 
     public void run() {
         //import network
-        JsbmlReader reader = new JsbmlReader(this.inputPath);
-        BioNetwork network = null;
-        try {
-            network = reader.read();
-        } catch (Met4jSbmlReaderException e) {
-            System.err.println("Error while reading the SBML file");
-            System.err.println(e.getMessage());
-            System.exit(1);
-        }
+        System.out.println("reading SBML...");
+        BioNetwork network = IOUtils.readSbml(this.inputPath);
 
         //Instantiate nodes to remove and mappers
         Set<BioEntity> removedNodes = new HashSet<>();
@@ -102,7 +96,7 @@ public class ExtractSubReactionNetwork extends AbstractMet4jApplication {
         Mapper<BioReaction> rxnMapper = new Mapper<>(network, BioNetwork::getReactionsView).skipIfNotFound();
 
         //Graph processing: import side compounds
-        System.err.println("importing side compounds...");
+        System.out.println("importing side compounds...");
         BioCollection<BioMetabolite> sideCpds = null;
         try {
             sideCpds = metMapper.map(sideCompoundFile);
@@ -113,10 +107,10 @@ public class ExtractSubReactionNetwork extends AbstractMet4jApplication {
         }
         if (metMapper.getNumberOfSkippedEntries() > 0)
             System.err.println(metMapper.getNumberOfSkippedEntries() + " side compounds not found in network.");
-        System.err.println(sideCpds.size() + " side compounds ignored during graph build.");
+        System.out.println(sideCpds.size() + " side compounds ignored during graph build.");
 
         //get sources and targets
-        System.err.println("extracting sources and targets");
+        System.out.println("extracting sources and targets");
         HashSet<BioReaction> sources = null;
         try {
             sources = new HashSet<>(rxnMapper.map(sourcePath));
@@ -126,7 +120,7 @@ public class ExtractSubReactionNetwork extends AbstractMet4jApplication {
             System.exit(1);
         }
         if (rxnMapper.getNumberOfSkippedEntries() > 0)
-            System.err.println(rxnMapper.getNumberOfSkippedEntries() + " source not found in network.");
+            System.err.println(rxnMapper.getNumberOfSkippedEntries() + " sources not found in network.");
         HashSet<BioReaction> targets = null;
         try {
             targets = new HashSet<>(rxnMapper.map(targetPath));
@@ -136,7 +130,7 @@ public class ExtractSubReactionNetwork extends AbstractMet4jApplication {
             System.exit(1);
         }
         if (rxnMapper.getNumberOfSkippedEntries() > 0)
-            System.err.println(rxnMapper.getNumberOfSkippedEntries() + " target not found in network.");
+            System.err.println(rxnMapper.getNumberOfSkippedEntries() + " targets not found in network.");
 
         //Create reaction graph
         Bionetwork2BioGraph builder = new Bionetwork2BioGraph(network);
@@ -144,7 +138,7 @@ public class ExtractSubReactionNetwork extends AbstractMet4jApplication {
 
         //Graph processing: reactions removal [optional]
         if (rExclude != null) {
-            System.err.println("removing reactions to exclude...");
+            System.out.println("removing reactions to exclude...");
             BioCollection<BioReaction> rList = null;
             try {
                 rList = rxnMapper.map(rExclude);
@@ -157,7 +151,7 @@ public class ExtractSubReactionNetwork extends AbstractMet4jApplication {
             if(removed) removedNodes.addAll(rList);
             if (rxnMapper.getNumberOfSkippedEntries() > 0)
             System.err.println(rxnMapper.getNumberOfSkippedEntries() + " reactions to exclude not found in network.");
-            System.err.println(rList.size() + " reactions ignored during graph build.");
+            System.out.println(rList.size() + " reactions ignored during graph build.");
         }
 
         //Graph processing: set weights [optional]
@@ -212,7 +206,7 @@ public class ExtractSubReactionNetwork extends AbstractMet4jApplication {
     @Override
     public String getLongDescription() {
         return this.getShortDescription() + "\n" +
-                "The subnetwork corresponds to part of the network that connects reactions from the first list to reactions from the second list.\n" +
+                "The subnetwork corresponds to the part of the network that connects reactions from the first list to reactions from the second list.\n" +
                 "Sources and targets list can have elements in common. The connecting part can be defined as the union of shortest or k-shortest paths between sources and targets, " +
                 "or the Steiner tree connecting them. Contrary to compound graph, reaction graph often lacks weighting policy for edge relevance. In order to ensure appropriate " +
                 "network density, a list of side compounds to ignore for linking reactions must be provided. An optional edge weight file, if available, can also be used.";
@@ -220,7 +214,7 @@ public class ExtractSubReactionNetwork extends AbstractMet4jApplication {
 
     @Override
     public String getShortDescription() {
-        return "Create a subnetwork from a GSMN in SBML format, and two files containing lists of reactions of interests ids, one per row, plus one file of the same format containing side compounds ids.";
+        return "Create a subnetwork from a metabolic network in SBML format, and two files containing lists of reactions of interests ids, one per row, plus one file of the same format containing side compounds ids.";
     }
 
     @Override
-- 
GitLab


From 8f31f9480461b98f6ac4a14838df858e1adc1f31 Mon Sep 17 00:00:00 2001
From: lcottret <ludovic.cottret@inrae.fr>
Date: Fri, 3 Jan 2025 16:37:53 +0100
Subject: [PATCH 45/74] doc and refactoring

---
 .../networkAnalysis/LoadPoint.java            | 29 +++++++------------
 1 file changed, 11 insertions(+), 18 deletions(-)

diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/LoadPoint.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/LoadPoint.java
index be05a91c6..70973a282 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/LoadPoint.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/LoadPoint.java
@@ -14,6 +14,7 @@ import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.AbstractMet4jApplicati
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.Format;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.ParameterType;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.utils.Doi;
+import fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils;
 import org.kohsuke.args4j.Option;
 
 import java.io.BufferedReader;
@@ -70,25 +71,17 @@ public class LoadPoint extends AbstractMet4jApplication {
         }
 
         //import network
-        System.err.println("reading SBML...");
-        JsbmlReader reader = new JsbmlReader(this.inputPath);
-        BioNetwork network = null;
-        try {
-            network = reader.read();
-        } catch (Met4jSbmlReaderException e) {
-            System.err.println("Error while reading the SBML file");
-            System.err.println(e.getMessage());
-            System.exit(1);
-        }
+        System.out.println("reading SBML...");
+        BioNetwork network = IOUtils.readSbml(inputPath);
 
         //Create compound graph
-        System.err.println("Creating network...");
+        System.out.println("Creating network...");
         Bionetwork2BioGraph builder = new Bionetwork2BioGraph(network);
         CompoundGraph graph = builder.getCompoundGraph();
 
         //Graph processing: side compound removal [optional]
         if (sideCompoundFile != null) {
-            System.err.println("removing side compounds...");
+            System.out.println("removing side compounds...");
             BioCollection<BioMetabolite> sideCpds = new BioCollection<>();
 
             try {
@@ -110,7 +103,7 @@ public class LoadPoint extends AbstractMet4jApplication {
                 System.exit(1);
             }
             boolean removed = graph.removeAllVertices(sideCpds);
-            if (removed) System.err.println(sideCpds.size() + " compounds removed.");
+            if (removed) System.out.println(sideCpds.size() + " compounds removed.");
         }
 
         //Graph processing: set weights
@@ -118,12 +111,12 @@ public class LoadPoint extends AbstractMet4jApplication {
         wp.setWeight(graph);
 
         //compute loads
-        System.err.println("Computing load points...");
+        System.out.println("Computing load points...");
         fr.inrae.toulouse.metexplore.met4j_graph.computation.analyze.LoadPoint computor = new fr.inrae.toulouse.metexplore.met4j_graph.computation.analyze.LoadPoint<BioMetabolite, ReactionEdge, CompoundGraph>(graph);
         HashMap<BioMetabolite, Double> loads = computor.getLoads(k);
 
         //export results
-        System.err.println("Export results...");
+        System.out.println("Export results...");
 
         try {
             for (Map.Entry<BioMetabolite, Double> e : loads.entrySet()) {
@@ -136,7 +129,7 @@ public class LoadPoint extends AbstractMet4jApplication {
             System.err.println(e.getMessage());
             System.exit(1);
         }
-        System.err.println("done.");
+        System.out.println("done.");
 
     }
 
@@ -160,11 +153,11 @@ public class LoadPoint extends AbstractMet4jApplication {
 
     @Override
     public String getShortDescription() {
-        return "Compute the Load points of a metabolic network. Load points constitute an indicator of lethality and can help identifying drug target.";
+        return "Compute the Load points of a metabolic network. Load points constitute an indicator of lethality and can help identifying drug targets.";
     }
 
     @Override
     public Set<Doi> getDois() {
-        return Set.of();
+        return Set.of(new Doi("https://doi.org/10.1093/bioinformatics/btl181"));
     }
 }
-- 
GitLab


From ee869d1bc166b94424333e3838dd6a6c36583d35 Mon Sep 17 00:00:00 2001
From: lcottret <ludovic.cottret@inrae.fr>
Date: Fri, 3 Jan 2025 16:44:26 +0100
Subject: [PATCH 46/74] doc and refactoring

---
 .../networkAnalysis/MetaboRank.java           | 51 +++++++------------
 1 file changed, 17 insertions(+), 34 deletions(-)

diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/MetaboRank.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/MetaboRank.java
index 86058c9ac..89eda0bf1 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/MetaboRank.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/MetaboRank.java
@@ -57,6 +57,7 @@ import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumParame
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.Format;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.ParameterType;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.utils.Doi;
+import fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils;
 import org.kohsuke.args4j.Option;
 
 import java.io.*;
@@ -143,14 +144,9 @@ public class MetaboRank extends AbstractMet4jApplication {
 
     public void run() {
 
-        BioNetwork model = null;
-        try {
-            model = importModel(sbmlFilePath);
-        } catch (Met4jSbmlReaderException e) {
-            System.err.println("Error while reading the SBML file");
-            System.err.println(e.getMessage());
-            System.exit(1);
-        }
+        System.out.println("reading SBML...");
+        BioNetwork model = IOUtils.readSbml(sbmlFilePath);
+
         createCompoundGraph(model);
         setEdgeWeights(firstGraph, edgeWeightsFilePaths);
 
@@ -168,23 +164,10 @@ public class MetaboRank extends AbstractMet4jApplication {
             compute();
             printCompoundTable(output);
         }
-        System.err.println("done.");
-
-    }
+        System.out.println("done.");
 
-    /*
-     * CREATE MODEL FROM SBML FILE
-     * use default parameters for attributes value extraction from notes.
-     *
-     */
-    private BioNetwork importModel(String sbmlFilePath) throws Met4jSbmlReaderException {
-        JsbmlReader reader = new JsbmlReader(sbmlFilePath);
-        BioNetwork model = reader.read();
-        System.err.println("model imported.");
-        return model;
     }
 
-
     /*
      * CREATE COMPOUND GRAPH
      *
@@ -195,11 +178,11 @@ public class MetaboRank extends AbstractMet4jApplication {
      */
     private void createCompoundGraph(BioNetwork model) {
         firstGraph = new Bionetwork2BioGraph(model).getCompoundGraph();
-        System.err.println("compound graph created.");
+        System.out.println("compound graph created.");
 
         //Graph processing: side compound removal [optional]
         if (inputSide != null) {
-            System.err.println("removing side compounds...");
+            System.out.println("removing side compounds...");
             NodeMapping<BioMetabolite, ReactionEdge, CompoundGraph> mapper = new NodeMapping<>(firstGraph).skipIfNotFound();
             BioCollection<BioMetabolite> sideCpds = null;
             try {
@@ -210,7 +193,7 @@ public class MetaboRank extends AbstractMet4jApplication {
                 System.exit(1);
             }
             boolean removed = firstGraph.removeAllVertices(sideCpds);
-            if (removed) System.err.println(sideCpds.size() + " compounds removed.");
+            if (removed) System.out.println(sideCpds.size() + " compounds removed.");
         }
     }
 
@@ -230,7 +213,7 @@ public class MetaboRank extends AbstractMet4jApplication {
             }
         };
         reverseGraph = factory.reverse(firstGraph);
-        System.err.println("reverse graph created.");
+        System.out.println("reverse graph created.");
     }
 
 
@@ -259,7 +242,7 @@ public class MetaboRank extends AbstractMet4jApplication {
         wp.setWeight(graph);
         WeightUtils.removeEdgeWithNaNWeight(graph);
         wp.noStructFilter(graph);
-        System.err.println("weights computed.");
+        System.out.println("weights computed.");
     }
 
     public void setEdgeWeights(CompoundGraph graph, String localFilePath) {
@@ -277,7 +260,7 @@ public class MetaboRank extends AbstractMet4jApplication {
         }
         //remove disconnected nodes
         graph.removeIsolatedNodes();
-        System.err.println("weights computed.");
+        System.out.println("weights computed.");
     }
 
 
@@ -338,8 +321,8 @@ public class MetaboRank extends AbstractMet4jApplication {
             }
         }
 
-        System.err.println("seeds file imported");
-        System.err.println(seeds.size() + " seeds");
+        System.out.println("seeds file imported");
+        System.out.println(seeds.size() + " seeds");
     }
 
     public void compute() {
@@ -347,22 +330,22 @@ public class MetaboRank extends AbstractMet4jApplication {
         globalPageRankScore = computeScore(firstGraph, dampingFactor, maxNbOfIter, tolerance);
         globalPageRank = getRankFromScore(globalPageRankScore, null);
         normalizeScore(globalPageRankScore);
-        System.err.println("global pageRank computed");
+        System.out.println("global pageRank computed");
 
         globalCheiRankScore = computeScore(reverseGraph, dampingFactor, maxNbOfIter, tolerance);
         globalCheiRank = getRankFromScore(globalCheiRankScore, null);
         normalizeScore(globalCheiRankScore);
-        System.err.println("global cheiRank computed");
+        System.out.println("global cheiRank computed");
 
         pageRankScore = computeScore(firstGraph, dampingFactor, seeds, maxNbOfIter, tolerance);
         pageRank = getRankFromScore(pageRankScore, seeds.keySet());
         normalizeScore(pageRankScore);
-        System.err.println("pageRank computed");
+        System.out.println("pageRank computed");
 
         cheiRankScore = computeScore(reverseGraph, dampingFactor, seeds, maxNbOfIter, tolerance);
         cheiRank = getRankFromScore(cheiRankScore, seeds.keySet());
         normalizeScore(cheiRankScore);
-        System.err.println("cheiRank computed");
+        System.out.println("cheiRank computed");
 
         globalVsPersonalizedPageRank = computeGlobalVsPersonalized(globalPageRankScore, pageRankScore);
         globalVsPersonalizedCheiRank = computeGlobalVsPersonalized(globalCheiRankScore, cheiRankScore);
-- 
GitLab


From e0d3676d02a429570d771948c202f4dd21f5e575 Mon Sep 17 00:00:00 2001
From: lcottret <ludovic.cottret@inrae.fr>
Date: Fri, 3 Jan 2025 16:51:24 +0100
Subject: [PATCH 47/74] fix apps

---
 .../metexplore/met4j_toolbox/attributes/SetPathways.java      | 2 +-
 .../toulouse/metexplore/met4j_toolbox/convert/Sbml2Tab.java   | 4 ++--
 .../met4j_toolbox/networkAnalysis/CarbonSkeletonNet.java      | 2 +-
 .../fr/inrae/toulouse/metexplore/met4j_toolbox/utils/Doi.java | 2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/SetPathways.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/SetPathways.java
index 396f5b58e..994d75bc4 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/SetPathways.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/SetPathways.java
@@ -85,7 +85,7 @@ public class SetPathways extends AbstractSbmlSetReaction {
 
     @Override
     public Set<Doi> getDois() {
-        return Set.of(new Doi("10.2390/biecoll-jib-2016-290"));
+        return Set.of(new Doi("https://doi.org/10.1515/jib-2016-290"));
     }
 
     /**
diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/convert/Sbml2Tab.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/convert/Sbml2Tab.java
index fed8ac959..2a53287e1 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/convert/Sbml2Tab.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/convert/Sbml2Tab.java
@@ -60,10 +60,10 @@ import java.util.Set;
  */
 public class Sbml2Tab extends AbstractMet4jApplication {
 
-    @Option(name = "-i", usage = "[-->] String for irreversible reaction")
+    @Option(name = "-irr", usage = "[-->] String for irreversible reaction")
     public String i = "-->";
 
-    @Option(name = "-r", usage = "[<==>] String for reversible reaction")
+    @Option(name = "-rev", usage = "[<==>] String for reversible reaction")
     public String r = "<==>";
 
     @Format(name = EnumFormats.Tsv)
diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/CarbonSkeletonNet.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/CarbonSkeletonNet.java
index 5509ad73a..69f9cad90 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/CarbonSkeletonNet.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/CarbonSkeletonNet.java
@@ -68,7 +68,7 @@ public class CarbonSkeletonNet extends AbstractMet4jApplication {
     @Option(name = "-main", aliases = {"--onlyMainTransition"}, usage = "Compute RPAIRS-like tags and keep only main transitions for each reaction")
     public boolean main = false;
 
-    @Option(name = "-i", aliases = {"--fromIndexes"}, usage = "Use GSAM output with carbon indexes")
+    @Option(name = "-fi", aliases = {"--fromIndexes"}, usage = "Use GSAM output with carbon indexes")
     public boolean fromIndexes = false;
 
     public static void main(String[] args) {
diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/utils/Doi.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/utils/Doi.java
index edb72d28b..f62c3bc6e 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/utils/Doi.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/utils/Doi.java
@@ -132,7 +132,7 @@ public class Doi {
             this.detailsRetrieved = true;
 
         } catch (Exception e) {
-            System.err.println("Doi not reachable");
+            System.err.println("Doi "+doi+" not reachable");
         }
     }
 
-- 
GitLab


From 8db6c011e8ade20bd3ca14f50458ed30ef85ad0a Mon Sep 17 00:00:00 2001
From: lcottret <ludovic.cottret@inrae.fr>
Date: Mon, 6 Jan 2025 07:40:11 +0100
Subject: [PATCH 48/74] Refactoring and doc

---
 .../networkAnalysis/NetworkSummary.java       | 66 ++++++++-----------
 1 file changed, 28 insertions(+), 38 deletions(-)

diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/NetworkSummary.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/NetworkSummary.java
index 069be1361..07934a292 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/NetworkSummary.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/NetworkSummary.java
@@ -3,25 +3,24 @@ package fr.inrae.toulouse.metexplore.met4j_toolbox.networkAnalysis;
 import fr.inrae.toulouse.metexplore.met4j_core.biodata.BioMetabolite;
 import fr.inrae.toulouse.metexplore.met4j_core.biodata.BioNetwork;
 import fr.inrae.toulouse.metexplore.met4j_core.biodata.collection.BioCollection;
-import fr.inrae.toulouse.metexplore.met4j_graph.computation.connect.FloydWarshall;
-import fr.inrae.toulouse.metexplore.met4j_graph.computation.analyze.centrality.PathBasedCentrality;
 import fr.inrae.toulouse.metexplore.met4j_graph.computation.analyze.GraphLocalMeasure;
 import fr.inrae.toulouse.metexplore.met4j_graph.computation.analyze.GraphMeasure;
-import fr.inrae.toulouse.metexplore.met4j_graph.computation.utils.RankUtils;
-import fr.inrae.toulouse.metexplore.met4j_graph.computation.utils.ComputeAdjacencyMatrix;
+import fr.inrae.toulouse.metexplore.met4j_graph.computation.analyze.centrality.PathBasedCentrality;
+import fr.inrae.toulouse.metexplore.met4j_graph.computation.connect.FloydWarshall;
 import fr.inrae.toulouse.metexplore.met4j_graph.computation.connect.weighting.UnweightedPolicy;
+import fr.inrae.toulouse.metexplore.met4j_graph.computation.utils.ComputeAdjacencyMatrix;
+import fr.inrae.toulouse.metexplore.met4j_graph.computation.utils.RankUtils;
 import fr.inrae.toulouse.metexplore.met4j_graph.core.WeightingPolicy;
 import fr.inrae.toulouse.metexplore.met4j_graph.core.compound.CompoundGraph;
 import fr.inrae.toulouse.metexplore.met4j_graph.core.compound.ReactionEdge;
 import fr.inrae.toulouse.metexplore.met4j_graph.io.Bionetwork2BioGraph;
-import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.JsbmlReader;
-import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.Met4jSbmlReaderException;
 import fr.inrae.toulouse.metexplore.met4j_mathUtils.matrix.BioMatrix;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.AbstractMet4jApplication;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumFormats;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.Format;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.ParameterType;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.utils.Doi;
+import fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils;
 import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics;
 import org.kohsuke.args4j.Option;
 
@@ -45,12 +44,12 @@ public class NetworkSummary extends AbstractMet4jApplication {
     public String inputPath = null;
 
     @ParameterType(name = OutputFile)
-    @Format(name= EnumFormats.Txt)
+    @Format(name = EnumFormats.Txt)
     @Option(name = "-o", usage = "output report file", required = true)
     public String outputPath = null;
 
     @ParameterType(name = InputFile)
-    @Format(name= EnumFormats.Txt)
+    @Format(name = EnumFormats.Txt)
     @Option(name = "-s", aliases = {"--side"}, usage = "an optional file containing list of side compounds to ignore (recommended)")
     public String sideCompoundFile = null;
 
@@ -61,7 +60,7 @@ public class NetworkSummary extends AbstractMet4jApplication {
     public Boolean directed = false;
 
 
-    public static void main(String[] args)  {
+    public static void main(String[] args) {
         NetworkSummary app = new NetworkSummary();
         app.parseArguments(args);
         app.run();
@@ -72,19 +71,11 @@ public class NetworkSummary extends AbstractMet4jApplication {
 
 
         //import network
-        System.err.println("reading SBML...");
-        JsbmlReader reader = new JsbmlReader(this.inputPath);
-        BioNetwork network = null;
-        try {
-            network = reader.read();
-        } catch (Met4jSbmlReaderException e) {
-            System.err.println("Error while reading the SBML file");
-            System.err.println(e.getMessage());
-            System.exit(1);
-        }
+        System.out.println("reading SBML...");
+        BioNetwork network = IOUtils.readSbml(this.inputPath);
 
         //Create compound graph
-        System.err.println("Creating network...");
+        System.out.println("Creating graph...");
         Bionetwork2BioGraph builder = new Bionetwork2BioGraph(network);
         CompoundGraph graph = builder.getCompoundGraph();
 
@@ -94,7 +85,7 @@ public class NetworkSummary extends AbstractMet4jApplication {
         //Graph processing: side compound removal
         if (sideCompoundFile != null) {
             try {
-                System.err.println("removing side compounds...");
+                System.out.println("removing side compounds...");
                 BioCollection<BioMetabolite> sideCpds = new BioCollection<>();
                 BufferedReader fr = new BufferedReader(new FileReader(sideCompoundFile));
                 String line;
@@ -109,7 +100,7 @@ public class NetworkSummary extends AbstractMet4jApplication {
                 }
                 fr.close();
                 boolean removed = graph.removeAllVertices(sideCpds);
-                if (removed) System.err.println(sideCpds.size() + " compounds removed.");
+                if (removed) System.out.println(sideCpds.size() + " compounds removed.");
             } catch (IOException e) {
                 System.err.println("Error while reading the side compound file");
                 System.err.println(e.getMessage());
@@ -118,7 +109,7 @@ public class NetworkSummary extends AbstractMet4jApplication {
         }
 
         //Start Anlysis
-        System.err.println("perform basic analysis...");
+        System.out.println("perform basic analysis...");
         GraphMeasure analyzer = new GraphMeasure(graph);
         analyzer.adjustEdgeCountForMultiGraph();
 
@@ -129,7 +120,7 @@ public class NetworkSummary extends AbstractMet4jApplication {
             fw.write("#\tNetwork: " + this.inputPath + "\n");
             if (sideCompoundFile != null) fw.write("#\tSide compounds: " + this.sideCompoundFile + "\n");
             Date currentDate = new Date();
-            fw.write("#\t" + currentDate.toString() + "\n");
+            fw.write("#\t" + currentDate + "\n");
             fw.write("#" + "-".repeat(60) + "\n");
             //basic stats
             fw.write("Number of nodes:\t" + graph.vertexSet().size() + "\n");
@@ -137,7 +128,7 @@ public class NetworkSummary extends AbstractMet4jApplication {
             fw.write("Number of neighbor pairs (ignore parallel edges):\t" + (int) analyzer.getNumberOfEdges() + "\n");
 
             //connectivity
-            System.err.println("extract connected component...");
+            System.out.println("extract connected component...");
             List<Set<BioMetabolite>> cc = GraphMeasure.getConnectedComponents(graph);
             fw.write("Number of connected component:\t" + cc.size() + "\n");
             Map<Integer, Integer> ccSizes = cc.stream().collect(Collectors.groupingBy(Set::size))
@@ -147,10 +138,10 @@ public class NetworkSummary extends AbstractMet4jApplication {
             }
 
             //density
-            System.err.println("Compute density...");
+            System.out.println("Compute density...");
             fw.write("Density (gamma index):\t" + analyzer.getGamma() + "\n");
             DescriptiveStatistics clusterStats = new DescriptiveStatistics();
-            System.err.println("Compute local clustering coefficients...");
+            System.out.println("Compute local clustering coefficients...");
             GraphLocalMeasure<BioMetabolite, ReactionEdge, CompoundGraph> analyzer2 = new GraphLocalMeasure(graph);
             for (BioMetabolite v : graph.vertexSet()) {
                 clusterStats.addValue(analyzer2.getLocalClusteringCoeff(v));
@@ -159,7 +150,7 @@ public class NetworkSummary extends AbstractMet4jApplication {
 
 
             //degree statistics
-            System.err.println("Compute degree statistics...");
+            System.out.println("Compute degree statistics...");
             DescriptiveStatistics degreeStats = new DescriptiveStatistics();
             for (BioMetabolite v : graph.vertexSet()) {
                 degreeStats.addValue(graph.degreeOf(v));
@@ -169,7 +160,7 @@ public class NetworkSummary extends AbstractMet4jApplication {
 
             //distances statistics
             if (!skipdist) {
-                System.err.println("Compute distances...");
+                System.out.println("Compute distances...");
                 //  compute distance matrix
                 ComputeAdjacencyMatrix adjBuilder = new ComputeAdjacencyMatrix(graph);
                 if (!directed) adjBuilder.asUndirected();
@@ -178,7 +169,7 @@ public class NetworkSummary extends AbstractMet4jApplication {
                 BioMatrix distM = distComputor.getDistances();
 
                 //  compute distance stats
-                System.err.println("Compute distances statistics...");
+                System.out.println("Compute distances statistics...");
                 DescriptiveStatistics distStats = new DescriptiveStatistics();
                 //  gather all elements in matrix, remove infinity
                 for (int i = 0; i < distM.numRows(); i++) {
@@ -197,18 +188,18 @@ public class NetworkSummary extends AbstractMet4jApplication {
                 fw.write("Average shortest path length:\t" + distStats.getMean() + "\n");
 
                 //Centrality analysis
-                System.err.println("Compute centrality...");
+                System.out.println("Compute centrality...");
                 PathBasedCentrality<BioMetabolite, ReactionEdge, CompoundGraph> cm = new PathBasedCentrality(graph);
 
 //            Set<BioPath<BioMetabolite,ReactionEdge>> sp = new HashSet<>(distComputor.getPaths().values());
 //            LinkedHashMap<BioMetabolite, Integer> betweenness = RankUtils.computeRank(cm.getBetweenness(sp).entrySet().stream().collect(
 //                    Collectors.toMap(Map.Entry::getKey, e -> e.getValue().doubleValue())
 //            ));
-//            System.err.println("\tBetweenness done.");
+//            System.out.println("\tBetweenness done.");
 
                 Map<BioMetabolite, Double> closenessRaw = cm.getCloseness(distM);
                 LinkedHashMap<BioMetabolite, Integer> closeness = RankUtils.computeRank(closenessRaw);
-                System.err.println("\tCloseness done.");
+                System.out.println("\tCloseness done.");
 
                 Iterator<Map.Entry<BioMetabolite, Integer>> it = closeness.entrySet().iterator();
                 fw.write("Top Closeness:\n");
@@ -226,10 +217,9 @@ public class NetworkSummary extends AbstractMet4jApplication {
 //                fw.write("\t"+e.getValue()+"\t"+e.getKey().getName());
 //            }
             }
-            System.err.println("Done.");
+            System.out.println("Done.");
             fw.close();
-        }
-        catch (IOException e) {
+        } catch (IOException e) {
             System.err.println("Error while writing the result file");
             System.err.println(e.getMessage());
             System.exit(1);
@@ -243,14 +233,14 @@ public class NetworkSummary extends AbstractMet4jApplication {
 
     @Override
     public String getLongDescription() {
-        return "Use a metabolic network in SBML file and an optional list of side compounds, " +
+        return this.getShortDescription() + "\nUse a metabolic network in SBML file and an optional list of side compounds, " +
                 "and produce a report summarizing several graph measures characterising the structure of the network." +
                 "This includes (non-exhaustive list): size and order, connectivity, density, degree distribution, shortest paths length, top centrality nodes...";
     }
 
     @Override
     public String getShortDescription() {
-        return "Create a report summarizing several graph measures characterising the structure of the network.";
+        return "Create a report summarizing several graph measures characterising the structure of a metabolic network.";
     }
 
     @Override
-- 
GitLab


From 714f0b82fce6d48e19573e5db9464b9fb0d38cc3 Mon Sep 17 00:00:00 2001
From: lcottret <ludovic.cottret@inrae.fr>
Date: Mon, 6 Jan 2025 07:44:22 +0100
Subject: [PATCH 49/74] doc and refactoring

---
 .../networkAnalysis/PathwayNet.java           | 86 ++++++++-----------
 1 file changed, 37 insertions(+), 49 deletions(-)

diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/PathwayNet.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/PathwayNet.java
index a65f3f21d..f38d59e7c 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/PathwayNet.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/PathwayNet.java
@@ -14,12 +14,6 @@ import fr.inrae.toulouse.metexplore.met4j_graph.core.pathway.PathwayGraph;
 import fr.inrae.toulouse.metexplore.met4j_graph.core.pathway.PathwayGraphEdge;
 import fr.inrae.toulouse.metexplore.met4j_graph.io.Bionetwork2BioGraph;
 import fr.inrae.toulouse.metexplore.met4j_graph.io.ExportGraph;
-import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.JsbmlReader;
-import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.Met4jSbmlReaderException;
-import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.plugin.FBCParser;
-import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.plugin.GroupPathwayParser;
-import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.plugin.NotesParser;
-import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.plugin.PackageParser;
 import fr.inrae.toulouse.metexplore.met4j_mapping.Mapper;
 import fr.inrae.toulouse.metexplore.met4j_mathUtils.matrix.ExportMatrix;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.AbstractMet4jApplication;
@@ -28,47 +22,50 @@ import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumParame
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.Format;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.ParameterType;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.utils.Doi;
+import fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils;
 import org.kohsuke.args4j.Option;
 
 import java.io.IOException;
-import java.util.*;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
 import java.util.stream.Collectors;
 
 public class PathwayNet extends AbstractMet4jApplication {
 
-    @Format(name= EnumFormats.Sbml)
-    @ParameterType(name= EnumParameterTypes.InputFile)
-    @Option(name = "-s", usage = "input SBML file", required = true)
+    @Format(name = EnumFormats.Sbml)
+    @ParameterType(name = EnumParameterTypes.InputFile)
+    @Option(name = "-i", usage = "input SBML file", required = true)
     public String inputPath = null;
 
-    @ParameterType(name= EnumParameterTypes.InputFile)
-    @Format(name= EnumFormats.Txt)
-    @Option(name = "-sc", usage = "input Side compound file (recommended)", required = false)
+    @ParameterType(name = EnumParameterTypes.InputFile)
+    @Format(name = EnumFormats.Txt)
+    @Option(name = "-sc", usage = "input Side compound file (recommended)")
     public String inputSide = null;
 
-    @ParameterType(name= EnumParameterTypes.OutputFile)
-    @Format(name= EnumFormats.Gml)
+    @ParameterType(name = EnumParameterTypes.OutputFile)
+    @Format(name = EnumFormats.Txt) // Txt because it can be a matrix or a GML file
     @Option(name = "-o", usage = "output Graph file", required = true)
     public String outputPath = null;
 
-    @Option(name = "-ri", aliases = {"--removeIsolatedNodes"}, usage = "remove isolated nodes", required = false)
+    @Option(name = "-ri", aliases = {"--removeIsolatedNodes"}, usage = "remove isolated nodes")
     public boolean removeIsolated = false;
 
-    @Option(name = "-oss", aliases = {"--onlySourcesAndSinks"}, usage = "consider only metabolites that are source or sink in the pathway (i.e non-intermediary compounds)", required = false)
+    @Option(name = "-oss", aliases = {"--onlySourcesAndSinks"}, usage = "consider only metabolites that are source or sink in the pathway (i.e non-intermediary compounds)")
     public boolean onlySourcesAndSinks = false;
 
-    @ParameterType(name=EnumParameterTypes.InputFile)
-    @Format(name=EnumFormats.Tsv)
+    @ParameterType(name = EnumParameterTypes.InputFile)
+    @Format(name = EnumFormats.Tsv)
     @Option(name = "-cw", aliases = {"--customWeights"}, usage = "an optional file containing weights for pathway pairs", forbids = {"-ncw"})
     public String weightFile = null;
 
     @Option(name = "-ncw", aliases = {"--connectorWeights"}, usage = "set number of connecting compounds as weight", forbids = {"-cw"})
     public Boolean connectors = false;
 
-    @Option(name = "-am", aliases = {"--asmatrix"}, usage = "export as matrix (implies simple graph conversion). Default export as GML file", required = false)
+    @Option(name = "-am", aliases = {"--asmatrix"}, usage = "export as matrix (implies simple graph conversion). Default export as GML file")
     public boolean asMatrix = false;
 
-    public static void main(String[] args)  {
+    public static void main(String[] args) {
 
         PathwayNet app = new PathwayNet();
 
@@ -81,25 +78,13 @@ public class PathwayNet extends AbstractMet4jApplication {
 
     public void run() {
         System.out.print("Reading SBML...");
-        JsbmlReader reader = new JsbmlReader(this.inputPath);
-        ArrayList<PackageParser> pkgs = new ArrayList<>(Arrays.asList(
-                new NotesParser(false), new FBCParser(), new GroupPathwayParser()));
-
-        BioNetwork network = null;
-
-        try {
-            network = reader.read(pkgs);
-        } catch (Met4jSbmlReaderException e) {
-            System.err.println("Error while reading the SBML file");
-            System.err.println(e.getMessage());
-            System.exit(1);
-        }
+        BioNetwork network = IOUtils.readSbml(this.inputPath);
         System.out.println(" Done.");
 
         //Graph processing: side compound removal [optional]
         BioCollection<BioMetabolite> sideCpds = new BioCollection<>();
         if (inputSide != null) {
-            System.err.println("importing side compounds...");
+            System.out.println("importing side compounds...");
             Mapper<BioMetabolite> cmapper = new Mapper<>(network, BioNetwork::getMetabolitesView).skipIfNotFound();
 
             try {
@@ -113,7 +98,7 @@ public class PathwayNet extends AbstractMet4jApplication {
                 System.err.println(cmapper.getNumberOfSkippedEntries() + " side compounds not found in network.");
         }
 
-        System.out.print("Buildinig Network...");
+        System.out.print("Building Graph...");
         Bionetwork2BioGraph builder = new Bionetwork2BioGraph(network);
         PathwayGraph graph = onlySourcesAndSinks ? builder.getPathwayGraph(sideCpds) : builder.getPathwayOverlapGraph(sideCpds);
         System.out.println(" Done.");
@@ -121,7 +106,7 @@ public class PathwayNet extends AbstractMet4jApplication {
         //Graph processing: set weights [optional]
         WeightingPolicy<BioPathway, PathwayGraphEdge, PathwayGraph> wp = new UnweightedPolicy<>();
         if (weightFile != null) {
-            System.err.println("Setting edge weights...");
+            System.out.println("Setting edge weights...");
             wp = new WeightsFromFile(weightFile);
         } else if (connectors) {
             wp = new CustomWeightPolicy<>(e -> Double.valueOf(e.getConnectingCompounds().size()));
@@ -130,12 +115,12 @@ public class PathwayNet extends AbstractMet4jApplication {
         System.out.println(" Done.");
 
         //remove isolated nodes
-        if(removeIsolated){
+        if (removeIsolated) {
             System.out.println("Remove isolated nodes...");
             HashSet<BioPathway> nodes = new HashSet<>(graph.vertexSet());
             graph.removeIsolatedNodes();
             nodes.removeAll(graph.vertexSet());
-            for(BioPathway n : nodes){
+            for (BioPathway n : nodes) {
                 System.out.println("\tremoving " + n.getName());
             }
             System.out.println(" Done.");
@@ -143,33 +128,36 @@ public class PathwayNet extends AbstractMet4jApplication {
 
         //export graph
         System.out.print("Exporting...");
-        if(asMatrix){
+        if (asMatrix) {
             ComputeAdjacencyMatrix adjBuilder = new ComputeAdjacencyMatrix(graph);
-            ExportMatrix.toCSV(this.outputPath,adjBuilder.getadjacencyMatrix());
-        }else{
-            if (!onlySourcesAndSinks) EdgeMerger.undirectedMergeEdgesWithOverride(graph,null);
+            ExportMatrix.toCSV(this.outputPath, adjBuilder.getadjacencyMatrix());
+        } else {
+            if (!onlySourcesAndSinks) EdgeMerger.undirectedMergeEdgesWithOverride(graph, null);
             BioNetwork finalNetwork = network;
-            Map<BioPathway,Integer> size = graph.vertexSet().stream()
+            Map<BioPathway, Integer> size = graph.vertexSet().stream()
                     .collect(Collectors.toMap(p -> p, p -> finalNetwork.getMetabolitesFromPathway(p).size()));
-            ExportGraph.toGmlWithAttributes(graph, this.outputPath, size, "size",true);
+            ExportGraph.toGmlWithAttributes(graph, this.outputPath, size, "size", true);
         }
         System.out.println(" Done.");
-        return;
     }
 
     @Override
-    public String getLabel() {return this.getClass().getSimpleName();}
+    public String getLabel() {
+        return this.getClass().getSimpleName();
+    }
 
     @Override
     public String getLongDescription() {
-        return "Genome-scale metabolic networks are often partitioned into metabolic pathways. Pathways are frequently " +
+        return this.getShortDescription() + "\nGenome-scale metabolic networks are often partitioned into metabolic pathways. Pathways are frequently " +
                 "considered independently despite frequent coupling in their activity due to shared metabolites. In " +
                 "order to decipher the interconnections linking overlapping pathways, this app proposes the creation of " +
                 "\"Pathway Network\", where two pathways are linked if they share compounds.";
     }
 
     @Override
-    public String getShortDescription() {return "Creation of a Pathway Network representation of a SBML file content";}
+    public String getShortDescription() {
+        return "Creation of a Pathway Network representation of a SBML file content";
+    }
 
     @Override
     public Set<Doi> getDois() {
-- 
GitLab


From 5c3ff3a8e308afd776ce5b418de50491795d24f3 Mon Sep 17 00:00:00 2001
From: lcottret <ludovic.cottret@inrae.fr>
Date: Mon, 6 Jan 2025 07:49:05 +0100
Subject: [PATCH 50/74] doc and refactoring

---
 .../networkAnalysis/PrecursorNetwork.java     | 45 +++++++++----------
 1 file changed, 20 insertions(+), 25 deletions(-)

diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/PrecursorNetwork.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/PrecursorNetwork.java
index f526215af..fcea05d4c 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/PrecursorNetwork.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/PrecursorNetwork.java
@@ -2,6 +2,7 @@ package fr.inrae.toulouse.metexplore.met4j_toolbox.networkAnalysis;
 
 import fr.inrae.toulouse.metexplore.met4j_core.biodata.BioEntity;
 import fr.inrae.toulouse.metexplore.met4j_core.biodata.BioMetabolite;
+import fr.inrae.toulouse.metexplore.met4j_core.biodata.BioNetwork;
 import fr.inrae.toulouse.metexplore.met4j_core.biodata.BioReaction;
 import fr.inrae.toulouse.metexplore.met4j_core.biodata.collection.BioCollection;
 import fr.inrae.toulouse.metexplore.met4j_graph.core.bipartite.BipartiteEdge;
@@ -9,21 +10,19 @@ import fr.inrae.toulouse.metexplore.met4j_graph.core.bipartite.BipartiteGraph;
 import fr.inrae.toulouse.metexplore.met4j_graph.io.Bionetwork2BioGraph;
 import fr.inrae.toulouse.metexplore.met4j_graph.io.ExportGraph;
 import fr.inrae.toulouse.metexplore.met4j_graph.io.NodeMapping;
-import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.JsbmlReader;
-import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.Met4jSbmlReaderException;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.AbstractMet4jApplication;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumFormats;
-import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumParameterTypes;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.Format;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.ParameterType;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.utils.Doi;
+import fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils;
 import org.kohsuke.args4j.Option;
 
 import java.io.IOException;
 import java.util.Set;
 
-import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumFormats.Gml;
 import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumFormats.Sbml;
+import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumFormats.Txt;
 import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumParameterTypes.InputFile;
 import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumParameterTypes.OutputFile;
 
@@ -36,29 +35,29 @@ public class PrecursorNetwork extends AbstractMet4jApplication {
     public String sbmlFilePath;
 
     @ParameterType(name = InputFile)
-    @Format(name= EnumFormats.Txt)
+    @Format(name = EnumFormats.Txt)
     @Option(name = "-t", aliases = {"--targets"}, usage = "input target file: tabulated file containing node of interest ids", required = true)
     public String targetsFilePath;
 
-    @Format(name = Gml)
+    @Format(name = Txt) // Because the output is a tabulated file or a GML file
     @ParameterType(name = OutputFile)
     @Option(name = "-o", usage = "output file: path to the .gml file where the results precursor network will be exported", required = true)
     public String output;
 
     //options
     @ParameterType(name = InputFile)
-    @Format(name= EnumFormats.Txt)
+    @Format(name = EnumFormats.Txt)
     @Option(name = "-sc", aliases = {"--sides"}, usage = "an optional file containing list of ubiquitous compounds to be considered already available")
     public String sideCompoundFile = null;
     @ParameterType(name = InputFile)
-    @Format(name= EnumFormats.Txt)
+    @Format(name = EnumFormats.Txt)
     @Option(name = "-ir", aliases = {"--ignore"}, usage = "an optional file containing list of reaction to ignore (forbid inclusion in scope)")
     public String reactionToIgnoreFile = null;
 
-    @Option(name = "-tab", aliases = {"--asTable"}, usage = "Export in tabulated file instead of .GML")
+    @Option(name = "-tab", aliases = {"--asTable"}, usage = "export in tabulated file instead of .GML")
     public Boolean asTable = false;
 
-    public static void main(String[] args)  {
+    public static void main(String[] args) {
         PrecursorNetwork app = new PrecursorNetwork();
         app.parseArguments(args);
         app.run();
@@ -66,15 +65,11 @@ public class PrecursorNetwork extends AbstractMet4jApplication {
 
 
     public void run() {
-        JsbmlReader in = new JsbmlReader(sbmlFilePath);
-        BipartiteGraph graph = null;
-        try {
-            graph = (new Bionetwork2BioGraph(in.read())).getBipartiteGraph();
-        } catch (Met4jSbmlReaderException e) {
-            System.err.println("Error while reading the SBML file");
-            System.err.println(e.getMessage());
-            System.exit(1);
-        }
+
+        BioNetwork network = IOUtils.readSbml(sbmlFilePath);
+
+        BipartiteGraph graph = (new Bionetwork2BioGraph(network)).getBipartiteGraph();
+
         NodeMapping<BioEntity, BipartiteEdge, BipartiteGraph> mapper = new NodeMapping<>(graph).skipIfNotFound();
 
         BioCollection<BioMetabolite> targets = null;
@@ -89,7 +84,7 @@ public class PrecursorNetwork extends AbstractMet4jApplication {
         }
         BioCollection<BioMetabolite> bootstraps = null;
         try {
-            bootstraps = (sideCompoundFile==null) ? new BioCollection<>() : mapper.map(sideCompoundFile).stream()
+            bootstraps = (sideCompoundFile == null) ? new BioCollection<>() : mapper.map(sideCompoundFile).stream()
                     .map(BioMetabolite.class::cast)
                     .collect(BioCollection::new, BioCollection::add, BioCollection::addAll);
         } catch (IOException e) {
@@ -99,7 +94,7 @@ public class PrecursorNetwork extends AbstractMet4jApplication {
         }
         BioCollection<BioReaction> forbidden = null;
         try {
-            forbidden = (reactionToIgnoreFile==null) ? new BioCollection<>() : mapper.map(reactionToIgnoreFile).stream()
+            forbidden = (reactionToIgnoreFile == null) ? new BioCollection<>() : mapper.map(reactionToIgnoreFile).stream()
                     .map(BioReaction.class::cast)
                     .collect(BioCollection::new, BioCollection::add, BioCollection::addAll);
         } catch (IOException e) {
@@ -108,15 +103,15 @@ public class PrecursorNetwork extends AbstractMet4jApplication {
             System.exit(1);
         }
 
-        if(targets.isEmpty()){
+        if (targets.isEmpty()) {
             System.err.println("no target available, computation aborted");
-        }else {
+        } else {
             fr.inrae.toulouse.metexplore.met4j_graph.computation.analyze.PrecursorNetwork precursorComp =
                     new fr.inrae.toulouse.metexplore.met4j_graph.computation.analyze.PrecursorNetwork(graph, bootstraps, targets, forbidden);
             BipartiteGraph precursorNet = precursorComp.getPrecursorNetwork();
-            if(asTable){
+            if (asTable) {
                 ExportGraph.toTab(precursorNet, output);
-            }else{
+            } else {
                 ExportGraph.toGml(precursorNet, output);
             }
         }
-- 
GitLab


From e952bca85d2d4c55e35786a50ef0113b6741d102 Mon Sep 17 00:00:00 2001
From: lcottret <ludovic.cottret@inrae.fr>
Date: Mon, 6 Jan 2025 07:52:28 +0100
Subject: [PATCH 51/74] doc and refactoring

---
 .../ReactionDistanceMatrix.java               | 80 +++++++++----------
 1 file changed, 38 insertions(+), 42 deletions(-)

diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/ReactionDistanceMatrix.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/ReactionDistanceMatrix.java
index eb0c0524a..b953ad157 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/ReactionDistanceMatrix.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/ReactionDistanceMatrix.java
@@ -14,14 +14,15 @@ import fr.inrae.toulouse.metexplore.met4j_graph.core.reaction.CompoundEdge;
 import fr.inrae.toulouse.metexplore.met4j_graph.core.reaction.ReactionGraph;
 import fr.inrae.toulouse.metexplore.met4j_graph.io.Bionetwork2BioGraph;
 import fr.inrae.toulouse.metexplore.met4j_graph.io.NodeMapping;
-import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.JsbmlReader;
-import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.Met4jSbmlReaderException;
 import fr.inrae.toulouse.metexplore.met4j_mapping.Mapper;
 import fr.inrae.toulouse.metexplore.met4j_mathUtils.matrix.BioMatrix;
 import fr.inrae.toulouse.metexplore.met4j_mathUtils.matrix.ExportMatrix;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.AbstractMet4jApplication;
-import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.*;
+import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumFormats;
+import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.Format;
+import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.ParameterType;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.utils.Doi;
+import fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils;
 import org.kohsuke.args4j.Option;
 
 import java.io.IOException;
@@ -30,7 +31,8 @@ import java.util.Set;
 
 import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumFormats.Csv;
 import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumFormats.Sbml;
-import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumParameterTypes.*;
+import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumParameterTypes.InputFile;
+import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumParameterTypes.OutputFile;
 
 public class ReactionDistanceMatrix extends AbstractMet4jApplication {
 
@@ -84,15 +86,9 @@ public class ReactionDistanceMatrix extends AbstractMet4jApplication {
 
     public void run() {
 
-        JsbmlReader reader = new JsbmlReader(this.inputPath);
-        BioNetwork network = null;
-        try {
-            network = reader.read();
-        } catch (Met4jSbmlReaderException e) {
-            System.err.println("Error while reading the SBML file");
-            System.err.println(e.getMessage());
-            System.exit(1);
-        }
+        System.out.println("Reading SBML...");
+        BioNetwork network = IOUtils.readSbml(inputPath);
+
         //Instantiate nodes to remove and mappers
         Mapper<BioMetabolite> metMapper = new Mapper<>(network, BioNetwork::getMetabolitesView).skipIfNotFound();
         Mapper<BioReaction> rxnMapper = new Mapper<>(network, BioNetwork::getReactionsView).skipIfNotFound();
@@ -101,7 +97,7 @@ public class ReactionDistanceMatrix extends AbstractMet4jApplication {
         BioCollection<BioMetabolite> sideCpds = new BioCollection<BioMetabolite>();
         if (sideCompoundFile != null) {
             try {
-                System.err.println("removing side compounds...");
+                System.out.println("removing side compounds...");
                 sideCpds = metMapper.map(sideCompoundFile);
             } catch (IOException e) {
                 System.err.println("Error while reading the side compound file");
@@ -110,23 +106,23 @@ public class ReactionDistanceMatrix extends AbstractMet4jApplication {
             }
             if (metMapper.getNumberOfSkippedEntries() > 0)
                 System.err.println(metMapper.getNumberOfSkippedEntries() + " side compounds not found in network.");
-            System.err.println(sideCpds.size() + " side compounds to ignore during graph build");
+            System.out.println(sideCpds.size() + " side compounds to ignore during graph build");
         }
         //Graph processing: reactions removal [optional]
         BioCollection<BioReaction> rList = new BioCollection<BioReaction>();
         if (rExclude != null) {
-          System.err.println("removing reactions to exclude...");
-          try {
-            rList = rxnMapper.map(rExclude);
-          } catch (IOException e) {
-              System.err.println("Error while reading the reaction to ignore file");
-              System.err.println(e.getMessage());
-              System.exit(1);
-          }
-          if (rxnMapper.getNumberOfSkippedEntries() > 0)
-          System.err.println(rxnMapper.getNumberOfSkippedEntries() + " reactions to exclude not found in network.");
-          System.err.println(rList.size() + " reactions ignored during graph build.");
-      }
+            System.out.println("removing reactions to exclude...");
+            try {
+                rList = rxnMapper.map(rExclude);
+            } catch (IOException e) {
+                System.err.println("Error while reading the reaction to ignore file");
+                System.err.println(e.getMessage());
+                System.exit(1);
+            }
+            if (rxnMapper.getNumberOfSkippedEntries() > 0)
+                System.err.println(rxnMapper.getNumberOfSkippedEntries() + " reactions to exclude not found in network.");
+            System.out.println(rList.size() + " reactions ignored during graph build.");
+        }
         //Create reaction graph
         Bionetwork2BioGraph builder = new Bionetwork2BioGraph(network);
         ReactionGraph graph = builder.getReactionGraph(sideCpds, rList);
@@ -135,20 +131,20 @@ public class ReactionDistanceMatrix extends AbstractMet4jApplication {
         if (weightFile != null) {
             wp = new WeightsFromFile(weightFile, true);
         } else if (degree) {
-            if(!undirected){
+            if (!undirected) {
                 int pow = 2;
                 wp = new DegreeWeightPolicy(pow);
-            }else{
+            } else {
                 //since degree weighting policy is not symmetric, for undirected case we create reversed edges, apply
                 //a corrected degree computation for each edge, and treat the graph as normal
                 graph.asUndirected();
-                undirected=false;
-                wp = new CustomWeightPolicy<BioReaction,CompoundEdge,ReactionGraph>(
+                undirected = false;
+                wp = new CustomWeightPolicy<BioReaction, CompoundEdge, ReactionGraph>(
                         e -> {
                             Double w = Double.valueOf(graph.inDegreeOf(e.getV2()));
                             w += Double.valueOf(graph.outDegreeOf(e.getV2()));
-                            w = w/2;    //adjust for undirected doubled edges
-                            w = StrictMath.pow(w,2);
+                            w = w / 2;    //adjust for undirected doubled edges
+                            w = StrictMath.pow(w, 2);
                             return w;
                         });
             }
@@ -157,13 +153,13 @@ public class ReactionDistanceMatrix extends AbstractMet4jApplication {
 
         //init BioMatrix
         BioMatrix distM = null;
-        if(rxnFile == null){
+        if (rxnFile == null) {
             //compute distance matrix
             ShortestPath matrixComputor = new ShortestPath<>(graph, !undirected);
             //get All SPs
             distM = matrixComputor.getShortestPathDistanceMatrix();
-        }else{
-            System.err.println("filtering matrix...");
+        } else {
+            System.out.println("filtering matrix...");
             NodeMapping mapper = new NodeMapping<>(graph).skipIfNotFound();
             Set<BioReaction> seeds = null;
             try {
@@ -176,7 +172,7 @@ public class ReactionDistanceMatrix extends AbstractMet4jApplication {
             //compute distance matrix
             ShortestPath<BioReaction, CompoundEdge, ReactionGraph> matrixComputor = new ShortestPath<>(graph, !undirected);
             //get SPs
-            distM = matrixComputor.getShortestPathDistanceMatrix(seeds,seeds);
+            distM = matrixComputor.getShortestPathDistanceMatrix(seeds, seeds);
         }
         //export results
         ExportMatrix.toCSV(outputPath, distM);
@@ -193,11 +189,11 @@ public class ReactionDistanceMatrix extends AbstractMet4jApplication {
     @Override
     public String getLongDescription() {
         return this.getShortDescription() + "\n" +
-            "The distance between two reactions is computed as the length of the shortest path connecting the two in the reaction graph, " +
-            "where two reactions are linked if they produce a metabolite consumed by the other or the other way around.\n" +
-            "An optional edge weighting can be used, turning the distances into the sum of edge weights in the lightest path, rather than the length of the shortest path." +
-            "The default weighting use target's degree squared. Alternatively, custom weighting can be provided in a file. In that case, edges without weight are ignored during path search.\n" +
-            "If no edge weighting is set, it is recommended to provide a list of side compounds to ignore during network traversal.";
+                "The distance between two reactions is computed as the length of the shortest path connecting the two in the reaction graph, " +
+                "where two reactions are linked if they produce a metabolite consumed by the other or the other way around.\n" +
+                "An optional edge weighting can be used, turning the distances into the sum of edge weights in the lightest path, rather than the length of the shortest path." +
+                "The default weighting use target's degree squared. Alternatively, custom weighting can be provided in a file. In that case, edges without weight are ignored during path search.\n" +
+                "If no edge weighting is set, it is recommended to provide a list of side compounds to ignore during network traversal.";
     }
 
     @Override
-- 
GitLab


From af90f5091b6f648f646168a17b7fb5508c56cb56 Mon Sep 17 00:00:00 2001
From: lcottret <ludovic.cottret@inrae.fr>
Date: Mon, 6 Jan 2025 07:57:15 +0100
Subject: [PATCH 52/74] doc and refactoring

---
 .../networkAnalysis/ScopeNetwork.java         | 49 +++++++++----------
 1 file changed, 22 insertions(+), 27 deletions(-)

diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/ScopeNetwork.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/ScopeNetwork.java
index a5f2e6fb3..c00b908b8 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/ScopeNetwork.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/ScopeNetwork.java
@@ -2,6 +2,7 @@ package fr.inrae.toulouse.metexplore.met4j_toolbox.networkAnalysis;
 
 import fr.inrae.toulouse.metexplore.met4j_core.biodata.BioEntity;
 import fr.inrae.toulouse.metexplore.met4j_core.biodata.BioMetabolite;
+import fr.inrae.toulouse.metexplore.met4j_core.biodata.BioNetwork;
 import fr.inrae.toulouse.metexplore.met4j_core.biodata.BioReaction;
 import fr.inrae.toulouse.metexplore.met4j_core.biodata.collection.BioCollection;
 import fr.inrae.toulouse.metexplore.met4j_graph.computation.analyze.ScopeCompounds;
@@ -10,22 +11,20 @@ import fr.inrae.toulouse.metexplore.met4j_graph.core.bipartite.BipartiteGraph;
 import fr.inrae.toulouse.metexplore.met4j_graph.io.Bionetwork2BioGraph;
 import fr.inrae.toulouse.metexplore.met4j_graph.io.ExportGraph;
 import fr.inrae.toulouse.metexplore.met4j_graph.io.NodeMapping;
-import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.JsbmlReader;
-import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.Met4jSbmlReaderException;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.AbstractMet4jApplication;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumFormats;
-import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumParameterTypes;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.Format;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.ParameterType;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.utils.Doi;
+import fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils;
 import org.kohsuke.args4j.Option;
 
 import java.io.IOException;
 import java.util.HashSet;
 import java.util.Set;
 
-import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumFormats.Gml;
 import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumFormats.Sbml;
+import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumFormats.Txt;
 import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumParameterTypes.InputFile;
 import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumParameterTypes.OutputFile;
 
@@ -38,18 +37,18 @@ public class ScopeNetwork extends AbstractMet4jApplication {
     public String sbmlFilePath;
 
     @ParameterType(name = InputFile)
-    @Format(name= EnumFormats.Txt)
+    @Format(name = EnumFormats.Txt)
     @Option(name = "-s", aliases = {"--seeds"}, usage = "input seeds file: tabulated file containing node of interest ids", required = true)
     public String seedsFilePath;
 
-    @Format(name = Gml)
+    @Format(name = Txt) // Because the output is a tabulated file or a GML file
     @ParameterType(name = OutputFile)
-    @Option(name = "-o", usage = "output file: path to the .gml file where the results scope network will be exported", required = true)
+    @Option(name = "-o", usage = "output file: path to the .gml file or tabulated file (see -asTable parameter) where the results scope network will be exported", required = true)
     public String output;
 
     //options
     @ParameterType(name = InputFile)
-    @Format(name= EnumFormats.Txt)
+    @Format(name = EnumFormats.Txt)
     @Option(name = "-sc", aliases = {"--sides"}, usage = "an optional file containing list of ubiquitous side compounds to be considered available by default but ignored during expansion")
     public String sideCompoundFile = null;
 
@@ -57,7 +56,7 @@ public class ScopeNetwork extends AbstractMet4jApplication {
     public boolean includeSides = false;
 
     @ParameterType(name = InputFile)
-    @Format(name= EnumFormats.Txt)
+    @Format(name = EnumFormats.Txt)
     @Option(name = "-ir", aliases = {"--ignore"}, usage = "an optional file containing list of reaction to ignore (forbid inclusion in scope")
     public String reactionToIgnoreFile = null;
 
@@ -67,7 +66,7 @@ public class ScopeNetwork extends AbstractMet4jApplication {
     @Option(name = "-tab", aliases = {"--asTable"}, usage = "Export in tabulated file instead of .GML")
     public Boolean asTable = false;
 
-    public static void main(String[] args)  {
+    public static void main(String[] args) {
         ScopeNetwork app = new ScopeNetwork();
         app.parseArguments(args);
         app.run();
@@ -75,15 +74,11 @@ public class ScopeNetwork extends AbstractMet4jApplication {
 
 
     public void run() {
-        JsbmlReader in = new JsbmlReader(sbmlFilePath);
-        BipartiteGraph graph = null;
-        try {
-            graph = (new Bionetwork2BioGraph(in.read())).getBipartiteGraph();
-        } catch (Met4jSbmlReaderException e) {
-            System.err.println("Error while reading the SBML file");
-            System.err.println(e.getMessage());
-            System.exit(1);
-        }
+
+        System.out.println("reading SBML...");
+        BioNetwork network = IOUtils.readSbml(sbmlFilePath);
+        BipartiteGraph graph = (new Bionetwork2BioGraph(network)).getBipartiteGraph();
+
         NodeMapping<BioEntity, BipartiteEdge, BipartiteGraph> mapper = new NodeMapping<>(graph).skipIfNotFound();
 
         BioCollection<BioMetabolite> seeds = null;
@@ -98,7 +93,7 @@ public class ScopeNetwork extends AbstractMet4jApplication {
         }
         BioCollection<BioMetabolite> bootstraps = null;
         try {
-            bootstraps = (sideCompoundFile==null) ? new BioCollection<>() : mapper.map(sideCompoundFile).stream()
+            bootstraps = (sideCompoundFile == null) ? new BioCollection<>() : mapper.map(sideCompoundFile).stream()
                     .map(BioMetabolite.class::cast)
                     .collect(BioCollection::new, BioCollection::add, BioCollection::addAll);
         } catch (IOException e) {
@@ -108,25 +103,25 @@ public class ScopeNetwork extends AbstractMet4jApplication {
         }
         BioCollection<BioReaction> forbidden = null;
         try {
-            forbidden = (reactionToIgnoreFile==null) ? new BioCollection<>() : mapper.map(reactionToIgnoreFile).stream()
-                        .map(BioReaction.class::cast)
-                        .collect(BioCollection::new, BioCollection::add, BioCollection::addAll);
+            forbidden = (reactionToIgnoreFile == null) ? new BioCollection<>() : mapper.map(reactionToIgnoreFile).stream()
+                    .map(BioReaction.class::cast)
+                    .collect(BioCollection::new, BioCollection::add, BioCollection::addAll);
         } catch (IOException e) {
             System.err.println("Error while reading the reactions-to-ignore file");
             System.err.println(e.getMessage());
             System.exit(1);
         }
 
-        if(seeds.isEmpty()){
+        if (seeds.isEmpty()) {
             System.err.println("no seed available, computation aborted");
-        }else {
+        } else {
             ScopeCompounds scopeComp = new ScopeCompounds(graph, seeds, bootstraps, forbidden);
             if (includeSides) scopeComp.includeBootstrapsInScope();
             if (trace) scopeComp.trace();
             BipartiteGraph scope = scopeComp.getScopeNetwork();
-            if(asTable){
+            if (asTable) {
                 ExportGraph.toTab(scope, output);
-            }else{
+            } else {
                 if (trace) {
                     ExportGraph.toGmlWithAttributes(scope, output, scopeComp.getExpansionSteps(), "step");
                 } else {
-- 
GitLab


From acbff2e46a3d9f01120f18ab5baf41ff1c073550 Mon Sep 17 00:00:00 2001
From: lcottret <ludovic.cottret@inrae.fr>
Date: Mon, 6 Jan 2025 08:18:55 +0100
Subject: [PATCH 53/74] doc and refactoring

---
 .../networkAnalysis/SeedsAndTargets.java      | 103 ++++++++----------
 1 file changed, 46 insertions(+), 57 deletions(-)

diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/SeedsAndTargets.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/SeedsAndTargets.java
index 082e88ead..a46e3d7d3 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/SeedsAndTargets.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/SeedsAndTargets.java
@@ -10,14 +10,13 @@ import fr.inrae.toulouse.metexplore.met4j_graph.core.compound.CompoundGraph;
 import fr.inrae.toulouse.metexplore.met4j_graph.core.compound.ReactionEdge;
 import fr.inrae.toulouse.metexplore.met4j_graph.io.Bionetwork2BioGraph;
 import fr.inrae.toulouse.metexplore.met4j_graph.io.NodeMapping;
-import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.JsbmlReader;
-import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.Met4jSbmlReaderException;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.AbstractMet4jApplication;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumFormats;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumParameterTypes;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.Format;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.ParameterType;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.utils.Doi;
+import fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils;
 import org.kohsuke.args4j.Option;
 
 import java.io.FileWriter;
@@ -27,58 +26,55 @@ import java.util.Set;
 
 public class SeedsAndTargets extends AbstractMet4jApplication {
 
-    @Format(name= EnumFormats.Sbml)
-    @ParameterType(name= EnumParameterTypes.InputFile)
+    @Format(name = EnumFormats.Sbml)
+    @ParameterType(name = EnumParameterTypes.InputFile)
     @Option(name = "-i", aliases = {"--inputSBML"}, usage = "input SBML file", required = true)
     public String inputPath = null;
 
-    @ParameterType(name= EnumParameterTypes.InputFile)
-    @Format(name= EnumFormats.Txt)
-    @Option(name = "-sc", aliases = {"--sideFile"}, usage = "input Side compound file", required = false)
+    @ParameterType(name = EnumParameterTypes.InputFile)
+    @Format(name = EnumFormats.Txt)
+    @Option(name = "-sc", aliases = {"--sideFile"}, usage = "input side compound file")
     public String inputSide = null;
 
-    @ParameterType(name= EnumParameterTypes.OutputFile)
-    @Format(name= EnumFormats.Tsv)
+    @ParameterType(name = EnumParameterTypes.OutputFile)
+    @Format(name = EnumFormats.Tsv)
     @Option(name = "-o", aliases = {"--output"}, usage = "output seeds file", required = true)
     public String outputPath = null;
 
-    @ParameterType(name= EnumParameterTypes.Text)
-    @Option(name = "-c", aliases = {"--comp"}, usage = "Selected compartment(s), as model identifiers, separated by \"+\" sign if more than one", required = false)
+    @ParameterType(name = EnumParameterTypes.Text)
+    @Option(name = "-c", aliases = {"--comp"}, usage = "selected compartment(s), as model identifiers, separated by \"+\" sign if more than one")
     public String comp = null;
 
-    @ParameterType(name= EnumParameterTypes.Boolean)
-    @Option(name = "-s", aliases = {"--seeds"}, usage = "export seeds", required = false)
+    @ParameterType(name = EnumParameterTypes.Boolean)
+    @Option(name = "-s", aliases = {"--seeds"}, usage = "export seeds")
     public boolean source = false;
 
-    @ParameterType(name= EnumParameterTypes.Boolean)
-    @Option(name = "-t", aliases = {"--targets"}, usage = "export targets", required = false)
+    @ParameterType(name = EnumParameterTypes.Boolean)
+    @Option(name = "-t", aliases = {"--targets"}, usage = "export targets")
     public boolean sink = false;
 
-    @ParameterType(name= EnumParameterTypes.Boolean)
-    @Option(name = "-!s", aliases = {"--notSeed"}, usage = "export nodes that are not seed", required = false)
+    @ParameterType(name = EnumParameterTypes.Boolean)
+    @Option(name = "-!s", aliases = {"--notSeed"}, usage = "export nodes that are not seeds")
     public boolean notsource = false;
 
-    @ParameterType(name= EnumParameterTypes.Boolean)
-    @Option(name = "-!t", aliases = {"--notTarget"}, usage = "export nodes that are not targets", required = false)
+    @ParameterType(name = EnumParameterTypes.Boolean)
+    @Option(name = "-!t", aliases = {"--notTarget"}, usage = "export nodes that are not targets")
     public boolean notsink = false;
 
-    @ParameterType(name= EnumParameterTypes.Boolean)
-    @Option(name = "-is", aliases = {"--keepIsolated"}, usage = "do not ignore isolated nodes, consider isolated both seed and target", required = false)
+    @ParameterType(name = EnumParameterTypes.Boolean)
+    @Option(name = "-is", aliases = {"--keepIsolated"}, usage = "do not ignore isolated nodes, consider isolated both seeds and targets")
     public boolean keepIsolated = false;
 
-    @ParameterType(name= EnumParameterTypes.Boolean)
-    @Option(name = "-B", aliases = {"--useBorensteinAlg"}, usage = "use Borenstein Algorithm. Please cite Borenstein et al. 2008 Large-scale reconstruction and phylogenetic analysis of metabolic environments https://doi.org/10.1073/pnas.0806162105). ignore internal option", required = false)
+    @ParameterType(name = EnumParameterTypes.Boolean)
+    @Option(name = "-B", aliases = {"--useBorensteinAlg"}, usage = "use Borenstein Algorithm. Please cite Borenstein et al. 2008 Large-scale reconstruction and phylogenetic analysis of metabolic environments https://doi.org/10.1073/pnas.0806162105), ignore internal option")
     public boolean useBorensteinAlg = false;
 
 
-    @ParameterType(name= EnumParameterTypes.Boolean)
-    @Option(name = "-in", aliases = {"--internal"}, usage = "if an external compartment is defined, adjust degree by considering internal counterpart", required = false)
+    @ParameterType(name = EnumParameterTypes.Boolean)
+    @Option(name = "-in", aliases = {"--internal"}, usage = "if an external compartment is defined, adjust degree by considering internal counterpart")
     public boolean useInternal = false;
 
 
-
-
-
     public static void main(String[] args) {
 
         SeedsAndTargets app = new SeedsAndTargets();
@@ -101,25 +97,17 @@ public class SeedsAndTargets extends AbstractMet4jApplication {
         }
 
         //import network
-        System.err.println("reading SBML...");
-        JsbmlReader reader = new JsbmlReader(this.inputPath);
-        BioNetwork network = null;
-        try {
-            network = reader.read();
-        } catch (Met4jSbmlReaderException e) {
-            System.err.println("Error while reading the SBML file");
-            System.err.println(e.getMessage());
-            System.exit(1);
-        }
+        System.out.println("reading SBML...");
+        BioNetwork network = IOUtils.readSbml(this.inputPath);
 
         //Create compound graph
-        System.err.println("Creating network...");
+        System.out.println("Creating graph...");
         Bionetwork2BioGraph builder = new Bionetwork2BioGraph(network);
         CompoundGraph graph = builder.getCompoundGraph();
 
         //Graph processing: side compound removal [optional]
         if (inputSide != null) {
-            System.err.println("removing side compounds...");
+            System.out.println("removing side compounds...");
             NodeMapping<BioMetabolite, ReactionEdge, CompoundGraph> mapper = new NodeMapping<>(graph).skipIfNotFound();
             BioCollection<BioMetabolite> sideCpds = null;
             try {
@@ -130,7 +118,7 @@ public class SeedsAndTargets extends AbstractMet4jApplication {
                 System.exit(1);
             }
             boolean removed = graph.removeAllVertices(sideCpds);
-            if (removed) System.err.println(sideCpds.size() + " compounds removed.");
+            if (removed) System.out.println(sideCpds.size() + " compounds removed.");
         }
 
         //compute seeds and targets
@@ -157,45 +145,46 @@ public class SeedsAndTargets extends AbstractMet4jApplication {
             System.err.println(e.getMessage());
             System.exit(1);
         }
-        System.err.println("done.");
+        System.out.println("done.");
 
 
     }
 
-    private BioCollection<BioMetabolite> getCandidates(BioNetwork network, CompoundGraph graph){
+    private BioCollection<BioMetabolite> getCandidates(BioNetwork network, CompoundGraph graph) {
         //Select Candidates
         BioCollection<BioMetabolite> compoundSet = new BioCollection<>();
-        if(comp!=null){
+        if (comp != null) {
             //for each "external" (available) compartment
-            for(String id : comp.split("\\+")){
+            for (String id : comp.split("\\+")) {
                 BioCompartment c = network.getCompartmentsView().get(id);
-                if(c!=null){
+                if (c != null) {
                     //add compound graph nodes belonging to external compartment as candidate
-                    for(BioEntity e : c.getComponentsView()){
-                        if(graph.vertexSet().contains(e)) compoundSet.add((BioMetabolite) e);
+                    for (BioEntity e : c.getComponentsView()) {
+                        if (graph.vertexSet().contains(e)) compoundSet.add((BioMetabolite) e);
                     }
-                }else{
-                    System.out.println("Error: Compartment "+id+" not found in network, please check sbml file.");
+                } else {
+                    System.out.println("Error: Compartment " + id + " not found in network, please check sbml file.");
                 }
             }
-        }else{
+        } else {
             compoundSet.addAll(graph.vertexSet());
         }
         return compoundSet;
     }
 
 
-
     @Override
-    public String getLabel() {return this.getClass().getSimpleName();}
+    public String getLabel() {
+        return this.getClass().getSimpleName();
+    }
 
     @Override
     public String getLongDescription() {
-        return "Identify exogenously acquired compounds, producible compounds exogenously available and/or dead ends metabolites from metabolic network topology. " +
-                "Metabolic seeds and targets are useful for identifying medium requirements and metabolic capability, and thus enable analysis of metabolic ties within communities of organisms.\n" +
+        return this.getShortDescription() +
+                "\nMetabolic seeds and targets are useful for identifying medium requirements and metabolic capability, and thus enable analysis of metabolic ties within communities of organisms.\n" +
                 "This application can use seed definition and SCC-based detection algorithm by Borenstein et al. or, alternatively, degree-based sink and source detection with compartment adjustment.\n" +
                 "The first method (see Borenstein et al. 2008 Large-scale reconstruction and phylogenetic analysis of metabolic environments https://doi.org/10.1073/pnas.0806162105) " +
-                "consider strongly connected components rather than individual nodes, thus, members of cycles can be considered as seed. " +
+                "consider strongly connected components rather than individual nodes, thus, members of cycles can be considered as seeds. " +
                 "A sink from an external compartment can however be connected to a non sink internal counterpart, thus highlighting what could end up in the external compartment rather than what must be exported.\n" +
                 "The second approach is neighborhood based and identify sources and sinks. Since \"real\" sinks and sources in intracellular compartment(s) may be involved in transport/exchange reactions " +
                 "reversible by default, thus not allowing extracellular source or sink, an option allows to take " +
@@ -204,7 +193,7 @@ public class SeedsAndTargets extends AbstractMet4jApplication {
 
     @Override
     public String getShortDescription() {
-        return "Identify exogenously acquired compounds, producible compounds exogenously available and/or dead ends metabolites from metabolic network topology";
+        return "Identify exogenously acquired compounds, exogenously available producible compounds and/or dead ends metabolites from metabolic network topology";
     }
 
     @Override
-- 
GitLab


From 3d45e33d9c8872b19789402618cd52c04af056f8 Mon Sep 17 00:00:00 2001
From: lcottret <ludovic.cottret@inrae.fr>
Date: Mon, 6 Jan 2025 08:25:42 +0100
Subject: [PATCH 54/74] doc and refactoring

---
 .../networkAnalysis/SideCompoundsScan.java    | 75 ++++++++-----------
 1 file changed, 31 insertions(+), 44 deletions(-)

diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/SideCompoundsScan.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/SideCompoundsScan.java
index 426b75c5a..57daeee4d 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/SideCompoundsScan.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/SideCompoundsScan.java
@@ -8,28 +8,27 @@ import fr.inrae.toulouse.metexplore.met4j_graph.computation.transform.VertexCont
 import fr.inrae.toulouse.metexplore.met4j_graph.core.WeightingPolicy;
 import fr.inrae.toulouse.metexplore.met4j_graph.core.compound.CompoundGraph;
 import fr.inrae.toulouse.metexplore.met4j_graph.io.Bionetwork2BioGraph;
-import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.JsbmlReader;
-import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.Met4jSbmlReaderException;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.AbstractMet4jApplication;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.Format;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.ParameterType;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.utils.Doi;
+import fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils;
 import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics;
 import org.kohsuke.args4j.Option;
 
 import java.io.FileWriter;
 import java.io.IOException;
-
-import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumFormats.Sbml;
-import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumFormats.Tsv;
-import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumParameterTypes.InputFile;
-import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumParameterTypes.OutputFile;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Set;
 import java.util.function.Function;
 import java.util.stream.Collectors;
 
+import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumFormats.Sbml;
+import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumFormats.Tsv;
+import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumParameterTypes.InputFile;
+import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumParameterTypes.OutputFile;
+
 /**
  *
  */
@@ -42,36 +41,33 @@ public class SideCompoundsScan extends AbstractMet4jApplication {
 
     @Format(name = Tsv)
     @ParameterType(name = OutputFile)
-    @Option(name = "-o", usage = "output Side-Compounds file", required = true)
+    @Option(name = "-o", usage = "output file containing the side compounds", required = true)
     public String outputPath = null;
 
-    @Option(name = "-s", aliases = {"--onlySides"}, usage = "output compounds flagged as side-Compounds only")
+    @Option(name = "-s", aliases = {"--onlySides"}, usage = "output compounds flagged as side compounds only")
     public boolean sideOnly = false;
 
-    @Option(name = "-id", aliases = {"--onlyIds"}, usage = "do not report values in output, export ids list of compounds flagged as side-Compounds, allowing piping results")
+    @Option(name = "-id", aliases = {"--onlyIds"}, usage = "do not report values in output, export ids of compounds flagged as side compounds, allowing piping results")
     public boolean noReportValue = false;
 
-    @Option(name = "-d", aliases = {"--degree"}, usage = "flag as side compounds any compounds with degree above threshold", forbids = {"-dp"})
+    @Option(name = "-d", aliases = {"--degree"}, usage = "flag as side compounds any compound with degree above threshold", forbids = {"-dp"})
     public int degree = 400;
 
     @Option(name = "-dp", aliases = {"--degreep"}, usage = "flag as side compounds the top x% of compounds according to their degree", forbids = {"-d"})
     public double degreePrecentile = Double.NaN;
 
-    @Option(name = "-cc", aliases = {"--noCarbonSkeleton"}, usage = "flag as side compound any compounds with less than 2 carbons in formula")
+    @Option(name = "-cc", aliases = {"--noCarbonSkeleton"}, usage = "flag as side compound any compound with less than 2 carbons in formula")
     public Boolean flagInorganic = false;
 
-    @Option(name = "-uf", aliases = {"--undefinedFormula"}, usage = "flag as side compound any compounds with no valid chemical formula")
+    @Option(name = "-uf", aliases = {"--undefinedFormula"}, usage = "flag as side compound any compound with no valid chemical formula")
     public Boolean flagNoFormula = false;
 
     @Option(name = "-nc", aliases = {"--neighborCoupling"}, usage = "flag as side compound any compound with a number of parallel edges shared with a neighbor above the given threshold")
     public double parallelEdge = Double.NaN;
-
-    enum strategy {no, by_name,by_id}
-    @Option(name = "-m", aliases = {"--merge"}, usage = "Degree is shared between compounds in different compartments. " +
+    @Option(name = "-m", aliases = {"--merge"}, usage = "degree is shared between compounds in different compartments. " +
             "Use names if consistent and unambiguous across compartments, or identifiers if compartment suffix is present (id in form \"xxx_y\" with xxx as base identifier and y as compartment label).")
     public strategy mergingStrat = strategy.no;
 
-
     public static void main(String[] args) {
 
         SideCompoundsScan app = new SideCompoundsScan();
@@ -82,28 +78,17 @@ public class SideCompoundsScan extends AbstractMet4jApplication {
 
     }
 
-
-    public void run()  {
+    public void run() {
 
 
         //import network
-        System.err.println("reading SBML...");
-        System.err.println(inputPath);
-        JsbmlReader reader = new JsbmlReader(this.inputPath);
-        BioNetwork network = null;
-        try {
-            network = reader.read();
-        } catch (Met4jSbmlReaderException e) {
-            System.err.println("Error while reading the SBML file");
-            System.err.println(e.getMessage());
-            System.exit(1);
-        }
+        System.out.println("reading SBML...");
+        BioNetwork network = IOUtils.readSbml(this.inputPath);
 
         //Create compound graph
-        System.err.println("Creating network...");
+        System.out.println("Creating network...");
         Bionetwork2BioGraph builder = new Bionetwork2BioGraph(network);
         CompoundGraph graph = builder.getCompoundGraph();
-        network = null;
 
         //Graph processing: set weights
         WeightingPolicy wp = new UnweightedPolicy();
@@ -112,14 +97,15 @@ public class SideCompoundsScan extends AbstractMet4jApplication {
 
         //perform scan
         //------------
-        System.err.println("Scaning...");
+        System.out.println("Scaning...");
 
         //if merging compartment
         Map<String, Integer> mergedDegree = new HashMap<>();
-        Boolean merge = (mergingStrat!=strategy.no);
-        Function<BioMetabolite,String> getSharedId = BioMetabolite::getName;
-        if(merge){
-            if(mergingStrat.equals(strategy.by_id)) getSharedId = (new VertexContraction.MapByIdSubString("^(\\w+)_\\w$"))::commonField;
+        Boolean merge = (mergingStrat != strategy.no);
+        Function<BioMetabolite, String> getSharedId = BioMetabolite::getName;
+        if (merge) {
+            if (mergingStrat.equals(strategy.by_id))
+                getSharedId = (new VertexContraction.MapByIdSubString("^(\\w+)_\\w$"))::commonField;
 
             mergedDegree = graph.vertexSet().stream().collect(
                     Collectors.groupingBy(
@@ -134,9 +120,9 @@ public class SideCompoundsScan extends AbstractMet4jApplication {
         double dt = degree;
         if (!Double.isNaN(degreePrecentile)) {
             for (BioMetabolite v : graph.vertexSet()) {
-                if (merge){
+                if (merge) {
                     degreeStats.addValue(mergedDegree.get(getSharedId.apply(v)));
-                }else{
+                } else {
                     degreeStats.addValue(graph.degreeOf(v));
                 }
             }
@@ -226,9 +212,8 @@ public class SideCompoundsScan extends AbstractMet4jApplication {
             }
 
             fw.close();
-            System.err.println("done");
-            System.err.println("found " + count + " side compound among " + graph.vertexSet().size() + " compounds");
-            System.err.println(outputPath);
+            System.out.println("done");
+            System.out.println("found " + count + " side compound among " + graph.vertexSet().size() + " compounds");
         } catch (IOException e) {
             System.err.println("Error while writing the result file");
             System.err.println(e.getMessage());
@@ -252,7 +237,7 @@ public class SideCompoundsScan extends AbstractMet4jApplication {
                 "- *Degree*: Compounds with an uncommonly high number of neighbors can betray a lack of process specificity.  \n" +
                 "High degree compounds typically include water and most main cofactors (CoA, ATP, NADPH...) but can also include central compounds such as pyruvate or acetyl-CoA  \n" +
                 "- *Neighbor Coupling*: Similar to degree, this criteria assume that side compounds are involved in many reactions, but in pairs with other side compounds.\n" +
-                "Therefore, the transition from ATP to ADP will appear multiple time in the network, creating redundant 'parallel edges' between these two neighbors.\n" +
+                "Therefore, the transition from ATP to ADP will appear multiple times in the network, creating redundant 'parallel edges' between these two neighbors.\n" +
                 "Being tightly coupled to another compound through a high number of redundant edges, can point out cofactors while keeping converging pathways' products with high degree like pyruvate aside.  \n" +
                 "- *Carbon Count*: Metabolic \"waste\", or degradation end-product such as ammonia or carbon dioxide are usually considered as side compounds.\n" +
                 "Most of them are inorganic compound, another ill-defined concept, sometimes defined as compound lacking C-C or C-H bonds. Since chemical structure is rarely available " +
@@ -265,11 +250,13 @@ public class SideCompoundsScan extends AbstractMet4jApplication {
 
     @Override
     public String getShortDescription() {
-        return "Scan a network to identify side-compounds.";
+        return "Scan a network to identify side compounds.";
     }
 
     @Override
     public Set<Doi> getDois() {
         return Set.of();
     }
+
+    enum strategy {no, by_name, by_id}
 }
-- 
GitLab


From 0822964a5fb301b1096f981885060a14d09e048f Mon Sep 17 00:00:00 2001
From: lcottret <ludovic.cottret@inrae.fr>
Date: Mon, 6 Jan 2025 08:29:09 +0100
Subject: [PATCH 55/74] doc and refactoring

---
 .../TopologicalPathwayAnalysis.java           | 103 +++++++-----------
 1 file changed, 42 insertions(+), 61 deletions(-)

diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/TopologicalPathwayAnalysis.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/TopologicalPathwayAnalysis.java
index 959e179fe..b796e06df 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/TopologicalPathwayAnalysis.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/TopologicalPathwayAnalysis.java
@@ -5,77 +5,65 @@ import fr.inrae.toulouse.metexplore.met4j_core.biodata.BioNetwork;
 import fr.inrae.toulouse.metexplore.met4j_core.biodata.BioPathway;
 import fr.inrae.toulouse.metexplore.met4j_core.biodata.collection.BioCollection;
 import fr.inrae.toulouse.metexplore.met4j_graph.computation.analyze.PathwayTopologyAnalysis;
-import fr.inrae.toulouse.metexplore.met4j_graph.computation.connect.weighting.*;
+import fr.inrae.toulouse.metexplore.met4j_graph.computation.connect.weighting.UnweightedPolicy;
+import fr.inrae.toulouse.metexplore.met4j_graph.computation.connect.weighting.WeightsFromFile;
 import fr.inrae.toulouse.metexplore.met4j_graph.computation.transform.VertexContraction;
 import fr.inrae.toulouse.metexplore.met4j_graph.core.WeightingPolicy;
 import fr.inrae.toulouse.metexplore.met4j_graph.core.compound.CompoundGraph;
 import fr.inrae.toulouse.metexplore.met4j_graph.core.compound.ReactionEdge;
 import fr.inrae.toulouse.metexplore.met4j_graph.io.Bionetwork2BioGraph;
 import fr.inrae.toulouse.metexplore.met4j_graph.io.NodeMapping;
-import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.JsbmlReader;
-import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.Met4jSbmlReaderException;
-import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.plugin.FBCParser;
-import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.plugin.GroupPathwayParser;
-import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.plugin.NotesParser;
-import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.plugin.PackageParser;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.AbstractMet4jApplication;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumFormats;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumParameterTypes;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.Format;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.ParameterType;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.utils.Doi;
+import fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils;
 import org.kohsuke.args4j.Option;
 
 import java.io.FileWriter;
 import java.io.IOException;
-import java.util.*;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
 
 public class TopologicalPathwayAnalysis extends AbstractMet4jApplication {
 
-    @Format(name= EnumFormats.Sbml)
-    @ParameterType(name= EnumParameterTypes.InputFile)
-    @Option(name = "-s", usage = "input SBML file", required = true)
+    @Format(name = EnumFormats.Sbml)
+    @ParameterType(name = EnumParameterTypes.InputFile)
+    @Option(name = "-i", usage = "input SBML file", required = true)
     public String inputPath = null;
 
-    @ParameterType(name= EnumParameterTypes.InputFile)
-    @Format(name= EnumFormats.Txt)
-    @Option(name = "-sc", usage = "input Side compound file (recommended)", required = false)
+    @ParameterType(name = EnumParameterTypes.InputFile)
+    @Format(name = EnumFormats.Txt)
+    @Option(name = "-sc", usage = "input Side compound file (recommended)")
     public String inputSide = null;
 
-    @ParameterType(name= EnumParameterTypes.OutputFile)
-    @Format(name= EnumFormats.Tsv)
+    @ParameterType(name = EnumParameterTypes.OutputFile)
+    @Format(name = EnumFormats.Tsv)
     @Option(name = "-o", usage = "output result file (tsv format)", required = true)
     public String outputPath = null;
-
-    enum strategy {no, by_name,by_id}
     @Option(name = "-mc", aliases = {"--mergecomp"}, usage = "merge compartments. " +
             "Use names if consistent and unambiguous across compartments, or identifiers if compartment suffix is present (id in form \"xxx_y\" with xxx as base identifier and y as compartment label).")
     public strategy mergingStrat = strategy.no;
     public String idRegex = "^(\\w+)_\\w$";
-
-
-    @Option(name = "-ri", aliases = {"--removeIsolatedNodes"}, usage = "remove isolated nodes", required = false)
+    @Option(name = "-ri", aliases = {"--removeIsolatedNodes"}, usage = "remove isolated nodes")
     public boolean removeIsolated = false;
-
-    @ParameterType(name=EnumParameterTypes.InputFile)
-    @Format(name=EnumFormats.Tsv)
+    @ParameterType(name = EnumParameterTypes.InputFile)
+    @Format(name = EnumFormats.Tsv)
     @Option(name = "-cw", aliases = {"--customWeights"}, usage = "an optional file containing weights for compound pairs, taken into account for betweenness computation. Edges not found in file will be removed", forbids = {"-dw"})
     public String weightFile = null;
-
-    @Option(name = "-un", aliases = {"--undirected"}, usage = "the compound graph built from the metabolic network and used for computations will undirected, i.e. the reaction directions won't be taken into account", required = false)
+    @Option(name = "-un", aliases = {"--undirected"}, usage = "the compound graph built from the metabolic network and used for computations will undirected, i.e. the reaction directions won't be taken into account")
     public boolean undirected = false;
-
-
-    @Format(name= EnumFormats.Txt)
-    @ParameterType(name= EnumParameterTypes.InputFile)
+    @Format(name = EnumFormats.Txt)
+    @ParameterType(name = EnumParameterTypes.InputFile)
     @Option(name = "-noi", usage = "file containing the list of metabolites of interests (one per line)", required = true)
     public String dataPath = null;
-
-    @Option(name = "-out", aliases = {"--outDegree"}, usage = "use out-degree as scoring function instead of betweenness (faster computation)", required = false)
+    @Option(name = "-out", aliases = {"--outDegree"}, usage = "use out-degree as scoring function instead of betweenness (faster computation)")
     public boolean out = false;
 
-
-    public static void main(String[] args)  {
+    public static void main(String[] args) {
 
         TopologicalPathwayAnalysis app = new TopologicalPathwayAnalysis();
 
@@ -85,7 +73,6 @@ public class TopologicalPathwayAnalysis extends AbstractMet4jApplication {
 
     }
 
-
     public void run() {
         //open file
         FileWriter fw = null;
@@ -98,23 +85,12 @@ public class TopologicalPathwayAnalysis extends AbstractMet4jApplication {
         }
 
         System.out.print("Reading SBML...");
-        JsbmlReader reader = new JsbmlReader(this.inputPath);
-        ArrayList<PackageParser> pkgs = new ArrayList<>(Arrays.asList(
-                new NotesParser(false), new GroupPathwayParser()));
-
-        BioNetwork network = null;
 
-        try {
-            network = reader.read(pkgs);
-        } catch (Met4jSbmlReaderException e) {
-            System.err.println("Error while reading the SBML file");
-            System.err.println(e.getMessage());
-            System.exit(1);
-        }
+        BioNetwork network = IOUtils.readSbml(inputPath);
         System.out.println(" Done.\n\n");
 
 
-        System.out.print("Building Network...");
+        System.out.print("Building graph...");
         Bionetwork2BioGraph builder = new Bionetwork2BioGraph(network);
         CompoundGraph graph = builder.getCompoundGraph();
 
@@ -141,19 +117,19 @@ public class TopologicalPathwayAnalysis extends AbstractMet4jApplication {
             wp = new WeightsFromFile(weightFile).removeEdgeNotInFile();
             wp.setWeight(graph);
             System.out.println(" Done.");
-        }else{
+        } else {
             wp.setWeight(graph);
         }
 
         //invert graph as undirected (copy edge weight to reversed edge)
-        if(undirected){
+        if (undirected) {
             System.out.print("Create Undirected...");
             graph.asUndirected();
             System.out.println(" Done.");
         }
 
         //merge compartment
-        if(mergingStrat!=strategy.no){
+        if (mergingStrat != strategy.no) {
             System.out.print("Merging compartments...");
             VertexContraction vc = new VertexContraction();
             VertexContraction.Mapper merger = mergingStrat.equals(strategy.by_name) ? new VertexContraction.MapByName() : new VertexContraction.MapByIdSubString(idRegex);
@@ -162,12 +138,12 @@ public class TopologicalPathwayAnalysis extends AbstractMet4jApplication {
         }
 
         //remove isolated nodes
-        if(removeIsolated){
+        if (removeIsolated) {
             System.out.println("Remove isolated nodes...");
             HashSet<BioMetabolite> nodes = new HashSet<>(graph.vertexSet());
             graph.removeIsolatedNodes();
             nodes.removeAll(graph.vertexSet());
-            for(BioMetabolite n : nodes){
+            for (BioMetabolite n : nodes) {
                 System.out.println("\tremoving " + n.getName());
             }
             System.out.println(" Done.");
@@ -189,9 +165,9 @@ public class TopologicalPathwayAnalysis extends AbstractMet4jApplication {
 
 
         System.out.println("Computing Pathway topology Analysis... (may take a while)");
-        PathwayTopologyAnalysis computor = new PathwayTopologyAnalysis(network,graph,data).useNormalization();
-        PathwayTopologyAnalysis.IndividualScoringStrategy strat = out ? PathwayTopologyAnalysis.IndividualScoringStrategy.outDegree() : PathwayTopologyAnalysis.IndividualScoringStrategy.betweenness() ;
-        Map<BioPathway, Double> res = computor.run(strat,PathwayTopologyAnalysis.AggregationStrategy.rawSum());
+        PathwayTopologyAnalysis computor = new PathwayTopologyAnalysis(network, graph, data).useNormalization();
+        PathwayTopologyAnalysis.IndividualScoringStrategy strat = out ? PathwayTopologyAnalysis.IndividualScoringStrategy.outDegree() : PathwayTopologyAnalysis.IndividualScoringStrategy.betweenness();
+        Map<BioPathway, Double> res = computor.run(strat, PathwayTopologyAnalysis.AggregationStrategy.rawSum());
         System.out.println("Done.");
 
         //export results
@@ -208,27 +184,32 @@ public class TopologicalPathwayAnalysis extends AbstractMet4jApplication {
             System.exit(1);
         }
         System.out.println("Done.");
-        return;
     }
 
     @Override
-    public String getLabel() {return this.getClass().getSimpleName();}
+    public String getLabel() {
+        return this.getClass().getSimpleName();
+    }
 
     @Override
     public String getLongDescription() {
-        return "Run a Topological Pathway Analysis (TPA) to identify key pathways based on topological properties of its mapped compounds." +
-                " From a list of compounds of interest, the app compute their betweenness centrality (which quantifies how often a compound acts as a intermediary along the shortest paths between pairs of other compounds in the network," +
+        return this.getShortDescription() +
+                "\nFrom a list of compounds of interest, the app compute their betweenness centrality (which quantifies how often a compound acts as a intermediary along the shortest paths between pairs of other compounds in the network," +
                 " which, if high, suggest a critical role in the overall flow within the network). Each pathway is scored according to the summed centrality of its metabolites found in the dataset." +
                 " Alternatively to the betweenness, one can make use of the out-degree (the number of outgoing link, i.e. number of direct metabolic product) as a criterion of importance." +
                 " TPA is complementary to statistical enrichment analysis to ensures a more meaningful interpretation of the data, by taking into account the influence of identified compounds on the structure of the pathways.";
     }
 
     @Override
-    public String getShortDescription() {return "Run a Topological Pathway Analysis to identify key pathways based on topological properties of its constituting compounds.";}
+    public String getShortDescription() {
+        return "Run a Topological Pathway Analysis (TPA) to identify key pathways based on topological properties of its constituting compounds.";
+    }
 
     @Override
     public Set<Doi> getDois() {
         return Set.of();
     }
+
+    enum strategy {no, by_name, by_id}
 }
 
-- 
GitLab


From 4086e874d95d96ea5e395e1e7261d9661fee3f34 Mon Sep 17 00:00:00 2001
From: lcottret <ludovic.cottret@inrae.fr>
Date: Mon, 6 Jan 2025 08:47:55 +0100
Subject: [PATCH 56/74] doc and refactoring

---
 .../reconstruction/CreateMetaNetwork.java     | 98 ++++++++-----------
 1 file changed, 41 insertions(+), 57 deletions(-)

diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/reconstruction/CreateMetaNetwork.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/reconstruction/CreateMetaNetwork.java
index 3b6985198..01f91bde1 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/reconstruction/CreateMetaNetwork.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/reconstruction/CreateMetaNetwork.java
@@ -4,9 +4,6 @@ import fr.inrae.toulouse.metexplore.met4j_core.biodata.*;
 import fr.inrae.toulouse.metexplore.met4j_core.biodata.multinetwork.CommunityNetworkBuilder;
 import fr.inrae.toulouse.metexplore.met4j_core.biodata.multinetwork.PrefixedMetaEntityFactory;
 import fr.inrae.toulouse.metexplore.met4j_io.annotations.network.NetworkAttributes;
-import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.JsbmlReader;
-import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.Met4jSbmlReaderException;
-import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.plugin.*;
 import fr.inrae.toulouse.metexplore.met4j_io.jsbml.units.BioUnitDefinition;
 import fr.inrae.toulouse.metexplore.met4j_io.jsbml.writer.JsbmlWriter;
 import fr.inrae.toulouse.metexplore.met4j_io.jsbml.writer.Met4jSbmlWriterException;
@@ -16,6 +13,7 @@ import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumParame
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.Format;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.ParameterType;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.utils.Doi;
+import fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils;
 import org.kohsuke.args4j.Option;
 
 import java.util.*;
@@ -30,33 +28,30 @@ public class CreateMetaNetwork extends AbstractMet4jApplication {
     //arguments
     @Format(name = Sbml)
     @ParameterType(name = InputFile)
-    @Option(name = "-n1", aliases = {"--network1"},  usage = "input SBML file: path to first network, in sbml format.", required = true)
+    @Option(name = "-n1", aliases = {"--network1"}, usage = "input SBML file: path to first network, in sbml format.", required = true)
     public String sbml1FilePath;
     @ParameterType(name = InputFile)
-    @Option(name = "-n2", aliases = {"--network2"},  usage = "input SBML file: path to second network, in sbml format.", required = true)
+    @Option(name = "-n2", aliases = {"--network2"}, usage = "input SBML file: path to second network, in sbml format.", required = true)
     public String sbml2FilePath;
 
-    @Option(name = "-n1ex", aliases = {"--external1"},  usage = "external compartment identifier in first network.", required = true)
+    @Option(name = "-n1ex", aliases = {"--external1"}, usage = "external compartment identifier in first network.", required = true)
     public String external1;
-    @Option(name = "-n2ex", aliases = {"--external2"},  usage = "external compartment identifier in second network.", required = true)
+    @Option(name = "-n2ex", aliases = {"--external2"}, usage = "external compartment identifier in second network.", required = true)
     public String external2;
 
-    @Option(name = "-n1px", aliases = {"--n1prefix"},  usage = "prefix that will be added to first network's entities identifiers", required = false)
+    @Option(name = "-n1px", aliases = {"--n1prefix"}, usage = "prefix that will be added to first network's entities identifiers")
     public String n1prefix = "Net1_";
-    @Option(name = "-n2px", aliases = {"--n2prefix"},   usage = "prefix that will be added to second network's entities identifiers", required = false)
+    @Option(name = "-n2px", aliases = {"--n2prefix"}, usage = "prefix that will be added to second network's entities identifiers")
     public String n2prefix = "Net2_";
 
-    @Option(name = "-k", aliases = {"--keepCompartment"}, usage = "keep the original external compartments in the meta-network, otherwise, they will be fused into the new shared external compartment", required = false)
+    @Option(name = "-k", aliases = {"--keepCompartment"}, usage = "keep the original external compartments in the meta-network, otherwise, they will be fused into the new shared external compartment")
     public boolean keepCompartment = false;
 
-    @Option(name = "-n1meta", aliases = {"--firstAsMeta"}, usage = "Treat first network as meta-network, allowing more than two sub-models with iterative fusions. This will overwrite shared compartment and pool compounds (which must follow the \"pool_\" prefix convention) and will ignore --n1prefix argument", required = false)
+    @Option(name = "-n1meta", aliases = {"--firstAsMeta"}, usage = "treat first network as meta-network, allowing more than two sub-models with iterative fusions. This will overwrite shared compartment and pool compounds (which must follow the \"pool_\" prefix convention) and will ignore --n1prefix argument")
     public boolean firstIsMeta = false;
-
-    enum strategy {by_metanetx, by_name, by_id}
     @Option(name = "-mc", aliases = {"--mergingCriterion"}, usage = "field used to identify the same metabolites across the two different networks. " +
             "\"by_name\"/\"by_id\" can be used if names/identifiers are consistent and unambiguous across source models, \"by_metanetx\" can be used if models contains MetaNetX identifiers in annotation field using standard miriam format.")
     public CreateMetaNetwork.strategy mergingCriterion = by_name;
-
     @ParameterType(name = EnumParameterTypes.OutputFile)
     @Format(name = EnumFormats.Sbml)
     @Option(name = "-o", usage = "output meta-network SBML file", required = true)
@@ -70,38 +65,28 @@ public class CreateMetaNetwork extends AbstractMet4jApplication {
 
     public void run() throws Met4jSbmlWriterException {
 
-        if(Objects.equals(this.n1prefix, this.n2prefix)){
+        if (Objects.equals(this.n1prefix, this.n2prefix)) {
             System.err.println("Error: prefixes must be different");
             System.exit(1);
         }
 
         //import networks
         System.out.print("Importing network 1...");
-        JsbmlReader reader = new JsbmlReader(this.sbml1FilePath);
-        ArrayList<PackageParser> pkgs = new ArrayList<>(Arrays.asList(
-                new NotesParser(false), new AnnotationParser(true), new FBCParser(), new GroupPathwayParser()));
-
-        BioNetwork network1 = null;
-        try {
-            network1 = reader.read(pkgs);
-        } catch (Met4jSbmlReaderException e) {
-            System.err.println("Error while reading the first SBML file");
-            System.err.println(e.getMessage());
-            System.exit(1);
-        }
+        BioNetwork network1 = IOUtils.readSbml(this.sbml1FilePath);
+
         BioCompartment co1ex = network1.getCompartment(external1);
-        if(co1ex==null){
+        if (co1ex == null) {
             System.err.println("Error: external compartment " + external1 + " not found in network 1");
             System.exit(1);
         }
-        if(firstIsMeta){
+        if (firstIsMeta) {
             n1prefix = "";
             BioMetabolite[] pool1 = network1.getCompartment(external1)
                     .getComponentsView().stream()
                     .filter(e -> e instanceof BioMetabolite)
                     .filter(m -> m.getId().startsWith("pool_"))
                     .toArray(BioMetabolite[]::new);
-            for(BioMetabolite pool : pool1){
+            for (BioMetabolite pool : pool1) {
                 network1.removeOnCascade(network1.getReactionsFromMetabolite(pool));
             }
             network1.removeOnCascade(pool1);
@@ -110,17 +95,10 @@ public class CreateMetaNetwork extends AbstractMet4jApplication {
 
 
         System.out.print("Importing network 2...");
-        reader = new JsbmlReader(this.sbml2FilePath);
-        BioNetwork network2 = null;
-        try {
-            network2 = reader.read(pkgs);
-        } catch (Met4jSbmlReaderException e) {
-            System.err.println("Error while reading the second SBML file");
-            System.err.println(e.getMessage());
-            System.exit(1);
-        }
+        BioNetwork network2 = IOUtils.readSbml(this.sbml2FilePath);
+
         BioCompartment co2ex = network2.getCompartment(external2);
-        if(co2ex==null){
+        if (co2ex == null) {
             System.err.println("Error: external compartment " + external2 + " not found in network 2");
             System.exit(1);
         }
@@ -128,24 +106,26 @@ public class CreateMetaNetwork extends AbstractMet4jApplication {
 
         System.out.print("Creating meta-network...");
         //setup
-        BioCompartment medium=new BioCompartment("medium"); medium.setName("medium");
-        HashMap<BioNetwork,String> alias = new HashMap<>();
-        alias.put(network1,n1prefix);alias.put(network2,n2prefix);
+        BioCompartment medium = new BioCompartment("medium");
+        medium.setName("medium");
+        HashMap<BioNetwork, String> alias = new HashMap<>();
+        alias.put(network1, n1prefix);
+        alias.put(network2, n2prefix);
         CommunityNetworkBuilder builder = initMetaNetworkBuilder(medium, alias);
         builder.add(network1);
         builder.add(network2);
 
         //build meta-network
-        if(!keepCompartment){
-            builder.fuseCompartmentIntoSharedCompartment(network1,co1ex,medium);
-            builder.fuseCompartmentIntoSharedCompartment(network2,co2ex,medium);
-        }else{
-            if(firstIsMeta) {
+        if (!keepCompartment) {
+            builder.fuseCompartmentIntoSharedCompartment(network1, co1ex, medium);
+            builder.fuseCompartmentIntoSharedCompartment(network2, co2ex, medium);
+        } else {
+            if (firstIsMeta) {
                 builder.fuseCompartmentIntoSharedCompartment(network1, co1ex, medium);
-            }else{
+            } else {
                 builder.bumpCompartmentIntoSharedCompartment(network1, co1ex, medium);
             }
-            builder.bumpCompartmentIntoSharedCompartment(network2,co2ex,medium);
+            builder.bumpCompartmentIntoSharedCompartment(network2, co2ex, medium);
         }
         BioNetwork metaNetwork = builder.build();
         System.out.println(" Done.");
@@ -153,15 +133,15 @@ public class CreateMetaNetwork extends AbstractMet4jApplication {
         //export the meta-network
         System.out.print("Exporting MetaNetwork...");
         NetworkAttributes.addUnitDefinition(metaNetwork, new BioUnitDefinition());
-        new JsbmlWriter(outputPath,metaNetwork).write();
+        new JsbmlWriter(outputPath, metaNetwork).write();
         System.out.println(" Done.");
 
     }
 
     private CommunityNetworkBuilder initMetaNetworkBuilder(BioCompartment medium, HashMap<BioNetwork, String> alias) {
         CommunityNetworkBuilder builder = new CommunityNetworkBuilder(medium);
-        PrefixedMetaEntityFactory factory = new PrefixedMetaEntityFactory(alias,"pool_");
-        factory.addCompSuffix = (id, comp) -> id+"_"+comp.getId();
+        PrefixedMetaEntityFactory factory = new PrefixedMetaEntityFactory(alias, "pool_");
+        factory.addCompSuffix = (id, comp) -> id + "_" + comp.getId();
         builder.setEntityFactory(factory);
         Function<BioMetabolite, String> getSharedIdFunction;
         switch (mergingCriterion) {
@@ -171,7 +151,7 @@ public class CreateMetaNetwork extends AbstractMet4jApplication {
                         BioRef r = x.getRefs("metanetx.chemical").iterator().next();
                         return r.getId();
                     } catch (NoSuchElementException | NullPointerException e) {
-                        return "unknown_"+UUID.randomUUID();
+                        return "unknown_" + UUID.randomUUID();
                     }
                 };
                 break;
@@ -189,7 +169,9 @@ public class CreateMetaNetwork extends AbstractMet4jApplication {
     }
 
     @Override
-    public String getLabel() {return this.getClass().getSimpleName();}
+    public String getLabel() {
+        return this.getClass().getSimpleName();
+    }
 
     @Override
     public String getShortDescription() {
@@ -203,8 +185,10 @@ public class CreateMetaNetwork extends AbstractMet4jApplication {
 
     @Override
     public String getLongDescription() {
-        return "Create a Meta-Network from two sub-networks in SBML format. A meta-network is a single model which contains several sub-networks that remains individualized within" +
-                "the meta-network (as opposed to models fusion), but which can share some of their components with " +
+        return this.getShortDescription() + "\n" + "A meta-network is a single model which contains several sub-networks that remains individualized within" +
+                " the meta-network (as opposed to model fusion), but which can share some of their components with " +
                 "other sub-networks through a shared \"medium\" compartment.";
     }
+
+    enum strategy {by_metanetx, by_name, by_id}
 }
-- 
GitLab


From a2ae6bc7673623a8cabaa575a2f688d41157c497 Mon Sep 17 00:00:00 2001
From: lcottret <ludovic.cottret@inrae.fr>
Date: Mon, 6 Jan 2025 08:50:11 +0100
Subject: [PATCH 57/74] doc and refactoring

---
 .../reconstruction/SbmlCheckBalance.java      | 39 ++++---------------
 1 file changed, 8 insertions(+), 31 deletions(-)

diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/reconstruction/SbmlCheckBalance.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/reconstruction/SbmlCheckBalance.java
index 7ca49f4b4..53d751f8b 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/reconstruction/SbmlCheckBalance.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/reconstruction/SbmlCheckBalance.java
@@ -37,15 +37,13 @@ package fr.inrae.toulouse.metexplore.met4j_toolbox.reconstruction;
 
 import fr.inrae.toulouse.metexplore.met4j_core.biodata.BioNetwork;
 import fr.inrae.toulouse.metexplore.met4j_core.biodata.utils.BioReactionUtils;
-import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.JsbmlReader;
-import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.Met4jSbmlReaderException;
-
 import fr.inrae.toulouse.metexplore.met4j_reconstruction.check.balance.NetworkBalanceAnalysis;
 import fr.inrae.toulouse.metexplore.met4j_reconstruction.check.balance.ReactionBalanceAnalysis;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.AbstractMet4jApplication;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.Format;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.ParameterType;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.utils.Doi;
+import fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils;
 import org.kohsuke.args4j.Option;
 
 import java.io.FileWriter;
@@ -63,7 +61,7 @@ public class SbmlCheckBalance extends AbstractMet4jApplication {
 
     @Format(name = Sbml)
     @ParameterType(name = InputFile)
-    @Option(name = "-sbml", usage = "Original sbml file", required = true)
+    @Option(name = "-i", usage = "Input Sbml file", required = true)
     public String sbml;
 
     @Format(name = Tsv)
@@ -75,22 +73,22 @@ public class SbmlCheckBalance extends AbstractMet4jApplication {
 
     public static void main(String[] args) {
         SbmlCheckBalance app = new SbmlCheckBalance();
-        
+
         app.parseArguments(args);
-        
+
         app.run();
     }
 
     private void run() {
 
-        BioNetwork network = this.readSbml();
+        BioNetwork network = IOUtils.readSbml(this.sbml);
 
         analysis = new NetworkBalanceAnalysis(network);
 
         try {
             this.writeResults();
         } catch (IOException e) {
-           e.printStackTrace();
+            e.printStackTrace();
             System.err.println("[MET4J ERROR] Error while writing the results");
         }
 
@@ -110,34 +108,13 @@ public class SbmlCheckBalance extends AbstractMet4jApplication {
             Set<String> metabolitesWithBadFormula = balance.getMetabolitesWithBadFormula().getIds();
             String formula = BioReactionUtils.getEquation(balance.getReaction(), false, true);
 
-            writer.write(id + "\t" + balance.isBalanced() + "\t" + balance.isExchange() + "\t" + formula +"\t" + atomBalances + "\t" + (metabolitesWithBadFormula.size() > 0 ? metabolitesWithBadFormula : "") + "\n");
+            writer.write(id + "\t" + balance.isBalanced() + "\t" + balance.isExchange() + "\t" + formula + "\t" + atomBalances + "\t" + (metabolitesWithBadFormula.size() > 0 ? metabolitesWithBadFormula : "") + "\n");
         }
 
         writer.close();
 
     }
 
-    /**
-     * <p>readSbml.</p>
-     *
-     * @return a {@link fr.inrae.toulouse.metexplore.met4j_core.biodata.BioNetwork} object.
-     */
-    private BioNetwork readSbml() {
-        JsbmlReader reader = new JsbmlReader(this.sbml);
-
-        BioNetwork bn = null;
-        try {
-            bn = reader.read();
-        } catch (Met4jSbmlReaderException e) {
-            e.printStackTrace();
-            System.err.println("Problem while reading the sbml file " + this.sbml);
-            System.exit(1);
-        }
-
-        return bn;
-
-    }
-
     @Override
     public String getLabel() {
         return this.getClass().getSimpleName();
@@ -145,7 +122,7 @@ public class SbmlCheckBalance extends AbstractMet4jApplication {
 
     @Override
     public String getLongDescription() {
-        return this.getShortDescription()+"\n"+
+        return this.getShortDescription() + "\n" +
                 "A reaction is balanced if all its reactants have a chemical formula with a good syntax and if the " +
                 "quantity of each atom is the same in both sides of the reaction.\n" +
                 "For each reaction, indicates if the reaction is balanced, the list of the atoms and the sum of their quantity, and the list of the metabolites " +
-- 
GitLab


From 132381ddda8e2a2cba3ef3c2ad93a60de6309d4c Mon Sep 17 00:00:00 2001
From: lcottret <ludovic.cottret@inrae.fr>
Date: Mon, 6 Jan 2025 09:10:21 +0100
Subject: [PATCH 58/74] add getMetabolitesFromFile method

---
 .../met4j_toolbox/utils/IOUtils.java          | 30 +++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/utils/IOUtils.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/utils/IOUtils.java
index 2a8c1ea26..b8a9b8669 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/utils/IOUtils.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/utils/IOUtils.java
@@ -36,10 +36,15 @@
 
 package fr.inrae.toulouse.metexplore.met4j_toolbox.utils;
 
+import fr.inrae.toulouse.metexplore.met4j_core.biodata.BioMetabolite;
 import fr.inrae.toulouse.metexplore.met4j_core.biodata.BioNetwork;
+import fr.inrae.toulouse.metexplore.met4j_core.biodata.collection.BioCollection;
 import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.JsbmlReader;
 import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.Met4jSbmlReaderException;
 import fr.inrae.toulouse.metexplore.met4j_io.jsbml.writer.JsbmlWriter;
+import fr.inrae.toulouse.metexplore.met4j_mapping.Mapper;
+
+import java.io.IOException;
 
 public class IOUtils {
 
@@ -83,5 +88,30 @@ public class IOUtils {
         }
     }
 
+    /**
+     * Reads a metabolite file and maps its contents to a BioCollection of BioMetabolite objects.
+     *
+     * @param path the path to the metabolite file
+     * @param network the BioNetwork object containing the metabolites
+     * @param label the label of the metabolite file
+     * @return a BioCollection of BioMetabolite objects read from the metabolite file
+     */
+    public static BioCollection<BioMetabolite> getMetabolitesFromFile(String path, BioNetwork network, String label) {
+        Mapper<BioMetabolite> metMapper = new Mapper<>(network, BioNetwork::getMetabolitesView).skipIfNotFound();
+        System.out.println("Read file containing "+label+"...");
+        BioCollection<BioMetabolite> metabolites = null;
+        try {
+            metabolites = metMapper.map(path);
+        } catch (IOException e) {
+            System.err.println("Error while reading the file containing "+label);
+            System.err.println(e.getMessage());
+            System.exit(1);
+        }
+        if (metMapper.getNumberOfSkippedEntries() > 0)
+            System.err.println(metMapper.getNumberOfSkippedEntries() + " "+label+" not found in network.");
+
+        return metabolites;
+    }
+
 
 }
-- 
GitLab


From df51b5b2ce7bb9a1d5f085d1a1e2caf35820d2b5 Mon Sep 17 00:00:00 2001
From: lcottret <ludovic.cottret@inrae.fr>
Date: Mon, 6 Jan 2025 09:10:36 +0100
Subject: [PATCH 59/74] use getMetabolitesFromFile method

---
 .../networkAnalysis/BipartiteDistanceMatrix.java   | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/BipartiteDistanceMatrix.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/BipartiteDistanceMatrix.java
index 40607fa21..9b06b12e5 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/BipartiteDistanceMatrix.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/BipartiteDistanceMatrix.java
@@ -31,6 +31,7 @@ import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.Enu
 import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumFormats.Sbml;
 import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumParameterTypes.InputFile;
 import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumParameterTypes.OutputFile;
+import static fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils.getMetabolitesFromFile;
 
 public class BipartiteDistanceMatrix extends AbstractMet4jApplication {
 
@@ -105,18 +106,11 @@ public class BipartiteDistanceMatrix extends AbstractMet4jApplication {
         //Graph processing: side compound removal [optional]
         if (sideCompoundFile != null) {
             System.out.println("removing side compounds...");
-            BioCollection<BioMetabolite> sideCpds = null;
-            try {
-                sideCpds = metMapper.map(sideCompoundFile);
-            } catch (IOException e) {
-                System.err.println("Error while reading the side compound file");
-                System.err.println(e.getMessage());
-                System.exit(1);
-            }
+            BioCollection<BioMetabolite> sideCpds = getMetabolitesFromFile(sideCompoundFile, network, "side compounds");
+
             boolean removed = graph.removeAllVertices(sideCpds);
             if (removed) removedNodes.addAll(sideCpds);
-            if (metMapper.getNumberOfSkippedEntries() > 0)
-                System.err.println(metMapper.getNumberOfSkippedEntries() + " side compounds not found in network.");
+
             System.out.println(sideCpds.size() + " side compounds ignored during graph build.");
         }
 
-- 
GitLab


From 453ef4f83d029a7565d4e0eb60f3bae14509698c Mon Sep 17 00:00:00 2001
From: lcottret <ludovic.cottret@inrae.fr>
Date: Mon, 6 Jan 2025 09:24:17 +0100
Subject: [PATCH 60/74] use getMetabolitesFromFile method

---
 .../networkAnalysis/CompoundNet.java             | 16 ++++------------
 .../networkAnalysis/DistanceMatrix.java          | 11 ++---------
 2 files changed, 6 insertions(+), 21 deletions(-)

diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/CompoundNet.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/CompoundNet.java
index c54c70794..5c7db7c22 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/CompoundNet.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/CompoundNet.java
@@ -12,7 +12,6 @@ import fr.inrae.toulouse.metexplore.met4j_graph.core.compound.CompoundGraph;
 import fr.inrae.toulouse.metexplore.met4j_graph.core.compound.ReactionEdge;
 import fr.inrae.toulouse.metexplore.met4j_graph.io.Bionetwork2BioGraph;
 import fr.inrae.toulouse.metexplore.met4j_graph.io.ExportGraph;
-import fr.inrae.toulouse.metexplore.met4j_graph.io.NodeMapping;
 import fr.inrae.toulouse.metexplore.met4j_mathUtils.matrix.ExportMatrix;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.AbstractMet4jApplication;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumFormats;
@@ -23,10 +22,11 @@ import fr.inrae.toulouse.metexplore.met4j_toolbox.utils.Doi;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils;
 import org.kohsuke.args4j.Option;
 
-import java.io.IOException;
 import java.util.HashSet;
 import java.util.Set;
 
+import static fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils.getMetabolitesFromFile;
+
 public class CompoundNet extends AbstractMet4jApplication {
 
     @Format(name = EnumFormats.Sbml)
@@ -94,16 +94,8 @@ public class CompoundNet extends AbstractMet4jApplication {
 
         //Graph processing: side compound removal [optional]
         if (inputSide != null) {
-            System.out.println("Removing side compounds...");
-            NodeMapping<BioMetabolite, ReactionEdge, CompoundGraph> mapper = new NodeMapping<>(graph).skipIfNotFound();
-            BioCollection<BioMetabolite> sideCpds = null;
-            try {
-                sideCpds = mapper.map(inputSide);
-            } catch (IOException e) {
-                System.err.println("Error while reading the side compound file");
-                System.err.println(e.getMessage());
-                System.exit(1);
-            }
+            System.out.println("removing side compounds...");
+            BioCollection<BioMetabolite> sideCpds = getMetabolitesFromFile(inputSide, network, "side compounds");
             boolean removed = graph.removeAllVertices(sideCpds);
             if (removed) System.out.println(sideCpds.size() + " compounds removed.");
         }
diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/DistanceMatrix.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/DistanceMatrix.java
index e1e196d1a..0b004e057 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/DistanceMatrix.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/DistanceMatrix.java
@@ -31,6 +31,7 @@ import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.Enu
 import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumFormats.Sbml;
 import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumParameterTypes.InputFile;
 import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumParameterTypes.OutputFile;
+import static fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils.getMetabolitesFromFile;
 
 public class DistanceMatrix extends AbstractMet4jApplication {
 
@@ -88,15 +89,7 @@ public class DistanceMatrix extends AbstractMet4jApplication {
         //Graph processing: side compound removal [optional]
         if (sideCompoundFile != null) {
             System.out.println("removing side compounds...");
-            NodeMapping mapper = new NodeMapping<>(graph).skipIfNotFound();
-            BioCollection<BioMetabolite> sideCpds = null;
-            try {
-                sideCpds = mapper.map(sideCompoundFile);
-            } catch (IOException e) {
-                System.err.println("Error while reading the side compound file");
-                System.err.println(e.getMessage());
-                System.exit(1);
-            }
+            BioCollection<BioMetabolite> sideCpds = getMetabolitesFromFile(sideCompoundFile, network, "side compounds");
             boolean removed = graph.removeAllVertices(sideCpds);
             if (removed) System.out.println(sideCpds.size() + " side compounds ignored during graph build.");
         }
-- 
GitLab


From 5203a23ee2e7afcd4ea9b4c4a19225163b0c0170 Mon Sep 17 00:00:00 2001
From: lcottret <ludovic.cottret@inrae.fr>
Date: Mon, 6 Jan 2025 09:31:15 +0100
Subject: [PATCH 61/74] use getMetabolitesFromFile method

---
 .../networkAnalysis/ExtractSubBipNetwork.java      | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)

diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/ExtractSubBipNetwork.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/ExtractSubBipNetwork.java
index 8e4155cda..a148995eb 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/ExtractSubBipNetwork.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/ExtractSubBipNetwork.java
@@ -33,6 +33,7 @@ import java.util.Set;
 import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumFormats.*;
 import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumParameterTypes.InputFile;
 import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumParameterTypes.OutputFile;
+import static fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils.getMetabolitesFromFile;
 
 public class ExtractSubBipNetwork extends AbstractMet4jApplication {
 
@@ -96,18 +97,7 @@ public class ExtractSubBipNetwork extends AbstractMet4jApplication {
 
         //Graph processing: import side compounds
         System.out.println("importing side compounds...");
-        Mapper<BioMetabolite> cmapper = new Mapper<>(network, BioNetwork::getMetabolitesView).skipIfNotFound();
-        BioCollection<BioMetabolite> sideCpds = null;
-
-        try {
-            sideCpds = cmapper.map(sideCompoundFile);
-        } catch (IOException e) {
-            System.err.println("Error while reading the side compound file");
-            System.err.println(e.getMessage());
-            System.exit(1);
-        }
-        if (cmapper.getNumberOfSkippedEntries() > 0)
-            System.err.println(cmapper.getNumberOfSkippedEntries() + " side compounds not found in network.");
+        BioCollection<BioMetabolite> sideCpds = getMetabolitesFromFile(sideCompoundFile, network, "side compounds");
 
         //Graph processing: import blocked reactions
         BioCollection<BioReaction> blkdReactions = null;
-- 
GitLab


From 18f98af791e3650146a0f8c36372fdd5f2c65cc9 Mon Sep 17 00:00:00 2001
From: lcottret <ludovic.cottret@inrae.fr>
Date: Mon, 6 Jan 2025 09:31:21 +0100
Subject: [PATCH 62/74] use getMetabolitesFromFile method

---
 .../networkAnalysis/ExtractSubNetwork.java          | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/ExtractSubNetwork.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/ExtractSubNetwork.java
index c7068bd1f..bbdae27c9 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/ExtractSubNetwork.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/ExtractSubNetwork.java
@@ -34,6 +34,7 @@ import java.util.Set;
 import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumFormats.*;
 import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumParameterTypes.InputFile;
 import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumParameterTypes.OutputFile;
+import static fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils.getMetabolitesFromFile;
 
 public class ExtractSubNetwork extends AbstractMet4jApplication {
 
@@ -102,17 +103,9 @@ public class ExtractSubNetwork extends AbstractMet4jApplication {
         //Graph processing: side compound removal [optional]
         if (sideCompoundFile != null) {
             System.err.println("removing side compounds...");
-            NodeMapping<BioMetabolite, ReactionEdge, CompoundGraph> mapper = new NodeMapping<>(graph).skipIfNotFound();
-            BioCollection<BioMetabolite> sideCpds = null;
-            try {
-                sideCpds = mapper.map(sideCompoundFile);
-            } catch (IOException e) {
-                System.err.println("Error while reading the side compound file");
-                System.err.println(e.getMessage());
-                System.exit(1);
-            }
+            BioCollection<BioMetabolite> sideCpds = getMetabolitesFromFile(sideCompoundFile, network, "side compounds");
             boolean removed = graph.removeAllVertices(sideCpds);
-            if (removed) System.err.println(sideCpds.size() + " compounds removed.");
+            if (removed) System.out.println(sideCpds.size() + " compounds removed.");
         }
 
         //get sources and targets
-- 
GitLab


From 03b1f0aced845d442866afbb0e4034f076279d52 Mon Sep 17 00:00:00 2001
From: lcottret <ludovic.cottret@inrae.fr>
Date: Mon, 6 Jan 2025 09:32:29 +0100
Subject: [PATCH 63/74] use getMetabolitesFromFile method

---
 .../ExtractSubReactionNetwork.java            | 41 +++++++------------
 1 file changed, 15 insertions(+), 26 deletions(-)

diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/ExtractSubReactionNetwork.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/ExtractSubReactionNetwork.java
index 153281c54..d57bb85da 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/ExtractSubReactionNetwork.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/ExtractSubReactionNetwork.java
@@ -2,8 +2,8 @@ package fr.inrae.toulouse.metexplore.met4j_toolbox.networkAnalysis;
 
 import fr.inrae.toulouse.metexplore.met4j_core.biodata.BioEntity;
 import fr.inrae.toulouse.metexplore.met4j_core.biodata.BioMetabolite;
-import fr.inrae.toulouse.metexplore.met4j_core.biodata.BioReaction;
 import fr.inrae.toulouse.metexplore.met4j_core.biodata.BioNetwork;
+import fr.inrae.toulouse.metexplore.met4j_core.biodata.BioReaction;
 import fr.inrae.toulouse.metexplore.met4j_core.biodata.collection.BioCollection;
 import fr.inrae.toulouse.metexplore.met4j_graph.computation.connect.KShortestPath;
 import fr.inrae.toulouse.metexplore.met4j_graph.computation.connect.ShortestPath;
@@ -17,11 +17,11 @@ import fr.inrae.toulouse.metexplore.met4j_graph.core.reaction.CompoundEdge;
 import fr.inrae.toulouse.metexplore.met4j_graph.core.reaction.ReactionGraph;
 import fr.inrae.toulouse.metexplore.met4j_graph.io.Bionetwork2BioGraph;
 import fr.inrae.toulouse.metexplore.met4j_graph.io.ExportGraph;
-import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.JsbmlReader;
-import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.Met4jSbmlReaderException;
 import fr.inrae.toulouse.metexplore.met4j_mapping.Mapper;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.AbstractMet4jApplication;
-import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.*;
+import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumFormats;
+import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.Format;
+import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.ParameterType;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.utils.Doi;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils;
 import org.kohsuke.args4j.Option;
@@ -34,6 +34,7 @@ import java.util.Set;
 import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumFormats.*;
 import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumParameterTypes.InputFile;
 import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumParameterTypes.OutputFile;
+import static fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils.getMetabolitesFromFile;
 
 public class ExtractSubReactionNetwork extends AbstractMet4jApplication {
 
@@ -84,6 +85,11 @@ public class ExtractSubReactionNetwork extends AbstractMet4jApplication {
     @Option(name = "-st", aliases = {"--steinertree"}, usage = "Extract Steiner Tree", forbids = {"-k"})
     public boolean st = false;
 
+    public static void main(String[] args) {
+        ExtractSubReactionNetwork app = new ExtractSubReactionNetwork();
+        app.parseArguments(args);
+        app.run();
+    }
 
     public void run() {
         //import network
@@ -96,18 +102,7 @@ public class ExtractSubReactionNetwork extends AbstractMet4jApplication {
         Mapper<BioReaction> rxnMapper = new Mapper<>(network, BioNetwork::getReactionsView).skipIfNotFound();
 
         //Graph processing: import side compounds
-        System.out.println("importing side compounds...");
-        BioCollection<BioMetabolite> sideCpds = null;
-        try {
-            sideCpds = metMapper.map(sideCompoundFile);
-        } catch (IOException e) {
-            System.err.println("Error while reading the side compound file");
-            System.err.println(e.getMessage());
-            System.exit(1);
-        }
-        if (metMapper.getNumberOfSkippedEntries() > 0)
-            System.err.println(metMapper.getNumberOfSkippedEntries() + " side compounds not found in network.");
-        System.out.println(sideCpds.size() + " side compounds ignored during graph build.");
+        BioCollection<BioMetabolite> sideCpds = getMetabolitesFromFile(sideCompoundFile, network, "side compounds");
 
         //get sources and targets
         System.out.println("extracting sources and targets");
@@ -148,9 +143,9 @@ public class ExtractSubReactionNetwork extends AbstractMet4jApplication {
                 System.exit(1);
             }
             boolean removed = graph.removeAllVertices(rList);
-            if(removed) removedNodes.addAll(rList);
+            if (removed) removedNodes.addAll(rList);
             if (rxnMapper.getNumberOfSkippedEntries() > 0)
-            System.err.println(rxnMapper.getNumberOfSkippedEntries() + " reactions to exclude not found in network.");
+                System.err.println(rxnMapper.getNumberOfSkippedEntries() + " reactions to exclude not found in network.");
             System.out.println(rList.size() + " reactions ignored during graph build.");
         }
 
@@ -184,20 +179,14 @@ public class ExtractSubReactionNetwork extends AbstractMet4jApplication {
         }
 
         //export sub-network
-        if(asTable){
+        if (asTable) {
             ExportGraph.toTab(subnet, outputPath);
-        }else{
+        } else {
             ExportGraph.toGmlWithAttributes(subnet, outputPath);
         }
 
     }
 
-    public static void main(String[] args)  {
-        ExtractSubReactionNetwork app = new ExtractSubReactionNetwork();
-        app.parseArguments(args);
-        app.run();
-    }
-
     @Override
     public String getLabel() {
         return this.getClass().getSimpleName();
-- 
GitLab


From de39f2e87f6b02b3b452a87b98cbeb9bedf299fe Mon Sep 17 00:00:00 2001
From: lcottret <ludovic.cottret@inrae.fr>
Date: Mon, 6 Jan 2025 09:33:21 +0100
Subject: [PATCH 64/74] use getMetabolitesFromFile method

---
 .../networkAnalysis/LoadPoint.java            | 26 ++-----------------
 1 file changed, 2 insertions(+), 24 deletions(-)

diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/LoadPoint.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/LoadPoint.java
index 70973a282..1b681751c 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/LoadPoint.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/LoadPoint.java
@@ -8,8 +8,6 @@ import fr.inrae.toulouse.metexplore.met4j_graph.core.WeightingPolicy;
 import fr.inrae.toulouse.metexplore.met4j_graph.core.compound.CompoundGraph;
 import fr.inrae.toulouse.metexplore.met4j_graph.core.compound.ReactionEdge;
 import fr.inrae.toulouse.metexplore.met4j_graph.io.Bionetwork2BioGraph;
-import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.JsbmlReader;
-import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.Met4jSbmlReaderException;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.AbstractMet4jApplication;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.Format;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.ParameterType;
@@ -17,8 +15,6 @@ import fr.inrae.toulouse.metexplore.met4j_toolbox.utils.Doi;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils;
 import org.kohsuke.args4j.Option;
 
-import java.io.BufferedReader;
-import java.io.FileReader;
 import java.io.FileWriter;
 import java.io.IOException;
 import java.util.HashMap;
@@ -28,6 +24,7 @@ import java.util.Set;
 import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumFormats.*;
 import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumParameterTypes.InputFile;
 import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumParameterTypes.OutputFile;
+import static fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils.getMetabolitesFromFile;
 
 public class LoadPoint extends AbstractMet4jApplication {
 
@@ -82,26 +79,7 @@ public class LoadPoint extends AbstractMet4jApplication {
         //Graph processing: side compound removal [optional]
         if (sideCompoundFile != null) {
             System.out.println("removing side compounds...");
-            BioCollection<BioMetabolite> sideCpds = new BioCollection<>();
-
-            try {
-                BufferedReader fr = new BufferedReader(new FileReader(sideCompoundFile));
-                String line;
-                while ((line = fr.readLine()) != null) {
-                    String sId = line.trim().split("\t")[0];
-                    BioMetabolite s = network.getMetabolite(sId);
-                    if (s != null) {
-                        sideCpds.add(s);
-                    } else {
-                        System.err.println(sId + " side compound not found in network.");
-                    }
-                }
-                fr.close();
-            } catch (IOException e) {
-                System.err.println("Error while reading the side compound file");
-                System.err.println(e.getMessage());
-                System.exit(1);
-            }
+            BioCollection<BioMetabolite> sideCpds = getMetabolitesFromFile(sideCompoundFile, network, "side compounds");
             boolean removed = graph.removeAllVertices(sideCpds);
             if (removed) System.out.println(sideCpds.size() + " compounds removed.");
         }
-- 
GitLab


From 04e334f16e2a8abf7112a822946869769eb00a6f Mon Sep 17 00:00:00 2001
From: lcottret <ludovic.cottret@inrae.fr>
Date: Mon, 6 Jan 2025 09:34:51 +0100
Subject: [PATCH 65/74] use getMetabolitesFromFile method

---
 .../networkAnalysis/MetaboRank.java           | 45 +++++++------------
 1 file changed, 16 insertions(+), 29 deletions(-)

diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/MetaboRank.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/MetaboRank.java
index 89eda0bf1..10a0873f7 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/MetaboRank.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/MetaboRank.java
@@ -48,9 +48,6 @@ import fr.inrae.toulouse.metexplore.met4j_graph.core.WeightingPolicy;
 import fr.inrae.toulouse.metexplore.met4j_graph.core.compound.CompoundGraph;
 import fr.inrae.toulouse.metexplore.met4j_graph.core.compound.ReactionEdge;
 import fr.inrae.toulouse.metexplore.met4j_graph.io.Bionetwork2BioGraph;
-import fr.inrae.toulouse.metexplore.met4j_graph.io.NodeMapping;
-import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.JsbmlReader;
-import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.Met4jSbmlReaderException;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.AbstractMet4jApplication;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumFormats;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumParameterTypes;
@@ -67,9 +64,9 @@ import java.util.*;
 import java.util.stream.IntStream;
 
 import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumFormats.Sbml;
-import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumFormats.Tsv;
 import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumParameterTypes.InputFile;
 import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumParameterTypes.OutputFile;
+import static fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils.getMetabolitesFromFile;
 import static java.util.stream.Collectors.toMap;
 
 /**
@@ -83,24 +80,24 @@ public class MetaboRank extends AbstractMet4jApplication {
     @Option(name = "-i", usage = "input SBML file: path to network used for computing centrality, in sbml format.", required = true)
     public String sbmlFilePath;
 
-    @Format(name= EnumFormats.Tsv)
+    @Format(name = EnumFormats.Tsv)
     @ParameterType(name = InputFile)
     @Option(name = "-s", usage = "input seeds file: tabulated file containing node of interest ids and weight", required = true)
     public String seedsFilePath;
 
-    @Format(name= EnumFormats.Tsv)
+    @Format(name = EnumFormats.Tsv)
     @ParameterType(name = OutputFile)
     @Option(name = "-o", usage = "output file: path to the file where the results will be exported", required = true)
     public String output;
 
     //parameters
-    @Format(name= EnumFormats.Tsv)
+    @Format(name = EnumFormats.Tsv)
     @ParameterType(name = InputFile)
     @Option(name = "-w", usage = "input edge weight file: (recommended) path to file containing edges' weights. Will be normalized as transition probabilities")
     public String edgeWeightsFilePaths;
 
-    @ParameterType(name= EnumParameterTypes.InputFile)
-    @Format(name= EnumFormats.Txt)
+    @ParameterType(name = EnumParameterTypes.InputFile)
+    @Format(name = EnumFormats.Txt)
     @Option(name = "-sc", usage = "input Side compound file", required = false)
     public String inputSide = null;
 
@@ -129,13 +126,11 @@ public class MetaboRank extends AbstractMet4jApplication {
     HashMap<String, Double> globalCheiRankScore;
     HashMap<String, Integer> globalPageRank;
     HashMap<String, Integer> globalCheiRank;
-
+    HashMap<String, Integer> finalRank;
     //results holder
     private HashMap<String, Double> globalVsPersonalizedPageRank;
     private HashMap<String, Double> globalVsPersonalizedCheiRank;
 
-    HashMap<String, Integer> finalRank;
-
     public static void main(String[] args) {
         MetaboRank app = new MetaboRank();
         app.parseArguments(args);
@@ -158,9 +153,9 @@ public class MetaboRank extends AbstractMet4jApplication {
         System.err.println("transition probabilities computed (reverse graph)");
 
         importSeeds(seedsFilePath);
-        if(seeds.isEmpty()){
+        if (seeds.isEmpty()) {
             System.err.println("no seed available, computation aborted");
-        }else{
+        } else {
             compute();
             printCompoundTable(output);
         }
@@ -183,15 +178,7 @@ public class MetaboRank extends AbstractMet4jApplication {
         //Graph processing: side compound removal [optional]
         if (inputSide != null) {
             System.out.println("removing side compounds...");
-            NodeMapping<BioMetabolite, ReactionEdge, CompoundGraph> mapper = new NodeMapping<>(firstGraph).skipIfNotFound();
-            BioCollection<BioMetabolite> sideCpds = null;
-            try {
-                sideCpds = mapper.map(inputSide);
-            } catch (IOException e) {
-                System.err.println("Error while reading the side compound file");
-                System.err.println(e.getMessage());
-                System.exit(1);
-            }
+            BioCollection<BioMetabolite> sideCpds = getMetabolitesFromFile(inputSide, model, "side compounds");
             boolean removed = firstGraph.removeAllVertices(sideCpds);
             if (removed) System.out.println(sideCpds.size() + " compounds removed.");
         }
@@ -246,7 +233,7 @@ public class MetaboRank extends AbstractMet4jApplication {
     }
 
     public void setEdgeWeights(CompoundGraph graph, String localFilePath) {
-        Boolean defaultWeight = (localFilePath==null || localFilePath.isEmpty() || localFilePath.isBlank());
+        Boolean defaultWeight = (localFilePath == null || localFilePath.isEmpty() || localFilePath.isBlank());
         //import weights from file
         WeightingPolicy wp = (defaultWeight) ? new UnweightedPolicy() : new WeightsFromFile<>(localFilePath, true);
         //set weights to edges
@@ -350,7 +337,7 @@ public class MetaboRank extends AbstractMet4jApplication {
         globalVsPersonalizedPageRank = computeGlobalVsPersonalized(globalPageRankScore, pageRankScore);
         globalVsPersonalizedCheiRank = computeGlobalVsPersonalized(globalCheiRankScore, cheiRankScore);
 
-        finalRank = computeFinalRank(globalVsPersonalizedPageRank,globalVsPersonalizedCheiRank);
+        finalRank = computeFinalRank(globalVsPersonalizedPageRank, globalVsPersonalizedCheiRank);
 
     }
 
@@ -419,11 +406,11 @@ public class MetaboRank extends AbstractMet4jApplication {
         Comparator<String> compWithTieBreaking = new Comparator<String>() {
             @Override
             public int compare(String s1, String s2) {
-                int result = Math.min(pr.get(s1),cr.get(s1)) - Math.min(pr.get(s2),cr.get(s2));
+                int result = Math.min(pr.get(s1), cr.get(s1)) - Math.min(pr.get(s2), cr.get(s2));
                 if (result == 0)
-                    result = Math.max(pr.get(s1),cr.get(s1)) - Math.max(pr.get(s2),cr.get(s2));
+                    result = Math.max(pr.get(s1), cr.get(s1)) - Math.max(pr.get(s2), cr.get(s2));
                 if (result == 0)
-                    result = pr.get(s1)-pr.get(s2);
+                    result = pr.get(s1) - pr.get(s2);
                 return result;
             }
         };
@@ -476,7 +463,7 @@ public class MetaboRank extends AbstractMet4jApplication {
                     double globalVsPersoCR = globalVsPersonalizedCheiRank.get(compound.getId());
                     bw.write(df.format(globalVsPersoPR) + "\t");
                     bw.write(df.format(globalVsPersoCR) + "\t");
-                    bw.write(Integer.toString(1+finalRank.get(compound.getId())));
+                    bw.write(Integer.toString(1 + finalRank.get(compound.getId())));
                 } else {
                     bw.write("NA\tNA\tNA");
                 }
-- 
GitLab


From 28aad2ac88a77d9d8042fc582a0d71572aeb5c0a Mon Sep 17 00:00:00 2001
From: lcottret <ludovic.cottret@inrae.fr>
Date: Mon, 6 Jan 2025 09:35:39 +0100
Subject: [PATCH 66/74] use getMetabolitesFromFile method

---
 .../networkAnalysis/NetworkSummary.java       | 29 ++++---------------
 1 file changed, 5 insertions(+), 24 deletions(-)

diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/NetworkSummary.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/NetworkSummary.java
index 07934a292..33af6b620 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/NetworkSummary.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/NetworkSummary.java
@@ -24,8 +24,6 @@ import fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils;
 import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics;
 import org.kohsuke.args4j.Option;
 
-import java.io.BufferedReader;
-import java.io.FileReader;
 import java.io.FileWriter;
 import java.io.IOException;
 import java.util.*;
@@ -34,6 +32,7 @@ import java.util.stream.Collectors;
 import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumFormats.Sbml;
 import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumParameterTypes.InputFile;
 import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumParameterTypes.OutputFile;
+import static fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils.getMetabolitesFromFile;
 
 
 public class NetworkSummary extends AbstractMet4jApplication {
@@ -84,28 +83,10 @@ public class NetworkSummary extends AbstractMet4jApplication {
 
         //Graph processing: side compound removal
         if (sideCompoundFile != null) {
-            try {
-                System.out.println("removing side compounds...");
-                BioCollection<BioMetabolite> sideCpds = new BioCollection<>();
-                BufferedReader fr = new BufferedReader(new FileReader(sideCompoundFile));
-                String line;
-                while ((line = fr.readLine()) != null) {
-                    String sId = line.trim().split("\t")[0];
-                    BioMetabolite s = network.getMetabolite(sId);
-                    if (s != null) {
-                        sideCpds.add(s);
-                    } else {
-                        System.err.println(sId + " side compound not found in network.");
-                    }
-                }
-                fr.close();
-                boolean removed = graph.removeAllVertices(sideCpds);
-                if (removed) System.out.println(sideCpds.size() + " compounds removed.");
-            } catch (IOException e) {
-                System.err.println("Error while reading the side compound file");
-                System.err.println(e.getMessage());
-                System.exit(1);
-            }
+            System.out.println("removing side compounds...");
+            BioCollection<BioMetabolite> sideCpds = getMetabolitesFromFile(sideCompoundFile, network, "side compounds");
+            boolean removed = graph.removeAllVertices(sideCpds);
+            if (removed) System.out.println(sideCpds.size() + " compounds removed.");
         }
 
         //Start Anlysis
-- 
GitLab


From caff87bfbbedf5bd3f2973cdc3dee5ff9599e42d Mon Sep 17 00:00:00 2001
From: lcottret <ludovic.cottret@inrae.fr>
Date: Mon, 6 Jan 2025 09:38:12 +0100
Subject: [PATCH 67/74] use getMetabolitesFromFile method

---
 .../networkAnalysis/PathwayNet.java             | 17 +++--------------
 1 file changed, 3 insertions(+), 14 deletions(-)

diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/PathwayNet.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/PathwayNet.java
index f38d59e7c..18cac753d 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/PathwayNet.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/PathwayNet.java
@@ -14,7 +14,6 @@ import fr.inrae.toulouse.metexplore.met4j_graph.core.pathway.PathwayGraph;
 import fr.inrae.toulouse.metexplore.met4j_graph.core.pathway.PathwayGraphEdge;
 import fr.inrae.toulouse.metexplore.met4j_graph.io.Bionetwork2BioGraph;
 import fr.inrae.toulouse.metexplore.met4j_graph.io.ExportGraph;
-import fr.inrae.toulouse.metexplore.met4j_mapping.Mapper;
 import fr.inrae.toulouse.metexplore.met4j_mathUtils.matrix.ExportMatrix;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.AbstractMet4jApplication;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumFormats;
@@ -25,12 +24,13 @@ import fr.inrae.toulouse.metexplore.met4j_toolbox.utils.Doi;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils;
 import org.kohsuke.args4j.Option;
 
-import java.io.IOException;
 import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
 import java.util.stream.Collectors;
 
+import static fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils.getMetabolitesFromFile;
+
 public class PathwayNet extends AbstractMet4jApplication {
 
     @Format(name = EnumFormats.Sbml)
@@ -84,18 +84,7 @@ public class PathwayNet extends AbstractMet4jApplication {
         //Graph processing: side compound removal [optional]
         BioCollection<BioMetabolite> sideCpds = new BioCollection<>();
         if (inputSide != null) {
-            System.out.println("importing side compounds...");
-            Mapper<BioMetabolite> cmapper = new Mapper<>(network, BioNetwork::getMetabolitesView).skipIfNotFound();
-
-            try {
-                sideCpds = cmapper.map(inputSide);
-            } catch (IOException e) {
-                System.err.println("Error while reading the side compound file");
-                System.err.println(e.getMessage());
-                System.exit(1);
-            }
-            if (cmapper.getNumberOfSkippedEntries() > 0)
-                System.err.println(cmapper.getNumberOfSkippedEntries() + " side compounds not found in network.");
+            sideCpds = getMetabolitesFromFile(inputSide, network, "side compounds");
         }
 
         System.out.print("Building Graph...");
-- 
GitLab


From 1f2e45cb9ede13e9dd88eada773a8f4a9270b053 Mon Sep 17 00:00:00 2001
From: lcottret <ludovic.cottret@inrae.fr>
Date: Mon, 6 Jan 2025 09:42:01 +0100
Subject: [PATCH 68/74] use getMetabolitesFromFile method

---
 .../networkAnalysis/ReactionDistanceMatrix.java      | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/ReactionDistanceMatrix.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/ReactionDistanceMatrix.java
index b953ad157..9976f8e34 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/ReactionDistanceMatrix.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/ReactionDistanceMatrix.java
@@ -33,6 +33,7 @@ import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.Enu
 import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumFormats.Sbml;
 import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumParameterTypes.InputFile;
 import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumParameterTypes.OutputFile;
+import static fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils.getMetabolitesFromFile;
 
 public class ReactionDistanceMatrix extends AbstractMet4jApplication {
 
@@ -96,16 +97,7 @@ public class ReactionDistanceMatrix extends AbstractMet4jApplication {
         //Graph processing: side compound removal [optional]
         BioCollection<BioMetabolite> sideCpds = new BioCollection<BioMetabolite>();
         if (sideCompoundFile != null) {
-            try {
-                System.out.println("removing side compounds...");
-                sideCpds = metMapper.map(sideCompoundFile);
-            } catch (IOException e) {
-                System.err.println("Error while reading the side compound file");
-                System.err.println(e.getMessage());
-                System.exit(1);
-            }
-            if (metMapper.getNumberOfSkippedEntries() > 0)
-                System.err.println(metMapper.getNumberOfSkippedEntries() + " side compounds not found in network.");
+            sideCpds = getMetabolitesFromFile(sideCompoundFile, network, "side compounds");
             System.out.println(sideCpds.size() + " side compounds to ignore during graph build");
         }
         //Graph processing: reactions removal [optional]
-- 
GitLab


From 5be15fa582f4de17b3cb4900f5d4b620779e9898 Mon Sep 17 00:00:00 2001
From: lcottret <ludovic.cottret@inrae.fr>
Date: Mon, 6 Jan 2025 09:43:08 +0100
Subject: [PATCH 69/74] use getMetabolitesFromFile method

---
 .../networkAnalysis/SeedsAndTargets.java           | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)

diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/SeedsAndTargets.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/SeedsAndTargets.java
index a46e3d7d3..f0d1dba39 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/SeedsAndTargets.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/SeedsAndTargets.java
@@ -7,9 +7,7 @@ import fr.inrae.toulouse.metexplore.met4j_core.biodata.BioNetwork;
 import fr.inrae.toulouse.metexplore.met4j_core.biodata.collection.BioCollection;
 import fr.inrae.toulouse.metexplore.met4j_graph.computation.analyze.SourcesAndSinks;
 import fr.inrae.toulouse.metexplore.met4j_graph.core.compound.CompoundGraph;
-import fr.inrae.toulouse.metexplore.met4j_graph.core.compound.ReactionEdge;
 import fr.inrae.toulouse.metexplore.met4j_graph.io.Bionetwork2BioGraph;
-import fr.inrae.toulouse.metexplore.met4j_graph.io.NodeMapping;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.AbstractMet4jApplication;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumFormats;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumParameterTypes;
@@ -24,6 +22,8 @@ import java.io.IOException;
 import java.util.HashSet;
 import java.util.Set;
 
+import static fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils.getMetabolitesFromFile;
+
 public class SeedsAndTargets extends AbstractMet4jApplication {
 
     @Format(name = EnumFormats.Sbml)
@@ -108,15 +108,7 @@ public class SeedsAndTargets extends AbstractMet4jApplication {
         //Graph processing: side compound removal [optional]
         if (inputSide != null) {
             System.out.println("removing side compounds...");
-            NodeMapping<BioMetabolite, ReactionEdge, CompoundGraph> mapper = new NodeMapping<>(graph).skipIfNotFound();
-            BioCollection<BioMetabolite> sideCpds = null;
-            try {
-                sideCpds = mapper.map(inputSide);
-            } catch (IOException e) {
-                System.err.println("Error while reading the side compound file");
-                System.err.println(e.getMessage());
-                System.exit(1);
-            }
+            BioCollection<BioMetabolite> sideCpds = getMetabolitesFromFile(inputSide, network, "side compounds");
             boolean removed = graph.removeAllVertices(sideCpds);
             if (removed) System.out.println(sideCpds.size() + " compounds removed.");
         }
-- 
GitLab


From 6c0aa5b169414977d6eefc3d8eb9ac14fa35af6e Mon Sep 17 00:00:00 2001
From: lcottret <ludovic.cottret@inrae.fr>
Date: Mon, 6 Jan 2025 09:45:56 +0100
Subject: [PATCH 70/74] use getMetabolitesFromFile method

---
 .../networkAnalysis/TopologicalPathwayAnalysis.java  | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/TopologicalPathwayAnalysis.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/TopologicalPathwayAnalysis.java
index b796e06df..89aded9e6 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/TopologicalPathwayAnalysis.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/TopologicalPathwayAnalysis.java
@@ -28,6 +28,8 @@ import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
 
+import static fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils.getMetabolitesFromFile;
+
 public class TopologicalPathwayAnalysis extends AbstractMet4jApplication {
 
     @Format(name = EnumFormats.Sbml)
@@ -97,15 +99,7 @@ public class TopologicalPathwayAnalysis extends AbstractMet4jApplication {
         //Graph processing: side compound removal [optional]
         if (inputSide != null) {
             System.out.println("Removing side compounds...");
-            NodeMapping<BioMetabolite, ReactionEdge, CompoundGraph> mapper = new NodeMapping<>(graph).skipIfNotFound();
-            BioCollection<BioMetabolite> sideCpds = null;
-            try {
-                sideCpds = mapper.map(inputSide);
-            } catch (IOException e) {
-                System.err.println("Error while reading the side compound file");
-                System.err.println(e.getMessage());
-                System.exit(1);
-            }
+            BioCollection<BioMetabolite> sideCpds = getMetabolitesFromFile(inputSide, network, "side compounds");
             boolean removed = graph.removeAllVertices(sideCpds);
             if (removed) System.out.println(sideCpds.size() + " compounds removed.");
         }
-- 
GitLab


From d1196c82376d0591c72699228f79c5c17744dac0 Mon Sep 17 00:00:00 2001
From: lcottret <ludovic.cottret@inrae.fr>
Date: Mon, 6 Jan 2025 09:49:16 +0100
Subject: [PATCH 71/74] use getMetabolitesFromFile method

---
 .../met4j_toolbox/convert/SbmlWizard.java          | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)

diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/convert/SbmlWizard.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/convert/SbmlWizard.java
index e235357da..6aeb6d53f 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/convert/SbmlWizard.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/convert/SbmlWizard.java
@@ -19,6 +19,8 @@ import org.kohsuke.args4j.Option;
 import java.io.IOException;
 import java.util.Set;
 
+import static fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils.getMetabolitesFromFile;
+
 public class SbmlWizard extends AbstractMet4jApplication {
 
     @Format(name = EnumFormats.Sbml)
@@ -88,19 +90,9 @@ public class SbmlWizard extends AbstractMet4jApplication {
 
         //side compound removal [optional]
         if (inputSide != null) {
-            BioCollection<BioMetabolite> sideCpds = new BioCollection<>();
             System.out.println("removing side compounds...");
-            Mapper<BioMetabolite> cmapper = new Mapper<>(network, BioNetwork::getMetabolitesView).skipIfNotFound();
 
-            try {
-                sideCpds = cmapper.map(inputSide);
-            } catch (IOException e) {
-                System.err.println("Error while reading the side compound file");
-                System.err.println(e.getMessage());
-                System.exit(1);
-            }
-            if (cmapper.getNumberOfSkippedEntries() > 0)
-                System.out.println(cmapper.getNumberOfSkippedEntries() + " side compounds not found in network.");
+            BioCollection<BioMetabolite> sideCpds = getMetabolitesFromFile(inputSide, network, "side compounds");
 
             for(BioMetabolite sc : sideCpds){
                 network.removeOnCascade(sc);
-- 
GitLab


From f34e38a1795b4d22605cad0d0aa17cc4c3c0bbf5 Mon Sep 17 00:00:00 2001
From: lcottret <ludovic.cottret@inrae.fr>
Date: Mon, 6 Jan 2025 15:45:21 +0100
Subject: [PATCH 72/74] refactoring classes

---
 .../Sbml2CarbonSkeletonNet.java}              | 42 +++++++++++++++++--
 .../Sbml2CompoundGraph.java}                  | 42 +++++++++++++++++--
 .../Sbml2PathwayNet.java}                     | 42 +++++++++++++++++--
 3 files changed, 117 insertions(+), 9 deletions(-)
 rename met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/{networkAnalysis/CarbonSkeletonNet.java => convert/Sbml2CarbonSkeletonNet.java} (83%)
 rename met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/{networkAnalysis/CompoundNet.java => convert/Sbml2CompoundGraph.java} (83%)
 rename met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/{networkAnalysis/PathwayNet.java => convert/Sbml2PathwayNet.java} (78%)

diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/CarbonSkeletonNet.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/convert/Sbml2CarbonSkeletonNet.java
similarity index 83%
rename from met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/CarbonSkeletonNet.java
rename to met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/convert/Sbml2CarbonSkeletonNet.java
index 69f9cad90..3c94729d1 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/CarbonSkeletonNet.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/convert/Sbml2CarbonSkeletonNet.java
@@ -1,4 +1,40 @@
-package fr.inrae.toulouse.metexplore.met4j_toolbox.networkAnalysis;
+/*
+ * Copyright INRAE (2025)
+ *
+ * contact-metexplore@inrae.fr
+ *
+ * This software is a computer program whose purpose is to [describe
+ * functionalities and technical features of your software].
+ *
+ * This software is governed by the CeCILL license under French law and
+ * abiding by the rules of distribution of free software.  You can  use,
+ * modify and/ or redistribute the software under the terms of the CeCILL
+ * license as circulated by CEA, CNRS and INRIA at the following URL
+ * "https://cecill.info/licences/Licence_CeCILL_V2.1-en.html".
+ *
+ * As a counterpart to the access to the source code and  rights to copy,
+ * modify and redistribute granted by the license, users are provided only
+ * with a limited warranty  and the software's author,  the holder of the
+ * economic rights,  and the successive licensors  have only  limited
+ * liability.
+ *
+ * In this respect, the user's attention is drawn to the risks associated
+ * with loading,  using,  modifying and/or developing or reproducing the
+ * software by the user in light of its specific status of free software,
+ * that may mean  that it is complicated to manipulate,  and  that  also
+ * therefore means  that it is reserved for developers  and  experienced
+ * professionals having in-depth computer knowledge. Users are therefore
+ * encouraged to load and test the software's suitability as regards their
+ * requirements in conditions enabling the security of their systems and/or
+ * data to be ensured and,  more generally, to use and operate it in the
+ * same conditions as regards security.
+ *
+ * The fact that you are presently reading this means that you have had
+ * knowledge of the CeCILL license and that you accept its terms.
+ *
+ */
+
+package fr.inrae.toulouse.metexplore.met4j_toolbox.convert;
 
 import fr.inrae.toulouse.metexplore.met4j_chemUtils.FormulaParser;
 import fr.inrae.toulouse.metexplore.met4j_core.biodata.BioMetabolite;
@@ -27,7 +63,7 @@ import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.Enu
 import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumParameterTypes.InputFile;
 import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumParameterTypes.OutputFile;
 
-public class CarbonSkeletonNet extends AbstractMet4jApplication {
+public class Sbml2CarbonSkeletonNet extends AbstractMet4jApplication {
 
     @Format(name = Sbml)
     @ParameterType(name = InputFile)
@@ -73,7 +109,7 @@ public class CarbonSkeletonNet extends AbstractMet4jApplication {
 
     public static void main(String[] args) {
 
-        CarbonSkeletonNet app = new CarbonSkeletonNet();
+        Sbml2CarbonSkeletonNet app = new Sbml2CarbonSkeletonNet();
 
         app.parseArguments(args);
 
diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/CompoundNet.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/convert/Sbml2CompoundGraph.java
similarity index 83%
rename from met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/CompoundNet.java
rename to met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/convert/Sbml2CompoundGraph.java
index 5c7db7c22..9cca4bacd 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/CompoundNet.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/convert/Sbml2CompoundGraph.java
@@ -1,4 +1,40 @@
-package fr.inrae.toulouse.metexplore.met4j_toolbox.networkAnalysis;
+/*
+ * Copyright INRAE (2025)
+ *
+ * contact-metexplore@inrae.fr
+ *
+ * This software is a computer program whose purpose is to [describe
+ * functionalities and technical features of your software].
+ *
+ * This software is governed by the CeCILL license under French law and
+ * abiding by the rules of distribution of free software.  You can  use,
+ * modify and/ or redistribute the software under the terms of the CeCILL
+ * license as circulated by CEA, CNRS and INRIA at the following URL
+ * "https://cecill.info/licences/Licence_CeCILL_V2.1-en.html".
+ *
+ * As a counterpart to the access to the source code and  rights to copy,
+ * modify and redistribute granted by the license, users are provided only
+ * with a limited warranty  and the software's author,  the holder of the
+ * economic rights,  and the successive licensors  have only  limited
+ * liability.
+ *
+ * In this respect, the user's attention is drawn to the risks associated
+ * with loading,  using,  modifying and/or developing or reproducing the
+ * software by the user in light of its specific status of free software,
+ * that may mean  that it is complicated to manipulate,  and  that  also
+ * therefore means  that it is reserved for developers  and  experienced
+ * professionals having in-depth computer knowledge. Users are therefore
+ * encouraged to load and test the software's suitability as regards their
+ * requirements in conditions enabling the security of their systems and/or
+ * data to be ensured and,  more generally, to use and operate it in the
+ * same conditions as regards security.
+ *
+ * The fact that you are presently reading this means that you have had
+ * knowledge of the CeCILL license and that you accept its terms.
+ *
+ */
+
+package fr.inrae.toulouse.metexplore.met4j_toolbox.convert;
 
 import fr.inrae.toulouse.metexplore.met4j_core.biodata.BioMetabolite;
 import fr.inrae.toulouse.metexplore.met4j_core.biodata.BioNetwork;
@@ -27,7 +63,7 @@ import java.util.Set;
 
 import static fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils.getMetabolitesFromFile;
 
-public class CompoundNet extends AbstractMet4jApplication {
+public class Sbml2CompoundGraph extends AbstractMet4jApplication {
 
     @Format(name = EnumFormats.Sbml)
     @ParameterType(name = EnumParameterTypes.InputFile)
@@ -74,7 +110,7 @@ public class CompoundNet extends AbstractMet4jApplication {
 
     public static void main(String[] args) {
 
-        CompoundNet app = new CompoundNet();
+        Sbml2CompoundGraph app = new Sbml2CompoundGraph();
 
         app.parseArguments(args);
 
diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/PathwayNet.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/convert/Sbml2PathwayNet.java
similarity index 78%
rename from met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/PathwayNet.java
rename to met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/convert/Sbml2PathwayNet.java
index 18cac753d..d5fbfee43 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/PathwayNet.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/convert/Sbml2PathwayNet.java
@@ -1,4 +1,40 @@
-package fr.inrae.toulouse.metexplore.met4j_toolbox.networkAnalysis;
+/*
+ * Copyright INRAE (2025)
+ *
+ * contact-metexplore@inrae.fr
+ *
+ * This software is a computer program whose purpose is to [describe
+ * functionalities and technical features of your software].
+ *
+ * This software is governed by the CeCILL license under French law and
+ * abiding by the rules of distribution of free software.  You can  use,
+ * modify and/ or redistribute the software under the terms of the CeCILL
+ * license as circulated by CEA, CNRS and INRIA at the following URL
+ * "https://cecill.info/licences/Licence_CeCILL_V2.1-en.html".
+ *
+ * As a counterpart to the access to the source code and  rights to copy,
+ * modify and redistribute granted by the license, users are provided only
+ * with a limited warranty  and the software's author,  the holder of the
+ * economic rights,  and the successive licensors  have only  limited
+ * liability.
+ *
+ * In this respect, the user's attention is drawn to the risks associated
+ * with loading,  using,  modifying and/or developing or reproducing the
+ * software by the user in light of its specific status of free software,
+ * that may mean  that it is complicated to manipulate,  and  that  also
+ * therefore means  that it is reserved for developers  and  experienced
+ * professionals having in-depth computer knowledge. Users are therefore
+ * encouraged to load and test the software's suitability as regards their
+ * requirements in conditions enabling the security of their systems and/or
+ * data to be ensured and,  more generally, to use and operate it in the
+ * same conditions as regards security.
+ *
+ * The fact that you are presently reading this means that you have had
+ * knowledge of the CeCILL license and that you accept its terms.
+ *
+ */
+
+package fr.inrae.toulouse.metexplore.met4j_toolbox.convert;
 
 import fr.inrae.toulouse.metexplore.met4j_core.biodata.BioMetabolite;
 import fr.inrae.toulouse.metexplore.met4j_core.biodata.BioNetwork;
@@ -31,7 +67,7 @@ import java.util.stream.Collectors;
 
 import static fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils.getMetabolitesFromFile;
 
-public class PathwayNet extends AbstractMet4jApplication {
+public class Sbml2PathwayNet extends AbstractMet4jApplication {
 
     @Format(name = EnumFormats.Sbml)
     @ParameterType(name = EnumParameterTypes.InputFile)
@@ -67,7 +103,7 @@ public class PathwayNet extends AbstractMet4jApplication {
 
     public static void main(String[] args) {
 
-        PathwayNet app = new PathwayNet();
+        Sbml2PathwayNet app = new Sbml2PathwayNet();
 
         app.parseArguments(args);
 
-- 
GitLab


From 655bb4872bb795a8fe48f9a49a329d83a834137c Mon Sep 17 00:00:00 2001
From: lcottret <ludovic.cottret@inrae.fr>
Date: Tue, 7 Jan 2025 09:31:25 +0100
Subject: [PATCH 73/74] parser en option de readSbml

---
 .../attributes/AbstractSbmlSet.java           |  3 +-
 .../attributes/ExtractAnnotations.java        |  4 ++-
 .../attributes/ExtractPathways.java           |  7 ++--
 .../met4j_toolbox/attributes/GetEntities.java |  4 ++-
 .../attributes/GetGenesFromReactions.java     |  5 ++-
 .../attributes/GetMetaboliteAttributes.java   |  4 ++-
 .../met4j_toolbox/convert/FbcToNotes.java     |  7 ++--
 .../convert/Sbml2CarbonSkeletonNet.java       |  7 ++--
 .../convert/Sbml2CompoundGraph.java           |  4 ++-
 .../convert/Sbml2PathwayNet.java              |  3 +-
 .../met4j_toolbox/convert/Sbml2Tab.java       |  5 ++-
 .../met4j_toolbox/convert/SbmlWizard.java     |  3 +-
 .../mapping/ORApathwayEnrichment.java         |  4 ++-
 .../networkAnalysis/SideCompoundsScan.java    |  4 ++-
 .../TopologicalPathwayAnalysis.java           |  4 ++-
 .../reconstruction/CreateMetaNetwork.java     |  5 +--
 .../reconstruction/SbmlCheckBalance.java      |  4 ++-
 .../met4j_toolbox/utils/IOUtils.java          | 33 +++++++++++++++++--
 18 files changed, 83 insertions(+), 27 deletions(-)

diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/AbstractSbmlSet.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/AbstractSbmlSet.java
index 5cc833234..0985db496 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/AbstractSbmlSet.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/AbstractSbmlSet.java
@@ -44,6 +44,7 @@ import fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils;
 
 import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumFormats.*;
 import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumParameterTypes.*;
+import static fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils.SbmlPackage.*;
 
 /**
  * <p>Abstract AbstractSbmlSet class.</p>
@@ -87,7 +88,7 @@ public abstract class AbstractSbmlSet extends AbstractMet4jApplication {
      * @return a {@link fr.inrae.toulouse.metexplore.met4j_core.biodata.BioNetwork} object.
      */
     protected BioNetwork readSbml() {
-        return IOUtils.readSbml(this.sbml);
+        return IOUtils.readSbml(this.sbml, ALL);
     }
 
     /**
diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/ExtractAnnotations.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/ExtractAnnotations.java
index 51c1cd20f..49668d6e6 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/ExtractAnnotations.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/ExtractAnnotations.java
@@ -18,6 +18,8 @@ import java.io.FileWriter;
 import java.io.IOException;
 import java.util.*;
 
+import static fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils.SbmlPackage.ANNOTATIONS;
+
 public class ExtractAnnotations extends AbstractMet4jApplication {
 
     @Format(name = EnumFormats.Sbml)
@@ -65,7 +67,7 @@ public class ExtractAnnotations extends AbstractMet4jApplication {
             fw = new FileWriter(outputPath);
 
             //read smbl
-            BioNetwork network = IOUtils.readSbml(this.inputPath);
+            BioNetwork network = IOUtils.readSbml(this.inputPath, ANNOTATIONS);
 
             BioCollection<? extends BioEntity> entities = new BioCollection<>();
             if (export == entity.METABOLITE) {
diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/ExtractPathways.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/ExtractPathways.java
index f3207d86f..0d17c420d 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/ExtractPathways.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/ExtractPathways.java
@@ -2,9 +2,7 @@ package fr.inrae.toulouse.metexplore.met4j_toolbox.attributes;
 
 import fr.inrae.toulouse.metexplore.met4j_core.biodata.*;
 import fr.inrae.toulouse.metexplore.met4j_core.biodata.collection.BioCollection;
-import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.JsbmlReader;
 import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.Met4jSbmlReaderException;
-import fr.inrae.toulouse.metexplore.met4j_io.jsbml.writer.JsbmlWriter;
 import fr.inrae.toulouse.metexplore.met4j_io.jsbml.writer.Met4jSbmlWriterException;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.AbstractMet4jApplication;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumFormats;
@@ -18,6 +16,9 @@ import org.kohsuke.args4j.Option;
 import java.io.IOException;
 import java.util.Set;
 
+import static fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils.SbmlPackage.GROUPS;
+import static fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils.SbmlPackage.NOTES;
+
 public class ExtractPathways extends AbstractMet4jApplication {
 
     @Format(name= EnumFormats.Sbml)
@@ -46,7 +47,7 @@ public class ExtractPathways extends AbstractMet4jApplication {
 
     public void run() {
         // read smbl
-        BioNetwork network = IOUtils.readSbml(this.inputPath);
+        BioNetwork network = IOUtils.readSbml(this.inputPath, GROUPS, NOTES);
 
         System.out.println("Number of reactions in original network: "+network.getReactionsView().size());
         System.out.println("Number of species in original network: "+network.getMetabolitesView().size());
diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/GetEntities.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/GetEntities.java
index e92e44c95..c07b68e36 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/GetEntities.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/GetEntities.java
@@ -15,6 +15,8 @@ import java.io.IOException;
 import java.io.PrintWriter;
 import java.util.Set;
 
+import static fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils.SbmlPackage.*;
+
 public class GetEntities extends AbstractMet4jApplication {
 
 
@@ -69,7 +71,7 @@ public class GetEntities extends AbstractMet4jApplication {
     public void run() {
 
         String fileIn = this.sbml;
-        BioNetwork network = IOUtils.readSbml(fileIn);
+        BioNetwork network = IOUtils.readSbml(fileIn, FBC, NOTES, GROUPS);
 
         //default case: everything printed
         if(!(printMetabolites|printReactions|printPathways|printGenes|printCompartments)){
diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/GetGenesFromReactions.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/GetGenesFromReactions.java
index ef011f764..a04256217 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/GetGenesFromReactions.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/GetGenesFromReactions.java
@@ -22,6 +22,9 @@ import java.io.IOException;
 import java.io.PrintWriter;
 import java.util.Set;
 
+import static fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils.SbmlPackage.FBC;
+import static fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils.SbmlPackage.NOTES;
+
 public class GetGenesFromReactions extends AbstractMet4jApplication {
 
 
@@ -71,7 +74,7 @@ public class GetGenesFromReactions extends AbstractMet4jApplication {
 
         //read SBML, create bionetwork
         String fileIn = this.sbml;
-        BioNetwork network = IOUtils.readSbml(fileIn);
+        BioNetwork network = IOUtils.readSbml(fileIn, FBC, NOTES);
 
         //Import Reaction File
         BioCollection<BioReaction> input = new BioCollection<>();
diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/GetMetaboliteAttributes.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/GetMetaboliteAttributes.java
index c17a8bf7b..1c788d063 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/GetMetaboliteAttributes.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/GetMetaboliteAttributes.java
@@ -52,6 +52,8 @@ import java.io.IOException;
 import java.io.PrintWriter;
 import java.util.Set;
 
+import static fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils.SbmlPackage.*;
+
 /**
  * <p>SbmlToMetaboliteTable class.</p>
  *
@@ -108,7 +110,7 @@ public class GetMetaboliteAttributes extends AbstractMet4jApplication {
     }
 
     BioNetwork readSbml() {
-        return IOUtils.readSbml(this.sbml);
+        return IOUtils.readSbml(this.sbml, NOTES, FBC, ANNOTATIONS);
     }
 
 
diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/convert/FbcToNotes.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/convert/FbcToNotes.java
index b721287db..3a7b2a8d4 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/convert/FbcToNotes.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/convert/FbcToNotes.java
@@ -37,8 +37,6 @@
 package fr.inrae.toulouse.metexplore.met4j_toolbox.convert;
 
 import fr.inrae.toulouse.metexplore.met4j_core.biodata.BioNetwork;
-import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.JsbmlReader;
-import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.Met4jSbmlReaderException;
 import fr.inrae.toulouse.metexplore.met4j_io.jsbml.writer.JsbmlWriter;
 import fr.inrae.toulouse.metexplore.met4j_io.jsbml.writer.Met4jSbmlWriterException;
 import fr.inrae.toulouse.metexplore.met4j_io.jsbml.writer.plugin.AnnotationWriter;
@@ -46,7 +44,6 @@ import fr.inrae.toulouse.metexplore.met4j_io.jsbml.writer.plugin.GroupPathwayWri
 import fr.inrae.toulouse.metexplore.met4j_io.jsbml.writer.plugin.NotesWriter;
 import fr.inrae.toulouse.metexplore.met4j_io.jsbml.writer.plugin.PackageWriter;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.AbstractMet4jApplication;
-import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumFormats;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.Format;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.ParameterType;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.utils.Doi;
@@ -55,13 +52,13 @@ import org.kohsuke.args4j.CmdLineException;
 import org.kohsuke.args4j.CmdLineParser;
 import org.kohsuke.args4j.Option;
 
-import java.io.IOException;
 import java.util.HashSet;
 import java.util.Set;
 
 import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumFormats.Sbml;
 import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumParameterTypes.InputFile;
 import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumParameterTypes.OutputFile;
+import static fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils.SbmlPackage.*;
 
 /**
  * <p>FbcToNotes class.</p>
@@ -109,7 +106,7 @@ public class FbcToNotes extends AbstractMet4jApplication {
 
     private void run() {
 
-        BioNetwork network = IOUtils.readSbml(this.inputPath);
+        BioNetwork network = IOUtils.readSbml(this.inputPath, FBC, GROUPS, ANNOTATIONS);
 
         JsbmlWriter writer = new JsbmlWriter(this.outputPath, network, 3, 1, false );
 
diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/convert/Sbml2CarbonSkeletonNet.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/convert/Sbml2CarbonSkeletonNet.java
index 3c94729d1..32c15ec86 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/convert/Sbml2CarbonSkeletonNet.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/convert/Sbml2CarbonSkeletonNet.java
@@ -62,6 +62,7 @@ import java.util.Set;
 import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumFormats.*;
 import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumParameterTypes.InputFile;
 import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumParameterTypes.OutputFile;
+import static fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils.SbmlPackage.*;
 
 public class Sbml2CarbonSkeletonNet extends AbstractMet4jApplication {
 
@@ -120,13 +121,15 @@ public class Sbml2CarbonSkeletonNet extends AbstractMet4jApplication {
 
     public void run() {
         System.out.print("Reading SBML...");
-        BioNetwork network = IOUtils.readSbml(this.inputPath);
+        BioNetwork network = IOUtils.readSbml(this.inputPath, FBC, NOTES, ANNOTATIONS);
+        System.out.println(network.getReactionsView().size()+ " reactions and "+network.getMetabolitesView().size()+" metabolites read.");
         System.out.println(" Done.");
 
 
         System.out.print("Building Network...");
         Bionetwork2BioGraph builder = new Bionetwork2BioGraph(network);
         CompoundGraph graph = builder.getCompoundGraph();
+        System.out.println(graph.vertexSet().size()+ " nodes and "+graph.edgeSet().size()+" edges created.");
         System.out.println(" Done.");
 
         System.out.print("Processing atom mappings...");
@@ -177,7 +180,7 @@ public class Sbml2CarbonSkeletonNet extends AbstractMet4jApplication {
                             System.out.println("\tdisconnecting " + n.getName());
                         }
                     } catch (IllegalArgumentException e) {
-                        System.out.println("\tcan't define structure of " + n.getName());
+                        System.err.println("\tcan't define structure of " + n.getName());
                     }
                 }
             }
diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/convert/Sbml2CompoundGraph.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/convert/Sbml2CompoundGraph.java
index 9cca4bacd..4dfb09da4 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/convert/Sbml2CompoundGraph.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/convert/Sbml2CompoundGraph.java
@@ -61,6 +61,8 @@ import org.kohsuke.args4j.Option;
 import java.util.HashSet;
 import java.util.Set;
 
+import static fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils.SbmlPackage.FBC;
+import static fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils.SbmlPackage.NOTES;
 import static fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils.getMetabolitesFromFile;
 
 public class Sbml2CompoundGraph extends AbstractMet4jApplication {
@@ -120,7 +122,7 @@ public class Sbml2CompoundGraph extends AbstractMet4jApplication {
 
     public void run() {
         System.out.print("Reading SBML...");
-        BioNetwork network = IOUtils.readSbml(inputPath);
+        BioNetwork network = IOUtils.readSbml(inputPath, FBC, NOTES );
         System.out.println(" Done.");
 
         System.out.print("Building Network...");
diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/convert/Sbml2PathwayNet.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/convert/Sbml2PathwayNet.java
index d5fbfee43..4aad3fa4f 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/convert/Sbml2PathwayNet.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/convert/Sbml2PathwayNet.java
@@ -65,6 +65,7 @@ import java.util.Map;
 import java.util.Set;
 import java.util.stream.Collectors;
 
+import static fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils.SbmlPackage.GROUPS;
 import static fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils.getMetabolitesFromFile;
 
 public class Sbml2PathwayNet extends AbstractMet4jApplication {
@@ -114,7 +115,7 @@ public class Sbml2PathwayNet extends AbstractMet4jApplication {
 
     public void run() {
         System.out.print("Reading SBML...");
-        BioNetwork network = IOUtils.readSbml(this.inputPath);
+        BioNetwork network = IOUtils.readSbml(this.inputPath, GROUPS);
         System.out.println(" Done.");
 
         //Graph processing: side compound removal [optional]
diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/convert/Sbml2Tab.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/convert/Sbml2Tab.java
index 2a53287e1..3c9ff6505 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/convert/Sbml2Tab.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/convert/Sbml2Tab.java
@@ -47,11 +47,14 @@ import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.Format;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.ParameterType;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.utils.Doi;
 import fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils;
+import org.checkerframework.checker.units.qual.N;
 import org.kohsuke.args4j.Option;
 
 import java.io.IOException;
 import java.util.Set;
 
+import static fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils.SbmlPackage.*;
+
 /**
  * <p>Sbml2Tab class.</p>
  *
@@ -98,7 +101,7 @@ public class Sbml2Tab extends AbstractMet4jApplication {
 
         String fileIn = this.in;
 
-        BioNetwork network = IOUtils.readSbml(fileIn);
+        BioNetwork network = IOUtils.readSbml(fileIn, ALL);
 
         BioNetwork2Tab bioNetwork2Tab = new BioNetwork2Tab(network, this.out, this.r, this.i);
 
diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/convert/SbmlWizard.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/convert/SbmlWizard.java
index 6aeb6d53f..398ffecf6 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/convert/SbmlWizard.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/convert/SbmlWizard.java
@@ -19,6 +19,7 @@ import org.kohsuke.args4j.Option;
 import java.io.IOException;
 import java.util.Set;
 
+import static fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils.SbmlPackage.ALL;
 import static fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils.getMetabolitesFromFile;
 
 public class SbmlWizard extends AbstractMet4jApplication {
@@ -76,7 +77,7 @@ public class SbmlWizard extends AbstractMet4jApplication {
     public void run() throws Met4jSbmlWriterException, IOException {
         System.out.print("Reading SBML...");
 
-        BioNetwork network = IOUtils.readSbml(inputPath);
+        BioNetwork network = IOUtils.readSbml(inputPath, ALL);
         System.out.println(" Done.");
 
         //print info
diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/mapping/ORApathwayEnrichment.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/mapping/ORApathwayEnrichment.java
index cdd055939..1b22591a6 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/mapping/ORApathwayEnrichment.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/mapping/ORApathwayEnrichment.java
@@ -24,6 +24,8 @@ import java.util.stream.Collectors;
 import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumFormats.Sbml;
 import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumFormats.Tsv;
 import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumParameterTypes.InputFile;
+import static fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils.SbmlPackage.GROUPS;
+import static fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils.SbmlPackage.NOTES;
 
 public class ORApathwayEnrichment extends AbstractMet4jApplication {
 
@@ -69,7 +71,7 @@ public class ORApathwayEnrichment extends AbstractMet4jApplication {
 
         //import network
         System.out.print("Reading SBML...");
-        BioNetwork network = IOUtils.readSbml(this.sbml);
+        BioNetwork network = IOUtils.readSbml(this.sbml, NOTES, GROUPS);
         System.out.println(" Done.");
 
         //import data
diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/SideCompoundsScan.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/SideCompoundsScan.java
index 57daeee4d..460e7fe67 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/SideCompoundsScan.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/SideCompoundsScan.java
@@ -28,6 +28,8 @@ import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.Enu
 import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumFormats.Tsv;
 import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumParameterTypes.InputFile;
 import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumParameterTypes.OutputFile;
+import static fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils.SbmlPackage.FBC;
+import static fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils.SbmlPackage.NOTES;
 
 /**
  *
@@ -83,7 +85,7 @@ public class SideCompoundsScan extends AbstractMet4jApplication {
 
         //import network
         System.out.println("reading SBML...");
-        BioNetwork network = IOUtils.readSbml(this.inputPath);
+        BioNetwork network = IOUtils.readSbml(this.inputPath, FBC, NOTES);
 
         //Create compound graph
         System.out.println("Creating network...");
diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/TopologicalPathwayAnalysis.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/TopologicalPathwayAnalysis.java
index 89aded9e6..b0c986ae6 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/TopologicalPathwayAnalysis.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/networkAnalysis/TopologicalPathwayAnalysis.java
@@ -28,6 +28,8 @@ import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
 
+import static fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils.SbmlPackage.GROUPS;
+import static fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils.SbmlPackage.NOTES;
 import static fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils.getMetabolitesFromFile;
 
 public class TopologicalPathwayAnalysis extends AbstractMet4jApplication {
@@ -88,7 +90,7 @@ public class TopologicalPathwayAnalysis extends AbstractMet4jApplication {
 
         System.out.print("Reading SBML...");
 
-        BioNetwork network = IOUtils.readSbml(inputPath);
+        BioNetwork network = IOUtils.readSbml(inputPath, NOTES, GROUPS);
         System.out.println(" Done.\n\n");
 
 
diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/reconstruction/CreateMetaNetwork.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/reconstruction/CreateMetaNetwork.java
index 01f91bde1..ddf228603 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/reconstruction/CreateMetaNetwork.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/reconstruction/CreateMetaNetwork.java
@@ -22,6 +22,7 @@ import java.util.function.Function;
 import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumFormats.Sbml;
 import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumParameterTypes.InputFile;
 import static fr.inrae.toulouse.metexplore.met4j_toolbox.reconstruction.CreateMetaNetwork.strategy.by_name;
+import static fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils.SbmlPackage.ALL;
 
 public class CreateMetaNetwork extends AbstractMet4jApplication {
 
@@ -72,7 +73,7 @@ public class CreateMetaNetwork extends AbstractMet4jApplication {
 
         //import networks
         System.out.print("Importing network 1...");
-        BioNetwork network1 = IOUtils.readSbml(this.sbml1FilePath);
+        BioNetwork network1 = IOUtils.readSbml(this.sbml1FilePath, ALL);
 
         BioCompartment co1ex = network1.getCompartment(external1);
         if (co1ex == null) {
@@ -95,7 +96,7 @@ public class CreateMetaNetwork extends AbstractMet4jApplication {
 
 
         System.out.print("Importing network 2...");
-        BioNetwork network2 = IOUtils.readSbml(this.sbml2FilePath);
+        BioNetwork network2 = IOUtils.readSbml(this.sbml2FilePath, ALL);
 
         BioCompartment co2ex = network2.getCompartment(external2);
         if (co2ex == null) {
diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/reconstruction/SbmlCheckBalance.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/reconstruction/SbmlCheckBalance.java
index 53d751f8b..cff749aa8 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/reconstruction/SbmlCheckBalance.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/reconstruction/SbmlCheckBalance.java
@@ -56,6 +56,8 @@ import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.Enu
 import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumFormats.Tsv;
 import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumParameterTypes.InputFile;
 import static fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumParameterTypes.OutputFile;
+import static fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils.SbmlPackage.FBC;
+import static fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils.SbmlPackage.NOTES;
 
 public class SbmlCheckBalance extends AbstractMet4jApplication {
 
@@ -81,7 +83,7 @@ public class SbmlCheckBalance extends AbstractMet4jApplication {
 
     private void run() {
 
-        BioNetwork network = IOUtils.readSbml(this.sbml);
+        BioNetwork network = IOUtils.readSbml(this.sbml, FBC, NOTES);
 
         analysis = new NetworkBalanceAnalysis(network);
 
diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/utils/IOUtils.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/utils/IOUtils.java
index b8a9b8669..db48c1a24 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/utils/IOUtils.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/utils/IOUtils.java
@@ -41,10 +41,13 @@ import fr.inrae.toulouse.metexplore.met4j_core.biodata.BioNetwork;
 import fr.inrae.toulouse.metexplore.met4j_core.biodata.collection.BioCollection;
 import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.JsbmlReader;
 import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.Met4jSbmlReaderException;
+import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.plugin.*;
 import fr.inrae.toulouse.metexplore.met4j_io.jsbml.writer.JsbmlWriter;
 import fr.inrae.toulouse.metexplore.met4j_mapping.Mapper;
 
 import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
 
 public class IOUtils {
 
@@ -54,12 +57,34 @@ public class IOUtils {
      * @param sbmlPath the path to the SBML file
      * @return the BioNetwork object read from the SBML file
      */
-    public static BioNetwork readSbml(String sbmlPath) {
+    public static BioNetwork readSbml(String sbmlPath, SbmlPackage... packages) {
         JsbmlReader reader = new JsbmlReader(sbmlPath);
 
+        ArrayList<PackageParser> pkgs = new ArrayList<>();
+
+        for(SbmlPackage pkg : packages) {
+            switch (pkg) {
+                case FBC:
+                    pkgs.add(new FBCParser());
+                    break;
+                case GROUPS:
+                    pkgs.add(new GroupPathwayParser());
+                    break;
+                case ANNOTATIONS:
+                    pkgs.add(new AnnotationParser(true));
+                    break;
+                case NOTES:
+                    pkgs.add(new NotesParser(true));
+                    break;
+                case ALL:
+                    pkgs.addAll(Arrays.asList(new FBCParser(), new GroupPathwayParser(), new AnnotationParser(true), new NotesParser(true)));
+                    break;
+            }
+        }
+
         BioNetwork bn = null;
         try {
-            bn = reader.read();
+            bn = reader.read(pkgs);
         } catch (Met4jSbmlReaderException e) {
             e.printStackTrace();
             System.err.println("Problem while reading the sbml file " + sbmlPath);
@@ -70,6 +95,10 @@ public class IOUtils {
 
     }
 
+    public enum SbmlPackage {
+        FBC, GROUPS, ANNOTATIONS, NOTES, ALL
+    }
+
     /**
      * Writes a BioNetwork object to an SBML file.
      *
-- 
GitLab


From 80b8053329642ee9c3d734ea9353c9ecb0e1d653 Mon Sep 17 00:00:00 2001
From: lcottret <ludovic.cottret@inrae.fr>
Date: Tue, 7 Jan 2025 11:30:20 +0100
Subject: [PATCH 74/74] fix import in ExtractAnnotations

---
 .../met4j_toolbox/attributes/ExtractAnnotations.java           | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/ExtractAnnotations.java b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/ExtractAnnotations.java
index 49668d6e6..9a5b9ba8d 100644
--- a/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/ExtractAnnotations.java
+++ b/met4j-toolbox/src/main/java/fr/inrae/toulouse/metexplore/met4j_toolbox/attributes/ExtractAnnotations.java
@@ -19,6 +19,7 @@ import java.io.IOException;
 import java.util.*;
 
 import static fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils.SbmlPackage.ANNOTATIONS;
+import static fr.inrae.toulouse.metexplore.met4j_toolbox.utils.IOUtils.SbmlPackage.NOTES;
 
 public class ExtractAnnotations extends AbstractMet4jApplication {
 
@@ -67,7 +68,7 @@ public class ExtractAnnotations extends AbstractMet4jApplication {
             fw = new FileWriter(outputPath);
 
             //read smbl
-            BioNetwork network = IOUtils.readSbml(this.inputPath, ANNOTATIONS);
+            BioNetwork network = IOUtils.readSbml(this.inputPath, ANNOTATIONS, NOTES);
 
             BioCollection<? extends BioEntity> entities = new BioCollection<>();
             if (export == entity.METABOLITE) {
-- 
GitLab