1010probabilities and fluxes from a user-defined kinetic diagram.
1111
1212.. autofunction:: calc_state_probs
13- .. autofunction:: calc_net_cycle_flux
13+ .. autofunction:: calc_cycle_flux
1414.. autofunction:: calc_sigma
1515.. autofunction:: calc_sigma_K
1616.. autofunction:: calc_pi_difference
@@ -282,7 +282,8 @@ def calc_sigma_K(G, cycle, flux_diags, key="name", output_strings=True):
282282 return sigma_K
283283
284284
285- def calc_pi_difference (G , cycle , order , key = "name" , output_strings = True ):
285+ def calc_pi_difference (G , cycle , order , key = "name" ,
286+ output_strings = True , net = True ):
286287 r"""
287288 Generates the expression for the cycle-based componenet of the
288289 sum of flux diagrams for some ``cycle`` in kinetic diagram ``G``.
@@ -305,13 +306,16 @@ def calc_pi_difference(G, cycle, order, key="name", output_strings=True):
305306 ``NetworkX`` edge key is ``"weight"``, however the ``kda`` edge keys
306307 are ``"name"`` (for rate constant names, e.g. ``"k12"``) and ``"val"``
307308 (for the rate constant values, e.g. ``100``). Default is ``"name"``.
308- Default is ``"name"``.
309309 output_strings : bool (optional)
310310 Used to denote whether values or strings will be combined. Default
311311 is ``False``, which tells the function to calculate the difference
312312 using numbers. If ``True``, this will assume the input ``'key'``
313313 will return strings of variable names to join into the analytic
314314 function.
315+ net : bool (optional)
316+ Used to determine whether to return the forward cycle product
317+ (i.e., ``net=False``) or the difference of the forward and reverse
318+ cycle products (i.e., ``net=True``). Default is ``True``.
315319
316320 Returns
317321 -------
@@ -357,14 +361,20 @@ def calc_pi_difference(G, cycle, order, key="name", output_strings=True):
357361 for edge in cycle_edges :
358362 ccw_rates .append (G .edges [edge [0 ], edge [1 ], edge [2 ]][key ])
359363 cw_rates .append (G .edges [edge [1 ], edge [0 ], edge [2 ]][key ])
360- pi_difference = "-" .join (["*" .join (ccw_rates ), "*" .join (cw_rates )])
364+ if net :
365+ pi_difference = "-" .join (["*" .join (ccw_rates ), "*" .join (cw_rates )])
366+ else :
367+ pi_difference = "*" .join (ccw_rates )
361368 else :
362369 ccw_rates = 1
363370 cw_rates = 1
364371 for edge in cycle_edges :
365372 ccw_rates *= G .edges [edge [0 ], edge [1 ], edge [2 ]][key ]
366373 cw_rates *= G .edges [edge [1 ], edge [0 ], edge [2 ]][key ]
367- pi_difference = ccw_rates - cw_rates
374+ if net :
375+ pi_difference = ccw_rates - cw_rates
376+ else :
377+ pi_difference = ccw_rates
368378 return pi_difference
369379
370380
@@ -563,10 +573,10 @@ def calc_state_probs(G, key="name", output_strings=True, dir_edges=None):
563573 return state_probs
564574
565575
566- def calc_net_cycle_flux (G , cycle , order , key = "name" ,
567- output_strings = True , dir_edges = None ):
568- r"""Generates the expression for the net cycle flux for
569- some ``cycle`` in kinetic diagram ``G``.
576+ def calc_cycle_flux (G , cycle , order , key = "name" ,
577+ output_strings = True , dir_edges = None , net = True ):
578+ r"""Generates the expression for the one-way or net cycle
579+ flux for a ``cycle`` in the kinetic diagram ``G``.
570580
571581 Parameters
572582 ----------
@@ -584,7 +594,6 @@ def calc_net_cycle_flux(G, cycle, order, key="name",
584594 ``NetworkX`` edge key is ``"weight"``, however the ``kda`` edge keys
585595 are ``"name"`` (for rate constant names, e.g. ``"k12"``) and ``"val"``
586596 (for the rate constant values, e.g. ``100``). Default is ``"name"``.
587- Default is ``"name"``.
588597 output_strings : bool (optional)
589598 Used to denote whether values or strings will be combined. Default
590599 is ``False``, which tells the function to calculate the cycle flux
@@ -598,11 +607,14 @@ def calc_net_cycle_flux(G, cycle, order, key="name",
598607 generate the directional diagram edges up front and provide them).
599608 Created using :meth:`~kda.diagrams.generate_directional_diagrams`
600609 with ``return_edges=True``.
610+ net : bool (optional)
611+ Used to determine whether to return the one-way or net cycle flux.
612+ Default is ``True`` (i.e., to generate the net cycle flux).
601613
602614 Returns
603615 -------
604- net_cycle_flux : float or ``SymPy`` expression
605- Net cycle flux for the input ``cycle``.
616+ cycle_flux : float or ``SymPy`` expression
617+ The one-way or net cycle flux for the input ``cycle``.
606618
607619 Notes
608620 -----
@@ -628,18 +640,19 @@ def calc_net_cycle_flux(G, cycle, order, key="name",
628640 # construct the expressions for (Pi+ - Pi-), sigma, and sigma_k
629641 # from the directional diagram edges
630642 pi_diff = calc_pi_difference (
631- G = G , cycle = cycle , order = order , key = key , output_strings = output_strings )
643+ G = G , cycle = cycle , order = order , key = key ,
644+ output_strings = output_strings , net = net )
632645 sigma_K = calc_sigma_K (
633646 G = G , cycle = cycle , flux_diags = flux_diags ,
634647 key = key , output_strings = output_strings )
635648 sigma = calc_sigma (
636649 G = G , dirpar_edges = dir_edges , key = key , output_strings = output_strings )
637650 if output_strings :
638- net_cycle_flux = expressions .construct_sympy_net_cycle_flux_func (
651+ cycle_flux = expressions .construct_sympy_net_cycle_flux_func (
639652 pi_diff_str = pi_diff , sigma_K_str = sigma_K , sigma_str = sigma )
640653 else :
641- net_cycle_flux = pi_diff * sigma_K / sigma
642- return net_cycle_flux
654+ cycle_flux = pi_diff * sigma_K / sigma
655+ return cycle_flux
643656
644657
645658def calc_state_probs_from_diags (G , dirpar_edges , key = "name" , output_strings = True ):
@@ -697,7 +710,7 @@ def calc_net_cycle_flux_from_diags(
697710 """Generates the expression for the net cycle flux for some ``cycle``
698711 in kinetic diagram ``G``. If directional diagram edges are already
699712 generated this offers better performance than
700- :meth:`~kda.calculations.calc_net_cycle_flux `.
713+ :meth:`~kda.calculations.calc_cycle_flux `.
701714
702715 Parameters
703716 ----------
@@ -734,13 +747,14 @@ def calc_net_cycle_flux_from_diags(
734747
735748 """
736749 msg = """`kda.calculations.calc_net_cycle_flux_from_diags` will be deprecated.
737- Use `kda.calculations.calc_net_cycle_flux ` with parameter `dir_edges`."""
750+ Use `kda.calculations.calc_cycle_flux ` with parameter `dir_edges`."""
738751 warnings .warn (msg , DeprecationWarning )
739- return calc_net_cycle_flux (
752+ return calc_cycle_flux (
740753 G = G ,
741754 cycle = cycle ,
742755 order = order ,
743756 key = key ,
744757 output_strings = output_strings ,
745758 dir_edges = dirpar_edges ,
759+ net = True ,
746760 )
0 commit comments