Skip to content

Commit

Permalink
feat: update OCL to v2024.11.1 (#241)
Browse files Browse the repository at this point in the history
Closes: #239
  • Loading branch information
targos authored Nov 5, 2024
1 parent 63f7771 commit 9cfc345
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3417,7 +3417,7 @@ private void encodeCoordinates(boolean keepPositionAndScale, Coordinates[] coord
mEncodingBuffer.append(includeHydrogenCoordinates ? '#' : '!');
encodeBits(mZCoordinatesAvailable ? 1 : 0, 1);
encodeBits(keepPositionAndScale ? 1 : 0, 1);
encodeBits(resolutionBits/2, 4); // resolution bits devided by 2
encodeBits(resolutionBits >> 1, 4); // resolution bits divided by 2

double maxDelta = 0.0;
for (int i=1; i<mMol.getAtoms(); i++)
Expand All @@ -3436,8 +3436,8 @@ private void encodeCoordinates(boolean keepPositionAndScale, Coordinates[] coord
}

int binCount = (1 << resolutionBits);
double increment = maxDelta / (binCount / 2.0 - 1);
double maxDeltaPlusHalfIncrement = maxDelta + increment / 2.0;
double increment = maxDelta / ((binCount >> 1) - 1);
double maxDeltaPlusHalfIncrement = maxDelta + 0.5 * increment;

for (int i=1; i<mMol.getAtoms(); i++)
encodeCoords(mGraphAtom[i], (mGraphFrom[i] == -1) ? -1 : mGraphAtom[mGraphFrom[i]], maxDeltaPlusHalfIncrement, increment, resolutionBits, coords);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -771,10 +771,13 @@ public void parse(StereoMolecule mol, byte[] idcode, byte[] coordinates, int idc
from = 0;
factor = 8.0;
}
mMol.setAtomX(atom, mMol.getAtomX(from) + factor * (decodeBits(resolutionBits) - binCount / 2.0));
mMol.setAtomY(atom, mMol.getAtomY(from) + factor * (decodeBits(resolutionBits) - binCount / 2.0));

double decodedDX = factor * (decodeBits(resolutionBits) + 1 - (binCount >> 1));
double decodedDY = factor * (decodeBits(resolutionBits) + 1 - (binCount >> 1));
mMol.setAtomX(atom, mMol.getAtomX(from) + decodedDX);
mMol.setAtomY(atom, mMol.getAtomY(from) + decodedDY);
if (coordsAre3D)
mMol.setAtomZ(atom, mMol.getAtomZ(from) + factor * (decodeBits(resolutionBits) - binCount / 2.0));
mMol.setAtomZ(atom, mMol.getAtomZ(from) + factor * (decodeBits(resolutionBits) + 1 - (binCount >> 1)));
}

if (coordinates[coordsStart] == '#') { // we have 3D-coordinates that include implicit hydrogen coordinates
Expand All @@ -790,10 +793,10 @@ public void parse(StereoMolecule mol, byte[] idcode, byte[] coordinates, int idc
int hydrogen = mMol.addAtom(1);
mMol.addBond(atom, hydrogen, Molecule.cBondTypeSingle);

mMol.setAtomX(hydrogen, mMol.getAtomX(atom) + (decodeBits(resolutionBits) - binCount / 2.0));
mMol.setAtomY(hydrogen, mMol.getAtomY(atom) + (decodeBits(resolutionBits) - binCount / 2.0));
mMol.setAtomX(hydrogen, mMol.getAtomX(atom) + (decodeBits(resolutionBits) + 1 - (binCount >> 1)));
mMol.setAtomY(hydrogen, mMol.getAtomY(atom) + (decodeBits(resolutionBits) + 1 - (binCount >> 1)));
if (coordsAre3D)
mMol.setAtomZ(hydrogen, mMol.getAtomZ(atom) + (decodeBits(resolutionBits) - binCount / 2.0));
mMol.setAtomZ(hydrogen, mMol.getAtomZ(atom) + (decodeBits(resolutionBits) + 1 - (binCount >> 1)));

if (selectedHydrogenBits != null && (selectedHydrogenBits[atom] & (1 << i)) != 0)
mMol.setAtomSelection(hydrogen, true);
Expand Down

0 comments on commit 9cfc345

Please sign in to comment.