Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: Improve KDA API #68

Closed
nawtrey opened this issue Aug 1, 2023 · 1 comment
Closed

ENH: Improve KDA API #68

nawtrey opened this issue Aug 1, 2023 · 1 comment
Labels
API API-related changes

Comments

@nawtrey
Copy link
Collaborator

nawtrey commented Aug 1, 2023

Motivation

The KDA API could use a great deal of improvement. Right now things are a bit clunky and can lead easily to errors.

For example, most diagrams and calculations require the user to use many different functions that all require similar information (this is targeted more specifically in issue #58). There should be a way to minimize the burden on the user while providing the same output. Moving towards an object-oriented approach would likely help with this, where the user creates their "universe" (i.e. graph) and can easily retrieve info about the graph by just calling built-in methods.

Another example -- when generating the net cycle fluxes, you need to know the "order" (i.e. direction) for each cycle (see issue #57), which is input as a pair of nodes in the cycle. Then once the net cycle fluxes are generated, there is no real way of linking one cycle to the next, making it difficult to generate the operational fluxes for a given system. If we can find a way to input more data about the system (or create & store it in the diagram object) up front, we could make this process a lot easier.

API Ideas

Here is an example of a more approachable API where the graph is read in from a graph file (maybe something similar to the multibind graph.csv and states.csv files):

    import kda
    # retrieve graph data from file
    G = kda.read_graph("./test_graph.csv")
    # plot the directional diagrams
    G.directional.plot()
    # get the state probability expressions
    state_probs = G.probability.collect_expressions(norm=False)

For the net transition fluxes an API like the following would prove very useful:

    import kda
    # retrieve graph data from file
    G = kda.read_graph("./test_graph.csv")
    # get the expression for the one-way transition flux j_56
    j_56_expr = G.flux(i=5, j=6, net=False, expr=True)
    # get the expression for the net transition flux from 5->6
    J_56_expr = G.flux(i=5, j=6, net=True, expr=True)
@nawtrey nawtrey added the API API-related changes label Aug 1, 2023
nawtrey added a commit that referenced this issue Mar 26, 2024
* Add `core.py` with new class object
`KineticModel` used to create and store
model information for kinetic diagrams

* Add `KineticModel` import to `__init__.py`
so new API is accessible by importing `kda`

* Addresses issue #68
nawtrey added a commit that referenced this issue Jun 6, 2024
* Add `core.py` with new class object
`KineticModel` used to create and store
model information for kinetic diagrams

* Add `KineticModel` import to `__init__.py`
so new API is accessible by importing `kda`

* Addresses issue #68
nawtrey added a commit that referenced this issue Aug 8, 2024
* Add `core.py` with new class object
`KineticModel` used to create and store
model information for kinetic diagrams

* Add `KineticModel` import to `__init__.py`
so new API is accessible by importing `kda`

* Addresses issue #68
nawtrey added a commit that referenced this issue Aug 8, 2024
* Adds `core.py` with new class object
`KineticModel` to operate as the main
access point to all KDA functions. `KineticModel`s
are accessible with a simple import of `kda`
and store all system information.

* Updates `README` to reflect the simpler API.
Also includes details about calculating transition
fluxes with the new API. Similar changes are made 
to `usage.rst` and `kda/__init__.py`.

* Updates existing tests to leverage the new API. Also
adds tests to cover new class/methods:
  - `test_3_state_model_symbolic`
  - `test_3_state_model_numeric`
  - `test_transition_flux_matching_indices`
  - `test_transition_flux_mismatched_symbolic`
  - `test_invalid_inputs`

* Fixes issue #68
@nawtrey
Copy link
Collaborator Author

nawtrey commented Aug 8, 2024

I'll close this and open new issues targeting specific API improvements (net cycle fluxes, plotting, input graph files like multibind).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API API-related changes
Projects
None yet
Development

No branches or pull requests

1 participant