Mercurial > repos > bimib > cobraxy
comparison COBRAxy/fromCSVtoCOBRA_beta.py @ 456:a6e45049c1b9 draft
Uploaded
| author | francesco_lapi |
|---|---|
| date | Fri, 12 Sep 2025 17:28:45 +0000 |
| parents | 4e2bc80764b6 |
| children |
comparison
equal
deleted
inserted
replaced
| 455:4e2bc80764b6 | 456:a6e45049c1b9 |
|---|---|
| 1 """ | |
| 2 Convert a tabular (CSV/TSV/Tabular) description of a COBRA model into a COBRA file. | |
| 3 | |
| 4 Supported output formats: SBML, JSON, MATLAB (.mat), YAML. | |
| 5 The script logs to a user-provided file for easier debugging in Galaxy. | |
| 6 """ | |
| 7 | |
| 1 import os | 8 import os |
| 2 import csv | |
| 3 import cobra | 9 import cobra |
| 4 import pickle | |
| 5 import argparse | 10 import argparse |
| 6 import pandas as pd | 11 from typing import List |
| 7 import utils.general_utils as utils | |
| 8 from typing import Optional, Tuple, Union, List, Dict | |
| 9 import logging | 12 import logging |
| 10 import utils.rule_parsing as rulesUtils | |
| 11 import utils.reaction_parsing as reactionUtils | |
| 12 import utils.model_utils as modelUtils | 13 import utils.model_utils as modelUtils |
| 13 | 14 |
| 14 ARGS : argparse.Namespace | 15 ARGS : argparse.Namespace |
| 15 def process_args(args: List[str] = None) -> argparse.Namespace: | 16 def process_args(args: List[str] = None) -> argparse.Namespace: |
| 17 """ | |
| 18 Parse command-line arguments for the CSV-to-COBRA conversion tool. | |
| 19 | |
| 20 Returns: | |
| 21 argparse.Namespace: Parsed arguments. | |
| 22 """ | |
| 16 parser = argparse.ArgumentParser( | 23 parser = argparse.ArgumentParser( |
| 17 usage="%(prog)s [options]", | 24 usage="%(prog)s [options]", |
| 18 description="Convert a tabular/CSV file to a COBRA model" | 25 description="Convert a tabular/CSV file to a COBRA model" |
| 19 ) | 26 ) |
| 20 | 27 |
| 43 | 50 |
| 44 | 51 |
| 45 ###############################- ENTRY POINT -################################ | 52 ###############################- ENTRY POINT -################################ |
| 46 | 53 |
| 47 def main(args: List[str] = None) -> None: | 54 def main(args: List[str] = None) -> None: |
| 55 """ | |
| 56 Entry point: parse arguments, build the COBRA model from a CSV/TSV file, | |
| 57 and save it in the requested format. | |
| 58 | |
| 59 Returns: | |
| 60 None | |
| 61 """ | |
| 48 global ARGS | 62 global ARGS |
| 49 ARGS = process_args(args) | 63 ARGS = process_args(args) |
| 50 | 64 |
| 51 # configure logging to the requested log file (overwrite each run) | 65 # configure logging to the requested log file (overwrite each run) |
| 52 logging.basicConfig(filename=ARGS.out_log, | 66 logging.basicConfig(filename=ARGS.out_log, |
