Skip to content

Commit

Permalink
Merge tag 'openchemlib-2024.7.1'
Browse files Browse the repository at this point in the history
[maven-release-plugin]  copy for tag openchemlib-2024.7.1
  • Loading branch information
targos committed Jul 18, 2024
2 parents 1067a3e + de1e462 commit bee7a71
Show file tree
Hide file tree
Showing 38 changed files with 2,657 additions and 1,128 deletions.
1 change: 1 addition & 0 deletions buildOpenChemLib
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ find . -name "*.java" > sources.txt
javac -target 8 -d ./build @sources.txt
rm sources.txt
jar -cf build/OpenChemLib.jar -C ./build .
ls -al build/OpenChemLib.jar
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.5.1</version>
<version>2024.7.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.5.1</tag>
<tag>openchemlib-2024.7.1</tag>
</scm>

<distributionManagement>
Expand Down
15 changes: 7 additions & 8 deletions src/main/java/com/actelion/research/chem/DrawingObjectList.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,9 @@ public DrawingObjectList() {
public DrawingObjectList(DrawingObjectList l) {
super();
try {
if (l != null) {
for (int i = 0; i < l.size(); i++)
add((AbstractDrawingObject) l.get(i).clone());
}
if (l != null)
for (AbstractDrawingObject abstractDrawingObject : l)
add(abstractDrawingObject.clone());
} catch (Exception e) {
} finally {

Expand All @@ -57,7 +56,7 @@ public DrawingObjectList(DrawingObjectList l) {

public DrawingObjectList(String objectString) {
super();
if (objectString == null || objectString.length() == 0)
if (objectString == null || objectString.isEmpty())
return;

int index1 = 0;
Expand All @@ -72,9 +71,9 @@ public DrawingObjectList(String objectString) {
}

public String toString() {
StringBuffer objectString = new StringBuffer();
for (int i=0; i<size(); i++)
objectString.append(get(i).getDescriptor()+"\n");
StringBuilder objectString = new StringBuilder();
for (AbstractDrawingObject abstractDrawingObject : this)
objectString.append(abstractDrawingObject.getDescriptor()).append("\n");
return objectString.toString();
}
}
43 changes: 30 additions & 13 deletions src/main/java/com/actelion/research/chem/ExtendedMolecule.java
Original file line number Diff line number Diff line change
Expand Up @@ -538,21 +538,37 @@ public int getConnAtom(int atom, int i) {

/**
* The neighbours (connected atoms) of any atom are sorted by their relevance:<br>
* 1. non-hydrogen atoms (bond order 1 and above) and unusual hydrogen atoms (non natural abundance isotops, custom labelled hydrogen, etc.)<br>
* 1. non-hydrogen atoms (bond order 1 and above) and unusual hydrogen atoms (non-natural abundance isotops, custom labelled hydrogen, etc.)<br>
* 2. plain-hydrogen atoms (natural abundance, bond order 1)<br>
* 3. loosely connected atoms (bond order 0, i.e. metall ligand bond)<br>
* Only valid after calling ensureHelperArrays(cHelperNeighbours or higher);
* Note: This method includes neighbours marked as being part of an exclude group!
* @param atom
* @return count of category 1 neighbour atoms (excludes plain H and bond zero orders)
*/
public int getNotExcludedConnAtoms(int atom) {
return mConnAtoms[atom] - getExcludedNeighbourCount(atom);
}


/**
* The neighbours (connected atoms) of any atom are sorted by their relevance:<br>
* 1. non-hydrogen atoms (bond order 1 and above) and unusual hydrogen atoms (non-natural abundance isotops, custom labelled hydrogen, etc.)<br>
* 2. plain-hydrogen atoms (natural abundance, bond order 1)<br>
* 3. loosely connected atoms (bond order 0, i.e. metall ligand bond)<br>
* Only valid after calling ensureHelperArrays(cHelperNeighbours or higher);
* Note: This method includes neighbours marked as being part of an exclude group!
* @param atom
* @return count of category 1 neighbour atoms (excludes plain H and bond zero orders)
*/
public int getConnAtoms(int atom) {
return mConnAtoms[atom];
}
}


/**
* The neighbours (connected atoms) of any atom are sorted by their relevance:<br>
* 1. non-hydrogen atoms (bond order 1 and above) and unusual hydrogen atoms (non natural abundance isotops, custom labelled hydrogen, etc.)<br>
* 1. non-hydrogen atoms (bond order 1 and above) and unusual hydrogen atoms (non-natural abundance isotops, custom labelled hydrogen, etc.)<br>
* 2. plain-hydrogen atoms (natural abundance, bond order 1)<br>
* 3. loosely connected atoms (bond order 0, i.e. metall ligand bond)<br>
* Only valid after calling ensureHelperArrays(cHelperNeighbours or higher);
Expand All @@ -566,7 +582,7 @@ public int getAllConnAtomsPlusMetalBonds(int atom) {

/**
* The neighbours (connected atoms) of any atom are sorted by their relevance:<br>
* 1. non-hydrogen atoms (bond order 1 and above) and unusual hydrogen atoms (non natural abundance isotops, custom labelled hydrogen, etc.)<br>
* 1. non-hydrogen atoms (bond order 1 and above) and unusual hydrogen atoms (non-natural abundance isotops, custom labelled hydrogen, etc.)<br>
* 2. plain-hydrogen atoms (natural abundance, bond order 1)<br>
* 3. loosely connected atoms (bond order 0, i.e. metall ligand bond)<br>
* Only valid after calling ensureHelperArrays(cHelperNeighbours or higher);
Expand All @@ -581,7 +597,7 @@ public int getConnBond(int atom, int i) {

/**
* The neighbours (connected atoms) of any atom are sorted by their relevance:<br>
* 1. non-hydrogen atoms (bond order 1 and above) and unusual hydrogen atoms (non natural abundance isotops, custom labelled hydrogen, etc.)<br>
* 1. non-hydrogen atoms (bond order 1 and above) and unusual hydrogen atoms (non-natural abundance isotops, custom labelled hydrogen, etc.)<br>
* 2. plain-hydrogen atoms (natural abundance, bond order 1)<br>
* 3. loosely connected atoms (bond order 0, i.e. metall ligand bond)<br>
* Only valid after calling ensureHelperArrays(cHelperNeighbours or higher);
Expand Down Expand Up @@ -616,13 +632,14 @@ public int getNonHydrogenNeighbourCount(int atom) {
/**
* This method returns the count of atom neighbours which are marked as being an exclude group.
* @param atom
* @return the number of non-hydrogen neighbor atoms
* @return the number of non-hydrogen neighbor atoms marked as being part of an exclude group
*/
public int getExcludedNeighbourCount(int atom) {
int count = 0;
for (int i=0; i<mConnAtoms[atom]; i++)
if ((mAtomQueryFeatures[mConnAtom[atom][i]] & Molecule.cAtomQFExcludeGroup) != 0)
count++;
if (mIsFragment)
for (int i=0; i<mConnAtoms[atom]; i++)
if ((mAtomQueryFeatures[mConnAtom[atom][i]] & Molecule.cAtomQFExcludeGroup) != 0)
count++;
return count;
}

Expand Down Expand Up @@ -1736,17 +1753,17 @@ public boolean isHeteroAromaticAtom(int atom) {
* @return whether the atom is a member of a delocalized ring (subset of aromatic rings)
*/
public boolean isDelocalizedAtom(int atom) {
return (atom < mAtoms) ? mRingSet.isDelocalizedAtom(atom) : false;
return atom<mAtoms && mRingSet.isDelocalizedAtom(atom);
}


public boolean isAromaticBond(int bond) {
return (bond < mBonds) ? mRingSet.isAromaticBond(bond) : false;
return bond<mBonds && mRingSet.isAromaticBond(bond);
}


public boolean isHeteroAromaticBond(int bond) {
return (bond < mBonds) ? mRingSet.isHeteroAromaticBond(bond) : false;
return bond<mBonds && mRingSet.isHeteroAromaticBond(bond);
}


Expand Down Expand Up @@ -3482,12 +3499,12 @@ public void ensureHelperArrays(int required) {
if ((mValidHelperArrays & cHelperBitNeighbours) == 0) {
handleHydrogens();
calculateNeighbours();

mValidHelperArrays |= cHelperBitNeighbours;

if (convertHydrogenToQueryFeatures()) {
handleHydrogens();
calculateNeighbours();
mValidHelperArrays |= cHelperBitNeighbours;
}
}

Expand Down
51 changes: 29 additions & 22 deletions src/main/java/com/actelion/research/chem/Molecule.java
Original file line number Diff line number Diff line change
Expand Up @@ -1179,23 +1179,43 @@ public int[] addMolecule(Molecule mol) {
* @return atom mapping from original mol to this molecule after incorporation of mol
*/
public int[] addMolecule(Molecule mol, int atoms, int bonds) {
return addMolecule(mol, 0, atoms, 0, bonds);
}


/**
* Copies first atoms and first bonds of mol to the end of this Molecule's atom and bond
* tables. If mol is a fragment then this Molecule's fragment flag is set to true
* and all query features of mol are also copied. Typically, this is used to add a
* molecule without explicit hydrogen atoms. If parities of copied molecules are valid,
* then you may call setParitiesValid() on this molecule after adding molecules.
* High level function for constructing a molecule. Does not require any helper arrays.
* @param mol
* @param atom1 first atom to be copied
* @param atom2 1+last atom to be copied
* @param bond1 first bond to be copied
* @param bond2 one+last bond to be copied
* @return atom mapping from original mol to this molecule after incorporation of mol
*/
public int[] addMolecule(Molecule mol, int atom1, int atom2, int bond1, int bond2) {
mIsFragment |= mol.mIsFragment;

int[] atomMap = new int[mol.mAllAtoms];
int esrGroupCountAND = renumberESRGroups(cESRTypeAnd);
int esrGroupCountOR = renumberESRGroups(cESRTypeOr);
for (int atom=0; atom<atoms; atom++) {
for (int atom=atom1; atom<atom2; atom++) {
atomMap[atom] = mol.copyAtom(this, atom, esrGroupCountAND, esrGroupCountOR);
}
for (int bond=0; bond<bonds; bond++) {
}
for (int bond=bond1; bond<bond2; bond++) {
mol.copyBond(this, bond, esrGroupCountAND, esrGroupCountOR, atomMap, false);
}
}

mIsRacemate = (mIsRacemate && mol.mIsRacemate);
mChirality = cChiralityUnknown;
mValidHelperArrays = cHelperNone;
return atomMap;
}
}


/**
* Adds and connects the substituent molecule to the rootAtom of this molecule.
Expand Down Expand Up @@ -1655,24 +1675,11 @@ public void swapBonds(int bond1, int bond2) {
* @param atom
*/
public void deleteAtom(int atom) {
for (int bnd=0; bnd<mAllBonds; bnd++) {
for (int i=0; i<2; i++) {
if (mBondAtom[i][bnd] == atom) {
for (int bnd=0; bnd<mAllBonds; bnd++)
for (int i=0; i<2; i++)
if (mBondAtom[i][bnd] == atom)
mBondType[bnd] = cBondTypeDeleted; // mark for delete
int bonds = 0;
for (int j=0; j<mAllBonds; j++) {
if (j == bnd) continue;
if ((mBondAtom[0][j] == mBondAtom[1-i][bnd])
|| (mBondAtom[1][j] == mBondAtom[1-i][bnd]))
bonds++;
}
if (bonds == 0) {
removeMappingNo(mAtomMapNo[mBondAtom[1-i][bnd]]);
mAtomicNo[mBondAtom[1-i][bnd]] = -1;
} // mark for delete
}
}
}

removeMappingNo(mAtomMapNo[atom]);
mAtomicNo[atom] = -1; // mark for delete
if (mAtomList != null)
Expand Down
Loading

0 comments on commit bee7a71

Please sign in to comment.