Mercurial > repos > bimib > marea_2
changeset 331:7557495e090c draft
Uploaded
author | luca_milaz |
---|---|
date | Mon, 05 Aug 2024 19:50:41 +0000 |
parents | 0312366eabfd |
children | 7113cf797cfa |
files | marea_2/ras_generator.py |
diffstat | 1 files changed, 23 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/marea_2/ras_generator.py Mon Aug 05 19:37:33 2024 +0000 +++ b/marea_2/ras_generator.py Mon Aug 05 19:50:41 2024 +0000 @@ -626,6 +626,26 @@ if geneName in supportedGenesInEncoding: return supportedGenesInEncoding[geneName] raise ValueError(f"Gene \"{geneName}\" non trovato, verifica di star utilizzando il modello corretto!") +def load_custom_rules2() -> Dict[str, ruleUtils.OpList]: + """ + Opens custom rules file and extracts the rules. If the file is in .csv format an additional parsing step will be + performed, significantly impacting the runtime. + + Returns: + Dict[str, ruleUtils.OpList] : dict mapping reaction IDs to rules. + """ + datFilePath = utils.FilePath.fromStrPath(ARGS.rule_list) # actual file, stored in galaxy as a .dat + + try: filenamePath = utils.FilePath.fromStrPath(ARGS.rules_name) # file's name in input, to determine its original ext + except utils.PathErr as err: + raise utils.PathErr(filenamePath, f"Please make sure your file's name is a valid file path, {err.msg}") + + + if filenamePath.ext is utils.FileFormat.PICKLE: return utils.readPickle(datFilePath) + + # csv rules need to be parsed, those in a pickle format are taken to be pre-parsed. + return { line[0] : ruleUtils.parseRuleToNestedList(line[1]) for line in utils.readCsv(datFilePath) } + def load_custom_rules() -> Dict[str, ruleUtils.OpList]: """ Opens custom rules file and extracts the rules. If the file is in .csv format an additional parsing step will be @@ -639,11 +659,12 @@ try: filenamePath = utils.FilePath.fromStrPath(ARGS.rules_name) # file's name in input, to determine its original ext except utils.PathErr as err: raise utils.PathErr(filenamePath, f"Please make sure your file's name is a valid file path, {err.msg}") + - if filenamePath.ext is utils.FileFormat.PICKLE: return utils.readPickle(datFilePath) + if filenamePath.ext is utils.FileFormat.PICKLE: return utils.readPickle(ARGS.rule_list) # csv rules need to be parsed, those in a pickle format are taken to be pre-parsed. - return { line[0] : ruleUtils.parseRuleToNestedList(line[1]) for line in utils.readCsv(datFilePath) } + return { line[0] : ruleUtils.parseRuleToNestedList(line[1]) for line in utils.readCsv(ARGS.rule_list) } def main() -> None: """