diff --git a/src/main/java/com/actelion/research/chem/descriptor/flexophore/ConstantsFlexophore.java b/src/main/java/com/actelion/research/chem/descriptor/flexophore/ConstantsFlexophore.java index 95bb58a6..bc360549 100644 --- a/src/main/java/com/actelion/research/chem/descriptor/flexophore/ConstantsFlexophore.java +++ b/src/main/java/com/actelion/research/chem/descriptor/flexophore/ConstantsFlexophore.java @@ -11,4 +11,13 @@ public class ConstantsFlexophore { public static final String TAG_FLEXOPHORE_OBJECT = "FlexDecoded"; + + + + public static final int LABEL_LOW = 0; + public static final int LABEL_NORMAL = 1; + public static final int LABEL_MANDATORY = 2; + public static final double VAL_WEIGHT_LOW = 0.5; + public static final double VAL_WEIGHT_NORMAL = 1; + public static final double VAL_WEIGHT_MANDATORY = 2; } diff --git a/src/main/java/com/actelion/research/chem/descriptor/flexophore/IMolDistHist.java b/src/main/java/com/actelion/research/chem/descriptor/flexophore/IMolDistHist.java index 27495889..6a86d7db 100644 --- a/src/main/java/com/actelion/research/chem/descriptor/flexophore/IMolDistHist.java +++ b/src/main/java/com/actelion/research/chem/descriptor/flexophore/IMolDistHist.java @@ -44,11 +44,11 @@ public interface IMolDistHist extends ICompleteGraph { byte [] getDistHist(int indexAt1, int indexAt2, byte[] arr); - boolean isInevitablePharmacophorePoint(int indexNode); + boolean isMandatoryPharmacophorePoint(int indexNode); double getWeightPharmacophorePoint(int indexNode); - int getNumInevitablePharmacophorePoints(); + int getNumMandatoryPharmacophorePoints(); } diff --git a/src/main/java/com/actelion/research/chem/descriptor/flexophore/MolDistHist.java b/src/main/java/com/actelion/research/chem/descriptor/flexophore/MolDistHist.java index c33af385..37ba19d7 100644 --- a/src/main/java/com/actelion/research/chem/descriptor/flexophore/MolDistHist.java +++ b/src/main/java/com/actelion/research/chem/descriptor/flexophore/MolDistHist.java @@ -452,13 +452,13 @@ public int getSizeBytes(){ * Only for interface compliance needed. */ @Override - public int getNumInevitablePharmacophorePoints() { + public int getNumMandatoryPharmacophorePoints() { // TODO Auto-generated method stub return 0; } @Override - public boolean isInevitablePharmacophorePoint(int indexNode) { + public boolean isMandatoryPharmacophorePoint(int indexNode) { return false; } @Override diff --git a/src/main/java/com/actelion/research/chem/descriptor/flexophore/MolDistHistViz.java b/src/main/java/com/actelion/research/chem/descriptor/flexophore/MolDistHistViz.java index c11d01d8..3196ee08 100644 --- a/src/main/java/com/actelion/research/chem/descriptor/flexophore/MolDistHistViz.java +++ b/src/main/java/com/actelion/research/chem/descriptor/flexophore/MolDistHistViz.java @@ -91,7 +91,8 @@ public class MolDistHistViz extends DistHist implements Serializable, IMolDistHi "yellow"}; private List liPPNodeViz; - + + // Contains the pharmacophore points protected Molecule3D molecule3D; private int flagsDescribe; @@ -103,7 +104,7 @@ public class MolDistHistViz extends DistHist implements Serializable, IMolDistHi private boolean finalized; - private HashSet hsIndexInevitablePPPoints; + private HashSet hsIndexMandatoryPPPoints; private double [] arrWeight; // List of the original distance table generated by the conformations. @@ -114,54 +115,36 @@ public class MolDistHistViz extends DistHist implements Serializable, IMolDistHi public MolDistHistViz() { super(); - molecule3D = null; - flagsDescribe = DESCRIBE_ALL; - liPPNodeViz = new ArrayList<>(); - - hsIndexInevitablePPPoints = new HashSet<>(); - + hsIndexMandatoryPPPoints = new HashSet<>(); modeFlexophore = ConstantsFlexophore.MODE_SOFT_PPPOINTS; - } public MolDistHistViz(int nNodes) { initHistogramArray(nNodes); - flagsDescribe = DESCRIBE_ALL; - - hsIndexInevitablePPPoints = new HashSet<>(); - + hsIndexMandatoryPPPoints = new HashSet<>(); modeFlexophore = ConstantsFlexophore.MODE_SOFT_PPPOINTS; } public MolDistHistViz(int nNodes, Molecule3D molecule3D) { initHistogramArray(nNodes); - flagsDescribe = DESCRIBE_ALL; - if(molecule3D!=null) { this.molecule3D = new Molecule3D(molecule3D); this.molecule3D.ensureHelperArrays(Molecule.cHelperRings); } - - hsIndexInevitablePPPoints = new HashSet<>(); - + hsIndexMandatoryPPPoints = new HashSet<>(); modeFlexophore = ConstantsFlexophore.MODE_SOFT_PPPOINTS; } public MolDistHistViz(MolDistHistViz mdhv) { - - hsIndexInevitablePPPoints = new HashSet(); - + hsIndexMandatoryPPPoints = new HashSet(); mdhv.copy(this); - flagsDescribe = DESCRIBE_ALL; - modeFlexophore = mdhv.modeFlexophore; - } public MolDistHistViz(MolDistHist mdh) { @@ -175,7 +158,7 @@ public MolDistHistViz(MolDistHist mdh) { PPNodeViz node = new PPNodeViz(mdh.getNode(i)); liPPNodeViz.add(node); } - hsIndexInevitablePPPoints = new HashSet<>(); + hsIndexMandatoryPPPoints = new HashSet<>(); realize(); } @@ -183,8 +166,8 @@ public static void createIndexTables(){ indexTables = MDHIndexTables.getInstance(); } - public void addInevitablePharmacophorePoint(int indexPPNode){ - hsIndexInevitablePPPoints.add(indexPPNode); + public void addMandatoryPharmacophorePoint(int indexPPNode){ + hsIndexMandatoryPPPoints.add(indexPPNode); } public void setNodeWeight(int indexNode, double weight){ @@ -195,7 +178,7 @@ public void setNodeWeight(int indexNode, double weight){ } public void removeInevitablePharmacophorePoint(int indexPPNode){ - hsIndexInevitablePPPoints.remove(indexPPNode); + hsIndexMandatoryPPPoints.remove(indexPPNode); } public void setModeFlexophore(byte modeFlexophore) { @@ -225,21 +208,14 @@ public boolean isMarked(int index){ * @return index of the node. */ public int addNode(PPNodeViz node) { - int index = liPPNodeViz.size(); - node.setIndex(liPPNodeViz.size()); - node.setModeFlexophore(modeFlexophore); - liPPNodeViz.add(node); - if(liPPNodeViz.size()>getNumPPNodes()){ throw new RuntimeException("To many nodes added!"); } - finalized = false; - return index; } @@ -264,11 +240,8 @@ public boolean check(){ protected void initHistogramArray(int size) { super.initHistogramArray(size); - liPPNodeViz = new ArrayList<>(); - finalized = false; - } public MolDistHistViz copy(){ @@ -280,35 +253,24 @@ public MolDistHistViz copy(){ * @param copy This is written into copy. */ public void copy(MolDistHistViz copy){ - super.copy(copy); - copy.flagsDescribe = flagsDescribe; - if(molecule3D !=null) copy.molecule3D = new Molecule3D(molecule3D); copy.liPPNodeViz = new ArrayList(); - for (int i = 0; i < liPPNodeViz.size(); i++) { copy.liPPNodeViz.add(new PPNodeViz(liPPNodeViz.get(i))); } // Exclusive C nodes copy.numCNodes=numCNodes; - copy.numHeteroNodes=numHeteroNodes; - copy.finalized=finalized; - - copy.hsIndexInevitablePPPoints.clear(); - - copy.hsIndexInevitablePPPoints.addAll(hsIndexInevitablePPPoints); - + copy.hsIndexMandatoryPPPoints.clear(); + copy.hsIndexMandatoryPPPoints.addAll(hsIndexMandatoryPPPoints); copy.arrWeight = new double[this.arrWeight.length]; - System.arraycopy(this.arrWeight, 0, copy.arrWeight, 0, this.arrWeight.length); - } /** @@ -316,20 +278,14 @@ public void copy(MolDistHistViz copy){ * Has to be called after changing the coordinates for the Molecule3D. */ public void recalculateCoordPPPoints(){ - for (PPNodeViz ppNodeViz : liPPNodeViz) { - List liIndexAts = ppNodeViz.getListIndexOriginalAtoms(); - int [] arrAtIndex = new int [liIndexAts.size()]; - for (int i = 0; i < arrAtIndex.length; i++) { arrAtIndex[i]=liIndexAts.get(i); } - Coordinates [] arrCoordinates = new Coordinates [arrAtIndex.length]; for (int i = 0; i < arrAtIndex.length; i++) { - double x = molecule3D.getAtomX(arrAtIndex[i]); double y = molecule3D.getAtomY(arrAtIndex[i]); double z = molecule3D.getAtomZ(arrAtIndex[i]); @@ -340,22 +296,17 @@ public void recalculateCoordPPPoints(){ Coordinates coordCenter = Coordinates.createBarycenter(arrCoordinates); ppNodeViz.setCoordinates(coordCenter.x, coordCenter.y, coordCenter.z); } - } public void resetInevitablePharmacophorePoints(){ - hsIndexInevitablePPPoints.clear(); + hsIndexMandatoryPPPoints.clear(); } public void resetInfoColor(){ - int size = getNumPPNodes(); - for (int i = 0; i < size; i++) { - PPNodeViz node = getNode(i); - node.resetInfoColor(); } } @@ -386,30 +337,23 @@ public int getBondAtom(int index, int bond) { public int getConnAtom(int at, int index) { if(index >= at) index++; - return index; - } public int getConnBond(int at, int index) { return indexTables.getConnectionTable(getNumPPNodes())[at][index]; - } public int getIndexFromCoord(double x, double y, double z) { int index = -1; - Coordinates c = new Coordinates(x, y, z); - for (int i = 0; i < getNumPPNodes(); i++) { PPNodeViz ppNodeViz = getNode(i); - if(ppNodeViz.getCoordinates().equals(c)){ index = i; break; } } - return index; } @@ -428,7 +372,6 @@ public PPNodeViz getNode(int i){ public List getNodes(){ return liPPNodeViz; } - public void set(List liPPNodeViz) { this.liPPNodeViz = liPPNodeViz; @@ -505,7 +448,6 @@ public void canonize(){ for (int i = 0; i < liPPNodeViz.size(); i++) { liPPNodeViz.get(i).setIndex(i); } - } private int compareNodes(int n1, int n2){ @@ -611,23 +553,23 @@ public int getNumHeteroNodes(){ public List getInevitablePharmacophorePoints(){ - List li = new ArrayList(hsIndexInevitablePPPoints); + List li = new ArrayList(hsIndexMandatoryPPPoints); return li; } protected HashSet getHashSetIndexInevitablePPPoints() { - return hsIndexInevitablePPPoints; + return hsIndexMandatoryPPPoints; } - public int getNumInevitablePharmacophorePoints(){ - return hsIndexInevitablePPPoints.size(); + public int getNumMandatoryPharmacophorePoints(){ + return hsIndexMandatoryPPPoints.size(); } - public boolean isInevitablePharmacophorePoint(int indexNode){ + public boolean isMandatoryPharmacophorePoint(int indexNode){ - return hsIndexInevitablePPPoints.contains(indexNode); + return hsIndexMandatoryPPPoints.contains(indexNode); } @Override public double getWeightPharmacophorePoint(int indexNode) { @@ -678,28 +620,18 @@ public boolean isAcceptor(int indexNode) { } public boolean isDonor(int indexNode) { - boolean donor = false; - PPNodeViz node = getNode(indexNode); - if(modeFlexophore==ConstantsFlexophore.MODE_HARD_PPPOINTS){ - if(IPharmacophorePoint.Functionality.DONOR.getIndex()==node.get()[0]){ donor=true; } - } else { List liIndexAtom = node.getListIndexOriginalAtoms(); - StereoMolecule mol = new Molecule3D(molecule3D); - mol.ensureHelperArrays(Molecule.cHelperRings); - for (int indexAtom : liIndexAtom) { - if (mol.getAtomicNo(indexAtom) == 8 || mol.getAtomicNo(indexAtom) == 7) { - if (mol.getAllHydrogens(indexAtom) > 0) { donor = true; break; @@ -707,52 +639,41 @@ public boolean isDonor(int indexNode) { } } } - return donor; } public boolean isAromatic(int indexNode) { boolean aromatic = false; - PPNodeViz node = getNode(indexNode); - if(modeFlexophore==ConstantsFlexophore.MODE_HARD_PPPOINTS){ if(IPharmacophorePoint.Functionality.AROM_RING.getIndex()==node.get()[0]){ aromatic=true; } } - return aromatic; } public boolean isChargePos(int indexNode) { - boolean charge = false; - PPNodeViz node = getNode(indexNode); - if(modeFlexophore==ConstantsFlexophore.MODE_HARD_PPPOINTS){ if(IPharmacophorePoint.Functionality.POS_CHARGE.getIndex()==node.get()[0]){ charge=true; } } - return charge; } public boolean isChargeNeg(int indexNode) { boolean charge = false; - PPNodeViz node = getNode(indexNode); - if(modeFlexophore==ConstantsFlexophore.MODE_HARD_PPPOINTS){ if(IPharmacophorePoint.Functionality.NEG_CHARGE.getIndex()==node.get()[0]){ charge=true; } } - return charge; } @@ -795,9 +716,7 @@ public void blurrSingleBinHistograms(){ for (int j = 0; j < size; j++) { if(i==j) continue; - arr = getDistHist(i, j, arr); - int occupied=0; int counts=0; for (int k = 0; k < arr.length; k++) { @@ -806,20 +725,14 @@ public void blurrSingleBinHistograms(){ counts+=arr[k]; } } - if(occupied==1){ if( counts >= MIN_COUNTS_BLURR){ blurrSingleBinHistogram(arr); - setDistHist(i, j, arr); } } - - } } - - } private void blurrSingleBinHistogram(byte [] arr){ @@ -895,39 +808,30 @@ protected static Molecule3D finalizeMolecule(Molecule3D mol) { public MolDistHist getMolDistHist(){ realize(); - int nPPNodes = getNumPPNodes(); - MolDistHist mdh = new MolDistHist(nPPNodes); - for (int i = 0; i < nPPNodes; i++) { mdh.addNode(getNode(i)); } - for (int i = 0; i < nPPNodes ; i++) { for (int j = i+1; j < nPPNodes ; j++) { mdh.setDistHist(i, j, getDistHist(i,j)); } } - return mdh; } public double getMaximumDistanceInPPPoint(int indexNode) { double maxDist = 0; - PPNodeViz node = getNode(indexNode); - List liIndexAtom = node.getListIndexOriginalAtoms(); - List liCoord = new ArrayList(); for (int atom : liIndexAtom) { Coordinates coord = molecule3D.getCoordinates(atom); liCoord.add(coord); } - - + for (int i = 0; i < liCoord.size(); i++) { Coordinates c1 = liCoord.get(i); for (int j = i+1; j < liCoord.size(); j++) { @@ -940,7 +844,6 @@ public double getMaximumDistanceInPPPoint(int indexNode) { } } } - return maxDist; } @@ -949,10 +852,8 @@ public double getMaximumDistanceInPPPoint(int indexNode) { * @return */ public Molecule3D getMolecule() { - if(molecule3D == null) return null; - return molecule3D; } @@ -966,16 +867,10 @@ public Molecule3D getMoleculeRemovedUnrelatedAtoms() { PPNodeViz node = (PPNodeViz)getNode(i); List liOriginalIndex = node.getListIndexOriginalAtoms(); hsIndexUnique.addAll(liOriginalIndex); - -// int indAtom = ff.addAtom(26); -// ff.setCoordinates(indAtom, node.getCoordinates()); -// ff.addBond(indAtom, liOriginalIndex.get(0), Molecule.cBondTypeSingle); -// hsIndexUnique.add(indAtom); } List liInd = new ArrayList(hsIndexUnique); - - + HashSet hsIndexOnPath = new HashSet(); for (int i = 0; i < liInd.size(); i++) { for (int j = i+1; j < liInd.size(); j++) { @@ -1008,11 +903,11 @@ public String toStringInevitable() { StringBuilder sb = new StringBuilder(); sb.append("Index inevitable "); - for (int index : hsIndexInevitablePPPoints) { + for (int index : hsIndexMandatoryPPPoints) { sb.append(index + " "); } sb.append("\n"); - sb.append("Num inevitable " + hsIndexInevitablePPPoints.size()); + sb.append("Num inevitable " + hsIndexMandatoryPPPoints.size()); return sb.toString(); } @@ -1055,49 +950,36 @@ public String toString(){ * @return */ public String toStringNodesText(){ - if(!finalized) realize(); - StringBuffer b = new StringBuffer(); - b.append("["); for (int i = 0; i < getNumPPNodes(); i++) { - PPNodeViz ppNodeViz = getNode(i); - b.append(ppNodeViz.toString()); - if(i liDistanceTable){ for (double[][] ds : liDistanceTable) { float [][] arrDT = new float [ds.length][ds.length]; - for (int i = 0; i < ds.length; i++) { for (int j = 0; j < ds.length; j++) { arrDT[i][j]=(float)ds[i][j]; } } - this.liDistanceTable.add(arrDT); - } } @@ -1221,27 +1092,19 @@ public void setDistanceTables(List liDistanceTable){ public List getDistanceTables() { return liDistanceTable; } - - - protected static String formatDescription(String s){ - StringTokenizer st = new StringTokenizer(s, ","); - HashSet set = new HashSet(); while(st.hasMoreTokens()) { String tok = st.nextToken().trim(); if(!set.contains(tok)){ set.add(tok); } - } List li = new ArrayList(set); - Collections.sort(li); - StringBuilder sb = new StringBuilder(); for (int i = 0; i < li.size(); i++) { if(i>0 && i < li.size()-1){ @@ -1298,29 +1161,17 @@ public static MolDistHistViz summarizeAlkaneCluster(MolDistHistViz mdh, int maxD for (int i = 0; i < liCluster.size(); i++) { ClusterNode cluster = liCluster.get(i); - PPNodeViz nodeCenter = mdh.getNode(cluster.getIndexCenter()); - List liIndexClusterNode = cluster.getClusterMember(); - for (int j = liIndexClusterNode.size()-1; j >= 0; j--) { - PPNode node = mdh.getNode(liIndexClusterNode.get(j)); - if(node.isCarbonExclusiveNode()) { - liIndexNode.remove(liIndexClusterNode.get(j)); - int sizeNode = node.getInteractionTypeCount(); - boolean added=false; - for (int k = 0; k < sizeNode; k++) { - int interactionIdNode = node.getInteractionType(k); - if(!nodeCenter.containsInteractionID(interactionIdNode)) { - nodeCenter.add(interactionIdNode); added=true; } @@ -1345,30 +1196,19 @@ public static MolDistHistViz summarizeAlkaneCluster(MolDistHistViz mdh, int maxD if(mdh.getDistanceTables() != null){ List liDistanceArrayNodes = mdh.getDistanceTables(); - List liDistanceArrayNodesSummary = new ArrayList(); - for (float[][] arrDistanceNodes : liDistanceArrayNodes) { - float[][] arrDistanceNodesSummary = new float [liIndexNode.size()][liIndexNode.size()]; - for (int i = 0; i < liIndexNode.size(); i++) { for (int j = 0; j < liIndexNode.size(); j++) { arrDistanceNodesSummary[i][j]=arrDistanceNodes[liIndexNode.get(i)][liIndexNode.get(j)]; } } - liDistanceArrayNodesSummary.add(arrDistanceNodesSummary); } - mdhSummary.liDistanceTable = liDistanceArrayNodesSummary; } - - mdhSummary.realize(); - return mdhSummary; } - - -} +} \ No newline at end of file diff --git a/src/main/java/com/actelion/research/chem/descriptor/flexophore/MolDistHistVizEncoder.java b/src/main/java/com/actelion/research/chem/descriptor/flexophore/MolDistHistVizEncoder.java index 559f97f1..84f7020b 100644 --- a/src/main/java/com/actelion/research/chem/descriptor/flexophore/MolDistHistVizEncoder.java +++ b/src/main/java/com/actelion/research/chem/descriptor/flexophore/MolDistHistVizEncoder.java @@ -142,7 +142,7 @@ public MolDistHistViz readEncoded(String vizinfo, String flexophore){ byte [] arrIndexInevitablePPPoints = de.decodeCounts(strInevitablePPPoints); for (int i = 0; i < arrIndexInevitablePPPoints.length; i++) { - mdhv.addInevitablePharmacophorePoint(arrIndexInevitablePPPoints[i]); + mdhv.addMandatoryPharmacophorePoint(arrIndexInevitablePPPoints[i]); } } diff --git a/src/main/java/com/actelion/research/chem/descriptor/flexophore/MolDistHistVizHelper.java b/src/main/java/com/actelion/research/chem/descriptor/flexophore/MolDistHistVizHelper.java index 3e069a07..c4aa799e 100644 --- a/src/main/java/com/actelion/research/chem/descriptor/flexophore/MolDistHistVizHelper.java +++ b/src/main/java/com/actelion/research/chem/descriptor/flexophore/MolDistHistVizHelper.java @@ -1,8 +1,10 @@ package com.actelion.research.chem.descriptor.flexophore; import com.actelion.research.chem.Coordinates; +import com.actelion.research.chem.Molecule; import com.actelion.research.chem.Molecule3D; import com.actelion.research.chem.descriptor.flexophore.generator.MultCoordFragIndex; +import com.actelion.research.util.ArrayUtils; import java.util.ArrayList; import java.util.List; @@ -62,4 +64,36 @@ public static MolDistHistViz create(List liPPNodeVizMultCoor } + public static void setWeights(MolDistHistViz mdhv, int [] arrWeight){ + + // The molecule in the descriptor contains the pharmacophore points as additional single atoms. + Molecule3D m3D = new Molecule3D(mdhv.getMolecule()); + m3D.ensureHelperArrays(Molecule.cHelperRings); + m3D.stripSmallFragments(); + + if(m3D.getAtoms()!=arrWeight.length){ + throw new RuntimeException("Weight vector differs in dimension to number of atoms!"); + } + + for (PPNodeViz ppNodeViz : mdhv.getNodes()) { + int [] a = ppNodeViz.getArrayIndexOriginalAtoms(); + int [] w = new int[a.length]; + for (int i = 0; i < a.length; i++) { + w[i]=arrWeight[a[i]]; + } + int maxWeight = ArrayUtils.max(w); + if(ConstantsFlexophore.LABEL_MANDATORY==maxWeight){ + mdhv.addMandatoryPharmacophorePoint(ppNodeViz.getIndex()); + mdhv.setNodeWeight(ppNodeViz.getIndex(), ConstantsFlexophore.VAL_WEIGHT_MANDATORY); + } else if(ConstantsFlexophore.LABEL_LOW==maxWeight){ + mdhv.setNodeWeight(ppNodeViz.getIndex(), ConstantsFlexophore.VAL_WEIGHT_LOW); + } + +// System.out.println(ArrayUtils.toString(a)); +// System.out.println(ArrayUtils.toString(w)); +// System.out.println(); +// + } + + } } diff --git a/src/main/java/com/actelion/research/chem/descriptor/flexophore/MolDistHistVizHiddenPPPoints.java b/src/main/java/com/actelion/research/chem/descriptor/flexophore/MolDistHistVizHiddenPPPoints.java index 053ff445..1ad87a39 100644 --- a/src/main/java/com/actelion/research/chem/descriptor/flexophore/MolDistHistVizHiddenPPPoints.java +++ b/src/main/java/com/actelion/research/chem/descriptor/flexophore/MolDistHistVizHiddenPPPoints.java @@ -108,13 +108,13 @@ private void hidden2Map(){ } - public void addInevitablePharmacophorePoint(int indexNodeAbsolute){ + public void addMandatoryPharmacophorePoint(int indexNodeAbsolute){ if(isHiddenPharmacophorePointAbsolute((byte)indexNodeAbsolute)) { removeHiddenPharmacophorePoint((byte)indexNodeAbsolute); } - super.addInevitablePharmacophorePoint(indexNodeAbsolute); + super.addMandatoryPharmacophorePoint(indexNodeAbsolute); } @@ -168,7 +168,7 @@ public PPNodeViz getNodeSkipHidden(int indexNode) { } public boolean isInevitablePharmacophorePointSkipHidden(int indexNode) { - return super.isInevitablePharmacophorePoint(arrMapHiddenPPPoints[indexNode]); + return super.isMandatoryPharmacophorePoint(arrMapHiddenPPPoints[indexNode]); } public int getNumInevitablePharmacophorePointsSkipHidden() { @@ -213,7 +213,7 @@ public boolean isHiddenPharmacophorePointAbsolute(byte indexNodeAbsolute) { } public boolean isInevitablePharmacophorePointAbsolute(int indexNodeAbsolute) { - return super.isInevitablePharmacophorePoint(indexNodeAbsolute); + return super.isMandatoryPharmacophorePoint(indexNodeAbsolute); } @@ -243,7 +243,7 @@ public MolDistHistViz getMolDistHistVizSkipHidden(){ int indexNNew = mdhv.addNode(node); if(isInevitablePharmacophorePointAbsolute(i)){ - mdhv.addInevitablePharmacophorePoint(indexNNew); + mdhv.addMandatoryPharmacophorePoint(indexNNew); } // System.out.println(i + " " + node.toString()); diff --git a/src/main/java/com/actelion/research/chem/descriptor/flexophore/completegraphmatcher/ObjectiveBlurFlexophoreHardMatchUncovered.java b/src/main/java/com/actelion/research/chem/descriptor/flexophore/completegraphmatcher/ObjectiveBlurFlexophoreHardMatchUncovered.java index 43b5e9ee..4823d5a4 100644 --- a/src/main/java/com/actelion/research/chem/descriptor/flexophore/completegraphmatcher/ObjectiveBlurFlexophoreHardMatchUncovered.java +++ b/src/main/java/com/actelion/research/chem/descriptor/flexophore/completegraphmatcher/ObjectiveBlurFlexophoreHardMatchUncovered.java @@ -104,7 +104,9 @@ public class ObjectiveBlurFlexophoreHardMatchUncovered implements IObjectiveComp private double sumDistanceMinSpanTreeBase; - private int numInevitablePPPoints; + private int numMandatoryPPPoints; + + private boolean [] arrMandatoryPPPoint; private double avrPairwiseMappingScaled; @@ -278,15 +280,15 @@ public boolean isValidSolution(SolutionCompleteGraph solution) { // // Check for inevitable pharmacophore points. // - if(numInevitablePPPoints > 0) { + if(numMandatoryPPPoints > 0) { int ccInevitablePPPointsInSolution = 0; for (int i = 0; i < heap; i++) { int indexNodeQuery = solution.getIndexQueryFromHeap(i); - if(mdhvQueryBlurredHist.isInevitablePharmacophorePoint(indexNodeQuery)){ + if(mdhvQueryBlurredHist.isMandatoryPharmacophorePoint(indexNodeQuery)){ ccInevitablePPPointsInSolution++; } } - int neededMinInevitablePPPoints = Math.min(heap, numInevitablePPPoints); + int neededMinInevitablePPPoints = Math.min(heap, numMandatoryPPPoints); if(ccInevitablePPPointsInSolution < neededMinInevitablePPPoints){ mapping = false; } @@ -468,39 +470,39 @@ public float getSimilarity(SolutionCompleteGraph solution) { return (float)similarity; } - - // double sumPairwiseMapping = 0; - - // double productPairwiseMapping = 0; + if(numMandatoryPPPoints>0) { + int ccMandatoryPPPoints = 0; + for (int i = 0; i < heap; i++) { + int indexNode1Query = solution.getIndexQueryFromHeap(i); + if (arrMandatoryPPPoint[indexNode1Query]) { + ccMandatoryPPPoints++; + } + } + if(numMandatoryPPPoints>ccMandatoryPPPoints){ + similarity=0; + return (float)similarity; + } + } int cc=0; - int nMappings = ((heap * heap)-heap) / 2; - double [] arrMappingWeights = new double[nMappings]; double [] arrSimilarityWeighted = new double[nMappings]; for (int i = 0; i < heap; i++) { - int indexNode1Query = solution.getIndexQueryFromHeap(i); - int indexNode1Base = solution.getIndexCorrespondingBaseNode(indexNode1Query); for (int j = i+1; j < heap; j++) { int indexNode2Query = solution.getIndexQueryFromHeap(j); - int indexNode2Base = solution.getIndexCorrespondingBaseNode(indexNode2Query); - double scorePairwiseMapping = getScorePairwiseMapping(indexNode1Query, indexNode2Query, indexNode1Base, indexNode2Base); - double w = mdhvQuery.getWeightPharmacophorePoint(indexNode1Query) * mdhvQuery.getWeightPharmacophorePoint(indexNode2Query); arrMappingWeights[cc]=w; - arrSimilarityWeighted[cc++]=scorePairwiseMapping * w; - if(verbose) { System.out.println("scorePairwiseMapping " + Formatter.format2(scorePairwiseMapping)); } @@ -867,8 +869,12 @@ public void setQuery(IMolDistHist iMolDistHistQuery) { slidingWindowDistHist.apply(mdhvQueryBlurredHist); nodesQuery = iMolDistHistQuery.getNumPPNodes(); - - numInevitablePPPoints = iMolDistHistQuery.getNumInevitablePharmacophorePoints(); + + arrMandatoryPPPoint = new boolean[nodesQuery]; + for (int i = 0; i < arrMandatoryPPPoint.length; i++) { + arrMandatoryPPPoint[i]=iMolDistHistQuery.isMandatoryPharmacophorePoint(i); + } + numMandatoryPPPoints = iMolDistHistQuery.getNumMandatoryPharmacophorePoints(); validHelpersQuery = false; diff --git a/src/main/java/com/actelion/research/chem/descriptor/flexophore/generator/CreatorMolDistHistViz.java b/src/main/java/com/actelion/research/chem/descriptor/flexophore/generator/CreatorMolDistHistViz.java index ce0dcba1..684d3c9c 100644 --- a/src/main/java/com/actelion/research/chem/descriptor/flexophore/generator/CreatorMolDistHistViz.java +++ b/src/main/java/com/actelion/research/chem/descriptor/flexophore/generator/CreatorMolDistHistViz.java @@ -184,6 +184,9 @@ public MolDistHistViz createMultipleConformations(StereoMolecule molOrig, int nC InteractionAtomTypeCalculator.setInteractionTypes(molInPlace); boolean successfulInitialization = conformerGeneratorStageTries.setMolecule(molInPlace); + + + if(!successfulInitialization){ return null; } @@ -196,11 +199,15 @@ public MolDistHistViz createMultipleConformations(StereoMolecule molOrig, int nC liSubGraphIndices = removeExoCyclicElectronPoorN(liSubGraphIndices, molInPlace); + + List liMultCoordFragIndex = new ArrayList<>(); for (SubGraphIndices subGraphIndices : liSubGraphIndices) { liMultCoordFragIndex.add(new MultCoordFragIndex(subGraphIndices.getAtomIndices())); } + + Molecule3D molViz = createConformations(molInPlace, liMultCoordFragIndex, nConformations); int nPotentialConformers = conformerGeneratorStageTries.getPotentialConformerCount(); @@ -219,6 +226,8 @@ public MolDistHistViz createMultipleConformations(StereoMolecule molOrig, int nC onlyOneConformer = true; } + + MolDistHistViz mdhv = create(liMultCoordFragIndex, molViz); return mdhv; diff --git a/src/main/java/com/actelion/research/chem/descriptor/flexophore/generator/SubFlexophoreGenerator.java b/src/main/java/com/actelion/research/chem/descriptor/flexophore/generator/SubFlexophoreGenerator.java index 816675f6..0e2d21e6 100644 --- a/src/main/java/com/actelion/research/chem/descriptor/flexophore/generator/SubFlexophoreGenerator.java +++ b/src/main/java/com/actelion/research/chem/descriptor/flexophore/generator/SubFlexophoreGenerator.java @@ -272,17 +272,17 @@ public static List getSubFragments(MolDistHistViz mdh, List< for (int [] arr : liIndices) { boolean inevitableAllInSub = true; - if(mdh.getNumInevitablePharmacophorePoints()>0){ + if(mdh.getNumMandatoryPharmacophorePoints()>0){ int nInevitableInSub = 0; for (int i = 0; i < arr.length; i++) { - if(mdh.isInevitablePharmacophorePoint(arr[i])){ + if(mdh.isMandatoryPharmacophorePoint(arr[i])){ nInevitableInSub++; } } - if(nInevitableInSub < mdh.getNumInevitablePharmacophorePoints()){ + if(nInevitableInSub < mdh.getNumMandatoryPharmacophorePoints()){ inevitableAllInSub = false; } } diff --git a/src/main/java/com/actelion/research/util/CommandLineParser.java b/src/main/java/com/actelion/research/util/CommandLineParser.java index b2f6c89f..cf1a1944 100644 --- a/src/main/java/com/actelion/research/util/CommandLineParser.java +++ b/src/main/java/com/actelion/research/util/CommandLineParser.java @@ -49,7 +49,7 @@ */ public class CommandLineParser { - public static final String SEP_TAG = ";"; + public static final String SEP_TAG = ","; public static final String HELP = "-h"; @@ -132,6 +132,16 @@ public List getAsList(String command) { } return l; } + public int [] getAsIntegerArray(String command) { + String s = hmCommandValue.get(command); + String [] a = s.split(SEP_TAG); + int [] b = new int[a.length]; + for (int i = 0; i < a.length; i++) { + b[i]=Integer.parseInt(a[i]); + } + + return b; + } public File getAsFile(String command) { return new File(get(command));