Skip to content

Commit 66a2646

Browse files
committed
Merge commit '384f58f59a4029b176d2b183323badb6543f2d77'
2 parents bee7a71 + 384f58f commit 66a2646

30 files changed

+483
-623
lines changed

pom.xml

+2-2
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.7.1</version>
11+
<version>2024.7.2-SNAPSHOT</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.7.1</tag>
212+
<tag>HEAD</tag>
213213
</scm>
214214

215215
<distributionManagement>

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

+28-26
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public void neglectSpaceDelimitedCoordinates() {
7575
* @return
7676
*/
7777
public StereoMolecule getCompactMolecule(String idcode) {
78-
return (idcode == null || idcode.length() == 0) ? null : getCompactMolecule(idcode.getBytes(StandardCharsets.UTF_8), null);
78+
return (idcode == null || idcode.isEmpty()) ? null : getCompactMolecule(idcode.getBytes(StandardCharsets.UTF_8), null);
7979
}
8080

8181
/**
@@ -151,7 +151,7 @@ public StereoMolecule getCompactMolecule(byte[] idcode, byte[] coordinates, int
151151
* @param idcode null or idcode, which may contain coordinates separated by a space character
152152
*/
153153
public void parse(StereoMolecule mol, String idcode) {
154-
if (idcode == null || idcode.length() == 0) {
154+
if (idcode == null || idcode.isEmpty()) {
155155
parse(mol, (byte[])null, (byte[])null);
156156
return;
157157
}
@@ -437,9 +437,10 @@ public void parse(StereoMolecule mol, byte[] idcode, byte[] coordinates, int idc
437437
int offset = 0;
438438
while (decodeBits(1) == 1) {
439439
int dataType = offset + decodeBits(4);
440+
int no;
440441
switch (dataType) {
441442
case 0: // datatype 'AtomQFNoMoreNeighbours'
442-
int no = decodeBits(abits);
443+
no = decodeBits(abits);
443444
for (int i=0; i<no; i++) {
444445
int atom = decodeBits(abits);
445446
mMol.setAtomQueryFeature(atom, Molecule.cAtomQFNoMoreNeighbours, true);
@@ -762,10 +763,10 @@ public void parse(StereoMolecule mol, byte[] idcode, byte[] coordinates, int idc
762763
from = 0;
763764
factor = 8.0;
764765
}
765-
mMol.setAtomX(atom, mMol.getAtomX(from) + factor * (decodeBits(resolutionBits) - binCount / 2));
766-
mMol.setAtomY(atom, mMol.getAtomY(from) + factor * (decodeBits(resolutionBits) - binCount / 2));
766+
mMol.setAtomX(atom, mMol.getAtomX(from) + factor * (decodeBits(resolutionBits) - binCount / 2.0));
767+
mMol.setAtomY(atom, mMol.getAtomY(from) + factor * (decodeBits(resolutionBits) - binCount / 2.0));
767768
if (coordsAre3D)
768-
mMol.setAtomZ(atom, mMol.getAtomZ(from) + factor * (decodeBits(resolutionBits) - binCount / 2));
769+
mMol.setAtomZ(atom, mMol.getAtomZ(from) + factor * (decodeBits(resolutionBits) - binCount / 2.0));
769770
}
770771

771772
if (coordinates[coordsStart] == '#') { // we have 3D-coordinates that include implicit hydrogen coordinates
@@ -781,10 +782,10 @@ public void parse(StereoMolecule mol, byte[] idcode, byte[] coordinates, int idc
781782
int hydrogen = mMol.addAtom(1);
782783
mMol.addBond(atom, hydrogen, Molecule.cBondTypeSingle);
783784

784-
mMol.setAtomX(hydrogen, mMol.getAtomX(atom) + (decodeBits(resolutionBits) - binCount / 2));
785-
mMol.setAtomY(hydrogen, mMol.getAtomY(atom) + (decodeBits(resolutionBits) - binCount / 2));
785+
mMol.setAtomX(hydrogen, mMol.getAtomX(atom) + (decodeBits(resolutionBits) - binCount / 2.0));
786+
mMol.setAtomY(hydrogen, mMol.getAtomY(atom) + (decodeBits(resolutionBits) - binCount / 2.0));
786787
if (coordsAre3D)
787-
mMol.setAtomZ(hydrogen, mMol.getAtomZ(atom) + (decodeBits(resolutionBits) - binCount / 2));
788+
mMol.setAtomZ(hydrogen, mMol.getAtomZ(atom) + (decodeBits(resolutionBits) - binCount / 2.0));
788789
}
789790
}
790791

@@ -935,10 +936,10 @@ public void parseCoordinates(byte[] encodedCoords, int coordsStart, StereoMolecu
935936
from = 0;
936937
factor = 8.0;
937938
}
938-
coords[atom].x = coords[from].x + factor * (decodeBits(resolutionBits) - binCount / 2);
939-
coords[atom].y = coords[from].y + factor * (decodeBits(resolutionBits) - binCount / 2);
939+
coords[atom].x = coords[from].x + factor * (decodeBits(resolutionBits) - binCount / 2.0);
940+
coords[atom].y = coords[from].y + factor * (decodeBits(resolutionBits) - binCount / 2.0);
940941
if (coordsAre3D)
941-
coords[atom].z = coords[from].z + factor * (decodeBits(resolutionBits) - binCount / 2);
942+
coords[atom].z = coords[from].z + factor * (decodeBits(resolutionBits) - binCount / 2.0);
942943
}
943944

944945
double avbl = coordsAre3D ? 1.5 : Molecule.getDefaultAverageBondLength();
@@ -954,10 +955,10 @@ public void parseCoordinates(byte[] encodedCoords, int coordsStart, StereoMolecu
954955
for (int atom = 0; atom < atomCount; atom++) {
955956
int hCount = mol.getAllConnAtoms(atom) - mol.getConnAtoms(atom);
956957
for (int i = 0; i < hCount; i++) {
957-
coords[hydrogen].x = coords[atom].x + (decodeBits(resolutionBits) - binCount / 2);
958-
coords[hydrogen].y = coords[atom].y + (decodeBits(resolutionBits) - binCount / 2);
958+
coords[hydrogen].x = coords[atom].x + (decodeBits(resolutionBits) - binCount / 2.0);
959+
coords[hydrogen].y = coords[atom].y + (decodeBits(resolutionBits) - binCount / 2.0);
959960
if (coordsAre3D)
960-
coords[hydrogen].z = coords[atom].z + (decodeBits(resolutionBits) - binCount / 2);
961+
coords[hydrogen].z = coords[atom].z + (decodeBits(resolutionBits) - binCount / 2.0);
961962

962963
hydrogen++;
963964
}
@@ -1072,7 +1073,7 @@ else if (coordinates[coordStart] == '!' || coordinates[coordStart] == '#') {
10721073
}
10731074

10741075
public int getIDCodeVersion(String idcode) {
1075-
if (idcode == null || idcode.length() == 0)
1076+
if (idcode == null || idcode.isEmpty())
10761077
return -1;
10771078

10781079
return getIDCodeVersion(idcode.getBytes(StandardCharsets.UTF_8));
@@ -1090,7 +1091,7 @@ public int getIDCodeVersion(byte[] idcode) {
10901091
}
10911092

10921093
public int getAtomCount(String idcode) {
1093-
if (idcode == null || idcode.length() == 0)
1094+
if (idcode == null || idcode.isEmpty())
10941095
return 0;
10951096

10961097
return getAtomCount(idcode.getBytes(StandardCharsets.UTF_8), 0);
@@ -1120,7 +1121,7 @@ public int getAtomCount(byte[] idcode, int offset) {
11201121
* @return int[] with atom and bond count as first and second values
11211122
*/
11221123
public int[] getAtomAndBondCounts(String idcode, int[] count) {
1123-
if (idcode == null || idcode.length() == 0)
1124+
if (idcode == null || idcode.isEmpty())
11241125
return null;
11251126

11261127
return getAtomAndBondCounts(idcode.getBytes(StandardCharsets.UTF_8), 0, count);
@@ -1192,7 +1193,7 @@ private double decodeShift(int value, int binCount) {
11921193
boolean isNegative = (value >= halfBinCount);
11931194
if (isNegative)
11941195
value -= halfBinCount;
1195-
double steepness = binCount/32;
1196+
double steepness = binCount/32.0;
11961197
double doubleValue = steepness * value / (halfBinCount - value);
11971198
return isNegative ? -doubleValue : doubleValue;
11981199
}
@@ -1366,9 +1367,10 @@ public void printContent(byte[] idcode, byte[] coordinates) {
13661367
int offset = 0;
13671368
while (decodeBits(1) == 1) {
13681369
int dataType = offset + decodeBits(4);
1370+
int no;
13691371
switch (dataType) {
13701372
case 0: // datatype 'AtomQFNoMoreNeighbours'
1371-
int no = decodeBits(abits);
1373+
no = decodeBits(abits);
13721374
System.out.print("noMoreNeighbours:");
13731375
for (int i = 0; i < no; i++)
13741376
System.out.print(" " + decodeBits(abits));
@@ -1675,12 +1677,12 @@ public void printContent(byte[] idcode, byte[] coordinates) {
16751677
factor = 8.0;
16761678
}
16771679
System.out.print(atom + " (");
1678-
coords[0][atom] = coords[0][from] + factor * (decodeBits(resolutionBits) - binCount / 2);
1680+
coords[0][atom] = coords[0][from] + factor * (decodeBits(resolutionBits) - binCount / 2.0);
16791681
System.out.print((int) coords[0][atom] + ",");
1680-
coords[1][atom] = coords[1][from] + factor * (decodeBits(resolutionBits) - binCount / 2);
1682+
coords[1][atom] = coords[1][from] + factor * (decodeBits(resolutionBits) - binCount / 2.0);
16811683
System.out.print((int) coords[1][atom]);
16821684
if (coordsAre3D) {
1683-
coords[2][atom] = coords[2][from] + factor * (decodeBits(resolutionBits) - binCount / 2);
1685+
coords[2][atom] = coords[2][from] + factor * (decodeBits(resolutionBits) - binCount / 2.0);
16841686
System.out.print("," + (int) coords[0][atom]);
16851687
}
16861688
System.out.print("), ");
@@ -1719,12 +1721,12 @@ public void printContent(byte[] idcode, byte[] coordinates) {
17191721
System.out.print(atom);
17201722
for (int i = 0; i < hCount[atom]; i++) {
17211723
System.out.print(" (");
1722-
coords[0][hydrogen] = coords[0][atom] + (decodeBits(resolutionBits) - binCount / 2);
1724+
coords[0][hydrogen] = coords[0][atom] + (decodeBits(resolutionBits) - binCount / 2.0);
17231725
System.out.print((int) coords[0][hydrogen] + ",");
1724-
coords[1][hydrogen] = coords[1][atom] + (decodeBits(resolutionBits) - binCount / 2);
1726+
coords[1][hydrogen] = coords[1][atom] + (decodeBits(resolutionBits) - binCount / 2.0);
17251727
System.out.print((int) coords[1][hydrogen]);
17261728
if (coordsAre3D) {
1727-
coords[2][hydrogen] = coords[2][atom] + (decodeBits(resolutionBits) - binCount / 2);
1729+
coords[2][hydrogen] = coords[2][atom] + (decodeBits(resolutionBits) - binCount / 2.0);
17281730
System.out.print("," + (int) coords[2][hydrogen]);
17291731
}
17301732
System.out.print("), ");

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

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public SmilesAtomParser(SmilesParser parser, int mode) {
2323
mParentParser = parser;
2424
mMode = mode;
2525
mAllowCactvs = (mode & SmilesParser.MODE_NO_CACTUS_SYNTAX) == 0;
26+
atomicNo = -1;
2627
charge = 0;
2728
mapNo = 0;
2829
abnormalValence = -1;

src/main/java/com/actelion/research/chem/descriptor/DescriptorHandlerFlexophore.java

-3
Original file line numberDiff line numberDiff line change
@@ -436,9 +436,7 @@ else if (includeNodeAtoms) {
436436
public MolDistHistViz createVisualDescriptor(StereoMolecule fragBiggest) {
437437

438438
MolDistHistViz mdhv = null;
439-
440439
recentException = null;
441-
442440
try {
443441
mdhv = creatorMolDistHistViz.create(fragBiggest);
444442
} catch (Exception e) {
@@ -453,7 +451,6 @@ public MolDistHistViz createVisualDescriptor(StereoMolecule fragBiggest) {
453451
recentException = e;
454452
}
455453
}
456-
457454
return mdhv;
458455
}
459456

src/main/java/com/actelion/research/chem/descriptor/flexophore/ConstantsFlexophore.java

+9
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,13 @@ public class ConstantsFlexophore {
1111

1212

1313
public static final String TAG_FLEXOPHORE_OBJECT = "FlexDecoded";
14+
15+
16+
17+
public static final int LABEL_WEIGHT_LOW = 0;
18+
public static final int LABEL_WEIGHT_NORMAL = 1;
19+
public static final int LABEL_WEIGHT_MANDATORY = 2;
20+
public static final double VAL_WEIGHT_LOW = 0.5;
21+
public static final double VAL_WEIGHT_NORMAL = 1;
22+
public static final double VAL_WEIGHT_MANDATORY = 2;
1423
}

src/main/java/com/actelion/research/chem/descriptor/flexophore/IMolDistHist.java

+5-3
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,11 @@ public interface IMolDistHist extends ICompleteGraph {
4444

4545
byte [] getDistHist(int indexAt1, int indexAt2, byte[] arr);
4646

47-
boolean isInevitablePharmacophorePoint(int indexNode);
48-
49-
int getNumInevitablePharmacophorePoints();
47+
boolean isMandatoryPharmacophorePoint(int indexNode);
48+
49+
double getWeightPharmacophorePoint(int indexNode);
50+
51+
int getNumMandatoryPharmacophorePoints();
5052

5153

5254
}

src/main/java/com/actelion/research/chem/descriptor/flexophore/MolDistHist.java

+6-3
Original file line numberDiff line numberDiff line change
@@ -452,16 +452,19 @@ public int getSizeBytes(){
452452
* Only for interface compliance needed.
453453
*/
454454
@Override
455-
public int getNumInevitablePharmacophorePoints() {
455+
public int getNumMandatoryPharmacophorePoints() {
456456
// TODO Auto-generated method stub
457457
return 0;
458458
}
459459

460460
@Override
461-
public boolean isInevitablePharmacophorePoint(int indexNode) {
462-
// TODO Auto-generated method stub
461+
public boolean isMandatoryPharmacophorePoint(int indexNode) {
463462
return false;
464463
}
464+
@Override
465+
public double getWeightPharmacophorePoint(int indexNode) {
466+
return 1.0;
467+
}
465468

466469
public static int getNumBytesEntry(){
467470
return PPNode.getNumBytesEntry()+1;

0 commit comments

Comments
 (0)