Skip to content

Commit

Permalink
stop reading node name at Multiplicity in case the name got split ont…
Browse files Browse the repository at this point in the history
…o multiple lines
  • Loading branch information
sevyharris committed Dec 22, 2024
1 parent a4f9f11 commit 562c6de
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions rmgpy/data/kinetics/family.py
Original file line number Diff line number Diff line change
Expand Up @@ -4522,8 +4522,26 @@ def extract_source_from_comments(self, reaction):

# Check whether we're using the old rate rule templates or the new BM tree nodes
if full_comment_string.find('for rate rule') < 0: # New trees
rate_rule_string = full_comment_string.split("Estimated from node", 1)[1].strip()
node = rate_rule_string.split()[0].strip() # cut off anything on the end

start_tag = 'Estimated from node '
end_tag = 'Multiplied by reaction path degeneracy'

start_loc = full_comment_string.find(start_tag)
end_loc = full_comment_string.find(end_tag)
if start_loc == -1:
raise ValueError('Could not find start of node in comments')
if end_loc == -1:
# check if the nodename is the last token
node_tokens = full_comment_string.split()
if node_tokens[-2] == 'node':
end_loc = None
else:
raise ValueError('Could not find end of node in comments')

node = full_comment_string[start_loc + len(start_tag): end_loc]
node = node.replace('\\n', '')
node = node.replace('# ', '')
node = node.replace(' ', '')
rules = ''
training_entries = ''
template = ''
Expand Down

0 comments on commit 562c6de

Please sign in to comment.