changeset 402:ccccb731c953 draft

Uploaded
author francesco_lapi
date Sun, 07 Sep 2025 21:16:26 +0000
parents 6c7ddf68381a
children 05092b0cfca0
files COBRAxy/ras_generator.py COBRAxy/rps_generator.py COBRAxy/rps_generator.xml
diffstat 3 files changed, 27 insertions(+), 41 deletions(-) [+]
line wrap: on
line diff
--- a/COBRAxy/ras_generator.py	Sun Sep 07 20:29:23 2025 +0000
+++ b/COBRAxy/ras_generator.py	Sun Sep 07 21:16:26 2025 +0000
@@ -28,7 +28,7 @@
         description = "process some value's genes to create a comparison's map.")
     
     parser.add_argument("-rl", "--model_upload", type = str,
-        help = "path to input file with custom rules, if provided")
+        help = "path to input file containing the rules")
 
     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
--- a/COBRAxy/rps_generator.py	Sun Sep 07 20:29:23 2025 +0000
+++ b/COBRAxy/rps_generator.py	Sun Sep 07 21:16:26 2025 +0000
@@ -25,14 +25,11 @@
     parser = argparse.ArgumentParser(usage = '%(prog)s [options]',
                                      description = 'process some value\'s'+
                                      ' abundances and reactions to create RPS scores.')
-    parser.add_argument('-rc', '--reaction_choice', 
-                        type = str,
-                        default = 'default',
-                        choices = ['default','custom'], 
-                        help = 'chose which type of reaction dataset you want use')
-    parser.add_argument('-cm', '--custom',
-                        type = str,
-                        help='your dataset if you want custom reactions')
+    
+    parser.add_argument("-rl", "--model_upload", type = str,
+        help = "path to input file containing the reactions")
+
+    # model_upload custom
     parser.add_argument('-td', '--tool_dir',
                         type = str,
                         required = True,
@@ -205,7 +202,6 @@
     cell_lines = dataset[0][1:]
     abundances_dict = {}
 
-    translationIsApplied = ARGS.reaction_choice == "default"
     for row in dataset[1:]:
         id = get_metabolite_id(row[0], syn_dict) #if translationIsApplied else row[0]
         if id: 
@@ -245,22 +241,22 @@
 
     dataset = utils.readCsv(utils.FilePath.fromStrPath(ARGS.input), '\t', skipHeader = False)
     tmp_dict = None
-    if ARGS.reaction_choice == 'default':
-        reactions = pk.load(open(ARGS.tool_dir + '/local/pickle files/reactions.pickle', 'rb'))
-        substrateFreqTable = pk.load(open(ARGS.tool_dir + '/local/pickle files/substrate_frequencies.pickle', 'rb'))
+    #if ARGS.reaction_choice == 'default':
+    #    reactions = pk.load(open(ARGS.tool_dir + '/local/pickle files/reactions.pickle', 'rb'))
+    #    substrateFreqTable = pk.load(open(ARGS.tool_dir + '/local/pickle files/substrate_frequencies.pickle', 'rb'))
     
-    elif ARGS.reaction_choice == 'custom':
-        reactions = reactionUtils.parse_custom_reactions(ARGS.custom)
-        for r, s in reactions.items():
-            tmp_list = list(s.keys())
-            for k in tmp_list:
-                if k[-2] == '_':
-                    s[k[:-2]] = s.pop(k)
-        substrateFreqTable = {}
-        for _, substrates in reactions.items():
-            for substrateName, _ in substrates.items():
-                if substrateName not in substrateFreqTable: substrateFreqTable[substrateName] = 0
-                substrateFreqTable[substrateName] += 1
+    #elif ARGS.reaction_choice == 'custom':
+    reactions = reactionUtils.parse_custom_reactions(ARGS.model_upload)
+    for r, s in reactions.items():
+        tmp_list = list(s.keys())
+        for k in tmp_list:
+            if k[-2] == '_':
+                s[k[:-2]] = s.pop(k)
+    substrateFreqTable = {}
+    for _, substrates in reactions.items():
+        for substrateName, _ in substrates.items():
+            if substrateName not in substrateFreqTable: substrateFreqTable[substrateName] = 0
+            substrateFreqTable[substrateName] += 1
 
         print(f"Reactions: {reactions}")
         print(f"Substrate Frequencies: {substrateFreqTable}")
--- a/COBRAxy/rps_generator.xml	Sun Sep 07 20:29:23 2025 +0000
+++ b/COBRAxy/rps_generator.xml	Sun Sep 07 21:16:26 2025 +0000
@@ -12,29 +12,19 @@
     <command detect_errors="exit_code">
         <![CDATA[
       	python $__tool_directory__/rps_generator.py
-        --input $input
-      	--reaction_choice $cond_reactions.reaction_choice	
+        --input $input	
         --tool_dir $__tool_directory__
         --out_log $log	
         --rps_output $rps_output
-        #if $cond_reactions.reaction_choice == 'custom'
-        	--custom $cond_reactions.Custom_react
-        #end if
+        --model_upload $model_upload
         ]]>
     </command>
-    <inputs>
+    <inputs> 
+        <param name="model_upload" argument="--model_upload" type="data" format="csv,tsv,tabular" 
+                label="Model rules file:" help="Upload a CSV/TSV file containing reaction rules generated by the Model Initialization tool." />
+
         <param name="input" argument="--input" type="data" format="tabular, tsv, csv" label="Abundance dataset:" />
         <param name="name" argument="--name" type="text" label="Dataset's name:" value="Dataset_RPS" help="Default: Dataset_RPS. Do not use white spaces or special symbols." />
-        
-        <conditional name="cond_reactions">
-			<param name="reaction_choice" argument="--reaction_choice" type="select" label="Choose reaction dataset:">
-                	<option value="default" selected="true">ENGRO2 reaction dataset </option>
-                	<option value="custom">Custom reaction dataset</option>
-        	</param>
-            <when value="custom">
-                <param name="Custom_react" type="data" format="csv" label="Custom reactions" />
-            </when>
-        </conditional>  
     </inputs>
 
     <outputs>