Skip to content

Commit d229a44

Browse files
committed
Merge tag 'openchemlib-2024.1.3'
[maven-release-plugin] copy for tag openchemlib-2024.1.3
2 parents 9c51e6a + 1031689 commit d229a44

File tree

11 files changed

+111
-153
lines changed

11 files changed

+111
-153
lines changed

pom.xml

Lines changed: 5 additions & 6 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.1.1</version>
11+
<version>2024.1.3</version>
1212

1313
<name>OpenChemLib</name>
1414
<description>Open Source Chemistry Library</description>
@@ -20,8 +20,7 @@
2020
<developers>
2121
<developer>
2222
<name>Thomas Sander</name>
23-
<email>[email protected]</email>
24-
<organization>Idorsia Pharmaceuticals Ltd.</organization>
23+
<organization>Openmolecules.org</organization>
2524
</developer>
2625
<developer>
2726
<name>Christian Rufener</name>
@@ -33,8 +32,8 @@
3332
</developer>
3433
<developer>
3534
<name>Modest von Korff</name>
36-
<email>modest.korff@idorsia.com</email>
37-
<organization>Idorsia Pharmaceuticals Ltd.</organization>
35+
<email>modest.korff@alipheron.com</email>
36+
<organization>Alipheron AG</organization>
3837
</developer>
3938
</developers>
4039

@@ -210,7 +209,7 @@
210209
<connection>scm:git:[email protected]:Actelion/openchemlib.git</connection>
211210
<developerConnection>scm:git:[email protected]:Actelion/openchemlib.git</developerConnection>
212211
<url>https://github.com/Actelion/openchemlib</url>
213-
<tag>openchemlib-2024.1.1</tag>
212+
<tag>openchemlib-2024.1.3</tag>
214213
</scm>
215214

216215
<distributionManagement>

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

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -485,35 +485,36 @@ public static int getNumBytesEntry(){
485485
* @return
486486
*/
487487
public static List<PPNode> readNodes(String strMolDistHist){
488-
489488
int start = strMolDistHist.indexOf('(');
490-
491489
boolean nodesProcessed = false;
492-
493490
List<PPNode> liPPNode = new ArrayList<>();
494491
while(!nodesProcessed){
495-
496492
int end = StringFunctions.nextClosing(strMolDistHist, start, '(', ')');
497-
498493
if(end==-1){
499494
throw new RuntimeException("Error for MolDistHist " + strMolDistHist);
500495
}
501-
502496
String strNode = strMolDistHist.substring(start+1, end);
503-
504497
PPNode n = PPNode.read(strNode);
505-
506498
liPPNode.add(n);
507-
508499
start = strMolDistHist.indexOf('(', end);
509-
510500
if(start==-1){
511501
nodesProcessed = true;
512502
}
513503
}
514-
515504
return liPPNode;
516505
}
506+
public static MolDistHist readNodes2MDH(String strMolDistHist){
507+
508+
List<PPNode> liPPNode = readNodes(strMolDistHist);
509+
int size = liPPNode.size();
510+
MolDistHist mdh = new MolDistHist(size);
511+
for (PPNode ppNode : liPPNode) {
512+
mdh.addNode(ppNode);
513+
}
514+
return mdh;
515+
}
516+
517+
517518

518519
public static MolDistHist read(String strMolDistHist){
519520

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

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import com.actelion.research.util.ArrayUtils;
55
import com.actelion.research.util.ByteArray;
66

7-
import java.util.Arrays;
7+
import java.util.*;
88

99
public class MolDistHistHelper {
1010

@@ -64,6 +64,29 @@ public static MolDistHist assemble (MolDistHist ... arr){
6464

6565
return mdh;
6666
}
67+
public static MolDistHist assembleNoDistHist (MolDistHist ... arr){
68+
69+
int nNodesSum = 0;
70+
int maxNumNodes = 0;
71+
for (MolDistHist mdhFrag : arr) {
72+
int nNodes = mdhFrag.getNumPPNodes();
73+
nNodesSum += nNodes;
74+
if(nNodes>maxNumNodes)
75+
maxNumNodes=nNodes;
76+
}
77+
MolDistHist mdh = new MolDistHist(nNodesSum);
78+
int [] [] arrMapIndexNew = new int[arr.length][maxNumNodes];
79+
int indexNew = 0;
80+
for (int i = 0; i < arr.length; i++) {
81+
int n = arr[i].getNumPPNodes();
82+
for (int j = 0; j < n; j++) {
83+
arrMapIndexNew[i][j]=indexNew;
84+
indexNew++;
85+
mdh.addNode(arr[i].getNode(j));
86+
}
87+
}
88+
return mdh;
89+
}
6790
public static boolean isZero(byte [] b){
6891
boolean z=true;
6992
for (byte v : b) {
@@ -163,7 +186,36 @@ public static MolDistHist getMostDistantPairOfNodesOneHeteroAtom (MolDistHist md
163186
return mdhSub;
164187
}
165188

189+
public static boolean areNodesEqual(MolDistHist mdh1, MolDistHist mdh2){
190+
boolean eq = true;
191+
if(mdh1.getNumPPNodes() != mdh2.getNumPPNodes()){
192+
eq = false;
193+
} else {
194+
for (int i = 0; i < mdh1.getNumPPNodes(); i++) {
195+
if(!mdh1.getNode(i).equals(mdh2.getNode(i))){
196+
eq = false;
197+
break;
198+
}
199+
}
200+
}
201+
return eq;
202+
}
166203

204+
public static MolDistHist createFromNodes (Collection<PPNode> li){
205+
MolDistHist mdh = new MolDistHist(li.size());
206+
for (PPNode ppNode : li) {
207+
mdh.addNode(ppNode);
208+
}
209+
mdh.realize();
210+
return mdh;
211+
}
167212

213+
public static MolDistHist [] toArray(List<MolDistHist> li){
214+
MolDistHist [] a = new MolDistHist[li.size()];
215+
for (int i = 0; i < li.size(); i++) {
216+
a[i]=li.get(i);
217+
}
218+
return a;
219+
}
168220

169221
}

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

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import com.actelion.research.calc.ArrayUtilsCalc;
3939
import com.actelion.research.chem.descriptor.flexophore.generator.ConstantsFlexophoreGenerator;
4040
import com.actelion.research.chem.interactionstatistics.InteractionAtomTypeCalculator;
41+
import com.actelion.research.util.BurtleHasher;
4142

4243
import java.util.ArrayList;
4344
import java.util.Collections;
@@ -214,18 +215,19 @@ public boolean equals(Object o) {
214215
PPNode n = (PPNode)o;
215216
return equalAtoms(n);
216217
}
217-
218+
219+
@Override
220+
public int hashCode() {
221+
return BurtleHasher.hashlittle(arrInteractionType, 13);
222+
}
223+
218224
/**
219225
* May be called after finishing adding new interaction types.
220226
*/
221227
public void realize(){
222-
223228
int sizeBytes = size * getNumBytesEntry();
224-
225229
arrInteractionType = ArrayUtilsCalc.resize(arrInteractionType, sizeBytes);
226-
227230
sortInteractionTypes();
228-
229231
calcHasHeteroAtom();
230232
}
231233

@@ -611,10 +613,14 @@ public String toStringLongHardPPPoint(){
611613
/**
612614
*
613615
* @param strNode i.e. 262,392,4358*2,8582,590088,598407
614-
* @return
616+
* @return the node with the atom types. If an empty string is given a node without atom types is returned.
615617
*/
616618
public static PPNode read(String strNode) {
617619

620+
if(strNode.length()==0){
621+
return new PPNode();
622+
}
623+
618624
String [] arr = strNode.split(SEPARATOR_ATOMS);
619625

620626
PPNode n = new PPNode();

0 commit comments

Comments
 (0)