Skip to content

Commit

Permalink
feat: update OCL to v2024.10.1 (#233)
Browse files Browse the repository at this point in the history
  • Loading branch information
targos authored Oct 14, 2024
1 parent 2b752e8 commit 5eb0ed8
Show file tree
Hide file tree
Showing 9 changed files with 109 additions and 104 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4118,24 +4118,32 @@ public void validateBondQueryFeatures() {
ensureHelperArrays(cHelperRings);

for (int bond=0; bond<mBonds; bond++) {
if (isDelocalizedBond(bond))
mBondQueryFeatures[bond] &= ~cBondQFDelocalized;
int bondTypeQFCount = Integer.bitCount(mBondQueryFeatures[bond] & (Molecule.cBondQFBondTypes | Molecule.cBondQFRareBondTypes));

int bondType = mBondType[bond] & cBondTypeMaskSimple;
if (bondType == cBondTypeSingle)
mBondQueryFeatures[bond] &= ~cBondQFSingle;
else if (bondType == cBondTypeDouble)
mBondQueryFeatures[bond] &= ~cBondQFDouble;
else if (bondType == cBondTypeTriple)
mBondQueryFeatures[bond] &= ~cBondQFTriple;
else if (bondType == cBondTypeQuadruple)
mBondQueryFeatures[bond] &= ~cBondQFQuadruple;
else if (bondType == cBondTypeQuintuple)
mBondQueryFeatures[bond] &= ~cBondQFQuintuple;
else if (bondType == cBondTypeMetalLigand)
mBondQueryFeatures[bond] &= ~cBondQFMetalLigand;
else if (bondType == cBondTypeDelocalized)
if (isDelocalizedBond(bond) & (mBondQueryFeatures[bond] & cBondQFDelocalized) != 0) {
mBondQueryFeatures[bond] &= ~cBondQFDelocalized;
bondTypeQFCount--;
}

// if we have allowed bond types defined, then make sure,
// that the explicit bond type is one of them.
if (bondTypeQFCount != 0) {
int bondType = mBondType[bond] & cBondTypeMaskSimple;
if (bondType == cBondTypeSingle)
mBondQueryFeatures[bond] |= cBondQFSingle;
else if (bondType == cBondTypeDouble)
mBondQueryFeatures[bond] |= cBondQFDouble;
else if (bondType == cBondTypeTriple)
mBondQueryFeatures[bond] |= cBondQFTriple;
else if (bondType == cBondTypeQuadruple)
mBondQueryFeatures[bond] |= cBondQFQuadruple;
else if (bondType == cBondTypeQuintuple)
mBondQueryFeatures[bond] |= cBondQFQuintuple;
else if (bondType == cBondTypeMetalLigand)
mBondQueryFeatures[bond] |= cBondQFMetalLigand;
else if (bondType == cBondTypeDelocalized)
mBondQueryFeatures[bond] |= cBondQFDelocalized;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3475,8 +3475,9 @@ public void setBondQueryFeature(int bond, int feature, boolean value) {
mBondQueryFeatures[bond] |= feature;
else
mBondQueryFeatures[bond] &= ~feature;
mValidHelperArrays = cHelperNone; // there is an influence on occipied valence, bond order, etc.
mIsFragment = true;
mValidHelperArrays = cHelperNone; // there is an influence on occupied valence, bond order, etc.
if (value && feature != 0)
mIsFragment = true;
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,12 @@

package com.actelion.research.chem.forcefield.mmff;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.HashMap;

import com.actelion.research.chem.StereoMolecule;
import com.actelion.research.chem.forcefield.AbstractForceField;

/**
import java.util.*;

/*
* The MMFF ForceField class is the top level class used to perform
* energy calculations/minimisation on a molecule. It accepts an
* ExtendedMolecule and the string name of the parameter tables to use.
Expand All @@ -68,17 +64,17 @@
* (default: 1.0)
* - "dielectric model": A string for the dielectric model. "distance"
* selects a distance-dependent dielectric model, everything else
* selects the constant dielectric model (default: "constant")
* selects the constant dielectric model (default: "constant")
* - "angle bend": A boolean, default True, for whether to include angle
* bending energy terms.
* - "bond stretch": A boolean, default True, for whether to include bond
* stretching energy terms.
* - "electrostatic": A boolean, default True, for whether to include the
* nonbonded electrostatic energy terms.
* - "out of plane": A boolean, default True, for whether to include out
of plane energy terms.
* of plane energy terms.
* - "stretch bend": A boolean, default True, for whether to include
stretch bending energy terms.
* stretch bending energy terms.
* - "torsion angle": A boolean, default True, for whether to include
* torsional angle energy terms.
* - "van der waals": A boolean, default True, for whether to include the
Expand All @@ -88,20 +84,15 @@
* @author joel
*
*/
/**
* @author joel
*
*/
public final class ForceFieldMMFF94 extends AbstractForceField {
public static final String MMFF94 = "MMFF94";
public static final String MMFF94S = "MMFF94s";
public static final String MMFF94SPLUS = "MMFF94s+";


//protected final ExtendedMolecule mol;
private final MMFFMolecule mMMFFMol;
public static Map<String, Tables> mTables = new HashMap<String, Tables>();
private List<EnergyTerm> mEnergies = new ArrayList<EnergyTerm>();
public static Map<String, Tables> mTables = new HashMap<>();
private final List<EnergyTerm> mEnergies = new ArrayList<>();


/**
Expand All @@ -114,25 +105,21 @@ public final class ForceFieldMMFF94 extends AbstractForceField {
* See class description of a list of options.
*/

public ForceFieldMMFF94(StereoMolecule m, String tablename,
Map<String, Object> options) {
public ForceFieldMMFF94(StereoMolecule m, String tablename, Map<String, Object> options)
throws BadAtomTypeException,BadRingAromException {
super(m);
mMMFFMol = new com.actelion.research.chem.forcefield.mmff.MMFFMolecule(m);
mMol.ensureHelperArrays(StereoMolecule.cHelperRings);
Tables table = mTables.get(tablename);

double nonBondedThresh = options.containsKey("nonbonded cutoff")
? ((Double)options.get("nonbonded cutoff")).doubleValue()
? (Double)options.get("nonbonded cutoff")
: 100.0;

double dielConst = options.containsKey("dielectric constant")
? ((Double)options.get("dielectric constant")).doubleValue() : 1.0;

boolean dielModel = options.containsKey("dielectric model")
? ((String)options.get("dielectric model")).equals("distance")
: false;

? (Double)options.get("dielectric constant") : 1.0;

boolean dielModel = options.containsKey("dielectric model") && (options.get("dielectric model")).equals("distance");

Separation sep = new Separation(mMMFFMol);

Expand Down Expand Up @@ -174,8 +161,8 @@ public ForceFieldMMFF94(StereoMolecule m, String tablename,
* must be a table with this name that has been loaded with
* "loadTable()".
*/
public ForceFieldMMFF94(StereoMolecule mol, String tablename) {
this(mol, tablename, new HashMap<String, Object>());
public ForceFieldMMFF94(StereoMolecule mol, String tablename) throws BadAtomTypeException,BadRingAromException {
this(mol, tablename, new HashMap<>());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,25 +36,24 @@
import com.actelion.research.chem.StereoMolecule;
import com.actelion.research.chem.RingCollection;

import java.util.Arrays;

/**
* MMFF molecule is a wrapper class for the ExtendedMolecule. It holds some
* additional data such as a cache of the atom types, whether the molecule is
* valid for MMFF and the ring mmff aromaticity property.
*/
public final class MMFFMolecule extends StereoMolecule {
private RingBoolean[] mRingArom;
private int[] mAtomTypes;
private int[] mHydrogenMap;
private final RingBoolean[] mRingArom;
private final int[] mAtomTypes;
private final int[] mHydrogenMap;

public MMFFMolecule(StereoMolecule mol) throws BadAtomTypeException,
BadRingAromException
{
public MMFFMolecule(StereoMolecule mol) throws BadAtomTypeException,BadRingAromException {
super(mol);
mHydrogenMap = getHandleHydrogenMap();
RingCollection rings = getRingSet();
mRingArom = new RingBoolean[rings.getSize()];
for (int i=0; i<mRingArom.length; i++)
mRingArom[i] = RingBoolean.NOT_SET;
Arrays.fill(mRingArom, RingBoolean.NOT_SET);

boolean allset = false, changed = true;
while (!allset && changed) {
Expand Down Expand Up @@ -109,7 +108,7 @@ public int[] getHydrogenMap() {
* @return True if the ring is aromatic, false otherwise.
*/
public boolean ringIsMMFFAromatic(int r) {
return mRingArom[r] == RingBoolean.TRUE ? true : false;
return mRingArom[r] == RingBoolean.TRUE;
}

/**
Expand All @@ -118,7 +117,7 @@ public boolean ringIsMMFFAromatic(int r) {
* @return True if the ring has had its flag set, false otherwise.
*/
public boolean isSetRingMMFFAromaticity(int r) {
return mRingArom[r] == RingBoolean.NOT_SET ? false : true;
return mRingArom[r] != RingBoolean.NOT_SET;
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,13 @@ public double[][] alignRootAndExitAtoms(FragmentGeometry3D geometry, int permuta
return Coordinates.getRmsd(mAlignmentCoords, coords) > maxRMSD ? null : matrix;
}

public boolean hasMatchingExitVectors(FragmentGeometry3D geometry, Coordinates[] coords, int permutation, double maxDiversion) {
public boolean hasMatchingExitVectors(FragmentGeometry3D geometry, Coordinates[] coords, int permutation, double maxAngleDivergence) {
maxAngleDivergence *= Math.PI / 180;
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) > maxDiversion)
if (v1.getAngle(v2) > maxAngleDivergence)
return false;
}
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,49 +291,54 @@ private void setQueryFeatures(int bond) {
queryFeatures |= (minAtoms << Molecule.cBondQFBridgeMinShift);
queryFeatures |= (atomSpan << Molecule.cBondQFBridgeSpanShift);
queryFeatures &= ~Molecule.cBondQFBondTypes;
mMol.setBondType(bond, Molecule.cBondTypeSingle);
}
else {
// priority in order of bond orders
int bondOrder = -1;
if (mCBSingle.isSelected()) {
mMol.setBondType(bond, Molecule.cBondTypeSingle);
bondOrder = 1;
}
else if (mCBDelocalized.isSelected() && !mMol.isDelocalizedBond(bond)) {
mMol.setBondType(bond, Molecule.cBondTypeDelocalized);
bondOrder = 4;
}
else if (mCBDouble.isSelected()) {
mMol.setBondType(bond, Molecule.cBondTypeDouble);
bondOrder = 2;
}
else if (mCBTriple.isSelected()) {
mMol.setBondType(bond, Molecule.cBondTypeTriple);
bondOrder = 3;
}
else if (mCBMetalLigand.isSelected()) {
mMol.setBondType(bond, Molecule.cBondTypeMetalLigand);
bondOrder = 0;
}
// priority in order of bond orders (except 0)
int bondType = -1;
int selectionCount = 0;

if (mCBSingle.isSelected() && bondOrder != 1)
queryFeatures |= Molecule.cBondQFSingle;
if (mCBDouble.isSelected() && bondOrder != 2)
queryFeatures |= Molecule.cBondQFDouble;
if (mCBTriple.isSelected() && bondOrder != 3)
queryFeatures |= Molecule.cBondQFTriple;
if (mCBQuadruple.isSelected() && bondOrder != 4)
queryFeatures |= Molecule.cBondQFQuadruple;
if (mCBQuintuple.isSelected() && bondOrder != 5)
queryFeatures |= Molecule.cBondQFQuintuple;
if (mCBDelocalized.isSelected() && !mMol.isDelocalizedBond(bond) && bondOrder != 4)
queryFeatures |= Molecule.cBondQFDelocalized;
if (mCBMetalLigand.isSelected() && bondOrder != 0)
if (mCBMetalLigand.isSelected()) {
bondType = Molecule.cBondTypeMetalLigand;
queryFeatures |= Molecule.cBondQFMetalLigand;
if (mCBMatchFormalOrder.isSelected())
queryFeatures |= Molecule.cBondQFMatchFormalOrder;
if (mCBMatchStereo.isSelected())
queryFeatures |= Molecule.cBondQFMatchStereo;
selectionCount++;
}
if (mCBQuintuple.isSelected()) {
bondType = Molecule.cBondTypeQuintuple;
queryFeatures |= Molecule.cBondQFQuintuple;
selectionCount++;
}
if (mCBQuadruple.isSelected()) {
bondType = Molecule.cBondTypeQuadruple;
queryFeatures |= Molecule.cBondQFQuadruple;
selectionCount++;
}
if (mCBTriple.isSelected()) {
bondType = Molecule.cBondTypeTriple;
queryFeatures |= Molecule.cBondQFTriple;
selectionCount++;
}
if (mCBDouble.isSelected()) {
bondType = Molecule.cBondTypeDouble;
queryFeatures |= Molecule.cBondQFDouble;
selectionCount++;
}
if (mCBDelocalized.isSelected()) {
bondType = Molecule.cBondTypeDelocalized;
queryFeatures |= Molecule.cBondQFDelocalized;
selectionCount++;
}
if (mCBSingle.isSelected()) {
bondType = Molecule.cBondTypeSingle;
queryFeatures |= Molecule.cBondQFSingle;
selectionCount++;
}

if (bondType != -1)
mMol.setBondType(bond, bondType); // set to the lowest bond order of query options

if (selectionCount < 2)
queryFeatures = 0;

if (mComboBoxRing.getSelectedIndex() != 0) {
if (mComboBoxRing.getSelectedIndex() == 1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -943,15 +943,19 @@ private void eventHappened(GenericMouseEvent e) {
return;
}

if (e.getButton() == 1) {
mMouseIsDown = false;
updateCursor();
mouseReleasedButton1();
}
}

if (e.getWhat() == GenericMouseEvent.MOUSE_CLICKED) {
if (e.getButton() == 1) {
if (e.getClickCount() == 2) {
handleDoubleClick(e.getX(), e.getY());
return;
}

mMouseIsDown = false;
updateCursor();
mouseReleasedButton1();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ public void setCurrentTool(int tool) {
public void paintContent(GenericDrawContext context) {
int background = mToolbarCanvas.getBackgroundRGB();
boolean isDark = (ColorHelper.perceivedBrightness(background) < 0.5);
int highlightBackground = isDark ? ColorHelper.brighter(background, 0.6f) : ColorHelper.darker(background, 0.6f);
int selectedBackground = isDark ? ColorHelper.brighter(background, 0.8f) : ColorHelper.darker(background, 0.8f);
int highlightBackground = isDark ? ColorHelper.brighter(background, 0.3f) : ColorHelper.darker(background, 0.6f);
int selectedBackground = isDark ? ColorHelper.brighter(background, 0.5f) : ColorHelper.darker(background, 0.8f);

int sw = mImageNormal.getWidth();
int sh = mImageNormal.getHeight();
Expand Down

0 comments on commit 5eb0ed8

Please sign in to comment.