Mercurial > repos > bimib > marea_2_0
changeset 245:59830a48b19d draft
Uploaded
author | luca_milaz |
---|---|
date | Mon, 08 Jul 2024 13:37:38 +0000 |
parents | e9757480e74a |
children | c2981cdb2dd7 |
files | marea_2_0/model_generator.py |
diffstat | 1 files changed, 1 insertions(+), 32 deletions(-) [+] |
line wrap: on
line diff
--- a/marea_2_0/model_generator.py Mon Jul 08 13:33:51 2024 +0000 +++ b/marea_2_0/model_generator.py Mon Jul 08 13:37:38 2024 +0000 @@ -84,35 +84,6 @@ pass - -################################- INPUT DATA LOADING -################################ -def load_custom_model(file_path :utils.FilePath, ext :Optional[utils.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 utils.FileFormat.XML: - return cobra.io.read_sbml_model(file_path.show()) - - if ext is utils.FileFormat.JSON: - return cobra.io.load_json_model(file_path.show()) - - except Exception as e: raise utils.DataErr(file_path, e.__str__()) - raise utils.DataErr(file_path, - f"Fomat \"{file_path.ext}\" is not recognized, only JSON and XML files are supported.") - - ############################# main ########################################### def main() -> None: """ @@ -141,9 +112,7 @@ model_type :utils.Model = ARGS.model_selector if model_type is utils.Model.Custom: - #model = model_type.getCOBRAmodel(customPath = utils.FilePath.fromStrPath(ARGS.model_name), customExtension = utils.FilePath.fromStrPath(ARGS.model_name).ext) - model = load_custom_model( - utils.FilePath.fromStrPath(ARGS.model_name), utils.FilePath.fromStrPath(ARGS.model_name).ext) + model = model_type.getCOBRAmodel(customPath = utils.FilePath.fromStrPath(ARGS.model), customExtension = utils.FilePath.fromStrPath(ARGS.model_name).ext) else: model = model_type.getCOBRAmodel() '''for index, row in ras.iterrows(): #iterate over cells RAS