Mercurial > repos > bimib > cobraxy
comparison COBRAxy/utils/general_utils.py @ 409:71850bdf9e1e draft
Uploaded
author | francesco_lapi |
---|---|
date | Mon, 08 Sep 2025 17:18:08 +0000 |
parents | f413b78d61bf |
children | 6b015d3184ab |
comparison
equal
deleted
inserted
replaced
408:f413b78d61bf | 409:71850bdf9e1e |
---|---|
9 from itertools import count | 9 from itertools import count |
10 from typing import Any, Callable, Dict, Generic, List, Literal, Optional, TypeVar, Union, Set, Tuple | 10 from typing import Any, Callable, Dict, Generic, List, Literal, Optional, TypeVar, Union, Set, Tuple |
11 | 11 |
12 import pandas as pd | 12 import pandas as pd |
13 import cobra | 13 import cobra |
14 from cobra import Model, Reaction, Metabolite | 14 from cobra import Model as cobraModel, Reaction, Metabolite |
15 | 15 |
16 import zipfile | 16 import zipfile |
17 import gzip | 17 import gzip |
18 import bz2 | 18 import bz2 |
19 from io import StringIO | 19 from io import StringIO |
715 rename_genes(model2,dict_genes) | 715 rename_genes(model2,dict_genes) |
716 | 716 |
717 return model2 | 717 return model2 |
718 | 718 |
719 | 719 |
720 def build_cobra_model_from_csv(csv_path: str, model_id: str = "ENGRO2_custom") -> cobra.Model: | 720 def build_cobra_model_from_csv(csv_path: str, model_id: str = "new_model") -> cobra.Model: |
721 """ | 721 """ |
722 Costruisce un modello COBRApy a partire da un file CSV con i dati delle reazioni. | 722 Costruisce un modello COBRApy a partire da un file CSV con i dati delle reazioni. |
723 | 723 |
724 Args: | 724 Args: |
725 csv_path: Path al file CSV (separato da tab) | 725 csv_path: Path al file CSV (separato da tab) |
731 | 731 |
732 # Leggi i dati dal CSV | 732 # Leggi i dati dal CSV |
733 df = pd.read_csv(csv_path, sep='\t') | 733 df = pd.read_csv(csv_path, sep='\t') |
734 | 734 |
735 # Crea il modello vuoto | 735 # Crea il modello vuoto |
736 model = Model(model_id) | 736 model = cobraModel(model_id) |
737 | 737 |
738 # Dict per tenere traccia di metaboliti e compartimenti | 738 # Dict per tenere traccia di metaboliti e compartimenti |
739 metabolites_dict = {} | 739 metabolites_dict = {} |
740 compartments_dict = {} | 740 compartments_dict = {} |
741 | 741 |