def _parse_reaction(line, all_species, parameters, reactions, tables): line_split_arrow = line.split('=>') if len(line_split_arrow) != 2: raise InvalidLine( f"Syntax error on line '{line}': There can only be one reaction per line. In a reaction, " f"the reactants and products are separated by the arrow '=>'.") left_side = line_split_arrow[0] line_split_excl = line_split_arrow[1].split('!') if len(line_split_excl) != 2: raise InvalidLine( f"Syntax error on line '{line}': Each reaction must have its rate specified. The rate " f"specification goes after the single exclamation mark '!'. The exclamation mark '!' " f"must not be used elsewhere.") right_side = line_split_excl[0] rate_spec = line_split_excl[1] reaction = Reaction(_parse_species(left_side, all_species), _parse_species(right_side, all_species)) _parse_rate(reaction, rate_spec, tables, parameters) # fills attributes rate_fun and table_name reaction.scale( parameters) # # scale the rate function: using the 'ratio' parameter reactions.append(reaction)