pykingenie package#

Subpackages#

Submodules#

pykingenie.fitter module#

class pykingenie.fitter.KineticsFitterGeneral[source]#

Bases: object

A class used to handle kinetics data both for solution-based and surface-based experiments.

__init__()[source]#

Initialize the KineticsFitterGeneral instance.

signal_ss_fit#

Fitted steady state signals.

Type:

list of numpy.ndarray or None

signal_assoc_fit#

Fitted association kinetics signals.

Type:

list of numpy.ndarray or None

signal_disso_fit#

Fitted dissociation kinetics signals.

Type:

list of numpy.ndarray or None

fit_params_kinetics#

Fitted parameters for the association / dissociation kinetics.

Type:

pandas.DataFrame or None

fit_params_ss#

Fitted parameters for the steady state.

Type:

pandas.DataFrame or None

fitted_params_boundaries#

DataFrame with fitting boundaries and fitted parameters.

Type:

pandas.DataFrame or None

params#

Parameters used for fitting.

Type:

numpy.ndarray or None

low_bounds#

Lower bounds for fitting parameters.

Type:

numpy.ndarray or None

high_bounds#

Upper bounds for fitting parameters.

Type:

numpy.ndarray or None

clear_fittings()[source]#

Clear all fitting results.

Resets all fitted signal arrays and parameter dataframes to None.

Return type:

None

create_fitting_bounds_table()[source]#

Create a dataframe with the fitting bounds and the fitted parameters.

Uses the class attributes params, low_bounds and high_bounds to create a DataFrame with fitting boundaries.

Returns:

Updates the fitted_params_boundaries attribute with a DataFrame.

Return type:

None

pykingenie.fitter_solution module#

class pykingenie.fitter_solution.KineticsFitterSolution(name, assoc, lig_conc, protein_conc, time_assoc)[source]#

Bases: KineticsFitterGeneral

A class used to fit solution-based kinetics data with shared thermodynamic parameters.

Parameters:
  • name (str) – Name of the experiment.

  • assoc (list) – List containing the association signals.

  • lig_conc (list) – List of ligand concentrations, one per element in assoc.

  • protein_conc (list) – List of protein concentrations, one per element in assoc.

  • time_assoc (list) – List of time points for the association signals.

name#

Name of the experiment.

Type:

str

assoc_lst#

List containing the association signals.

Type:

list

lig_conc#

List of ligand concentrations, one per element in assoc.

Type:

list

prot_conc#

List of protein concentrations, one per element in assoc.

Type:

list

time_assoc_lst#

List of time points for the association signals.

Type:

list

signal_ss#

List of steady state signals.

Type:

list

signal_ss_fit#

List of steady state fitted signals.

Type:

list

signal_assoc_fit#

List of association kinetics fitted signals.

Type:

list

fit_params_kinetics#

DataFrame with the fitted parameters.

Type:

pd.DataFrame

fit_params_ss#

DataFrame with the values of the fitted parameters - steady state.

Type:

pd.DataFrame

__init__(name, assoc, lig_conc, protein_conc, time_assoc)[source]#

Initialize the KineticsFitterSolution class.

Parameters:
  • name (str) – Name of the experiment.

  • assoc (list) – List containing the association signals.

  • lig_conc (list) – List of ligand concentrations, one per element in assoc.

  • protein_conc (list) – List of protein concentrations, one per element in assoc.

  • time_assoc (list) – List of time points for the association signals.

get_steady_state()[source]#

Get the steady state signals from the association signals.

The steady state signal is calculated as the median of the last 5 values of each association signal. The signals are grouped by protein concentration.

Returns:

Updates the following instance attributes: - unq_prot_conc: Unique protein concentrations - signal_ss_per_protein: Steady state signals grouped by protein concentration - lig_conc_per_protein: Ligand concentrations grouped by protein concentration

Return type:

None

fit_single_exponentials()[source]#

Fit single exponentials to the association signals in the solution kinetics experiment.

This method fits each association curve with a single exponential function and extracts the observed rate constants (k_obs). The results are then grouped by protein concentration.

Returns:

Updates the following instance attributes: - k_obs: List of observed rate constants for each association curve - signal_assoc_fit: List of fitted association signals - fit_params_kinetics: DataFrame with the fitted parameters

Return type:

None

group_k_obs_by_protein_concentration()[source]#

Group the observed rate constants by protein concentration.

This is useful for plotting the rate constants against the protein concentration and for subsequent analysis of the concentration dependence of the kinetics.

Returns:

Updates the k_obs_per_prot attribute with a dictionary mapping protein concentrations to arrays of observed rate constants.

Return type:

None

fit_double_exponentials(min_log_k=-4, max_log_k=4, log_k_points=22)[source]#

Fit double exponentials to the association signals in the solution kinetics experiment.

This method fits each association curve with a double exponential function and extracts two observed rate constants (k_obs_1 and k_obs_2). The results are then grouped by protein concentration.

Parameters:
  • min_log_k (float, optional) – Minimum value of log10(k) to search, default is -4.

  • max_log_k (float, optional) – Maximum value of log10(k) to search, default is 4.

  • log_k_points (int, optional) – Number of points to sample in the log(k) space, default is 22.

Returns:

Updates the following instance attributes: - k_obs_1: List of first observed rate constants for each association curve - k_obs_2: List of second observed rate constants for each association curve - signal_assoc_fit: List of fitted association signals - fit_params_kinetics: DataFrame with the fitted parameters

Return type:

None

group_double_exponential_k_obs_by_protein_concentration()[source]#

Group the observed rate constants by protein concentration for double exponential fits.

This is useful for plotting the rate constants against the protein concentration and for subsequent analysis of the concentration dependence of the kinetics when using double exponential fits.

Returns:

Updates the following instance attributes: - k_obs_1_per_prot: Dictionary mapping protein concentrations to arrays of first observed rate constants - k_obs_2_per_prot: Dictionary mapping protein concentrations to arrays of second observed rate constants

Return type:

None

fit_one_binding_site(fit_signal_E=False, fit_signal_S=False, fit_signal_ES=True, fixed_t0=True)[source]#

Fit the association signals assuming one binding site.

This is a simplified model that assumes a single binding site for the ligand on the protein. The model fits global parameters to all curves simultaneously.

Parameters:
  • fit_signal_E (bool, optional) – If True, fit the signal of the free protein E, default is False.

  • fit_signal_S (bool, optional) – If True, fit the signal of the free ligand S, default is False.

  • fit_signal_ES (bool, optional) – If True, fit the signal of the complex ES, default is True.

  • fixed_t0 (bool, optional) – If True, fix the t0 parameter to 0, default is True.

Returns:

Updates the following instance attributes: - signal_assoc_fit: List of fitted association signals - fit_params_kinetics: DataFrame with the fitted parameters

Return type:

None

find_initial_params_if(fit_signal_E=False, fit_signal_S=False, fit_signal_ES=True, ESint_equals_ES=True, fixed_t0=True)[source]#

Find optimal initial parameters for the induced fit model.

Heuristically finds the best initial parameters for the fit by exploring fixed values of kc and krev and fitting kon and koff (and the signal of the complex).

Parameters:
  • fit_signal_E (bool, optional) – If True, fit the signal of the free protein E, default is False.

  • fit_signal_S (bool, optional) – If True, fit the signal of the free ligand S, default is False.

  • fit_signal_ES (bool, optional) – If True, fit the signal of the complex ES, default is True.

  • ESint_equals_ES (bool, optional) – If True, assume that the signal of the intermediate ESint is equal to the signal of the complex ES, default is True.

  • fixed_t0 (bool, optional) – If True, fix the t0 parameter to 0, default is True.

Returns:

Updates the params_guess attribute with the best initial parameters.

Return type:

None

fit_induced_fit(fit_signal_E=False, fit_signal_S=False, fit_signal_ES=True, ESint_equals_ES=True, fixed_t0=True)[source]#

Fit the association signals assuming an induced-fit mechanism.

A + B <-> AB_intermediate <-> AB_trapped

This model accounts for conformational changes in the protein upon ligand binding. The method first calls find_initial_params_if to get good starting values, then performs the actual fitting with those values.

Parameters:
  • fit_signal_E (bool, optional) – If True, fit the signal of the free protein E, default is False.

  • fit_signal_S (bool, optional) – If True, fit the signal of the free ligand S, default is False.

  • fit_signal_ES (bool, optional) – If True, fit the signal of the complex ES, default is True.

  • ESint_equals_ES (bool, optional) – If True, assume that the signal of the intermediate ESint is equal to the signal of the complex ES, default is True.

  • fixed_t0 (bool, optional) – If True, fix the t0 parameter to 0, default is True.

Returns:

Updates the following instance attributes: - signal_assoc_fit: List of fitted association signals - fit_params_kinetics: DataFrame with the fitted parameters

Return type:

None

pykingenie.fitter_surface module#

class pykingenie.fitter_surface.KineticsFitter(time_assoc_lst, association_signal_lst, lig_conc_lst, time_diss_lst=None, dissociation_signal_lst=None, smax_id=None, name_lst=None, is_single_cycle=False)[source]#

Bases: KineticsFitterGeneral

A class used to fit kinetics data with shared thermodynamic parameters.

Parameters:
  • time_assoc_lst (list) – List of time points for the association signals, one per replicate.

  • association_signal_lst (list) – List of association signals, one per replicate.

  • lig_conc_lst (list) – List of ligand concentrations, one per replicate.

  • time_diss_lst (list, optional) – List of time points for the dissociation signals, one per replicate.

  • dissociation_signal_lst (list, optional) – List of dissociation signals, one per replicate.

  • smax_id (list, optional) – List containing the Smax IDs (maximum amplitude identifiers).

  • name_lst (list, optional) – List of experiment names.

  • is_single_cycle (bool, optional) – Whether the experiment is a single cycle kinetics experiment.

names#

List of experiment names.

Type:

list

assoc_lst#

List of association signals, one per replicate. Each signal is a numpy matrix of size n*m where n is the number of time points and m is the number of ligand concentrations.

Type:

list

disso_lst#

List of dissociation signals, one per replicate. Each signal is a numpy matrix of size n*m where n is the number of time points and m is the number of ligand concentrations (different from zero).

Type:

list

lig_conc_lst#

List of ligand concentrations, one per replicate.

Type:

list

time_assoc_lst#

List of time points for the association signals, one per replicate.

Type:

list

time_disso_lst#

List of time points for the dissociation signals, one per replicate.

Type:

list

is_single_cycle#

Whether the experiment is a single cycle kinetics experiment.

Type:

bool

signal_ss#

List of steady state signals, one per replicate.

Type:

list

signal_ss_fit#

List of steady state fitted signals, one per replicate.

Type:

list

signal_assoc_fit#

List of association kinetics fitted signals, one per replicate.

Type:

list

signal_disso_fit#

List of dissociation kinetics fitted signals, one per replicate.

Type:

list

lig_conc_lst_per_id#

Ligand concentrations per Smax ID.

Type:

list

smax_guesses_unq#

Smax guesses per association signal.

Type:

list

smax_guesses_shared#

Smax guesses per Smax ID.

Type:

list

fit_params_kinetics#

DataFrame with the fitted parameters for the association/dissociation kinetics.

Type:

pd.DataFrame

fit_params_ss#

DataFrame with the values of the fitted parameters - steady state.

Type:

pd.DataFrame

__init__(time_assoc_lst, association_signal_lst, lig_conc_lst, time_diss_lst=None, dissociation_signal_lst=None, smax_id=None, name_lst=None, is_single_cycle=False)[source]#

Initialize the KineticsFitter class.

Parameters:
  • time_assoc_lst (list) – List of time points for the association signals, one per replicate.

  • association_signal_lst (list) – List of association signals, one per replicate.

  • lig_conc_lst (list) – List of ligand concentrations, one per replicate.

  • time_diss_lst (list, optional) – List of time points for the dissociation signals, one per replicate.

  • dissociation_signal_lst (list, optional) – List of dissociation signals, one per replicate.

  • smax_id (list, optional) – List containing the Smax IDs (maximum amplitude identifiers).

  • name_lst (list, optional) – List of experiment names.

  • is_single_cycle (bool, optional) – Whether the experiment is a single cycle kinetics experiment, default is False.

get_steady_state()[source]#

Calculate the steady state signal and group it by Smax ID.

This function calculates the steady state signal for each association curve and groups the signals by Smax ID. It also calculates the Smax guesses for each association signal.

Returns:

Updates the following instance attributes: - signal_ss: List of steady state signals grouped by Smax ID - lig_conc_lst_per_id: List of ligand concentrations grouped by Smax ID - smax_guesses_unq: Smax guesses for each association signal - smax_guesses_shared: Smax guesses for each Smax ID

Return type:

None

fit_steady_state()[source]#

Fit the steady state signal using the one-site binding model.

This function fits the steady state signal to a one-site binding model to estimate the equilibrium dissociation constant (Kd) and maximum signal (Smax). It also calculates the 95% confidence intervals for the Kd.

Returns:

Updates the following instance attributes: - params: The fitted parameters [Kd, Smax1, Smax2, …] - signal_ss_fit: The fitted steady state signals - fit_params_ss: DataFrame with the fitted parameters - Kd_ss: The equilibrium dissociation constant - Smax_upper_bound_factor: Factor to determine the upper bound for Smax

Return type:

None

get_k_off_initial_guess()[source]#

Get initial guess and bounds for k_off parameter.

This method determines initial values and fitting bounds for Kd and k_off. If dissociation data is available, it fits the dissociation curves to get a better estimate of k_off.

Returns:

A tuple containing: - p0: Initial parameter guesses [Kd, k_off] - low_bounds: Lower bounds for the parameters - high_bounds: Upper bounds for the parameters

Return type:

tuple

Raises:

ValueError – If Kd_ss is not set and fit_steady_state has not been run

fit_one_site_association(shared_smax=True)[source]#

Fit the association curves using the one-site binding model.

This function fits the association curves to a one-site binding model to estimate the equilibrium dissociation constant (Kd), dissociation rate constant (k_off), and maximum signal (Smax).

Parameters:

shared_smax (bool, optional) – Whether to share Smax across curves with the same Smax ID, default is True.

Returns:

Updates the following instance attributes: - params: The fitted parameters [Kd, k_off, Smax1, Smax2, …] - signal_assoc_fit: The fitted association signals - Kd: The equilibrium dissociation constant - k_off: The dissociation rate constant - Smax: The maximum signal values

Return type:

None

fit_one_site_dissociation(time_limit=0)[source]#

Fit the dissociation curves using the one-site binding model.

This function fits the dissociation curves to a one-site binding model to estimate the dissociation rate constant (k_off) and the initial signal (S0).

Parameters:

time_limit (float, optional) – Time limit for fitting (in seconds). If > 0, only fit data up to this time, default is 0 (fit all data).

Returns:

Updates the following instance attributes: - params: The fitted parameters [k_off, S0_1, S0_2, …] - signal_disso_fit: The fitted dissociation signals - k_off: The dissociation rate constant - fit_params_kinetics: DataFrame with the fitted parameters - fit_params_kinetics_error: DataFrame with the relative errors

Return type:

None

fit_single_exponentials()[source]#

Fit single exponentials to the association signals.

This method fits each association curve with a single exponential function and extracts the observed rate constants (k_obs).

Returns:

Updates the k_obs attribute with a list of observed rate constants for each association curve.

Return type:

None

fit_one_site_assoc_and_disso(shared_smax=True, fixed_t0=True, fit_ktr=False)[source]#
calculate_ci95(shared_smax=True, fixed_t0=True, fit_ktr=False)[source]#

Calculate 95% confidence intervals for the fitted parameters.

This method computes asymmetrical 95% confidence intervals for the equilibrium dissociation constant (Kd) and the dissociation rate constant (k_off).

Parameters:
  • shared_smax (bool, optional) – Whether Smax was shared across curves with the same Smax ID, default is True.

  • fixed_t0 (bool, optional) – Whether the time offset (t0) was fixed to zero, default is True.

  • fit_ktr (bool, optional) – Whether mass transport rate constants were included in the model, default is False.

Returns:

Updates the fit_params_kinetics_ci95 attribute with a DataFrame containing the 95% confidence intervals for Kd and k_off.

Return type:

None

Notes

This method will create an empty DataFrame if the confidence interval calculation fails.

fit_one_site_if_assoc_and_disso(shared_smax=True)[source]#

Fit the association and dissociation signals using the induced fit model.

This method first fits a simple one-site model to get initial parameter estimates, then explores different values of the conformational change rate constants (kc and krev) to find good initial guesses for the induced fit model. Finally, it fits the full induced fit model with these initial guesses.

Parameters:

shared_smax (bool, optional) – Whether to share Smax across curves with the same Smax ID, default is True.

Returns:

Updates the following instance attributes: - params: The fitted parameters [k_on, k_off, k_c, k_rev, Smax1, Smax2, …] - signal_assoc_fit: The fitted association signals - signal_disso_fit: The fitted dissociation signals - k_on: The association rate constant - k_off: The dissociation rate constant - k_c: The forward conformational change rate constant - k_rev: The reverse conformational change rate constant - Smax: The maximum signal values - fit_params_kinetics: DataFrame with the fitted parameters

Return type:

None

pykingenie.gator module#

class pykingenie.gator.GatorExperiment(name='Gator_experiment')[source]#

Bases: SurfaceBasedExperiment

Class to handle Gator Bio-Layer Interferometry (BLI) experiments.

This class extends the SurfaceBasedExperiment to provide functionality specific to Gator BLI instruments, including parsing experiment files and loading sensor data.

Parameters:

name (str, optional) – Name of the experiment, default is ‘Gator_experiment’.

__init__(name='Gator_experiment')[source]#

Initialize the SurfaceBasedExperiment instance.

Parameters:
  • name (str) – The name of the experiment.

  • type (str) – The type of the experiment (e.g., ‘Octet’, ‘SPR’).

read_all_gator_data(files, names=None)[source]#

Read all Gator data files for the experiment.

This method reads all necessary files for a Gator experiment, including the experiment settings, step information, and sensor data.

Parameters:
  • files (str or list) – Path to a zip file containing Gator data files or a list of file paths. If a zip file is provided, it will be extracted to the same directory.

  • names (list, optional) – List of file names corresponding to the file paths in files. If None, the file names will be extracted from the file paths.

Returns:

Updates instance attributes with the loaded experiment data.

Return type:

None

read_experiment_ini(file, nr_max_columns=12)[source]#

Read the experiment initialization file.

Parses the ExperimentStep.ini file that contains information about the experimental steps, their durations, and types (baseline, association, dissociation, etc.).

Parameters:
  • file (str) – Path to the ExperimentStep.ini file.

  • nr_max_columns (int, optional) – Maximum number of columns in the plate, default is 12.

Returns:

Updates the df_steps attribute with a DataFrame containing step information.

Return type:

None

Notes

Example format for ExperimentStep.ini:

[Experiment] Num=4 [Experiment1] Step1=0,0,60,0 Step2=1,60,104,1 Step3=5,104,164,0 Step4=6,164,464,2 Step5=7,464,764,3 Num=5 ProbeIndex=12 [ExperimentLog] Step1=”{“StepType”:0,”AssayNumber”:1,”PlateIndex”:1,”PlateColumnType”:12,”RowLocation”:0,”Location”:0,”Speed”:400,”Time”:600,”SumTime”:0,”ProbeIndex”:0,”PickerUsed”:1,”AllChannelUsed”:[255],”ChannelUsed”:0,”bAssayFirstStep”:false,”kst”:0,”Status”:0}” Step2=”{“StepType”:3,”AssayNumber”:1,”PlateIndex”:1,”PlateColumnType”:12,”RowLocation”:0,”Location”:1,”Speed”:1000,”Time”:5,”SumTime”:0,”ProbeIndex”:0,”PickerUsed”:1,”AllChannelUsed”:[255],”ChannelUsed”:0,”bAssayFirstStep”:false,”kst”:0,”Status”:0}” Step3=”{“StepType”:4,”AssayNumber”:1,”PlateIndex”:1,”PlateColumnType”:12,”RowLocation”:0,”Location”:2,”Speed”:1000,”Time”:5,”SumTime”:0,”ProbeIndex”:0,”PickerUsed”:1,”AllChannelUsed”:[255],”ChannelUsed”:0,”bAssayFirstStep”:false,”kst”:0,”Status”:0}” Step4=”{“StepType”:3,”AssayNumber”:1,”PlateIndex”:1,”PlateColumnType”:12,”RowLocation”:0,”Location”:1,”Speed”:1000,”Time”:5,”SumTime”:0,”ProbeIndex”:0,”PickerUsed”:1,”AllChannelUsed”:[255],”ChannelUsed”:0,”bAssayFirstStep”:false,”kst”:0,”Status”:0}” Step5=”{“StepType”:4,”AssayNumber”:1,”PlateIndex”:1,”PlateColumnType”:12,”RowLocation”:0,”Location”:2,”Speed”:1000,”Time”:5,”SumTime”:0,”ProbeIndex”:0,”PickerUsed”:1,”AllChannelUsed”:[255],”ChannelUsed”:0,”bAssayFirstStep”:false,”kst”:0,”Status”:0}” Step6=”{“StepType”:3,”AssayNumber”:1,”PlateIndex”:1,”PlateColumnType”:12,”RowLocation”:0,”Location”:1,”Speed”:1000,”Time”:5,”SumTime”:0,”ProbeIndex”:0,”PickerUsed”:1,”AllChannelUsed”:[255],”ChannelUsed”:0,”bAssayFirstStep”:false,”kst”:0,”Status”:0}” Step7=”{“StepType”:4,”AssayNumber”:1,”PlateIndex”:1,”PlateColumnType”:12,”RowLocation”:0,”Location”:2,”Speed”:1000,”Time”:5,”SumTime”:0,”ProbeIndex”:0,”PickerUsed”:1,”AllChannelUsed”:[255],”ChannelUsed”:0,”bAssayFirstStep”:false,”kst”:0,”Status”:0}” Step8=”{“StepType”:2,”AssayNumber”:1,”PlateIndex”:0,”PlateColumnType”:12,”RowLocation”:0,”Location”:12,”Speed”:1000,”Time”:60,”SumTime”:0,”ProbeIndex”:0,”PickerUsed”:1,”AllChannelUsed”:[255],”ChannelUsed”:0,”bAssayFirstStep”:true,”kst”:0,”Status”:0}” Step9=”{“StepType”:2,”AssayNumber”:1,”PlateIndex”:0,”PlateColumnType”:12,”RowLocation”:0,”Location”:13,”Speed”:400,”Time”:44,”SumTime”:60,”ProbeIndex”:0,”PickerUsed”:1,”AllChannelUsed”:[255],”ChannelUsed”:0,”bAssayFirstStep”:false,”kst”:1,”Status”:1}”

read_settings_ini(file, nr_max_sensors=8, nr_max_columns=12)[source]#

Read the settings initialization file.

Parses the Setting.ini file that contains information about the experiment settings, including sensor configurations, sample concentrations, and plate layout.

Parameters:
  • file (str) – Path to the Setting.ini file.

  • nr_max_sensors (int, optional) – Maximum number of sensors per column, default is 8.

  • nr_max_columns (int, optional) – Maximum number of columns in the plate, default is 12.

Returns:

Updates several instance attributes: - sensor_names: List of sensor names - ligand_conc_df: DataFrame with ligand concentration information

Return type:

None

Notes

Example format for Setting.ini:

[BasicInformation] PreExperiment=”{“AssayDescription”:””,”AssayUser”:”Marianna”,”CreationTime”:”03-31-2025 14:01:50”,…}” ExperimentType=Kinetics SaveTime=03/31/2025 15:55:27 Frequency=10Hz DataVersion=2.15.5.1221 [Regeneration] RegenerationEnable=1 Repeat=3 RTime=5 RSpeed=1000 NTime=5 NSpeed=1000 [SampleKinetics] Well1=4,-1,-1,-1,, Well2=4,-1,-1,-1,, …

read_sensor_data(files, names=None)[source]#

Read the sensor data from CSV files.

Parses the Gator sensor data CSV files containing time series data for each sensor channel. The method organizes the data according to experimental steps and sensors.

Parameters:
  • files (list) – List of file paths that may include sensor data CSV files.

  • names (list, optional) – List of file names corresponding to the file paths in files. If None, the file names will be extracted from the file paths.

Returns:

Updates several instance attributes: - xs: List of time arrays for each sensor - ys: List of signal arrays for each sensor - df_steps: DataFrame with filtered step information containing only steps with data - no_steps: Number of steps with data - traces_loaded: Boolean indicating if traces were successfully loaded

Return type:

None

Notes

The sensor data files are expected to be in CSV format with the following characteristics: - File names contain ‘Channel’ and have a ‘.csv’ extension - The first column contains signal values - The second column contains time values

pykingenie.kingenie_solution module#

class pykingenie.kingenie_solution.KinGenieCsvSolution(name)[source]#

Bases: SolutionBasedExp

A class used to represent a KinGenie simulation (solution-based).

This class handles KinGenie solution simulation data that can be exported from the Simulation panel.

Parameters:

name (str) – Name of the experiment.

name#

Name of the experiment.

Type:

str

xs#

List of x values (time), one array per trace.

Type:

list of numpy.ndarray

ys#

List of y values (signal), one array per trace.

Type:

list of numpy.ndarray

no_traces#

Number of traces.

Type:

int

traces_names#

List of trace names, one per trace.

Type:

list of str

traces_names_unique#

List of unique trace names.

Type:

list of str

conc_df#

DataFrame with the concentration information for each trace.

Type:

pandas.DataFrame

traces_loaded#

Whether traces have been loaded.

Type:

bool

__init__(name)[source]#

Initialize the SolutionBasedExp instance.

Parameters:
  • name (str) – Name of the experiment.

  • type (str) – Type of the experiment.

read_csv(file)[source]#

Read the KinGenie CSV file containing solution-based simulation data.

Parameters:

file (str) – Path to the CSV file.

Returns:

The method populates class attributes with data from the CSV file.

Return type:

None

Notes

The CSV file should have the following columns: - Time: time points of the simulation - Signal: signal values at each time point - Protein_concentration_micromolar: protein concentration - Ligand_concentration_micromolar: ligand concentration

Example CSV format:

Time Signal Protein_concentration_micromolar Ligand_concentration_micromolar 0 0 5 0.1 0.5 1 5 0.1

After reading, this method creates the following attributes: - self.xs: list of time values for each trace - self.ys: list of signal values for each trace - self.no_traces: number of unique traces - self.traces_names: list of trace names - self.conc_df: DataFrame with concentration information

pykingenie.kingenie_surface module#

class pykingenie.kingenie_surface.KinGenieCsv(name='kingenie_csv')[source]#

Bases: SurfaceBasedExperiment

A class used to represent a KinGenie surface-based simulation.

This class handles data from KinGenie simulation CSV files that can be exported from the Simulation panel.

Parameters:

name (str, optional) – Name of the experiment. Default is ‘kingenie_csv’.

name#

Name of the experiment.

Type:

str

fn#

File name.

Type:

str

xs#

List of time values for each sensor and phase. Structure is: [sensor_1[assoc_phase, disso_phase], sensor_2[assoc_phase, disso_phase], …].

Type:

list of list of numpy.ndarray

ys#

List of signal values for each sensor and phase. Structure is: [sensor_1[assoc_phase, disso_phase], sensor_2[assoc_phase, disso_phase], …].

Type:

list of list of numpy.ndarray

no_sensors#

Number of sensors.

Type:

int

sensor_names#

List of sensor names, one per sensor.

Type:

list of str

sensor_names_unique#

List of unique sensor names.

Type:

list of str

ligand_conc_df#

DataFrame with the ligand concentration information.

Type:

pandas.DataFrame

df_steps#

DataFrame with step information (association, dissociation).

Type:

pandas.DataFrame

traces_loaded#

Whether traces have been loaded.

Type:

bool

Notes

The CSV file should contain columns for Time, Signal, Smax, and Analyte_concentration_micromolar_constant. For single cycle kinetics, it should also include a Cycle column.

__init__(name='kingenie_csv')[source]#

Initialize the SurfaceBasedExperiment instance.

Parameters:
  • name (str) – The name of the experiment.

  • type (str) – The type of the experiment (e.g., ‘Octet’, ‘SPR’).

read_csv(file)[source]#

Read the KinGenie CSV file containing surface-based simulation data.

Parameters:

file (str) – Path to the CSV file.

Returns:

The method populates class attributes with data from the CSV file.

Return type:

None

Notes

The CSV file should have the following columns: - Time: time points of the simulation - Signal: signal values at each time point - Smax: maximum signal value - Analyte_concentration_micromolar_constant: analyte concentration - Cycle: (optional) cycle number for single cycle kinetics

This method creates the following attributes: - self.xs: list of time values for each sensor and phase - self.ys: list of signal values for each sensor and phase - self.no_sensors: number of sensors - self.sensor_names: list of sensor names - self.ligand_conc_df: DataFrame with concentration information - self.df_steps: DataFrame with step information

The method handles both multi-cycle and single-cycle kinetics data.

pykingenie.main module#

class pykingenie.main.KineticsAnalyzer[source]#

Bases: object

__init__()[source]#

Initialize the KineticsAnalyzer instance.

Parameters:

None

experiments#

Dictionary of experiment objects with experiment names as keys.

Type:

dict

experiment_names#

List of experiment names.

Type:

list

fittings#

Dictionary of fitting objects with fitting names as keys.

Type:

dict

fittings_names#

List of fitting names.

Type:

list

delete_experiment(experiment_names)[source]#

Delete experiment(s) from the analyzer.

Parameters:

experiment_names (str or list of str) – Name(s) of the experiment(s) to delete.

add_experiment(experiment, experiment_name)[source]#

Add an experiment to the analyzer.

Parameters:
  • experiment (object) – Experiment instance to add.

  • experiment_name (str) – Name of the experiment.

init_fittings()[source]#

Initialize (reset) the fittings dictionary and names list.

Parameters:

None

add_fitting(fitting, fitting_name)[source]#

Add a fitting object to the analyzer.

Parameters:
  • fitting (object) – Fitting object to add.

  • fitting_name (str) – Name of the fitting.

get_experiment_properties(variable, fittings=False)[source]#

Get a list of properties from experiments or fittings.

Parameters:
  • variable (str) – Name of the property to retrieve.

  • fittings (bool, optional) – If True, get from fittings; else from experiments. Default is False.

Returns:

List of property values.

Return type:

list

merge_ligand_conc_df()[source]#

Merge ligand concentration DataFrames from all experiments.

Return type:

None

merge_conc_df_solution()[source]#

Merge concentration DataFrames from all solution-based experiments.

Parameters:

None

Returns:

Creates a combined_conc_df attribute containing the merged concentration data.

Return type:

None

Notes

This method combines the concentration DataFrames from all solution-based experiments in the analyzer. It adds a ‘Select’ column with all values set to True, which can be used for filtering data in subsequent analyses.

generate_fittings(df)[source]#

Generate fitting objects for surface-based experiments from a DataFrame.

Parameters:

df (pandas.DataFrame) – DataFrame containing experiment data.

Returns:

List of messages about fitting creation.

Return type:

list

generate_fittings_solution(df)[source]#

Generate fitting objects for solution-based experiments from a DataFrame.

Parameters:

df (pandas.DataFrame) – DataFrame containing experiment data.

Returns:

List of messages about fitting creation.

Return type:

list

submit_steady_state_fitting()[source]#

Submit steady-state fitting for all fitting objects.

Return type:

None

submit_fitting_solution(fitting_model='single', **kwargs)[source]#

Fit models to solution-based kinetics data.

Parameters:
  • fitting_model (str, optional) – Model to fit. Options: ‘single’, ‘double’, ‘one_binding_site’, ‘one_binding_site_if’. Default is ‘single’.

  • **kwargs (dict) – Additional keyword arguments for fitting methods.

Return type:

None

submit_kinetics_fitting(fitting_model='one_to_one', fitting_region='association_dissociation', linkedSmax=False)[source]#

Fit models to surface-based kinetics data.

Parameters:
  • fitting_model (str, optional) – Model to fit. Options: ‘one_to_one’, ‘one_to_one_mtl’, ‘one_to_one_if’. Default is ‘one_to_one’.

  • fitting_region (str, optional) – Region to fit. Options: ‘association_dissociation’, ‘association’, ‘dissociation’. Default is ‘association_dissociation’.

  • linkedSmax (bool, optional) – Whether to link Smax values across curves. Default is False.

Return type:

None

calculate_asymmetric_error(shared_smax=True, fixed_t0=True, fit_ktr=False)[source]#

Calculate asymmetric error (confidence intervals) for all fitting objects.

Parameters:
  • shared_smax (bool, optional) – Whether Smax is shared across different curves. Default is True.

  • fixed_t0 (bool, optional) – Whether t0 (start time) is fixed during fitting. Default is True.

  • fit_ktr (bool, optional) – Whether to fit mass transport limitation parameter ktr. Default is False.

Returns:

Updates the fitting objects with confidence intervals for the fitted parameters.

Return type:

None

Notes

This method calculates asymmetric confidence intervals for the kinetic parameters (kon, koff, Kd) for each fitting object. The confidence intervals are stored in the fitting objects and can be accessed through the get_fitting_results method.

get_fitting_results()[source]#

Get the results of the fitting process as a DataFrame.

Parameters:

None

Returns:

DataFrame containing fitting results from all fitting objects. The DataFrame includes parameters like kon, koff, Kd, and their confidence intervals. Returns None if no fitting results are available.

Return type:

pandas.DataFrame or None

get_legends_table()[source]#

Get the legends table for plotting the kinetics data.

Returns:

DataFrame containing legend information for plotting.

Return type:

pandas.DataFrame

pykingenie.octet module#

class pykingenie.octet.OctetExperiment(name='BLI_experiment')[source]#

Bases: SurfaceBasedExperiment

OctetExperiment class for handling Octet BLI data.

Parameters:

name (str) – Name of the experiment.

name(str)#
Type:

name of the experiment

fns(list)#
Type:

list of file names (length n, one per sensor)

xs(list)#
Type:

list of x values (time, length n, one per sensor)

ys(list)#
Type:

list of y values (length n, one per sensor)

exp_info(list)#
Type:

list of dictionaries with experimental information

step_info(list)#
Type:

list of dictionaries with step information

no_steps(int)#
Type:

number of steps

no_sensors(int)#
Type:

number of sensors

sample_column(np.ndarray)#
Type:

array of sample column information (96 elements, one per well)

sample_row(np.ndarray)#
Type:

array of sample row information (96 elements, one per well)

sample_type(list)#
Type:

list of sample types (96 elements, one per well)

sample_id(list)#
Type:

list of sample ids (96 elements, one per well)

sensor_names_unique(list)#
Type:

list of unique sensor names (length n, one per sensor)

sensor_names(list)#
Type:

list of sensor names (length n, one per sensor)

df_steps(pd.DataFrame)#
Type:

dataframe with the steps information

ligand_conc_df(pd.DataFrame)#
Type:

dataframe with the ligand concentration information

ligand_conc_df.head(2)#
Sensor Analyte_location  Concentration_micromolar SampleID  Replicate Experiment
A1        5                    0.1300       wt          1          t
B1        5                    0.0692       wt          1          t
traces_loaded(bool)#
Type:

True if traces are loaded

sample_plate_loaded(bool)#
Type:

True if sample plate information is loaded

sample_conc(np.array)#
Type:

array with the sample concentrations (96 elements, one per well)

sample_conc_labeled(list)#
Type:

list with the sample concentrations labeled (96 elements, one per well)

steps_performed(pd.DataFrame)#
Type:

dataframe with the steps performed

steps_performed.head(2)#
#Step         Type              Column   Time
1            Regeneration      1        25
2  BaselineNeutralization      2        90
3         BaselineLoading      3        50
__init__(name='BLI_experiment')[source]#

Initialize the OctetExperiment instance.

Parameters:

name (str, optional) – Name of the experiment. Default is ‘BLI_experiment’.

read_sensor_data(files, names=None)[source]#

Read the sensor data from the .frd files.

Parameters:
  • files (str or list of str) – Path(s) to .frd file(s) to read.

  • names (str or list of str, optional) – Name(s) to assign to the sensors. If None, file names are used.

Returns:

The method populates class attributes with data from the files.

Return type:

None

Notes

This method creates the following attributes:

  • traces_loaded : bool Whether traces were successfully loaded.

  • xs : list List of x values (time) for each sensor.

  • ys : list List of y values (signal) for each sensor.

  • exp_info : list List of dictionaries with experimental information.

  • step_info : list List of dictionaries with step information.

  • no_steps : int Number of steps in the experiment.

  • no_sensors : int Number of sensors in the experiment.

generate_ligand_conc_df()[source]#

Generate a DataFrame with the analyte concentrations based on step_info and exp_info.

Parameters:

None

Returns:

This method populates class attributes related to ligand concentration.

Return type:

None

Notes

This method requires the following attributes to be already populated:

  • step_info : list List of dictionaries with step information.

  • exp_info : list List of dictionaries with experimental information.

  • fns : list List of file names.

This method creates/updates the following attributes:

  • no_steps : int Number of steps in the experiment.

  • no_sensors : int Number of sensors.

  • sensor_names : list List of sensor names.

  • df_steps : pandas.DataFrame DataFrame with step information.

  • ligand_conc_df : pandas.DataFrame DataFrame with ligand concentration information.

merge_consecutive_steps(idx_ref, idx_to_merge)[source]#

Combine two consecutive steps into one step.

Parameters:
  • idx_ref (int) – Index of the reference step. The type of step will be taken from this step.

  • idx_to_merge (int) – Index of the step to merge with the reference step.

Returns:

The method modifies the xs, ys, and step information in place.

Return type:

None

Notes

The two steps must be consecutive (their indices must differ by exactly 1).

merge_consecutive_steps_by_name(step_name, reference=True)[source]#

Merge steps with a specific name with their consecutive step.

Parameters:
  • step_name (str) – Name of the step to merge with the next/previous step.

  • reference (bool, optional) – If True, the step with name step_name will be used as reference to extract the analyte concentration, loading location, etc. Default is True.

Returns:

The method modifies the xs, ys, and step information in place.

Return type:

None

Notes

This method finds all steps with the given name and merges them with their adjacent step. The merged step inherits properties from the reference step.

read_sample_plate_info(files, names=None)[source]#

Read the sample plate information from the .fmf file.

Parameters:
  • files (str or list of str) – Path(s) to .fmf file(s) containing sample plate information.

  • names (str or list of str, optional) – Name(s) to assign to the files. If None, file names are used.

Returns:

The method populates class attributes with sample plate data.

Return type:

None

Notes

This method creates the following attributes:

  • sample_column : numpy.ndarray Array of sample column information (96 elements, one per well).

  • sample_row : numpy.ndarray Array of sample row information (96 elements, one per well).

  • sample_type : list List of sample types (96 elements, one per well).

  • sample_id : list List of sample IDs (96 elements, one per well).

  • sample_plate_loaded : bool Set to True if sample plate information is successfully loaded.

  • sample_conc : numpy.ndarray Array with the sample concentrations (96 elements, one per well).

  • sample_conc_labeled : list List with the sample concentrations labeled (96 elements, one per well).

convert_to_numbers()[source]#

Convert the strings in the step info to numbers.

Parameters:

None

Returns:

The method modifies the step_info attribute in place.

Return type:

None

Notes

This method processes the following entries in step_info: ‘Concentration’, ‘MolarConcentration’, ‘MolecularWeight’, ‘Temperature’, ‘StartTime’, ‘AssayTime’, ‘FlowRate’, ‘ActualTime’, ‘CycleTime’.

pykingenie.solution_exp module#

class pykingenie.solution_exp.SolutionBasedExp(name, type)[source]#

Bases: object

Base class for solution-based kinetics experiments.

This class serves as a foundation for classes that handle solution-based kinetic experiments data.

Parameters:
  • name (str) – Name of the experiment.

  • type (str) – Type of the experiment.

name#

Name of the experiment.

Type:

str

type#

Type of the experiment.

Type:

str

xs#

List of x values (time) for each trace.

Type:

list of numpy.ndarray or None

ys#

List of y values (signal) for each trace.

Type:

list of numpy.ndarray or None

no_traces#

Number of traces.

Type:

int or None

traces_names#

List of trace names.

Type:

list of str or None

traces_names_unique#

List of unique trace names (includes experiment name).

Type:

list of str or None

conc_df#

DataFrame with concentration information.

Type:

pandas.DataFrame or None

traces_loaded#

Whether traces have been loaded.

Type:

bool

__init__(name, type)[source]#

Initialize the SolutionBasedExp instance.

Parameters:
  • name (str) – Name of the experiment.

  • type (str) – Type of the experiment.

create_unique_traces_names()[source]#

Create unique trace names by appending the experiment name to the trace names.

Parameters:

None

Returns:

Updates the traces_names_unique attribute.

Return type:

None

Notes

This method creates unique identifiers for each trace by combining the experiment name with the individual trace names.

cut_off_time(time)[source]#

Remove all data before a specified time.

Parameters:

time (float) – The time to cut off the data.

get_trace_xy(trace_name, type='y')[source]#

Return the x or y values of a specific trace.

Parameters:
  • trace_name (str) – Name of the trace to retrieve data from.

  • type ({'x', 'y'}, optional) – Type of data to return. Default is ‘y’.

Returns:

The x or y values of the specified trace.

Return type:

numpy.ndarray

Notes

This method finds the trace by name in the traces_names list and returns either its x values (time) or y values (signal).

pykingenie.surface_exp module#

class pykingenie.surface_exp.SurfaceBasedExperiment(name, type)[source]#

Bases: object

A class representing surface-based kinetics experiments.

This class handles operations related to surface-based experiments, such as biolayer interferometry (BLI) or surface plasmon resonance (SPR). It provides functionality for data processing, analysis, and visualization.

Parameters:
  • name (str) – The name of the experiment.

  • type (str) – The type of the experiment (e.g., ‘Octet’, ‘SPR’).

name#

The name of the experiment.

Type:

str

type#

The type of the experiment.

Type:

str

xs#

Time values for each sensor and step.

Type:

list of list

ys#

Signal values for each sensor and step.

Type:

list of list

sensor_names#

Names of the sensors.

Type:

list

ligand_conc_df#

DataFrame containing ligand concentration information.

Type:

pandas.DataFrame

df_steps#

DataFrame containing step information.

Type:

pandas.DataFrame

steps_performed#

List of steps performed in the experiment.

Type:

list

traces_loaded#

Whether traces have been loaded.

Type:

bool

sample_plate_loaded#

Whether the sample plate information has been loaded.

Type:

bool

__init__(name, type)[source]#

Initialize the SurfaceBasedExperiment instance.

Parameters:
  • name (str) – The name of the experiment.

  • type (str) – The type of the experiment (e.g., ‘Octet’, ‘SPR’).

create_unique_sensor_names()[source]#

Create unique sensor names by adding the experiment name to each sensor name.

This method updates the sensor_names_unique attribute by prefixing each sensor name with the experiment name.

Returns:

The method modifies the sensor_names_unique attribute in-place.

Return type:

None

check_sensor_name(new_sensor_name)[source]#

Check if a sensor name already exists and modify it if necessary.

Parameters:

new_sensor_name (str) – The proposed name for a new sensor.

Returns:

A unique sensor name, either the original if it doesn’t exist or a modified version with ‘ rep’ appended.

Return type:

str

subtraction_one_to_one(sensor_name1, sensor_name2, inplace=True)[source]#

Subtract the signal of one sensor from another.

Parameters:
  • sensor_name1 (str) – Name of the sensor to subtract from.

  • sensor_name2 (str) – Name of the sensor to subtract.

  • inplace (bool, optional) – If True, the subtraction is done in place, otherwise a new sensor is created, by default True.

Returns:

The method modifies the instance attributes in-place.

Return type:

None

Notes

This method modifies the following attributes: - self.xs - self.ys - self.sensor_names - self.ligand_conc_df

Raises:

RuntimeError – If no traces are loaded or if sensors are incompatible.

subtraction(list_of_sensor_names, reference_sensor, inplace=True)[source]#

Apply subtraction operation to a list of sensors.

Parameters:
  • list_of_sensor_names (list or str) – List of sensor names to subtract from. If a string is provided, it will be converted to a list.

  • reference_sensor (str) – Name of the sensor to subtract.

  • inplace (bool, optional) – If True, the subtraction is done in place, otherwise new sensors are created, by default True.

Returns:

The method modifies the instance attributes in-place.

Return type:

None

Notes

This method modifies the following attributes: - self.xs - self.ys - self.sensor_names - self.ligand_conc_df

average(list_of_sensor_names, new_sensor_name='Average')[source]#

Average the signals of the sensors in the list.

Parameters:
  • list_of_sensor_names (list) – List of sensor names to average.

  • new_sensor_name (str, optional) – Name of the new sensor, by default ‘Average’.

Returns:

The method modifies the instance attributes in-place.

Return type:

None

Notes

This method modifies the following attributes: - self.xs - self.ys - self.sensor_names - self.ligand_conc_df

Raises:

RuntimeError – If no traces are loaded.

align_association(sensor_names, inplace=True, new_names=False, npoints=10)[source]#

Align BLI traces based on the signal before the association step(s).

Parameters:
  • sensor_names (str or list) – Name of the sensor(s) to align. If a string is provided, it will be converted to a list.

  • inplace (bool, optional) – If True, the alignment is done in place, otherwise new sensors are created, by default True.

  • new_names (bool, optional) – If True, new sensor names are generated, otherwise the original names are kept, by default False.

  • npoints (int, optional) – Number of points to use for averaging at alignment positions, by default 10.

Returns:

The method modifies the instance attributes in-place.

Return type:

None

Notes

This method modifies the following attributes: - self.xs - self.ys - self.sensor_names - self.ligand_conc_df

The alignment is performed by subtracting the average signal of the last npoints points before each association step.

align_dissociation(sensor_names, inplace=True, new_names=False, npoints=10)[source]#

Align BLI traces based on the signal before the dissociation step(s).

Parameters:
  • sensor_names (str or list) – Name of the sensor(s) to align. If a string is provided, it will be converted to a list.

  • inplace (bool, optional) – If True, the alignment is done in place, otherwise new sensors are created, by default True.

  • new_names (bool, optional) – If True, new sensor names are generated, otherwise the original names are kept, by default False.

  • npoints (int, optional) – Number of points to use for averaging at alignment positions, by default 10.

Returns:

The method modifies the instance attributes in-place.

Return type:

None

Notes

This method modifies the following attributes: - self.xs - self.ys - self.sensor_names - self.ligand_conc_df

The alignment is performed by smoothing the transition between association and dissociation steps.

discard_steps(sensor_names, step_types=['KREGENERATION', 'LOADING'])[source]#

Discard specific step types from the sensors in the list.

Parameters:
  • sensor_names (str or list) – Name of the sensor(s) to process. If a string is provided, it will be converted to a list.

  • step_types (str or list, optional) – Type(s) of steps to discard, by default [‘KREGENERATION’, ‘LOADING’]. If a string is provided, it will be converted to a list.

Returns:

The method modifies the instance attributes in-place.

Return type:

None

Notes

This method modifies the following attributes: - self.ys

The discarded steps are replaced with NaN values.

get_step_xy(sensor_name, location_loading, location_sample, step_type='ASSOC', replicate=1, type='y')[source]#

Return the x or y values of a specific step.

Parameters:
  • sensor_name (str) – Name of the sensor.

  • location_loading (int) – Column location of the loading. If zero, assumes only one location.

  • location_sample (int) – Column location of the sample. If zero, assumes only one location.

  • step_type (str, optional) – Type of step, only ‘ASSOC’ or ‘DISASSOC’ are valid, by default ‘ASSOC’.

  • replicate (int, optional) – Replicate number, by default 1.

  • type (str, optional) – Data type to return, either ‘x’ or ‘y’, by default ‘y’.

Returns:

The x (time) or y (signal) values of the specified step.

Return type:

numpy.ndarray

Raises:
  • ValueError – If location_sample, location_loading, or replicate are not valid integers.

  • TypeError – If any parameter has an incorrect type.

Notes

For ‘x’ type data, time values are processed to start from zero for each step. For association steps, time starts at the beginning of the step. For dissociation steps, time continues from the association step.