Source code for cytocalc.helper

#! /usr/bin/env python3
# This file contains helper functions i.e. functions
# that have a one-off use and do not really fit elsewhere
# NOTE: When 3-4 functions have a similar paradigm, convert
# them into a different class/file.

import math


# For the formulae, refer to supplementary information: https://doi.org/10.15252%2Fmsb.20177796
[docs] def theoretical_cont_rate( motor_count, crosslinker_count, sim_params, buckling_thres, scale ): """Predicts the concentration rate for a given set of simulation parameters""" s = math.pi * (sim_params["cell_radius"]) ** 2 # Area of cell l = sim_params["filament"]["length"] f = sim_params["filament_count"] x = ((f * (f - 1)) * l * l) / (math.pi * s) # number of intersections def _get_probability(obj, obj_count): """finds the probability of couple being attached to filament""" k_on = obj["binding_rate"] k_off = obj["unbinding_rate"] eps = obj["binding_range"] v2 = 4 * math.pi * x * (eps**2) v1 = 2 * f * l * eps - v2 a = k_on / k_off avg = ( obj_count * (a**2 * v2 / (2 * s)) * (1 + a * ((v1 + v2) / s) + a * (v2**2 / (2 * s))) ** (-1) ) lamda = avg / x # not a typo - lambda shouldn't be used a var name in python prob = 1 - math.e ** (-lamda) return prob prob_m = _get_probability(sim_params["plus_motor"], motor_count) prob_c = _get_probability(sim_params["binder"], crosslinker_count) return scale * (prob_m) * (prob_c) * (1 - prob_c) ** (buckling_thres)