Skip to content

Updated Ragtimer Format #5

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions src/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,27 @@ def create_transition(transition_line, species_idxes):
always_enabled = False
is_consumer = False
for reactant in reactants:
rcount = 1
if reactant == "0":
always_enabled = True
break
transition_vector[species_idxes[reactant]] -= 1
elif '*' in reactant:
reactant, rcount_str = reactant.split("*")
reactant = reactant.strip()
# TODO: better error handling for malformed line
rcount = int(rcount_str)
transition_vector[species_idxes[reactant]] -= rcount
for product in products:
pcount = 1
if product == "0":
is_consumer = True
break
transition_vector[species_idxes[product]] += 1
elif '*' in product:
product, pcount_str = product.split("*")
product = product.strip()
# TODO: better error handling for malformed line
pcount = int(pcount_str)
transition_vector[species_idxes[product]] += pcount
# Is 1.0 iff is reactant
rate_mul_vector = np.array([float(elem < 0) for elem in transition_vector])
# The rate, from rate constant k and reactants A, B, is k * A^count(A) * B^count(B)
Expand Down