Skip to content

Commit

Permalink
Allow coordinates to be passed in via CXSMARTS and ensure query coord…
Browse files Browse the repository at this point in the history
…inates are scaled correctly.

Unfortunately for now this means we duplicate a lot of code from the CXSMILES parse but I would rather keep these internal APIs for the time being.
  • Loading branch information
johnmay authored and egonw committed Feb 1, 2024
1 parent f796f56 commit bc1244b
Show file tree
Hide file tree
Showing 4 changed files with 1,050 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ public final void generateAlignedCoordinates(IAtomContainer mol, IAtomContainer
RWLOCK.writeLock().unlock();
}
}

// rescale if needed
if (Math.abs(GeometryUtil.getBondLengthMedian(ref) - bondLength) > 0.1) {
try {
Expand Down Expand Up @@ -318,6 +319,17 @@ public final void generateAlignedCoordinates(IAtomContainer mol, IAtomContainer
if (!GeometryUtil.has2DCoordinates(cpy)) {
setMolecule(cpy, false);
generateCoordinates();
} else {
// if there is already coordinates, make sure the scaled is correct
if (Math.abs(GeometryUtil.getBondLengthMedian(cpy) - bondLength) > 0.1) {
try {
RWLOCK.writeLock().lock();
GeometryUtil.scaleMolecule(cpy,
bondLength / GeometryUtil.getBondLengthMedian(cpy));
} finally {
RWLOCK.writeLock().unlock();
}
}
}

// backup coordinates for future calls
Expand Down

0 comments on commit bc1244b

Please sign in to comment.