petab.core¶
PEtab core functions (or functions that don’t fit anywhere else)
Functions
concat_tables (tables, …) |
Concatenate DataFrames provided as DataFrames or filenames, and a parser |
flatten_timepoint_specific_output_overrides (…) |
Flatten timepoint-specific output parameter overrides. |
get_notnull_columns (df, candidates) |
Return list of df -columns in candidates which are not all null/nan. |
get_observable_id (parameter_id) |
Get PEtab observable ID from PEtab-style sigma or observable AssignmentRule-target parameter_id . |
get_simulation_df (simulation_file) |
Read PEtab simulation table |
get_visualization_df (visualization_file) |
Read PEtab visualization table |
parameter_is_offset_parameter (parameter, formula) |
Check if is offset parameter. |
parameter_is_scaling_parameter (parameter, …) |
Check if is scaling parameter. |
to_float_if_float (x) |
Return input as float if possible, otherwise return as is |
write_simulation_df (df, filename) |
Write PEtab simulation table |
write_visualization_df (df, filename) |
Write PEtab visualization table |
-
petab.core.
concat_tables
(tables: Union[str, pandas.core.frame.DataFrame, Iterable[Union[pandas.core.frame.DataFrame, str]]], file_parser: Optional[Callable] = None) → pandas.core.frame.DataFrame¶ Concatenate DataFrames provided as DataFrames or filenames, and a parser
Parameters: - tables – Iterable of tables to join, as DataFrame or filename.
- file_parser – Function used to read the table in case filenames are provided, accepting a filename as only argument.
Returns: The concatenated DataFrames
-
petab.core.
flatten_timepoint_specific_output_overrides
(petab_problem: petab.problem.Problem) → None¶ Flatten timepoint-specific output parameter overrides.
If the PEtab problem definition has timepoint-specific observableParameters or noiseParameters for the same observable, replace those by replicating the respective observable.
This is a helper function for some tools which may not support such timepoint-specific mappings. The observable table and measurement table are modified in place.
Parameters: petab_problem – PEtab problem to work on
-
petab.core.
get_notnull_columns
(df: pandas.core.frame.DataFrame, candidates: Iterable[T_co])¶ Return list of
df
-columns incandidates
which are not all null/nan.The output can e.g. be used as input for
pandas.DataFrame.groupby
.Parameters: - df – Dataframe
- candidates – Columns of
df
to consider
-
petab.core.
get_observable_id
(parameter_id: str) → str¶ Get PEtab observable ID from PEtab-style sigma or observable AssignmentRule-target
parameter_id
.e.g. for ‘observable_obs1’ -> ‘obs1’, for ‘sigma_obs1’ -> ‘obs1’
Parameters: parameter_id – Some parameter ID Returns: Observable ID
-
petab.core.
get_simulation_df
(simulation_file: str) → pandas.core.frame.DataFrame¶ Read PEtab simulation table
Parameters: simulation_file – URL or filename of PEtab simulation table Returns: Simulation DataFrame
-
petab.core.
get_visualization_df
(visualization_file: str) → pandas.core.frame.DataFrame¶ Read PEtab visualization table
Parameters: visualization_file – URL or filename of PEtab visualization table Returns: Visualization DataFrame
-
petab.core.
parameter_is_offset_parameter
(parameter: str, formula: str) → bool¶ Check if is offset parameter.
Parameters: - parameter – Some identifier.
- formula – Some sympy-compatible formula.
Returns: True
if parameterparameter
is an offset parameter with positive sign in formulaformula
.
-
petab.core.
parameter_is_scaling_parameter
(parameter: str, formula: str) → bool¶ Check if is scaling parameter.
Parameters: - parameter – Some identifier.
- formula – Some sympy-compatible formula.
Returns: True
if parameterparameter
is a scaling parameter in formulaformula
.
-
petab.core.
to_float_if_float
(x: Any) → Any¶ Return input as float if possible, otherwise return as is
Parameters: x – Anything Returns: x
as float if possible, otherwisex
-
petab.core.
write_simulation_df
(df: pandas.core.frame.DataFrame, filename: str) → None¶ Write PEtab simulation table
Parameters: - df – PEtab simulation table
- filename – Destination file name
-
petab.core.
write_visualization_df
(df: pandas.core.frame.DataFrame, filename: str) → None¶ Write PEtab visualization table
Parameters: - df – PEtab visualization table
- filename – Destination file name