Skip to content

Commit

Permalink
Merge tag 'openchemlib-2024.3.1'
Browse files Browse the repository at this point in the history
[maven-release-plugin]  copy for tag openchemlib-2024.3.1
  • Loading branch information
targos committed Mar 23, 2024
2 parents 8b4a0c3 + cc70c29 commit 786df4f
Show file tree
Hide file tree
Showing 22 changed files with 2,727 additions and 453 deletions.
2 changes: 1 addition & 1 deletion buildOpenChemLib
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ rm -rf ./build
mkdir build
cp -r ./src/main/resources/* ./build/
find . -name "*.java" > sources.txt
javac -d ./build @sources.txt
javac -target 8 -d ./build @sources.txt
rm sources.txt
jar -cf build/OpenChemLib.jar -C ./build .
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
Please follow the naming scheme YEAR.MONTH.RELEASE_NO_OF_MONTH
(eg. 2016.4.1 for second release in Apr 2016)
-->
<version>2024.2.2</version>
<version>2024.3.1</version>

<name>OpenChemLib</name>
<description>Open Source Chemistry Library</description>
Expand Down Expand Up @@ -209,7 +209,7 @@
<connection>scm:git:[email protected]:Actelion/openchemlib.git</connection>
<developerConnection>scm:git:[email protected]:Actelion/openchemlib.git</developerConnection>
<url>https://github.com/Actelion/openchemlib</url>
<tag>openchemlib-2024.2.2</tag>
<tag>openchemlib-2024.3.1</tag>
</scm>

<distributionManagement>
Expand Down
52 changes: 45 additions & 7 deletions src/main/java/com/actelion/research/chem/Canonizer.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ public class Canonizer {

// The following options CONSIDER_DIASTEREOTOPICITY, CONSIDER_ENANTIOTOPICITY
// and CONSIDER_STEREOHETEROTOPICITY have no influence on the idcode,
// i.e. the idcode is the same whether or not one of these options is
// used. However, if you require e.g. a pro-E atom always to appear
// i.e. the idcode is the same whether one of these options is used.
// However, if you require e.g. a pro-E atom always to appear
// before the pro-Z, e.g. because you can distinguish them from the
// encoded coordinates, then you need to use one of these options.
// Of course, pro-R or pro-S can only be assigned, if one of the bonds
Expand Down Expand Up @@ -928,7 +928,7 @@ private void canRecursivelyFindCIPParities() {
while ((mNoOfRanks < mMol.getAtoms()) && paritiesFound) {
for (int atom=0; atom<mMol.getAtoms(); atom++) {
mCanBase[atom].init(atom);
mCanBase[atom].add(mAtomBits+4, (mCanRank[atom] << 4)
mCanBase[atom].add(mAtomBits+4, ((long)mCanRank[atom] << 4)
| (mTHParity[atom] << 2));
}

Expand Down Expand Up @@ -987,9 +987,9 @@ private void canRecursivelyFindCanonizedParities() {
// then only consider the ESR type and the rank of the group.

if (!mTHESRTypeNeedsNormalization[atom]
&& mTHESRType[atom] != Molecule.cESRTypeAbs)
&& mTHESRType[atom] != Molecule.cESRTypeAbs)
mCanBase[atom].add((mTHESRType[atom] << 18)
+ (groupRank[(mTHESRType[atom] == Molecule.cESRTypeAnd) ? 0 : 1][mTHESRGroup[atom]] << 8));
+ ((long)groupRank[(mTHESRType[atom] == Molecule.cESRTypeAnd) ? 0 : 1][mTHESRGroup[atom]] << 8));

// if (!mTHParityNeedsNormalization[atom]) {
int parity = mTHParity[atom];
Expand Down Expand Up @@ -2503,8 +2503,8 @@ else if (order == 2) {

/**
* If the molecule contains exactly one stereo center and if that has unknown configuration,
* than assume that the configuration is meant to be racemic and update molecule accordingly.
* If stereo configuration is ill defined with a stereo bond whose pointed tip is not at the
* then assume that the configuration is meant to be racemic and update molecule accordingly.
* If stereo configuration is ill-defined with a stereo bond whose pointed tip is not at the
* stereo center, then the molecule is not touched and the stereo center kept as undefined.
* @return whether a stereo center was converted to be racemic
*/
Expand Down Expand Up @@ -3753,6 +3753,25 @@ public int getTHParity(int atom) {
}


/**
* Returns the atoms's enhanced stereo representation type.
* @param atom
* @return one of the Molecule.cESRTypeXXX constants
*/
public int getTHESRType(int atom) {
return mTHESRType[atom];
}


/**
* @param atom
* @return whether this atom's TH-parity is pseudo
*/
public boolean isPseudoTHParity(int atom) {
return mTHParityIsPseudo[atom];
}


/**
* Returns the absolute bond parity, which is based on priority ranks.
* @param bond
Expand All @@ -3763,6 +3782,25 @@ public int getEZParity(int bond) {
}


/**
* Returns the bond's enhanced stereo representation type.
* @param bond
* @return one of the Molecule.cESRTypeXXX constants
*/
public int getEZESRType(int bond) {
return mEZESRType[bond];
}


/**
* @param bond
* @return whether this bond's EZ-parity is pseudo
*/
public boolean isPseudoEZParity(int bond) {
return mEZParityIsPseudo[bond];
}


/**
* If mMode includes CREATE_PSEUDO_STEREO_GROUPS, then this method returns
* the number of independent relative stereo feature groups. A relative stereo
Expand Down
48 changes: 11 additions & 37 deletions src/main/java/com/actelion/research/chem/ExtendedMolecule.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,7 @@

import com.actelion.research.util.Angle;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.io.*;
import java.util.Arrays;

/**
Expand Down Expand Up @@ -629,7 +626,7 @@ public int getNonHydrogenNeighbourCount(int atom) {
public int getExcludedNeighbourCount(int atom) {
int count = 0;
for (int i=0; i<mConnAtoms[atom]; i++)
if ((mAtomQueryFeatures[i] & Molecule.cAtomQFExcludeGroup) != 0)
if ((mAtomQueryFeatures[mConnAtom[atom][i]] & Molecule.cAtomQFExcludeGroup) != 0)
count++;
return count;
}
Expand Down Expand Up @@ -4070,7 +4067,14 @@ else if ((mAtomQueryFeatures[atom] & cAtomQFAromatic) != 0)
mAtomQueryFeatures[atom] &= ~cAtomQFNotChain; // redundant

if (mAtomCharge[atom] != 0) // explicit charge supersedes query features
mAtomFlags[atom] &= ~cAtomQFCharge;
mAtomQueryFeatures[atom] &= ~cAtomQFCharge;

if (getOccupiedValence(atom) == getMaxValence(atom)) {
mAtomQueryFeatures[atom] &= ~cAtomQFNeighbours;
mAtomQueryFeatures[atom] &= ~cAtomQFENeighbours;
mAtomQueryFeatures[atom] &= ~cAtomQFHydrogen;
mAtomQueryFeatures[atom] &= ~cAtomQFPiElectrons;
}
}
}

Expand Down Expand Up @@ -4107,37 +4111,7 @@ else if (bondType == cBondTypeDelocalized)
}
}


private void writeObject(ObjectOutputStream stream) throws IOException {}
private void readObject(ObjectInputStream stream) throws IOException {}


public final static Coordinates getCenterGravity(ExtendedMolecule mol) {

int n = mol.getAllAtoms();

int [] indices = new int [n];

for (int i = 0; i < indices.length; i++) {
indices[i]=i;
}

return getCenterGravity(mol, indices);
}

public final static Coordinates getCenterGravity(ExtendedMolecule mol, int[] indices) {

Coordinates c = new Coordinates();
for (int i = 0; i < indices.length; i++) {
c.x += mol.getAtomX(indices[i]);
c.y += mol.getAtomY(indices[i]);
c.z += mol.getAtomZ(indices[i]);
}
c.x /= indices.length;
c.y /= indices.length;
c.z /= indices.length;

return c;
}

private void readObject(ObjectInputStream stream) throws IOException {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1163,9 +1163,7 @@ public static boolean isSulfoxyGroup(StereoMolecule mol, int atom) {
public static boolean isIsolatedCarbon(StereoMolecule mol, int indexAtCentral, int [] arrIndexAt){

boolean isolated=true;

int nConnected = mol.getConnAtoms(indexAtCentral);

boolean [] arrConnected = new boolean[mol.getAtoms()];

for (int i = 0; i < nConnected; i++) {
Expand All @@ -1176,7 +1174,6 @@ public static boolean isIsolatedCarbon(StereoMolecule mol, int indexAtCentral, i
if(!arrConnected[indexAt]){
continue;
}

if(mol.getAtomicNo(indexAt)==6){
isolated=false;
break;
Expand Down
48 changes: 43 additions & 5 deletions src/main/java/com/actelion/research/chem/Molecule.java
Original file line number Diff line number Diff line change
Expand Up @@ -2289,6 +2289,28 @@ public Coordinates getCoordinates(int atom) {
}


public Coordinates getCenterOfGravity() {
if (mAllAtoms == 0)
return null;

Coordinates c = new Coordinates();
for (int atom = 0; atom<mAllAtoms; atom++)
c.add(mCoordinates[atom]);
return c.scale(1.0 / mAllAtoms);
}


public Coordinates getCenterOfGravity(int[] atomIndex) {
if (atomIndex == null || atomIndex.length==0 || atomIndex.length>mAllAtoms)
return null;

Coordinates c = new Coordinates();
for (int atom:atomIndex)
c.add(mCoordinates[atom]);
return c.scale(1.0 / atomIndex.length);
}


public double getAtomX(int atom) {
return mCoordinates[atom].x;
}
Expand Down Expand Up @@ -2604,10 +2626,26 @@ public double getBondLength(int bond) {
* Returns the formal bond order. Delocalized rings have alternating single and double
* bonds, which are returned as such. Bonds that are explicitly marked as being delocalized
* are returned as 1. Dative bonds are returned as 0.
* In fragments with at least one bond type set as bond query feature, the smallest
* non-zero order of allowed bonds is returned.
* @param bond
* @return formal bond order 0 (dative bonds), 1, 2, 3, 4, or 5
*/
public int getBondOrder(int bond) {
if (mIsFragment && (mBondQueryFeatures[bond] & cBondQFBondTypes) != 0) {
if ((mBondQueryFeatures[bond] & (cBondQFSingle | cBondQFDelocalized)) != 0)
return 1;
if ((mBondQueryFeatures[bond] & cBondQFDouble) != 0)
return 2;
if ((mBondQueryFeatures[bond] & cBondQFTriple) != 0)
return 3;
if ((mBondQueryFeatures[bond] & cBondQFQuadruple) != 0)
return 4;
if ((mBondQueryFeatures[bond] & cBondQFQuintuple) != 0)
return 5;
if ((mBondQueryFeatures[bond] & cBondQFMetalLigand) != 0)
return 0;
}
switch (mBondType[bond] & cBondTypeMaskSimple) {
case cBondTypeSingle:
case cBondTypeDelocalized: return 1;
Expand Down Expand Up @@ -2796,11 +2834,11 @@ public int getMaxBonds() {
* @param v
*/
public void setMaxBonds(int v) {
mBondAtom[0] = (int[])copyOf(mBondAtom[0], v);
mBondAtom[1] = (int[])copyOf(mBondAtom[1], v);
mBondType = (int[])copyOf(mBondType, v);
mBondFlags = (int[])copyOf(mBondFlags, v);
mBondQueryFeatures = (int[])copyOf(mBondQueryFeatures, v);
mBondAtom[0] = copyOf(mBondAtom[0], v);
mBondAtom[1] = copyOf(mBondAtom[1], v);
mBondType = copyOf(mBondType, v);
mBondFlags = copyOf(mBondFlags, v);
mBondQueryFeatures = copyOf(mBondQueryFeatures, v);
mMaxBonds = v;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public static StereoMolecule getStandardized(String idcode, String coordinates,

/**
* Standardises a molecule and fixes some structural errors.
* Typically this is done before canonicalization.
* Typically, this is done before canonicalization.
* It includes the following changes:<br>
* - different forms of functional groups (e.g. nitro) are normalized to a preferred one<br>
* - charged acidic or basic atoms are (de-)protonated to remove charges and neutralize the molecule, if possible.<br>
Expand Down Expand Up @@ -77,7 +77,6 @@ public static void standardize(StereoMolecule mol, int mode) throws Exception {
* sulfonic acid, phosphoric acid, phenolic oxygen. Means: negative charges are removed.
* Adds Na+ or Cl- for final charge equilibration.
* @param mol
* @return true if an atom was added.
*/
private static void repairAndUnify(StereoMolecule mol) {
mol.ensureHelperArrays(Molecule.cHelperRings);
Expand Down
Loading

0 comments on commit 786df4f

Please sign in to comment.