changeset 102:182c710c1660 draft

Uploaded
author luca_milaz
date Sun, 13 Oct 2024 13:23:12 +0000
parents 6cb85065b38b
children d1370b6bb4c5
files COBRAxy/ras_to_bounds.py
diffstat 1 files changed, 10 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/COBRAxy/ras_to_bounds.py	Sun Oct 13 12:00:59 2024 +0000
+++ b/COBRAxy/ras_to_bounds.py	Sun Oct 13 13:23:12 2024 +0000
@@ -128,7 +128,6 @@
             scaling_factor = ras_row[reaction]
             lower_bound=model.reactions.get_by_id(reaction).lower_bound
             upper_bound=model.reactions.get_by_id(reaction).upper_bound
-            #warning("Reaction: "+reaction+" Lower Bound: "+str(lower_bound)+" Upper Bound: "+str(upper_bound)+" Scaling Factor: "+str(scaling_factor))
             valMax=float((upper_bound)*scaling_factor)
             valMin=float((lower_bound)*scaling_factor)
             if upper_bound!=0 and lower_bound==0:
@@ -176,6 +175,14 @@
     rxns_ids = [rxn.id for rxn in model.reactions]
     
     # Set medium conditions
+    ''' 
+    reactions_medium=model2.medium.keys()
+        for reaction in reactions_medium:
+            if(reaction != "EX_thbpt_e" and reaction != "EX_lac__L_e"):
+                model2.reactions.get_by_id(reaction).lower_bound=-float(ras_meta.loc[cell,"countmatrix_"+reaction])
+            if(reaction == "EX_lac__L_e"):
+                model2.reactions.get_by_id(reaction).lower_bound=float(0.0)
+    '''
     for reaction, value in medium.items():
         if value is not None:
             model.reactions.get_by_id(reaction).lower_bound = -float(value)
@@ -185,14 +192,11 @@
     
     # Set FVA bounds
     for reaction in rxns_ids:
-        rxn = model.reactions.get_by_id(reaction)
-        rxn.lower_bound = float(df_FVA.loc[reaction, "minimum"])
-        rxn.upper_bound = float(df_FVA.loc[reaction, "maximum"])
+        model.reactions.get_by_id(reaction).lower_bound = float(df_FVA.loc[reaction, "minimum"])
+        model.reactions.get_by_id(reaction).upper_bound = float(df_FVA.loc[reaction, "maximum"])
 
     if ras is not None:
         Parallel(n_jobs=cpu_count())(delayed(process_ras_cell)(cellName, ras_row, model, rxns_ids, output_folder) for cellName, ras_row in ras.iterrows())
-         #for cellName, ras_row in ras.iterrows():
-            #process_ras_cell(cellName, ras_row, model, rxns_ids, output_folder) 
     else:
         model_new = model.copy()
         apply_ras_bounds(model_new, pd.Series([1]*len(rxns_ids), index=rxns_ids), rxns_ids)