Mercurial > repos > bimib > cobraxy
changeset 161:9159e12b03fa draft
Uploaded
author | francesco_lapi |
---|---|
date | Tue, 12 Nov 2024 17:11:17 +0000 |
parents | e1b0ddc770a9 |
children | b5a26d1c4fdc |
files | COBRAxy/flux_simulation.py |
diffstat | 1 files changed, 11 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/COBRAxy/flux_simulation.py Tue Nov 12 17:05:33 2024 +0000 +++ b/COBRAxy/flux_simulation.py Tue Nov 12 17:11:17 2024 +0000 @@ -114,8 +114,8 @@ def write_to_file(dataset: pd.DataFrame, name: str, keep_index:bool=False)->None: dataset.index.name = 'Reactions' - print(ARGS.output_path + name + ".csv") - dataset.to_csv(ARGS.output_path + name + ".csv", sep = '\t', index = keep_index) + print(ARGS.output_path + "/" + name + ".csv") + dataset.to_csv(ARGS.output_path + "/" + name + ".csv", sep = '\t', index = keep_index) ############################ dataset input #################################### def read_dataset(data :str, name :str) -> pd.DataFrame: @@ -162,17 +162,17 @@ for i in range(0, n_batches): optgp = OptGPSampler(model, thinning, seed) samples = optgp.sample(n_samples) - samples.to_csv(ARGS.output_path + model_name + '_'+ str(i)+'_OPTGP.csv', index=False) + samples.to_csv(ARGS.output_path + "/" + model_name + '_'+ str(i)+'_OPTGP.csv', index=False) seed+=1 samplesTotal = pd.DataFrame() for i in range(0, n_batches): - samples_batch = pd.read_csv(ARGS.output_path + model_name + '_'+ str(i)+'_OPTGP.csv') + samples_batch = pd.read_csv(ARGS.output_path + "/" + model_name + '_'+ str(i)+'_OPTGP.csv') samplesTotal = pd.concat([samplesTotal, samples_batch], ignore_index = True) write_to_file(samplesTotal.T, model_name, True) for i in range(0, n_batches): - os.remove(ARGS.output_path + model_name + '_'+ str(i)+'_OPTGP.csv') + os.remove(ARGS.output_path + "/" + model_name + '_'+ str(i)+'_OPTGP.csv') pass @@ -205,18 +205,18 @@ ARGS.out_log) CBS_backend.randomObjectiveFunctionSampling_cobrapy(model, n_samples, df_coefficients.iloc[:,i*n_samples:(i+1)*n_samples], samples) - utils.logWarning(ARGS.output_path + model_name + '_'+ str(i)+'_CBS.csv', ARGS.out_log) - samples.to_csv(ARGS.output_path + model_name + '_'+ str(i)+'_CBS.csv', index=False) + utils.logWarning(ARGS.output_path + "/" + model_name + '_'+ str(i)+'_CBS.csv', ARGS.out_log) + samples.to_csv(ARGS.output_path + "/" + model_name + '_'+ str(i)+'_CBS.csv', index=False) samplesTotal = pd.DataFrame() for i in range(0, n_batches): - samples_batch = pd.read_csv(ARGS.output_path + model_name + '_'+ str(i)+'_CBS.csv') + samples_batch = pd.read_csv(ARGS.output_path + "/" + model_name + '_'+ str(i)+'_CBS.csv') samplesTotal = pd.concat([samplesTotal, samples_batch], ignore_index = True) write_to_file(samplesTotal.T, model_name, True) for i in range(0, n_batches): - os.remove(ARGS.output_path + model_name + '_'+ str(i)+'_CBS.csv') + os.remove(ARGS.output_path + "/" + model_name + '_'+ str(i)+'_CBS.csv') pass @@ -250,7 +250,7 @@ df_mean, df_median, df_quantiles = fluxes_statistics(name, ARGS.output_types) if("fluxes" not in ARGS.output_types): - os.remove(ARGS.output_path + name + '.csv') + os.remove(ARGS.output_path + "/" + name + '.csv') returnList = [] returnList.append(df_mean) @@ -284,7 +284,7 @@ df_median= pd.DataFrame() df_quantiles= pd.DataFrame() - df_samples = pd.read_csv(ARGS.output_path + model_name + '.csv', sep = '\t', index_col = 0).T + df_samples = pd.read_csv(ARGS.output_path + "/" + model_name + '.csv', sep = '\t', index_col = 0).T df_samples = df_samples.round(8) for output_type in output_types: