Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
thsa committed Sep 4, 2024
2 parents 9f1c588 + f60b78d commit 3c8e195
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 6 deletions.
2 changes: 1 addition & 1 deletion 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.8.3-SNAPSHOT</version>
<version>2024.8.5-SNAPSHOT</version>

<name>OpenChemLib</name>
<description>Open Source Chemistry Library</description>
Expand Down
13 changes: 10 additions & 3 deletions src/main/java/com/actelion/research/calc/ArrayUtilsCalc.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,12 @@ public class ArrayUtilsCalc {

public final static int [] cat(int [] a, int [] b) {
int [] c = new int [a.length + b.length];

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

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

return c;
}

Expand All @@ -80,6 +77,16 @@ public final static boolean contains(int [] a, int b) {
}
return bFound;
}
public final static boolean containsAll(int [] a, int [] b) {
boolean bFound = true;
for (int i = 0; i < b.length; i++) {
if(!contains(a, b[i])){
bFound=false;
break;
}
}
return bFound;
}

public final static int [] copy(int [] a) {
int [] b = new int [a.length];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.text.NumberFormat;
import java.util.Collection;
import java.util.Locale;
import java.util.Random;

Expand Down Expand Up @@ -83,6 +84,15 @@ public Histogram(double [] arrRaw, double min, double max, int bins) {
initialize(arrRaw,min,max,bins);
}

public Histogram(Collection<Double> values, double min, double max, int bins) {
double [] v = new double[values.size()];
int c=0;
for (Double value : values) {
v[c++]=value;
}
initialize(v,min,max,bins);
}

public Histogram(double [] arrRaw, int bins) {

double max = -Double.MAX_VALUE;
Expand All @@ -96,7 +106,6 @@ public Histogram(double [] arrRaw, int bins) {
min=v;
}
}

initialize(arrRaw,min,max,bins);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,14 @@ public void setNodeWeight(int indexNode, double weight){
}
arrWeight[indexNode]=weight;
}
public void resetNodeWeights(){
if(!finalized){
throw new RuntimeException("MolDistHistViz not finalized!");
}
for (int i = 0; i < liPPNodeViz.size(); i++) {
arrWeight[i]=1;
}
}

public void removeInevitablePharmacophorePoint(int indexPPNode){
hsIndexMandatoryPPPoints.remove(indexPPNode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ public class ObjectiveBlurFlexophoreHardMatchUncovered implements IObjectiveComp
// 03.03.2016 Top result so far for 0.9
// 13.04.2020 Maybe obsolete
// ToDo
final static double THRESH_NODE_SIMILARITY_START = 0.5;
// final static double THRESH_NODE_SIMILARITY_START = 0.5;

// Changed to 0.9 21.08.2024 MvK
final static double THRESH_NODE_SIMILARITY_START = 0.9;

private static final float INIT_VAL = -1;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,15 @@

package com.actelion.research.chem.descriptor.flexophore.generator;

import com.actelion.research.calc.ArrayUtilsCalc;
import com.actelion.research.calc.ThreadMaster;
import com.actelion.research.chem.*;
import com.actelion.research.chem.descriptor.DescriptorHandlerFlexophore;
import com.actelion.research.chem.descriptor.flexophore.*;
import com.actelion.research.chem.descriptor.flexophore.redgraph.SubGraphExtractor;
import com.actelion.research.chem.descriptor.flexophore.redgraph.SubGraphIndices;
import com.actelion.research.chem.interactionstatistics.InteractionAtomTypeCalculator;
import com.actelion.research.util.StringFunctions;

import java.util.*;

Expand Down Expand Up @@ -422,12 +424,61 @@ public static MolDistHistViz create(List<MultCoordFragIndex> liMultCoordFragInde

return molDistHistViz;

}

public void addFlexophoreDistanceHistograms(MolDistHistViz mdhv){
Molecule3D molecule = mdhv.getMolecule();

List<MultCoordFragIndex> liMultCoordFragIndex = new ArrayList<>();
for (PPNodeViz node : mdhv.getNodes()) {
liMultCoordFragIndex.add(new MultCoordFragIndex(node.getArrayIndexOriginalAtoms()));
}
conformerGeneratorStageTries.setMolecule(molecule);
int ccConformationsGenerated=0;
for (int i = 0; i < DescriptorHandlerFlexophore.NUM_CONFORMATIONS; i++) {
boolean conformerGenerated = false;
try {
conformerGenerated = conformerGeneratorStageTries.generateConformerAndSetCoordinates(molecule.getAtoms(), molecule);
} catch (ExceptionTimeOutConformerGeneration e) {
System.err.println(
"CreatorMolDistHistViz: ExceptionTimeOutConformerGeneration for idcode " + molecule.getIDCode( )+ ", hence generated " + ccConformationsGenerated + " conformers.");
// e.printStackTrace();
break;
}

if(!conformerGenerated){
break;
}
ccConformationsGenerated++;
calcFragmentCenter(molecule, liMultCoordFragIndex);

}

for (int i = 0; i < liMultCoordFragIndex.size(); i++) {
for (int j = i+1; j < liMultCoordFragIndex.size(); j++) {
byte [] arrDistHist = MultCoordFragIndex.getDistHist(liMultCoordFragIndex.get(i), liMultCoordFragIndex.get(j));
// System.out.println(StringFunctions.toString(arrDistHist));
mdhv.setDistHist(i,j,arrDistHist);
}
}

}
public MolDistHistViz createWithoutCoordinates(Molecule3D molecule3D){
InteractionAtomTypeCalculator.setInteractionTypes(molecule3D);
List<SubGraphIndices> sgis = getSubGraphIndices(molecule3D);
return createWithoutCoordinates(sgis, molecule3D);
}
public MolDistHistViz createWithoutCoordinates(Molecule3D molecule3D, int [] indices2consider){
InteractionAtomTypeCalculator.setInteractionTypes(molecule3D);
List<SubGraphIndices> sgis = getSubGraphIndices(molecule3D);
List<SubGraphIndices> sgis2consider = new ArrayList<>();
for (SubGraphIndices sgi : sgis) {
if(ArrayUtilsCalc.containsAll(indices2consider, sgi.getAtomIndices())) {
sgis2consider.add(sgi);
}
}
return createWithoutCoordinates(sgis2consider, molecule3D);
}


public static MolDistHistViz createWithoutCoordinates(List<SubGraphIndices> liMultCoordFragIndex, Molecule3D molecule3D){
Expand Down

0 comments on commit 3c8e195

Please sign in to comment.