# HG changeset patch # User francesco_lapi # Date 1757077529 0 # Node ID a0b53ccc73a8b6ecdaf596cab33f199188da5c35 # Parent 52658ddcaa5d9e52adf6ba4bee152bafaa1f846a Uploaded diff -r 52658ddcaa5d -r a0b53ccc73a8 COBRAxy/utils/general_utils.py --- 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