Once upon a time, there was a DeduceBondSystemsTool, and...
Er, anyway. Further to a patch made on the tool (patch ID : 3040138), there is a failing test for 1,4-benzoquinone:
The tool generates A, and the test wants B. Now, the problem is not that the tool is not trying B as a possibility, but that it generates A first and the final step doesn't remove it or rank it as better than A.
Understanding this requires an understanding of the algorithm. This is (roughly):
- For each ring, generate a list of possible positions for all numbers of double bonds.
- Generate a set of molecules by combining these positions together.
- Remove 'bad' solutions and pick a solution with the least number of 'bad' N/S atoms.
Now, neither A nor B are bad solutions, and they don't contain N or S atoms, so they both have a rank of zero, and the first one generated will be returned. So, there is really no particular reason that the test should pass.
In general, it might be good to separate the generation of possible solutions from the ranking/filtering process. So that the computational or mathematical problem of generation is done by one class, while other classes determine which is the optimal solution (or set of solutions).
Comments
This is where a separation between generation and chemical rules would make things clearer. Of course, it would be better to constrain and generate, rather than generate and test.
Another architectural issue is that a bond system generation tool might benefit from detecting symmetric atoms. This would mean new module dependencies (eg, on the signature module).