changeset 260:29bda13a88a9 draft

Uploaded
author luca_milaz
date Mon, 08 Jul 2024 15:59:28 +0000
parents 58a61b3ebda7
children 71e6863b1430
files marea_2_0/marea.xml marea_2_0/model_generator.py marea_2_0/ras_generator.xml marea_2_0/rps_generator.xml marea_2_0/utils/cobra_utils.py marea_2_0/utils/general_utils.py
diffstat 5 files changed, 34 insertions(+), 36 deletions(-) [+]
line wrap: on
line diff
--- a/marea_2_0/model_generator.py	Mon Jul 08 15:54:21 2024 +0000
+++ b/marea_2_0/model_generator.py	Mon Jul 08 15:59:28 2024 +0000
@@ -83,7 +83,7 @@
     dataset.to_csv(ARGS.output_folder + name + ".csv", sep = '\t', index = keep_index)
 
 
-def generate_model(model, cell_name, ras, medium, output_model_format)->cobra.:
+def generate_model(model, cell_name, ras, medium, output_model_format):
     model_new = model.copy()
     rxns_ids = []
     for rxn in model.reactions:
--- a/marea_2_0/ras_generator.xml	Mon Jul 08 15:54:21 2024 +0000
+++ b/marea_2_0/ras_generator.xml	Mon Jul 08 15:59:28 2024 +0000
@@ -9,7 +9,6 @@
         <requirement type="package" version="4.6.3">lxml</requirement>
         <requirement type="package" version="1.1.0">svglib</requirement>
         <requirement type="package" version="3.5.67">reportlab</requirement>
-        <requirement type="package" version="0.29.0">cobra</requirement>
     </requirements>
     <command detect_errors="exit_code">
         <![CDATA[
--- a/marea_2_0/rps_generator.xml	Mon Jul 08 15:54:21 2024 +0000
+++ b/marea_2_0/rps_generator.xml	Mon Jul 08 15:59:28 2024 +0000
@@ -4,7 +4,6 @@
         <import>marea_macros.xml</import>
     </macros>
     <requirements>
-        <requirement type="package" version="0.29.0">cobra</requirement>
         <requirement type="package" version="0.25.3">pandas</requirement>
         <requirement type="package" version="4.6.3">lxml</requirement>
         <requirement type="package" version="1.21.6">numpy</requirement>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/marea_2_0/utils/cobra_utils.py	Mon Jul 08 15:59:28 2024 +0000
@@ -0,0 +1,33 @@
+import cobra
+
+def getCOBRAmodel(self, toolDir = ".", customPath :Optional[FilePath] = None, customExtension :Optional[FilePath]=None)->cobra.Model:
+    if(self is Model.Custom):
+        return self.load_custom_model(customPath, customExtension)
+    else:
+        return cobra.io.read_sbml_model(FilePath(f"{self.name}", FileFormat.XML, prefix = f"{toolDir}/local/COBRA models/").show())
+
+def load_custom_model(self, file_path :FilePath, ext :Optional[FileFormat] = None) -> cobra.Model:
+    """
+    Loads a custom model from a file, either in JSON or XML format.
+
+    Args:
+        file_path : The path to the file containing the custom model.
+        ext : explicit file extension. Necessary for standard use in galaxy because of its weird behaviour.
+
+    Raises:
+        DataErr : if the file is in an invalid format or cannot be opened for whatever reason.    
+    
+    Returns:
+        cobra.Model : the model, if successfully opened.
+    """
+    ext = ext if ext else file_path.ext
+    try:
+        if ext is FileFormat.XML:
+            return cobra.io.read_sbml_model(file_path.show())
+        
+        if ext is FileFormat.JSON:
+            return cobra.io.load_json_model(file_path.show())
+
+    except Exception as e: raise DataErr(file_path, e.__str__())
+    raise DataErr(file_path,
+        f"Fomat \"{file_path.ext}\" is not recognized, only JSON and XML files are supported.")
\ No newline at end of file
--- a/marea_2_0/utils/general_utils.py	Mon Jul 08 15:54:21 2024 +0000
+++ b/marea_2_0/utils/general_utils.py	Mon Jul 08 15:59:28 2024 +0000
@@ -4,7 +4,6 @@
 import csv
 import pickle
 import lxml.etree as ET
-import cobra
 
 from enum import Enum
 from itertools import count
@@ -548,37 +547,5 @@
         path = customPath if self is Model.Custom else FilePath(f"{self.name}_map", FileFormat.SVG, prefix = f"{toolDir}/local/svg metabolic maps/")
         self.__raiseMissingPathErr(path)
         return readSvg(path, customErr = DataErr(path, f"custom map in wrong format"))
-    
-    def getCOBRAmodel(self, toolDir = ".", customPath :Optional[FilePath] = None, customExtension :Optional[FilePath]=None)->cobra.Model:
-        if(self is Model.Custom):
-            return self.load_custom_model(customPath, customExtension)
-        else:
-            return cobra.io.read_sbml_model(FilePath(f"{self.name}", FileFormat.XML, prefix = f"{toolDir}/local/COBRA models/").show())
-    
-    def load_custom_model(self, file_path :FilePath, ext :Optional[FileFormat] = None) -> cobra.Model:
-        """
-        Loads a custom model from a file, either in JSON or XML format.
-
-        Args:
-            file_path : The path to the file containing the custom model.
-            ext : explicit file extension. Necessary for standard use in galaxy because of its weird behaviour.
-
-        Raises:
-            DataErr : if the file is in an invalid format or cannot be opened for whatever reason.    
-        
-        Returns:
-            cobra.Model : the model, if successfully opened.
-        """
-        ext = ext if ext else file_path.ext
-        try:
-            if ext is FileFormat.XML:
-                return cobra.io.read_sbml_model(file_path.show())
-            
-            if ext is FileFormat.JSON:
-                return cobra.io.load_json_model(file_path.show())
-
-        except Exception as e: raise DataErr(file_path, e.__str__())
-        raise DataErr(file_path,
-            f"Fomat \"{file_path.ext}\" is not recognized, only JSON and XML files are supported.")
 
     def __str__(self) -> str: return self.value
\ No newline at end of file