Compare commits
5 Commits
362a559c20
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 148bdbcdc0 | |||
| 8fdf433691 | |||
| 4659bd1938 | |||
| ca5ebfcf1a | |||
| 2026ddf566 |
@@ -1,4 +1,4 @@
|
|||||||
# mc_sim.py - Helpers for Monte-Carlo style simulations
|
# mc_in.py - Helpers for Monte-Carlo style simulations
|
||||||
#
|
#
|
||||||
# Author: Konstantin E Bosbach <konstantin.bosbach@mars.uni-freiburg.de>
|
# Author: Konstantin E Bosbach <konstantin.bosbach@mars.uni-freiburg.de>
|
||||||
|
|
||||||
@@ -29,11 +29,13 @@ def load_config(input_folder="input/", section="default"):
|
|||||||
print(f"No {configFilePath} provided.")
|
print(f"No {configFilePath} provided.")
|
||||||
|
|
||||||
|
|
||||||
def conc_df_from_file(input_path="input/", foundation="vivo_average"):
|
def conc_df_from_file(input_path="input/", foundation="vivo_average",
|
||||||
|
include_molecules=[], save_df=True):
|
||||||
sections = load_config(input_path, "")
|
sections = load_config(input_path, "")
|
||||||
"""Generates concentration dataframe for mc method.
|
"""Generates concentration dataframe for mc method.
|
||||||
Supports different variation types (absolute/delta/relative)
|
Supports different variation types (absolute/delta/relative)
|
||||||
Returns data_frame of different concentrations"""
|
Returns data_frame of different concentrations.
|
||||||
|
include_molecules needed for option some_molecules"""
|
||||||
# Load all relevant sections
|
# Load all relevant sections
|
||||||
list_parser_parameter = []
|
list_parser_parameter = []
|
||||||
|
|
||||||
@@ -43,12 +45,36 @@ def conc_df_from_file(input_path="input/", foundation="vivo_average"):
|
|||||||
|
|
||||||
# Load foundation file, a line with e.g. in-vivo averages
|
# Load foundation file, a line with e.g. in-vivo averages
|
||||||
# The code expects a one-line-foundation.
|
# The code expects a one-line-foundation.
|
||||||
|
molecule_names = ['Ala', 'Asc', 'Asp', 'Cr', 'GABA', 'GPC', 'GSH',
|
||||||
|
'Glc', 'Gln', 'Glu', 'Ins', 'Lac', 'NAA', 'NAAG',
|
||||||
|
'PCho', 'PCr', 'PE', 'Scyllo', 'Tau',
|
||||||
|
'mm', 'Glu+Gln', 'GPC+PCho', 'Cr+PCr',
|
||||||
|
'Glc+Tau', 'NAA+NAAG']
|
||||||
|
|
||||||
if foundation == "vivo_average":
|
if foundation == "vivo_average":
|
||||||
try:
|
try:
|
||||||
df_foundation = pd.read_csv(
|
df_foundation = pd.read_csv(
|
||||||
"basis/fit_conc_result.csv").mean().to_frame().transpose()
|
"basis/fit_conc_result.csv").mean().to_frame().transpose()
|
||||||
except:
|
except:
|
||||||
print("No basis/fit_conc_result.csv file supplied")
|
print("No basis/fit_conc_result.csv file supplied")
|
||||||
|
# Sets all initial molecules, including some groups, to 0
|
||||||
|
if foundation == "flat":
|
||||||
|
try:
|
||||||
|
df_foundation = pd.read_csv(
|
||||||
|
"basis/fit_conc_result.csv").mean().to_frame().transpose()
|
||||||
|
for molecule in molecule_names:
|
||||||
|
df_foundation[molecule] = 0
|
||||||
|
except:
|
||||||
|
print("No basis/fit_conc_result.csv file supplied")
|
||||||
|
if foundation == "some_molecules":
|
||||||
|
try:
|
||||||
|
df_foundation = pd.read_csv(
|
||||||
|
"basis/fit_conc_result.csv").mean().to_frame().transpose()
|
||||||
|
for molecule in molecule_names:
|
||||||
|
if molecule not in include_molecules:
|
||||||
|
df_foundation[molecule] = 0
|
||||||
|
except:
|
||||||
|
print("No basis/fit_conc_result.csv file supplied")
|
||||||
else:
|
else:
|
||||||
print("Only foundation mode vivo_average not chosen")
|
print("Only foundation mode vivo_average not chosen")
|
||||||
|
|
||||||
@@ -92,4 +118,7 @@ def conc_df_from_file(input_path="input/", foundation="vivo_average"):
|
|||||||
df_conc[parameter_name] = parameter_values
|
df_conc[parameter_name] = parameter_values
|
||||||
i = i+1
|
i = i+1
|
||||||
|
|
||||||
|
if save_df:
|
||||||
|
df_conc.to_csv(str(input_path+"df_conc.csv"))
|
||||||
|
|
||||||
return df_conc
|
return df_conc
|
||||||
|
|||||||
Reference in New Issue
Block a user