stevenshave / pybindingcurve

Binding curve simulation and experimental data fitting for multi component protein-ligand systems
MIT License
15 stars 3 forks source link

Readout on single component #4

Closed sunhwan closed 2 years ago

sunhwan commented 2 years ago

I'd like to readout one of my single component. Below is my code adopted from the custom system example.

custom_system = """
    P+L*<->PL
    PL+P<->PLP
"""

my_system = pbc.BindingCurve(custom_system)

system_parameters = {
    "p": np.linspace(0, 10), 
     "l": 10, 
     "kd_p_l_pl": 0.01,
     "kd_pl_p_plp": 0.1,
}

my_system.add_curve(system_parameters)
my_system.show_plot(min_y=0, max_y=10)

This gives me the following error:

~/miniconda3/lib/python3.8/site-packages/pybindingcurve/systems/binding_system.py in query(self, parameters)
    188                             changing_parameters[0]
    189                         ][i]
--> 190                         results[i] = self._system(**tmp_params)[self.default_readout]
    191             else:
    192                 print(

KeyError: 'l'

If I set the readout to a product, it seems to work. Can you help me figure out how to set readout on a component?

stevenshave commented 2 years ago

The issue is that when defining custom binding systems, it looks at which components are fundamental (cannot be made) starting components (in your case l_total in classical terminology), and then generates a new system l_f (representing the amount free - unbound).

I have now amended the code - see 43e656ba25cfbb65d2a19efdcce5a20381bafdb3 so that if a non-product is requested, then the amount free of the fundamental component is returned. If you look at the latest commit, or update from pypi to PBC ver 1.1.1, you will see the above code works, producing a plot of l_f (ligand free).

Hope this helps.

stevenshave commented 2 years ago

I assume that this has solved your problem and am closing this issue.