Refactor smiles parsing code to use C++ lexer and parser (#7015) #7016
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This refactors the smiles parsing procedure to separate the parsing and ROMol construction procedures. Given the intricate nature of the mol construction procedure, a 1D list of mol events made the most sense as the parsers output. This allowed me to ensure that the order in which atoms/bonds are created and properties are set follows that from the previous implementation.
I also added the FlexLexer.h header (source: https://github.com/westes/flex) to SmilesParse because C++
scanners generated by flex require it. We need this to be present whether users have flex installed or not, and this was the easiest way to achieve that.
Summary of changes:
An important concern for this change is performance, so I ran all of the tests in SmilesParse::test.cpp x1000 and noticed that this change increases the runtime by about 5% i.e. from about 82ms to 86ms.
Reference Issue
Implements #7015