From a6acf159460985a9edf1a88df69da365aad8c138 Mon Sep 17 00:00:00 2001 From: Joshua Jeppson Date: Fri, 12 Jan 2024 16:25:16 -0700 Subject: [PATCH] First edit for new ragtimer format --- src/parser.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/parser.py b/src/parser.py index f79d782..d4c87e2 100644 --- a/src/parser.py +++ b/src/parser.py @@ -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)