Skip to content

Commit

Permalink
feat: update OCL to v2024.10.2
Browse files Browse the repository at this point in the history
  • Loading branch information
targos committed Oct 29, 2024
1 parent 26cf515 commit 2fdc652
Show file tree
Hide file tree
Showing 10 changed files with 164 additions and 108 deletions.
2 changes: 1 addition & 1 deletion openchemlib
Submodule openchemlib updated 20 files
+3 −3 .github/workflows/maven.yml
+9 −11 pom.xml
+12 −21 src/main/java/com/actelion/research/chem/Canonizer.java
+25 −3 src/main/java/com/actelion/research/chem/ExtendedMolecule.java
+1 −1 src/main/java/com/actelion/research/chem/IsomericSmilesCreator.java
+8 −0 src/main/java/com/actelion/research/chem/SSSearcher.java
+1 −1 src/main/java/com/actelion/research/chem/descriptor/DescriptorWeightsHelper.java
+35 −1 src/main/java/com/actelion/research/chem/descriptor/flexophore/MolDistHistViz.java
+9 −1 src/main/java/com/actelion/research/chem/descriptor/flexophore/MolDistHistVizHelper.java
+21 −1 ...in/java/com/actelion/research/chem/descriptor/flexophore/completegraphmatcher/HistogramMatchCalculator.java
+1 −1 ...ion/research/chem/descriptor/flexophore/completegraphmatcher/ObjectiveBlurFlexophoreHardMatchUncovered.java
+18 −9 src/main/java/com/actelion/research/chem/shredder/FragmentGeometry3D.java
+1 −1 src/main/java/com/actelion/research/chem/shredder/Fragmenter3D.java
+9 −4 src/main/java/com/actelion/research/gui/CompoundCollectionPane.java
+7 −2 src/main/java/com/actelion/research/gui/editor/BondQueryFeatureDialogBuilder.java
+90 −69 src/main/java/com/actelion/research/gui/editor/GenericEditorArea.java
+5 −0 src/main/java/com/actelion/research/gui/table/HighlightListener.java
+210 −170 src/main/java/com/actelion/research/gui/table/JTableWithRowNumbers.java
+7 −0 src/main/java/com/actelion/research/util/CommandLineParser.java
+1 −1 src/main/java/smile/LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,12 @@ public class Canonizer {
private boolean[] mNitrogenQualifiesForParity;
private ArrayList<CanonizerFragment> mFragmentList;
private ArrayList<int[]> mTHParityNormalizationGroupList;
private int mMode,mNoOfRanks,mNoOfPseudoGroups;
private final int mMode;
private int mNoOfRanks,mNoOfPseudoGroups;
private boolean mIsOddParityRound;
private boolean mZCoordinatesAvailable,mAllHydrogensAreExplicit;
private final boolean mZCoordinatesAvailable,mAllHydrogensAreExplicit;
private boolean mCIPParityNoDistinctionProblem;
private boolean mEncodeAvoid127;

private boolean mGraphGenerated;
private int mGraphRings,mFeatureBlock;
private int[] mGraphAtom;
Expand All @@ -184,9 +184,10 @@ public class Canonizer {
private int[] mGraphFrom;
private int[] mGraphClosure;

private String mIDCode, mEncodedCoords,mMapping;
private StringBuilder mEncodingBuffer;
private int mEncodingBitsAvail,mEncodingTempData,mAtomBits,mMaxConnAtoms;
private String mIDCode, mEncodedCoords,mMapping;
private StringBuilder mEncodingBuffer;
private int mEncodingBitsAvail,mEncodingTempData,mMaxConnAtoms;
private final int mAtomBits;

/**
* Runs a canonicalization procedure for the given molecule that creates unique atom ranks,
Expand All @@ -204,7 +205,7 @@ public Canonizer(StereoMolecule mol) {
* If mode includes ENCODE_ATOM_CUSTOM_LABELS, than custom atom labels are
* considered for the atom ranking and are encoded into the idcode.<br>
* If mode includes COORDS_ARE_3D, then getEncodedCoordinates() always returns
* a 3D-encoding even if all z-coordinates are 0.0. Otherwise coordinates are
* a 3D-encoding even if all z-coordinates are 0.0. Otherwise, coordinates are
* encoded in 3D only, if at least one of the z-coords is not 0.0.
* @param mol
* @param mode 0 or one or more of CONSIDER...TOPICITY, CREATE..., ENCODE_ATOM_CUSTOM_LABELS, ASSIGN_PARITIES_TO_TETRAHEDRAL_N, COORDS_ARE_3D
Expand All @@ -226,17 +227,7 @@ public Canonizer(StereoMolecule mol, int mode) {

mZCoordinatesAvailable = ((mode & COORDS_ARE_3D) != 0) || mMol.is3D();

mAllHydrogensAreExplicit = false;
if (mMol.getAllAtoms() > mMol.getAtoms()
&& !mMol.isFragment()) {
mAllHydrogensAreExplicit = true;
for (int i=0; i<mMol.getAtoms(); i++) {
if (mMol.getImplicitHydrogens(i) != 0) {
mAllHydrogensAreExplicit = false;
break;
}
}
}
mAllHydrogensAreExplicit = (mMol.getImplicitHydrogens() == 0);

if ((mMode & NEGLECT_ANY_STEREO_INFORMATION) == 0) {
mTHParity = new byte[mMol.getAtoms()];
Expand Down Expand Up @@ -639,7 +630,7 @@ private boolean canInnerBreakTiesByHeteroTopicity() {
private void canBreakTiesRandomly() {
for (int atom=0; atom<mMol.getAtoms(); atom++) {
mCanBase[atom].init(atom);
mCanBase[atom].add(mAtomBits+1, 2*mCanRank[atom]);
mCanBase[atom].add(mAtomBits+1, (long)2*mCanRank[atom]);
}

// promote randomly one atom of lowest shared rank.
Expand Down Expand Up @@ -895,7 +886,7 @@ private void canRecursivelyFindAllParities() {
thParityInfo |= mTHESRGroup[atom];
}

mCanBase[atom].add(2 * parityInfoBits, thParityInfo << parityInfoBits); // generate space for bond parity
mCanBase[atom].add(2 * parityInfoBits, (long)thParityInfo << parityInfoBits); // generate space for bond parity
}

for (int bond=0; bond<mMol.getBonds(); bond++) {
Expand Down Expand Up @@ -3371,7 +3362,7 @@ public String getEncodedCoordinates() {
* original molecule including coordinates.<br>
* If keepPositionAndScale==false, then coordinate encoding will be relative,
* i.e. scale and absolute positions get lost during the encoding.
* Otherwise the encoding retains scale and absolute positions.<br>
* Otherwise, the encoding retains scale and absolute positions.<br>
* If the molecule has 3D-coordinates and if there are no implicit hydrogen atoms,
* i.e. all hydrogen atoms are explicitly available with their coordinates, then
* hydrogen 3D-coordinates are also encoded despite the fact that the idcode itself does
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1445,7 +1445,28 @@ public boolean supportsImplicitHydrogen(int atom) {
}

/**
* Calculates and return the number of implicit hydrogens at atom.
* Calculates and returns the number of implicit hydrogens of the molecule.
* For hydrogens atoms, metals except Al, or a noble gases, 0 is assumed.
* For all other atom kinds the number of implicit hydrogens is basically
* the lowest typical valence that is compatible with the occupied valence,
* minus the occupied valence corrected by atom charge and radical state.
* If this molecule is a fragment, then 0 is returned.
* @return number of implicit hydrogens of the molecule
*/
public int getImplicitHydrogens() {
if (mIsFragment)
return 0;

ensureHelperArrays(cHelperNeighbours);
int implicitHydrogens = 0;
for (int atom=0; atom<mAtoms; atom++)
implicitHydrogens += getImplicitHydrogens(atom);

return implicitHydrogens;
}

/**
* Calculates and returns the number of implicit hydrogens at atom.
* If atom is itself a hydrogen atom, a metal except Al, or a noble gas,
* then 0 is returned. For all other atom kinds the number of
* implicit hydrogens is basically the lowest typical valence that is compatible
Expand All @@ -1463,8 +1484,9 @@ public int getImplicitHydrogens(int atom) {
if (!supportsImplicitHydrogen(atom))
return 0;

if ("*".equals(getAtomCustomLabel(atom)))
return 0;
// attachment points have at least a valence of 1, i.e. they must be connected to something
if (mAtomicNo[atom] == 0 || "*".equals(getAtomCustomLabel(atom)))
return mAllConnAtoms[atom] == 0 ? 1 : 0;

ensureHelperArrays(cHelperNeighbours);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,7 @@ private void appendBondOrderSymbol(int bond, int parentAtom, StringBuilder build
if (mEZHalfParity[bond] != 0)
builder.append(mEZHalfParity[bond] == 1 ? '/' : '\\');
if (mMode == MODE_CREATE_SMARTS) {
int bondTypes = mMol.getBondQueryFeatures(Molecule.cBondQFBondTypes | Molecule.cBondQFRareBondTypes);
int bondTypes = mMol.getBondQueryFeatures(bond) & (Molecule.cBondQFBondTypes | Molecule.cBondQFRareBondTypes);
if (bondTypes != 0) {
if ((bondTypes & Molecule.cBondTypeSingle) != 0 && mEZHalfParity[bond] == 0) {
builder.append('-');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1322,6 +1322,14 @@ public boolean areBondsSimilar(int moleculeBond, int fragmentBond) {
&& ringSize == (mMolecule.getBondQueryFeatures(fragmentBond) & Molecule.cBondQFRingSize) >> Molecule.cBondQFRingSizeShift)
return true;

if (ringSize <= 2) { // ring size 8-11 is encoded as 1; ring size >=12 is encoded as 2
int moleculeRingSize = mMolecule.getBondRingSize(moleculeBond);
if (ringSize == 1)
return (moleculeRingSize >= 8) && (moleculeRingSize <= 12);
else
return moleculeRingSize >= 12;
}

boolean found = false;
RingCollection ringSet = mMolecule.getRingSet();
for (int i=0; i<ringSet.getSize(); i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public DescriptorWeightsHelper() {
* - Charged pp points are set mandatory.
* @param liSubGraphIndices
* @param molecule3D
* @return
* @return array with dimension molecule3D.getAtoms().
*/
public static int [] calcWeightLabels(List<SubGraphIndices> liSubGraphIndices, Molecule3D molecule3D){

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ private Coordinates[] determineAlignmentCoords() {
coords[i] = mMol.getCoordinates(mExitVector[i].rootAtom);
coords[mExitVector.length + i] = mMol.getCoordinates(mExitVector[i].exitAtom);

// for lonely hydrogens (selected H connects to other exit atom)
// for lonely hydrogens (single selected H connecting to non-selected exit atom)
// we need to place the root coord (hydrogen) further away from the exit atom,
// to reflect the longer bond length of a C-C compared to H-C
if (mMol.getAtomicNo(mExitVector[i].rootAtom) == 1)
Expand Down Expand Up @@ -123,9 +123,10 @@ public boolean equals(FragmentGeometry3D geometry) {
* is returned.
* @param geometry the geometry to be aligned with this
* @param permutation permutation index for equivalent root atoms of the passed geometry
* @param rmsdHolder null or double[1] to receive RMSD value
* @return rotation matrix or null, depending on whether alignment is acceptable
*/
public double[][] alignRootAndExitAtoms(FragmentGeometry3D geometry, int permutation, double maxRMSD) {
public double[][] alignRootAndExitAtoms(FragmentGeometry3D geometry, int permutation, double[] rmsdHolder, double maxRMSD) {
ExitVector[] geomEV = geometry.mExitVector;
Coordinates[] coords = new Coordinates[2*geomEV.length];
for (int i=0; i<geomEV.length; i++)
Expand All @@ -141,19 +142,27 @@ public double[][] alignRootAndExitAtoms(FragmentGeometry3D geometry, int permuta
c.add(mAlignmentCOG);
}

return Coordinates.getRmsd(mAlignmentCoords, coords) > maxRMSD ? null : matrix;
double rmsd = Coordinates.getRmsd(mAlignmentCoords, coords);
if (rmsdHolder != null)
rmsdHolder[0] = rmsd;

return rmsd > maxRMSD ? null : matrix;
}

public boolean hasMatchingExitVectors(FragmentGeometry3D geometry, Coordinates[] coords, int permutation, double maxAngleDivergence) {
maxAngleDivergence *= Math.PI / 180;
for (int i = 0; i<mExitVector.length; i++) {
public boolean hasMatchingExitVectors(FragmentGeometry3D geometry, Coordinates[] coords, int permutation, double[][] angleHolder, double maxAngleDivergence) {
double[] angleDif = new double[mExitVector.length];
boolean qualifies = true;
for (int i=0; i<mExitVector.length; i++) {
Coordinates v1 = mAlignmentCoords[mExitVector.length+i].subC(mAlignmentCoords[i]);
ExitVector ev2 = geometry.mExitVector[mPermutation[permutation][i]];
Coordinates v2 = coords[ev2.exitAtom].subC(coords[ev2.rootAtom]);
if (v1.getAngle(v2) > maxAngleDivergence)
return false;
angleDif[i] = v1.getAngle(v2) * 180 / Math.PI;
if (angleDif[i] > maxAngleDivergence)
qualifies = false;
}
return true;
if (angleHolder != null)
angleHolder[0] = angleDif;
return qualifies;
}

public int getPermutationCount() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public ArrayList<Fragment3D> buildFragments(StereoMolecule mol, boolean withHydr
int fragmentCount = mol.getFragmentNumbers(fragmentNo, isRotatableBond, true);

int[] atomCount = new int[fragmentCount];
for (int atom=0; atom<mol.getAllAtoms(); atom++)
for (int atom=0; atom<mol.getAtoms(); atom++)
atomCount[fragmentNo[atom]]++;

BaseFragmentInfo[] fragmentData = new BaseFragmentInfo[fragmentCount];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ private void build(ExtendedMolecule mol, int bond) {
mComboBoxRingSize.addItem("is in 5-membered ring");
mComboBoxRingSize.addItem("is in 6-membered ring");
mComboBoxRingSize.addItem("is in 7-membered ring");
mComboBoxRingSize.addItem("smallest ring 8 to 11");
mComboBoxRingSize.addItem("smallest ring >= 12");
mDialog.add(mComboBoxRingSize, 1,13,3,13);

mCBMatchFormalOrder = mDialog.createCheckBox("Match formal bond order");
Expand Down Expand Up @@ -223,7 +225,7 @@ else if (aromState == Molecule.cBondQFNotAromatic)
mComboBoxRing.setSelectedIndex(0);

int ringSize = (queryFeatures & Molecule.cBondQFRingSize) >> Molecule.cBondQFRingSizeShift;
mComboBoxRingSize.setSelectedIndex((ringSize == 0) ? 0 : ringSize-2);
mComboBoxRingSize.setSelectedIndex((ringSize == 0) ? 0 : (ringSize <= 2) ? ringSize+5 : ringSize-2);

if ((queryFeatures & Molecule.cBondQFBridge) != 0) {
mCBIsBridge.setSelected(true);
Expand Down Expand Up @@ -361,9 +363,12 @@ else if (mComboBoxRing.getSelectedIndex() == 4) {

if (mComboBoxRingSize.getSelectedIndex() != 0) {
int ringSize = mComboBoxRingSize.getSelectedIndex() + 2;
if (ringSize > 7) // ringsize 8-11 is encoded as 1; ringsize >12 is encoded as 2
ringSize -= 7;
int implicitSize = mMol.getBondRingSize(bond);
if (ringSize != implicitSize)
if (ringSize <= 2 || ringSize != implicitSize) { // options 1 and 2 cover spans and cannot be implicit
queryFeatures |= (ringSize << Molecule.cBondQFRingSizeShift);
}
}
}

Expand Down
Loading

0 comments on commit 2fdc652

Please sign in to comment.