Skip to content

Commit bee7a71

Browse files
committed
Merge tag 'openchemlib-2024.7.1'
[maven-release-plugin] copy for tag openchemlib-2024.7.1
2 parents 1067a3e + de1e462 commit bee7a71

38 files changed

+2657
-1128
lines changed

buildOpenChemLib

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ find . -name "*.java" > sources.txt
99
javac -target 8 -d ./build @sources.txt
1010
rm sources.txt
1111
jar -cf build/OpenChemLib.jar -C ./build .
12+
ls -al build/OpenChemLib.jar

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
Please follow the naming scheme YEAR.MONTH.RELEASE_NO_OF_MONTH
99
(eg. 2016.4.1 for second release in Apr 2016)
1010
-->
11-
<version>2024.5.1</version>
11+
<version>2024.7.1</version>
1212

1313
<name>OpenChemLib</name>
1414
<description>Open Source Chemistry Library</description>
@@ -209,7 +209,7 @@
209209
<connection>scm:git:[email protected]:Actelion/openchemlib.git</connection>
210210
<developerConnection>scm:git:[email protected]:Actelion/openchemlib.git</developerConnection>
211211
<url>https://github.com/Actelion/openchemlib</url>
212-
<tag>openchemlib-2024.5.1</tag>
212+
<tag>openchemlib-2024.7.1</tag>
213213
</scm>
214214

215215
<distributionManagement>

src/main/java/com/actelion/research/chem/DrawingObjectList.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,9 @@ public DrawingObjectList() {
4545
public DrawingObjectList(DrawingObjectList l) {
4646
super();
4747
try {
48-
if (l != null) {
49-
for (int i = 0; i < l.size(); i++)
50-
add((AbstractDrawingObject) l.get(i).clone());
51-
}
48+
if (l != null)
49+
for (AbstractDrawingObject abstractDrawingObject : l)
50+
add(abstractDrawingObject.clone());
5251
} catch (Exception e) {
5352
} finally {
5453

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

5857
public DrawingObjectList(String objectString) {
5958
super();
60-
if (objectString == null || objectString.length() == 0)
59+
if (objectString == null || objectString.isEmpty())
6160
return;
6261

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

7473
public String toString() {
75-
StringBuffer objectString = new StringBuffer();
76-
for (int i=0; i<size(); i++)
77-
objectString.append(get(i).getDescriptor()+"\n");
74+
StringBuilder objectString = new StringBuilder();
75+
for (AbstractDrawingObject abstractDrawingObject : this)
76+
objectString.append(abstractDrawingObject.getDescriptor()).append("\n");
7877
return objectString.toString();
7978
}
8079
}

src/main/java/com/actelion/research/chem/ExtendedMolecule.java

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -538,21 +538,37 @@ public int getConnAtom(int atom, int i) {
538538

539539
/**
540540
* The neighbours (connected atoms) of any atom are sorted by their relevance:<br>
541-
* 1. non-hydrogen atoms (bond order 1 and above) and unusual hydrogen atoms (non natural abundance isotops, custom labelled hydrogen, etc.)<br>
541+
* 1. non-hydrogen atoms (bond order 1 and above) and unusual hydrogen atoms (non-natural abundance isotops, custom labelled hydrogen, etc.)<br>
542+
* 2. plain-hydrogen atoms (natural abundance, bond order 1)<br>
543+
* 3. loosely connected atoms (bond order 0, i.e. metall ligand bond)<br>
544+
* Only valid after calling ensureHelperArrays(cHelperNeighbours or higher);
545+
* Note: This method includes neighbours marked as being part of an exclude group!
546+
* @param atom
547+
* @return count of category 1 neighbour atoms (excludes plain H and bond zero orders)
548+
*/
549+
public int getNotExcludedConnAtoms(int atom) {
550+
return mConnAtoms[atom] - getExcludedNeighbourCount(atom);
551+
}
552+
553+
554+
/**
555+
* The neighbours (connected atoms) of any atom are sorted by their relevance:<br>
556+
* 1. non-hydrogen atoms (bond order 1 and above) and unusual hydrogen atoms (non-natural abundance isotops, custom labelled hydrogen, etc.)<br>
542557
* 2. plain-hydrogen atoms (natural abundance, bond order 1)<br>
543558
* 3. loosely connected atoms (bond order 0, i.e. metall ligand bond)<br>
544559
* Only valid after calling ensureHelperArrays(cHelperNeighbours or higher);
560+
* Note: This method includes neighbours marked as being part of an exclude group!
545561
* @param atom
546562
* @return count of category 1 neighbour atoms (excludes plain H and bond zero orders)
547563
*/
548564
public int getConnAtoms(int atom) {
549565
return mConnAtoms[atom];
550-
}
566+
}
551567

552568

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

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

582598
/**
583599
* The neighbours (connected atoms) of any atom are sorted by their relevance:<br>
584-
* 1. non-hydrogen atoms (bond order 1 and above) and unusual hydrogen atoms (non natural abundance isotops, custom labelled hydrogen, etc.)<br>
600+
* 1. non-hydrogen atoms (bond order 1 and above) and unusual hydrogen atoms (non-natural abundance isotops, custom labelled hydrogen, etc.)<br>
585601
* 2. plain-hydrogen atoms (natural abundance, bond order 1)<br>
586602
* 3. loosely connected atoms (bond order 0, i.e. metall ligand bond)<br>
587603
* Only valid after calling ensureHelperArrays(cHelperNeighbours or higher);
@@ -616,13 +632,14 @@ public int getNonHydrogenNeighbourCount(int atom) {
616632
/**
617633
* This method returns the count of atom neighbours which are marked as being an exclude group.
618634
* @param atom
619-
* @return the number of non-hydrogen neighbor atoms
635+
* @return the number of non-hydrogen neighbor atoms marked as being part of an exclude group
620636
*/
621637
public int getExcludedNeighbourCount(int atom) {
622638
int count = 0;
623-
for (int i=0; i<mConnAtoms[atom]; i++)
624-
if ((mAtomQueryFeatures[mConnAtom[atom][i]] & Molecule.cAtomQFExcludeGroup) != 0)
625-
count++;
639+
if (mIsFragment)
640+
for (int i=0; i<mConnAtoms[atom]; i++)
641+
if ((mAtomQueryFeatures[mConnAtom[atom][i]] & Molecule.cAtomQFExcludeGroup) != 0)
642+
count++;
626643
return count;
627644
}
628645

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

17421759

17431760
public boolean isAromaticBond(int bond) {
1744-
return (bond < mBonds) ? mRingSet.isAromaticBond(bond) : false;
1761+
return bond<mBonds && mRingSet.isAromaticBond(bond);
17451762
}
17461763

17471764

17481765
public boolean isHeteroAromaticBond(int bond) {
1749-
return (bond < mBonds) ? mRingSet.isHeteroAromaticBond(bond) : false;
1766+
return bond<mBonds && mRingSet.isHeteroAromaticBond(bond);
17501767
}
17511768

17521769

@@ -3482,12 +3499,12 @@ public void ensureHelperArrays(int required) {
34823499
if ((mValidHelperArrays & cHelperBitNeighbours) == 0) {
34833500
handleHydrogens();
34843501
calculateNeighbours();
3485-
34863502
mValidHelperArrays |= cHelperBitNeighbours;
34873503

34883504
if (convertHydrogenToQueryFeatures()) {
34893505
handleHydrogens();
34903506
calculateNeighbours();
3507+
mValidHelperArrays |= cHelperBitNeighbours;
34913508
}
34923509
}
34933510

src/main/java/com/actelion/research/chem/Molecule.java

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,23 +1179,43 @@ public int[] addMolecule(Molecule mol) {
11791179
* @return atom mapping from original mol to this molecule after incorporation of mol
11801180
*/
11811181
public int[] addMolecule(Molecule mol, int atoms, int bonds) {
1182+
return addMolecule(mol, 0, atoms, 0, bonds);
1183+
}
1184+
1185+
1186+
/**
1187+
* Copies first atoms and first bonds of mol to the end of this Molecule's atom and bond
1188+
* tables. If mol is a fragment then this Molecule's fragment flag is set to true
1189+
* and all query features of mol are also copied. Typically, this is used to add a
1190+
* molecule without explicit hydrogen atoms. If parities of copied molecules are valid,
1191+
* then you may call setParitiesValid() on this molecule after adding molecules.
1192+
* High level function for constructing a molecule. Does not require any helper arrays.
1193+
* @param mol
1194+
* @param atom1 first atom to be copied
1195+
* @param atom2 1+last atom to be copied
1196+
* @param bond1 first bond to be copied
1197+
* @param bond2 one+last bond to be copied
1198+
* @return atom mapping from original mol to this molecule after incorporation of mol
1199+
*/
1200+
public int[] addMolecule(Molecule mol, int atom1, int atom2, int bond1, int bond2) {
11821201
mIsFragment |= mol.mIsFragment;
11831202

11841203
int[] atomMap = new int[mol.mAllAtoms];
11851204
int esrGroupCountAND = renumberESRGroups(cESRTypeAnd);
11861205
int esrGroupCountOR = renumberESRGroups(cESRTypeOr);
1187-
for (int atom=0; atom<atoms; atom++) {
1206+
for (int atom=atom1; atom<atom2; atom++) {
11881207
atomMap[atom] = mol.copyAtom(this, atom, esrGroupCountAND, esrGroupCountOR);
1189-
}
1190-
for (int bond=0; bond<bonds; bond++) {
1208+
}
1209+
for (int bond=bond1; bond<bond2; bond++) {
11911210
mol.copyBond(this, bond, esrGroupCountAND, esrGroupCountOR, atomMap, false);
1192-
}
1211+
}
11931212

11941213
mIsRacemate = (mIsRacemate && mol.mIsRacemate);
11951214
mChirality = cChiralityUnknown;
11961215
mValidHelperArrays = cHelperNone;
11971216
return atomMap;
1198-
}
1217+
}
1218+
11991219

12001220
/**
12011221
* Adds and connects the substituent molecule to the rootAtom of this molecule.
@@ -1655,24 +1675,11 @@ public void swapBonds(int bond1, int bond2) {
16551675
* @param atom
16561676
*/
16571677
public void deleteAtom(int atom) {
1658-
for (int bnd=0; bnd<mAllBonds; bnd++) {
1659-
for (int i=0; i<2; i++) {
1660-
if (mBondAtom[i][bnd] == atom) {
1678+
for (int bnd=0; bnd<mAllBonds; bnd++)
1679+
for (int i=0; i<2; i++)
1680+
if (mBondAtom[i][bnd] == atom)
16611681
mBondType[bnd] = cBondTypeDeleted; // mark for delete
1662-
int bonds = 0;
1663-
for (int j=0; j<mAllBonds; j++) {
1664-
if (j == bnd) continue;
1665-
if ((mBondAtom[0][j] == mBondAtom[1-i][bnd])
1666-
|| (mBondAtom[1][j] == mBondAtom[1-i][bnd]))
1667-
bonds++;
1668-
}
1669-
if (bonds == 0) {
1670-
removeMappingNo(mAtomMapNo[mBondAtom[1-i][bnd]]);
1671-
mAtomicNo[mBondAtom[1-i][bnd]] = -1;
1672-
} // mark for delete
1673-
}
1674-
}
1675-
}
1682+
16761683
removeMappingNo(mAtomMapNo[atom]);
16771684
mAtomicNo[atom] = -1; // mark for delete
16781685
if (mAtomList != null)

0 commit comments

Comments
 (0)