changeset 394:a0b53ccc73a8 draft

Uploaded
author francesco_lapi
date Fri, 05 Sep 2025 13:05:29 +0000
parents 52658ddcaa5d
children 64563ca68ace
files COBRAxy/utils/general_utils.py
diffstat 1 files changed, 16 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/COBRAxy/utils/general_utils.py	Fri Sep 05 13:02:22 2025 +0000
+++ b/COBRAxy/utils/general_utils.py	Fri Sep 05 13:05:29 2025 +0000
@@ -17,6 +17,8 @@
 import bz2
 from io import StringIO
 
+
+
 class ValueErr(Exception):
     def __init__(self, param_name, expected, actual):
         super().__init__(f"Invalid value for {param_name}: expected {expected}, got {actual}")
@@ -698,4 +700,17 @@
         
 
 
-    def __str__(self) -> str: return self.value
\ No newline at end of file
+    def __str__(self) -> str: return self.value
+
+
+def convert_genes(model,annotation):
+    from cobra.manipulation import rename_genes
+    model2=model.copy()
+    try:
+        dict_genes={gene.id:gene.notes[annotation]  for gene in model2.genes}
+    except:
+        print("No annotation in gene dict!")
+        return -1
+    rename_genes(model2,dict_genes)
+
+    return model2
\ No newline at end of file