Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Observables function #269

Merged
merged 17 commits into from
Feb 7, 2020
Merged
Show file tree
Hide file tree
Changes from 13 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
8 changes: 7 additions & 1 deletion petab/problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,14 +314,20 @@ def get_model_parameters(self):

def get_observables(self, remove: bool = False):
"""
Returns dictionary of observables definitions
Returns dictionary of observables definitions.
See `assignment_rules_to_dict` for details.
"""
warn("This function will be removed in future releases.",
DeprecationWarning)

return sbml.get_observables(sbml_model=self.sbml_model, remove=remove)

def get_observable_ids(self):
"""
Returns dictionary of observable ids.
"""
return list(self.observable_df.index)

def get_sigmas(self, remove: bool = False):
"""
Return dictionary of observableId => sigma as defined in the SBML
Expand Down
18 changes: 17 additions & 1 deletion tests/test_petab.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,23 @@ def petab_problem():
parameter_file_name = fh.name
parameter_df.to_csv(fh, sep='\t', index=False)

observable_df = pd.DataFrame(data={
OBSERVABLE_ID: ['observable_1'],
OBSERVABLE_NAME: ['julius'],
OBSERVABLE_FORMULA: ['observable_1'],
NOISE_FORMULA: [1],
})

with tempfile.NamedTemporaryFile(mode='w', delete=False) as fh:
observable_file_name = fh.name
observable_df.to_csv(fh, sep='\t', index=False)

problem = petab.Problem.from_files(
sbml_file=sbml_file_name,
measurement_file=measurement_file_name,
condition_file=condition_file_name,
parameter_file=parameter_file_name)
parameter_file=parameter_file_name,
observable_files=observable_file_name)

return problem

Expand Down Expand Up @@ -349,6 +361,10 @@ def test_concat_measurements():
petab.measurements.get_measurement_df))


def test_get_obervable_ids(petab_problem):
assert set(petab_problem.get_observable_ids()) == set(['observable_1'])


def test_to_float_if_float():
to_float_if_float = petab.core.to_float_if_float

Expand Down