Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions pyenzyme/thinlayers/basico.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,11 @@ def _initialize_parameters(self):
)

param_dict["name"] = 'Values[' + param.symbol + ']'
parameters.append(param_dict)

# add only if lower and upper bound are not np.nan
if "lower" in param_dict and "upper" in param_dict:
if not (np.isnan(param_dict["lower"]) or np.isnan(param_dict["upper"])):
parameters.append(param_dict)

return parameters

Expand All @@ -296,6 +300,9 @@ def _get_experimental_data(self):
# get all species
species_df = basico.get_species(model=self.model).reset_index()

# construct sbml_id to name mapping dictionary
sbml_id_to_name = {row['sbml_id']: row['name'] for _, row in species_df.iterrows()}

# loop over 'id' colum of self.df and create a new experiment for each id
for id in self.df['id'].unique():
# get the dataframe for the id
Expand All @@ -315,14 +322,22 @@ def _get_experimental_data(self):
if col in species_df['name'].values:
df = df.rename(columns={col: f"[{col}]"})
continue
if col in sbml_id_to_name.keys():
# locate the name corresponding to the sbml_id
species_name = sbml_id_to_name[col]
df = df.rename(columns={col: f"[{species_name}]"})
continue
# otherwise raise error
else:
raise ValueError(f"Column {col} not found in species_df")

# finally add all the initial concentrations to the dataframe with the
# initial value at Time == 0
for species in inits.species.keys():
df.loc[df.index[0], f"[{species}]_0"] = inits.species[species]
if species in sbml_id_to_name.keys():
df.loc[df.index[0], f"[{sbml_id_to_name[species]}]_0"] = inits.species[species]
else:
df.loc[df.index[0], f"[{species}]_0"] = inits.species[species]

# now add as experiment to basico
basico.add_experiment(name=id, data=df, data_dir=self.model_dir)
Expand Down