changeset 398:09064ce8f095 draft

Uploaded
author francesco_lapi
date Sun, 07 Sep 2025 16:01:16 +0000
parents de4a373e338b
children 172b3959dccf
files COBRAxy/ras_generator.py COBRAxy/ras_generator.xml
diffstat 2 files changed, 43 insertions(+), 43 deletions(-) [+]
line wrap: on
line diff
--- a/COBRAxy/ras_generator.py	Fri Sep 05 13:35:35 2025 +0000
+++ b/COBRAxy/ras_generator.py	Sun Sep 07 16:01:16 2025 +0000
@@ -27,15 +27,10 @@
         usage = '%(prog)s [options]',
         description = "process some value's genes to create a comparison's map.")
     
-    parser.add_argument(
-        '-rs', '--rules_selector', 
-        type = utils.Model, default = utils.Model.ENGRO2, choices = list(utils.Model),
-        help = 'chose which type of dataset you want use')
-    
-    parser.add_argument("-rl", "--rule_list", type = str,
+    parser.add_argument("-rl", "--model_upload", type = str,
         help = "path to input file with custom rules, if provided")
 
-    parser.add_argument("-rn", "--rules_name", type = str, help = "custom rules name")
+    parser.add_argument("-rn", "--model_upload_name", type = str, help = "custom rules name")
     # ^ I need this because galaxy converts my files into .dat but I need to know what extension they were in
     
     parser.add_argument(
@@ -642,9 +637,9 @@
     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
+    datFilePath = utils.FilePath.fromStrPath(ARGS.model_upload) # actual file, stored in galaxy as a .dat
+
+    try: filenamePath = utils.FilePath.fromStrPath(ARGS.model_upload_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}")
      
@@ -678,35 +673,46 @@
     # remove versioning from gene names
     dataset.iloc[:, 0] = dataset.iloc[:, 0].str.split('.').str[0]
 
-    # handle custom models
-    model :utils.Model = ARGS.rules_selector
+    rules = load_custom_rules()
+    reactions = list(rules.keys())
 
-    if model is utils.Model.Custom:
-        rules = load_custom_rules()
-        reactions = list(rules.keys())
+    save_as_tsv(ras_for_cell_lines(dataset, rules), reactions)
+    if ERRORS: utils.logWarning(
+        f"The following genes are mentioned in the rules but don't appear in the dataset: {ERRORS}",
+        ARGS.out_log)  
+
+
+    ############
 
-        save_as_tsv(ras_for_cell_lines(dataset, rules), reactions)
-        if ERRORS: utils.logWarning(
-            f"The following genes are mentioned in the rules but don't appear in the dataset: {ERRORS}",
-            ARGS.out_log)
+    # handle custom models
+    #model :utils.Model = ARGS.rules_selector
+
+    #if model is utils.Model.Custom:
+    #    rules = load_custom_rules()
+    #    reactions = list(rules.keys())
+
+    #    save_as_tsv(ras_for_cell_lines(dataset, rules), reactions)
+    #    if ERRORS: utils.logWarning(
+    #        f"The following genes are mentioned in the rules but don't appear in the dataset: {ERRORS}",
+    #        ARGS.out_log)
         
-        return
+    #    return
     
     # This is the standard flow of the ras_generator program, for non-custom models.
-    name = "RAS Dataset"
-    type_gene = gene_type(dataset.iloc[0, 0], name)
+    #name = "RAS Dataset"
+    #type_gene = gene_type(dataset.iloc[0, 0], name)
 
-    rules      = model.getRules(ARGS.tool_dir)
-    genes      = data_gene(dataset, type_gene, name, None)
-    ids, rules = load_id_rules(rules.get(type_gene))
+    #rules      = model.getRules(ARGS.tool_dir)
+    #genes      = data_gene(dataset, type_gene, name, None)
+    #ids, rules = load_id_rules(rules.get(type_gene))
 
-    resolve_rules, err = resolve(genes, rules, ids, ARGS.none, name)
-    create_ras(resolve_rules, name, rules, ids, ARGS.ras_output)
+    #resolve_rules, err = resolve(genes, rules, ids, ARGS.none, name)
+    #create_ras(resolve_rules, name, rules, ids, ARGS.ras_output)
     
-    if err: utils.logWarning(
-        f"Warning: gene(s) {err} not found in class \"{name}\", " +
-        "the expression level for this gene will be considered NaN",
-        ARGS.out_log)
+    #if err: utils.logWarning(
+    #    f"Warning: gene(s) {err} not found in class \"{name}\", " +
+    #    "the expression level for this gene will be considered NaN",
+    #    ARGS.out_log)
     
     print("Execution succeded")
 
--- a/COBRAxy/ras_generator.xml	Fri Sep 05 13:35:35 2025 +0000
+++ b/COBRAxy/ras_generator.xml	Sun Sep 07 16:01:16 2025 +0000
@@ -12,25 +12,19 @@
     <command detect_errors="exit_code">
         <![CDATA[
       	python $__tool_directory__/ras_generator.py
-      	--rules_selector $cond_rule.rules_selector
+        --tool_dir $__tool_directory__
+        --model_upload $model_upload
+        --model_upload_name $model_upload.element_identifier
         --input $input
         --none $none
-        --tool_dir $__tool_directory__
+
         --out_log $log
         --ras_output $ras_output
-        #if $cond_rule.rules_selector == 'Custom'
-            --rule_list $rule_list
-            --rules_name $rule_list.element_identifier
-        #end if
+        
         ]]>
     </command>
     <inputs>
-        <conditional name="cond_rule">
-            <expand macro="options"/>
-            <when value="Custom">
-                <param name="rule_list" argument="--rule_list" type="data" format="tabular, csv, pickle, p, pk" label="Custom rules" />
-            </when>
-        </conditional>
+        <param name="model_upload" argument="--model_upload" type="data" format="sbml, xml, json, json.gz, mat, pickle, p, pk" label="Custom model (optional)" help="If not provided, the selected model will be used." />
         <param name="input" argument="--input" type="data" format="tabular, csv, tsv" label="Gene Expression dataset:" />
         <param name="name" argument="--name" type="text" label="Dataset's name:" value="Dataset_RAS" help="Default: Dataset_RAS. Do not use white spaces or special symbols." />
         <param name="none" argument="--none" type="boolean" checked="true" label="(A and NaN) solved as (A)?" />