Skip to content

Commit

Permalink
feat: update OCL to v2023.2.1 (#160)
Browse files Browse the repository at this point in the history
Closes: #155
  • Loading branch information
targos authored Feb 15, 2023
1 parent f688501 commit 9d2dd13
Show file tree
Hide file tree
Showing 25 changed files with 1,367 additions and 1,061 deletions.
2 changes: 1 addition & 1 deletion openchemlib
Submodule openchemlib updated 38 files
+2 −2 pom.xml
+179 −178 src/main/java/com/actelion/research/calc/ArrayUtilsCalc.java
+24 −19 src/main/java/com/actelion/research/chem/AbstractDepictor.java
+1 −1 src/main/java/com/actelion/research/chem/SVGDepictor.java
+1 −1 src/main/java/com/actelion/research/chem/ScaffoldHelper.java
+16 −1 src/main/java/com/actelion/research/chem/StereoMolecule.java
+5 −21 src/main/java/com/actelion/research/chem/alignment3d/PheSAAlignmentOptimizer.java
+3 −1 src/main/java/com/actelion/research/chem/conf/BondLengthSet.java
+10 −14 src/main/java/com/actelion/research/chem/conf/Conformer.java
+14 −11 src/main/java/com/actelion/research/chem/conf/ConformerSetGenerator.java
+3 −1 src/main/java/com/actelion/research/chem/conf/TorsionDB.java
+1 −1 src/main/java/com/actelion/research/chem/conf/TorsionDescriptorHelper.java
+7 −12 src/main/java/com/actelion/research/chem/conf/torsionstrain/StatisticalTorsionPotential.java
+9 −29 src/main/java/com/actelion/research/chem/docking/DockingEngine.java
+4 −6 src/main/java/com/actelion/research/chem/docking/shape/ShapeDocking.java
+6 −2 src/main/java/com/actelion/research/chem/prediction/CLogPPredictor.java
+10 −2 src/main/java/com/actelion/research/chem/prediction/DruglikenessPredictor.java
+8 −0 src/main/java/com/actelion/research/chem/prediction/DruglikenessPredictorWithIndex.java
+5 −2 src/main/java/com/actelion/research/chem/prediction/FastMolecularComplexityCalculator.java
+5 −1 src/main/java/com/actelion/research/chem/prediction/PolarSurfaceAreaPredictor.java
+9 −0 src/main/java/com/actelion/research/chem/prediction/SolubilityPredictor.java
+20 −4 src/main/java/com/actelion/research/chem/prediction/TotalSurfaceAreaPredictor.java
+14 −4 src/main/java/com/actelion/research/chem/prediction/ToxicityPredictor.java
+8 −0 src/main/java/com/actelion/research/util/CommandLineParser.java
+0 −5 src/main/java/com/actelion/research/util/IO.java
+86 −0 src/main/java/org/openmolecules/chem/conf/gen/ConformerDiagnostics.java
+52 −132 src/main/java/org/openmolecules/chem/conf/gen/ConformerGenerator.java
+186 −0 src/main/java/org/openmolecules/chem/conf/gen/ConformerSetDiagnostics.java
+4 −0 src/main/java/org/openmolecules/chem/conf/gen/RigidFragment.java
+1 −1 src/main/java/org/openmolecules/chem/conf/gen/RigidFragmentProvider.java
+7 −1 src/main/java/org/openmolecules/chem/conf/gen/RotatableBond.java
+9 −13 src/main/java/org/openmolecules/chem/conf/gen/TorsionSetStrategy.java
+183 −120 src/main/java/org/openmolecules/chem/conf/so/TetrahedralStereoRule.java
+44 −38 src/main/resources/resources/cod/torsionAngle.txt
+50 −44 src/main/resources/resources/cod/torsionBins.txt
+41 −35 src/main/resources/resources/cod/torsionFrequency.txt
+26 −20 src/main/resources/resources/cod/torsionID.txt
+46 −40 src/main/resources/resources/cod/torsionRange.txt
1,466 changes: 733 additions & 733 deletions package-lock.json

Large diffs are not rendered by default.

11 changes: 4 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@
"test": "npm run build && npm run test-only && npm run eslint",
"test-only": "jest"
},
"jest": {
"testEnvironment": "node"
},
"main": "./core.js",
"files": [
"dist",
Expand All @@ -56,12 +53,12 @@
"homepage": "https://github.com/cheminfo/openchemlib-js",
"devDependencies": {
"benchmark": "^2.1.4",
"eslint": "^8.33.0",
"eslint": "^8.34.0",
"eslint-config-cheminfo": "^8.1.3",
"gwt-api-exporter": "^2.0.0",
"jest": "^29.4.1",
"openchemlib-utils": "^2.3.0",
"prettier": "^2.8.3",
"jest": "^29.4.2",
"openchemlib-utils": "^2.4.0",
"prettier": "^2.8.4",
"yargs": "^17.6.2"
}
}
9 changes: 9 additions & 0 deletions scripts/openchemlib/classes.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ const modified = [
exports.modified = modified.map(getFilename);

const changed = [
[
'@org/openmolecules/chem/conf/gen/ConformerSetDiagnostics',
changeConformerSetDiagnostics,
],
['@org/openmolecules/chem/conf/gen/RigidFragmentCache', removeCacheIO],
['chem/ChemistryHelper', removePrintf],
['chem/Coordinates', removeToStringSpaceDelimited],
Expand Down Expand Up @@ -457,6 +461,11 @@ function changeBondLengthSet(code) {
return code;
}

function changeConformerSetDiagnostics(code) {
code = code.replace(methodRegExp('writeEliminationRuleFile'), '');
return code;
}

function removeCacheIO(code) {
code = removeSlice(
code,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1662,32 +1662,45 @@ private void mpShortenLine(DepictorLine theLine,int pointNo,int tabuZoneNo) {
}


private int mpPreferredSide(int bnd) {
boolean[] isAromatic = new boolean[ExtendedMolecule.cMaxConnAtoms];
boolean[] isInRing = new boolean[ExtendedMolecule.cMaxConnAtoms];
private int mpPreferredSide(int bond) {
int[] value = new int[ExtendedMolecule.cMaxConnAtoms];
double[] angle = new double[ExtendedMolecule.cMaxConnAtoms];
double[] bondAngle = new double[2];

int angles = 0;
for (int i=0; i<2; i++) {
int atm = mMol.getBondAtom(i,bnd);
int atm = mMol.getBondAtom(i,bond);

for (int j=0; j<mMol.getConnAtoms(atm); j++) {
int connBond = mMol.getConnBond(atm,j);
if (connBond == bnd)
if (connBond == bond)
continue;

if (angles == 4)
return 0;

isAromatic[angles] = mMol.isAromaticBond(connBond);
isInRing[angles] = mMol.isRingBond(connBond);
angle[angles++] = mMol.getBondAngle(atm, mMol.getConnAtom(atm,j));
int connAtom = mMol.getConnAtom(atm,j);

value[angles] = 16;

// Prefer bond on side with conjugated pi systems
if (mMol.getAtomPi(connAtom) != 0)
value[angles] += mMol.isRingAtom(connAtom) ? 1 : 4;

// Prefer bond inside of ring. Even more, if it is aromatic.
if (mMol.isRingBond(bond)
&& mMol.isRingBond(connBond)) {
int sharedRing = mMol.getRingSet().getSharedRing(bond, connBond);
if (sharedRing != -1)
value[angles] += mMol.getRingSet().isAromatic(sharedRing) ? 64 : 6;
}

angle[angles++] = mMol.getBondAngle(atm, connAtom);
}
}

boolean changed;
bondAngle[0] = mMol.getBondAngle(mMol.getBondAtom(0,bnd),mMol.getBondAtom(1,bnd));
bondAngle[0] = mMol.getBondAngle(mMol.getBondAtom(0,bond),mMol.getBondAtom(1,bond));
if (bondAngle[0] < 0) {
bondAngle[1] = bondAngle[0] + Math.PI;
changed = false;
Expand All @@ -1700,18 +1713,10 @@ private int mpPreferredSide(int bnd) {

int side = 0;
for (int i=0; i<angles; i++) {
int value;
if (isAromatic[i])
value = 20;
else if (isInRing[i])
value = 17;
else
value = 16;

if ((angle[i] > bondAngle[0]) && (angle[i] < bondAngle[1]))
side -= value;
side -= value[i];
else
side += value;
side += value[i];
}

return (changed) ? -side : side;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
import java.math.RoundingMode;
import java.util.ArrayList;

public class SVGDepictor extends AbstractDepictor {
public class SVGDepictor extends AbstractDepictor<Void> {
public static final int DEFAULT_ELEM_WIDTH = 8;

private static final String FONTNAME = "Helvetica";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public static StereoMolecule getMurckoScaffold(StereoMolecule mol, boolean skele
return scaffold;
}

private static void makeSkeleton(StereoMolecule mol) {
public static void makeSkeleton(StereoMolecule mol) {
for (int bond=0; bond<mol.getAllBonds(); bond++)
mol.setBondType(bond, Molecule.cBondTypeSingle);
for (int atom=0; atom<mol.getAllAtoms(); atom++)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@

package com.actelion.research.chem;

import java.io.*;
import com.actelion.research.chem.coords.CoordinateInventor;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

public class StereoMolecule extends ExtendedMolecule {
static final long serialVersionUID = 0x2006CAFE;
Expand Down Expand Up @@ -191,6 +195,13 @@ public void ensureHelperArrays(int required) {
if ((required & ~mValidHelperArrays) == 0)
return;

// If we have valid parities, but no atom coordinates, and if we need to run the Canonizer
// for extended stereo features, then we need to create 2D-coordinates first to not loose
// the given parities, because the Canonizer recalculates parities from coords and up/down bonds.
if ((mValidHelperArrays & cHelperParities) != 0
&& (mAllAtoms > 1) && mCoordinates[0].equals(mCoordinates[1]))
new CoordinateInventor(0).invent(this);

if (mAssignParitiesToNitrogen)
required |= cHelperBitIncludeNitrogenParities;

Expand Down Expand Up @@ -367,6 +378,8 @@ public int getSymmetryRank(int atom) {
*/
public String getIDCode() {
ensureHelperArrays(cHelperParities);
if (mCanonizer == null && (getAtoms() < 2 || !mCoordinates[0].equals(mCoordinates[1])))
mCanonizer = new Canonizer(this);
return mCanonizer == null ? null : mCanonizer.getIDCode();
}

Expand All @@ -380,6 +393,8 @@ public String getIDCode() {
*/
public String getIDCoordinates() {
ensureHelperArrays(cHelperParities);
if (mCanonizer == null && (getAtoms() < 2 || !mCoordinates[0].equals(mCoordinates[1])))
mCanonizer = new Canonizer(this);
return mCanonizer == null ? null : mCanonizer.getEncodedCoordinates();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ public void setZ(int atom, double z) {
/**
* Removes atoms Coordinates objects from those atoms that are marked in the given array.
* Make sure to also remove those atoms from the underlying Molecule.
*
* When this method is used, bond torsion angles are lost.
* @param isToBeDeleted
* @return
*/
Expand All @@ -196,18 +196,13 @@ public int deleteAtoms(boolean[] isToBeDeleted) {

if (count != 0) {
Coordinates[] newCoords = new Coordinates[mCoordinates.length - count];
short[] newBondTorsion = (mBondTorsion == null) ? null : new short[mCoordinates.length - count];
int newIndex = 0;
for (int i = 0; i < mCoordinates.length; i++) {
if (!isToBeDeleted[i]) {
newCoords[newIndex] = mCoordinates[i];
if (newBondTorsion != null)
newBondTorsion[newIndex] = mBondTorsion[i];
newIndex++;
}
}
for (int i = 0; i < mCoordinates.length; i++)
if (!isToBeDeleted[i])
newCoords[newIndex++] = mCoordinates[i];

mCoordinates = newCoords;
mBondTorsion = newBondTorsion;
mBondTorsion = null;
}

return count;
Expand Down Expand Up @@ -242,8 +237,7 @@ public double calculateTorsion(int[] atom) {
}

/**
* Returns the current bond torsion angle in degrees, it is was set before.
*
* Returns the current bond torsion angle in degrees, as it was set before.
* @param bond
* @return -1 or previously set torsion angle in the range 0 ... 359
*/
Expand All @@ -258,8 +252,10 @@ public int getBondTorsion(int bond) {
* @param torsion in degrees
*/
public void setBondTorsion(int bond, short torsion) {
if (mBondTorsion == null)
if (mBondTorsion == null) {
mBondTorsion = new short[mMol.getAllBonds()];
Arrays.fill(mBondTorsion, (short)-1);
}
mBondTorsion[bond] = torsion;
}

Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public TorsionDescriptor getTorsionDescriptor() {

/**
* Creates a TorsionDescriptor from the coordinates of the passed conformer assuming that its
* underlying molecule is the same that waas passed to this TorsionDescriptorHelper's constructor.
* underlying molecule is the same that was passed to this TorsionDescriptorHelper's constructor.
* This TorsionDescriptorHelper uses the default method to detect rotatable bonds.
* The torsion descriptor is not canonical, unless the passed molecule is canonical.
* Rotatable bonds need to carry at least one external non-hydrogen neighbor on each side.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,13 @@ public CLogPPredictor() {
}

/**
* Ambiguous bonds are normalized.
* Before calculating any kind of property, make sure that the molecule's structure is standardized.
* Typically, molecules created by an IDCodeParser are standardized. Molecules generated from a
* SmilesParser or MolfileParser, or just drawn within an editor, should be standardized using the
* MoleculeStandardizer.
* This method may normalize ambiguous bonds of the molecule.
* @param mol
* @return
* @return logP value estimated from atom type specific increments
*/
public float assessCLogP(StereoMolecule mol) {
float cLogP = 0.0f;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@ public DruglikenessPredictorWithIndex() {
}
}

/**
* Before calculating any kind of property, make sure that the molecule's structure is standardized.
* Typically, molecules created by an IDCodeParser are standardized. Molecules generated from a
* SmilesParser or MolfileParser, or just drawn within an editor, should be standardized using the
* MoleculeStandardizer.
* @param mol
* @return druglikeness value estimated from atom type specific increments
*/
public double assessDruglikeness(StereoMolecule mol, long[] index, ThreadMaster threadMaster) {
if (!sInitialized)
return cDruglikenessUnknown;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,12 @@ public static int getPolarAtomTypeCount() {
* Calculates the topological polar surface area (TPSA) of a molecule as a sum of
* contributions of its polar atom-types. This method uses the polar atom contributions
* originally published by Peter Ertl et al. in J. Med. Chem. 2000, 43, 3714-3717.
* Before calculating any kind of property, make sure that the molecule's structure is standardized.
* Typically, molecules created by an IDCodeParser are standardized. Molecules generated from a
* SmilesParser or MolfileParser, or just drawn within an editor, should be standardized using the
* MoleculeStandardizer.
* @param mol
* @return
* @return topological polar surface area estimated from atom type specific increments
*/
public float assessPSA(StereoMolecule mol) {
int[] count = getPolarAtomTypeCounts(mol);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,15 @@ public SolubilityPredictor() {
}


/**
* Before calculating any kind of property, make sure that the molecule's structure is standardized.
* Typically, molecules created by an IDCodeParser are standardized. Molecules generated from a
* SmilesParser or MolfileParser, or just drawn within an editor, should be standardized using the
* MoleculeStandardizer.
* This method may normalize ambiguous bonds of the molecule.
* @param mol
* @return aquous solubility value estimated from atom type specific increments
*/
public float assessSolubility(StereoMolecule mol) {
float logS = -0.530f;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,12 @@ public static int getNonPolarAtomTypeCount() {
* as solvent accessible surface using Van der Waals radii and a probe of 1.4 angstrom
* radius. Surface contribution values were for 43 polar and 20 non polar atom types were
* calculated as a multi-linear regression with a PLS approach.
* Before calculating any kind of property, make sure that the molecule's structure is standardized.
* Typically, molecules created by an IDCodeParser are standardized. Molecules generated from a
* SmilesParser or MolfileParser, or just drawn within an editor, should be standardized using the
* MoleculeStandardizer.
* @param mol
* @return
* @return topological total surface area estimated from atom type specific increments
*/
public float assessTotalSurfaceArea(StereoMolecule mol) {
return assessNonPolarSurfaceArea(mol) + assessPolarSurfaceArea(mol);
Expand All @@ -137,8 +141,12 @@ public float assessTotalSurfaceArea(StereoMolecule mol) {
* as solvent accessible surface using Van der Waals radii and a probe of 1.4 angstrom
* radius. Surface contribution values were for 43 polar and 20 non polar atom types were
* calculated as a multi-linear regression with a PLS approach.
* Before calculating any kind of property, make sure that the molecule's structure is standardized.
* Typically, molecules created by an IDCodeParser are standardized. Molecules generated from a
* SmilesParser or MolfileParser, or just drawn within an editor, should be standardized using the
* MoleculeStandardizer.
* @param mol
* @return
* @return topological polar surface area estimated from atom type specific increments
*/
public float assessPolarSurfaceArea(StereoMolecule mol) {
int[] count = getPolarAtomTypeCounts(mol);
Expand All @@ -160,8 +168,12 @@ public float assessPolarSurfaceArea(StereoMolecule mol) {
* as solvent accessible surface using Van der Waals radii and a probe of 1.4 angstrom
* radius. Surface contribution values were for 43 polar and 20 non polar atom types were
* calculated as a multi-linear regression with a PLS approach.
* Before calculating any kind of property, make sure that the molecule's structure is standardized.
* Typically, molecules created by an IDCodeParser are standardized. Molecules generated from a
* SmilesParser or MolfileParser, or just drawn within an editor, should be standardized using the
* MoleculeStandardizer.
* @param mol
* @return
* @return topological non-polar surface area estimated from atom type specific increments
*/
public float assessNonPolarSurfaceArea(StereoMolecule mol) {
int[] count = getNonPolarAtomTypeCounts(mol);
Expand All @@ -176,8 +188,12 @@ public float assessNonPolarSurfaceArea(StereoMolecule mol) {
/**
* Calculates the relative (fractional) polar surface area from polar and non-polar atom
* contributions. This method does not use the Peter Ertl increments.
* Before calculating any kind of property, make sure that the molecule's structure is standardized.
* Typically, molecules created by an IDCodeParser are standardized. Molecules generated from a
* SmilesParser or MolfileParser, or just drawn within an editor, should be standardized using the
* MoleculeStandardizer.
* @param mol
* @return
* @return topological relative surface area estimated from atom type specific increments
*/
public float assessRelativePolarSurfaceArea(StereoMolecule mol) {
float psa = assessPolarSurfaceArea(mol);
Expand Down
Loading

0 comments on commit 9d2dd13

Please sign in to comment.