Skip to content

Commit

Permalink
Added topological Flexophore for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
korffmo committed Aug 21, 2024
1 parent deeb2cd commit 94e467b
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,7 @@ public final static boolean atomAtomSubStrucMatch(StereoMolecule molecule, int a
return arr;
}

public final static int getMedianTopologicalDistance(int [][] topoDistMatrix, int [] at1, int [] at2) {
public final static int [] getTopologicalDistances(int [][] topoDistMatrix, int [] at1, int [] at2) {

int [] d = new int[at1.length*at2.length];
int cc=0;
Expand All @@ -781,6 +781,11 @@ public final static int getMedianTopologicalDistance(int [][] topoDistMatrix, in
d[cc++]=topoDistMatrix[at1[i]][at2[j]];
}
}

return d;
}
public final static int getMedianTopologicalDistance(int [][] topoDistMatrix, int [] at1, int [] at2) {
int [] d = getTopologicalDistances(topoDistMatrix, at1, at2);
int medTopoDist = MedianStatisticFunctions.getMedianForInteger(d).median;
return medTopoDist;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,22 @@ public void apply(DistHist distHist){
// System.out.println("\n\n");
// System.out.println(StringFunctions.toStringShort(distHist.arrDistHists));
}

public byte [] getBlurred(byte [] hist){

byte [] histBlurred = new byte[ConstantsFlexophoreGenerator.BINS_HISTOGRAM];

int n = ConstantsFlexophoreGenerator.BINS_HISTOGRAM;
int end = n - lenFilHalf;

for (int k = lenFilHalf; k < end; k++) {
double v = 0;
for (int l = 0; l < arrFilter.length; l++) {
int ind = k - lenFilHalf + l;
v += hist[ind] * arrFilter[l];
}
histBlurred[k] = (byte)(v+0.5);
}
return histBlurred;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,7 @@ public void setBase(IMolDistHist iMolDistHistBase) {
}


if(!fragmentNodesMapping)
if((slidingWindowDistHist!=null) && !fragmentNodesMapping)
slidingWindowDistHist.apply(mdhvBaseBlurredHist);

nodesBase = iMolDistHistBase.getNumPPNodes();
Expand All @@ -851,7 +851,11 @@ public void setBase(IMolDistHist iMolDistHistBase) {

deltaNanoBaseBlur += System.nanoTime()-t0;
}


public void setSlidingWindowDistHistNull() {
this.slidingWindowDistHist = null;
}

public void setQuery(IMolDistHist iMolDistHistQuery) {

if(iMolDistHistQuery.getNumPPNodes()>=ConstantsFlexophore.MAX_NUM_NODES_FLEXOPHORE){
Expand All @@ -868,7 +872,7 @@ public void setQuery(IMolDistHist iMolDistHistQuery) {
mdhvQueryBlurredHist = new MolDistHistViz((MolDistHist) iMolDistHistQuery);
}

if(!fragmentNodesMapping)
if((slidingWindowDistHist!=null) && !fragmentNodesMapping)
slidingWindowDistHist.apply(mdhvQueryBlurredHist);

nodesQuery = iMolDistHistQuery.getNumPPNodes();
Expand Down Expand Up @@ -1153,10 +1157,13 @@ public float getSimilarityHistogram(int indexNode1Query, int indexNode2Query, in

if(arrSimilarityHistograms[indexHistogramQuery][indexHistogramBase] < 0){

float similarityHistogram =
float similarityHistogram = 0;

similarityHistogram =
(float)HistogramMatchCalculator.getSimilarity(
mdhvQueryBlurredHist, indexNode1Query, indexNode2Query, mdhvBaseBlurredHist, indexNode1Base, indexNode2Base);


arrSimilarityHistograms[indexHistogramQuery][indexHistogramBase]=similarityHistogram;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -515,11 +515,7 @@ public MolDistHistViz createFromGivenConformation(StereoMolecule molOrig) {
InteractionAtomTypeCalculator.setInteractionTypes(molStart);
Molecule3D molInPlace = new Molecule3D(molStart);
molInPlace.ensureHelperArrays(Molecule.cHelperRings);

List<SubGraphIndices> liSubGraphIndices = getSubGraphIndices(molInPlace);



List<MultCoordFragIndex> liMultCoordFragIndex = new ArrayList<>();
for (SubGraphIndices subGraphIndices : liSubGraphIndices) {
liMultCoordFragIndex.add(new MultCoordFragIndex(subGraphIndices.getAtomIndices()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -401,8 +401,9 @@ private boolean getNeighbourSolutions(SolutionCompleteGraph solution){
if(objectiveCompleteGraph.areNodesMapping(indexNodeQuery, indexNodeBase)){

SolutionCompleteGraph solutionNew = cm.getWithCopy(solution);

solutionNew.copyIntoThis(solution);

// to do: is this necessary?, no 21.08.2024
// solutionNew.copyIntoThis(solution);

solutionNew.setNodesQuery(nodesQuery);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,10 @@ public String toString() {

if(sizeHeap>0) {

for (int i = 0; i < sizeHeap; i++) {
sb.append(arrSolution[i]);
if(i < sizeHeap -1)
for (int i = 0; i < maxIndexNodeQuery+1; i++) {
if(sb.length()>0)
sb.append(" ");
sb.append(arrSolution[i]);
}

} else {
Expand Down

0 comments on commit 94e467b

Please sign in to comment.