changeset 283:33e499061029 draft

Uploaded
author luca_milaz
date Sun, 04 Aug 2024 18:37:57 +0000
parents ebc6bb8526c9
children 90185e1784ab
files marea_2/flux_simulation.py
diffstat 1 files changed, 59 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/marea_2/flux_simulation.py	Sun Aug 04 18:16:37 2024 +0000
+++ b/marea_2/flux_simulation.py	Sun Aug 04 18:37:57 2024 +0000
@@ -138,6 +138,20 @@
 
 
 def OPTGP_sampler(model:cobra.Model, model_name:str, n_samples:int=1000, thinning:int=100, n_batches:int=1, seed:int=0)-> None:
+    """
+    Samples from the OPTGP (Optimal Global Perturbation) algorithm and saves the results to CSV files.
+
+    Args:
+        model (cobra.Model): The COBRA model to sample from.
+        model_name (str): The name of the model, used in naming output files.
+        n_samples (int, optional): Number of samples per batch. Default is 1000.
+        thinning (int, optional): Thinning parameter for the sampler. Default is 100.
+        n_batches (int, optional): Number of batches to run. Default is 1.
+        seed (int, optional): Random seed for reproducibility. Default is 0.
+    
+    Returns:
+        None
+    """
 
     for i in range(0, n_batches):
         optgp = OptGPSampler(model, thinning, seed)
@@ -157,6 +171,19 @@
 
 
 def CBS_sampler(model:cobra.Model, model_name:str, n_samples:int=1000, n_batches:int=1, seed:int=0)-> None:
+    """
+    Samples using the CBS (Constraint-based Sampling) algorithm and saves the results to CSV files.
+
+    Args:
+        model (cobra.Model): The COBRA model to sample from.
+        model_name (str): The name of the model, used in naming output files.
+        n_samples (int, optional): Number of samples per batch. Default is 1000.
+        n_batches (int, optional): Number of batches to run. Default is 1.
+        seed (int, optional): Random seed for reproducibility. Default is 0.
+    
+    Returns:
+        None
+    """
 
     df_FVA = cobra.flux_analysis.flux_variability_analysis(model,fraction_of_optimum=0).round(6)
     
@@ -188,6 +215,17 @@
 
 
 def model_sampler(model_input_original:cobra.Model, bounds_path:str, cell_name:str)-> List[pd.DataFrame]:
+    """
+    Prepares the model with bounds from the dataset and performs sampling and analysis based on the selected algorithm.
+
+    Args:
+        model_input_original (cobra.Model): The original COBRA model.
+        bounds_path (str): Path to the CSV file containing the bounds dataset.
+        cell_name (str): Name of the cell, used to generate filenames for output.
+
+    Returns:
+        List[pd.DataFrame]: A list of DataFrames containing statistics and analysis results.
+    """
 
     model_input = model_input_original.copy()
     bounds_df = read_dataset(bounds_path, "bounds dataset")
@@ -225,6 +263,16 @@
     return returnList
 
 def fluxes_statistics(model_name: str,  output_types:List)-> List[pd.DataFrame]:
+    """
+    Computes statistics (mean, median, quantiles) for the fluxes.
+
+    Args:
+        model_name (str): Name of the model, used in filename for input.
+        output_types (List[str]): Types of statistics to compute (mean, median, quantiles).
+
+    Returns:
+        List[pd.DataFrame]: List of DataFrames containing mean, median, and quantiles statistics.
+    """
 
     df_mean = pd.DataFrame()
     df_median= pd.DataFrame()
@@ -263,6 +311,17 @@
     return df_mean, df_median, df_quantiles
 
 def fluxes_analysis(model:cobra.Model,  model_name:str, output_types:List)-> List[pd.DataFrame]:
+    """
+    Performs flux analysis including pFBA, FVA, and sensitivity analysis.
+
+    Args:
+        model (cobra.Model): The COBRA model to analyze.
+        model_name (str): Name of the model, used in filenames for output.
+        output_types (List[str]): Types of analysis to perform (pFBA, FVA, sensitivity).
+
+    Returns:
+        List[pd.DataFrame]: List of DataFrames containing pFBA, FVA, and sensitivity analysis results.
+    """
 
     df_pFBA = pd.DataFrame()
     df_FVA= pd.DataFrame()