ncats / lychi

Layered Chemical Identifier
Apache License 2.0
14 stars 10 forks source link

Graph invariant fix #19

Open tylerperyea opened 5 years ago

tylerperyea commented 5 years ago

This fix incorporates the fixes for graph invariant issues found in the following pull requests:

https://github.com/ncats/lychi/pull/18 https://github.com/ncats/lychi/pull/17

More information on those parts can be found in those individual pull requests. This particular change, however, mostly concerns a fix for issues like the following:

image

The above 2 structures currently get the same lychi-3. This happens because of the way layer-3 is generated, which is by walking the graph in a specific order specified by a modified label-agnostic graph invariant value. The issue is that the original graph invariant values for the atoms are based on the framework, but ties are broken by using the atom number (as discussed in a previous pull request). The tie breaking is actually not done as a strict tie breaker, but by multiplying the invariant number by the atomic numbers. This means that order can be shifted around for the same framework even when there is no framework symmetry involved. In the case above, the multiplying the nitrogen (7) by its graph invariant number ends up giving the same order of atom labels for both, which is how the lychi-3 is calculated.

This fix piggy-backs on the fix from pull 18, but decides to not try to preserve old Lychis, as that seems to not be possible while still fixing this issue. A new test was added to ensure that this works for this case, and a few other tests needed to be modified to not expect the exact lychi that it produced before.

CAUTION! This will change a VERY large portion of lychi values for structures. If this version is used, it can not be assumed compatible with any other lychi previously made.

dkatzel-ncats commented 4 years ago

I merged with latest master and resolved all conflicts. All tests pass in java 8.

I also bumped the version from 0.6 to 0.7.1 since the version of master is now 0.7.0