$darkmode
DENOPTIM
FragmentAlignement.java
Go to the documentation of this file.
1package denoptim.fragmenter;
2
3import java.util.Iterator;
4
5import javax.vecmath.Point3d;
6
7import org.biojava.nbio.structure.geometry.SuperPositionSVD;
8import org.jgrapht.GraphMapping;
9
10import denoptim.exception.DENOPTIMException;
11import denoptim.graph.FragIsomorphEdge;
12import denoptim.graph.FragIsomorphNode;
13import denoptim.graph.Fragment;
14import denoptim.graph.FragmentIsomorphismInspector;
15
22{
26 private double minRMSD = Double.MAX_VALUE;
27
31 private GraphMapping<FragIsomorphNode, FragIsomorphEdge> bestMapping = null;
32
33//------------------------------------------------------------------------------
34
44 {
45 // Map graph nodes (atom and APs)
47 new FragmentIsomorphismInspector(fragA, fragB);
48 if(!fii.isomorphismExists())
49 {
50 throw new DENOPTIMException("Failed to find isomorphism.");
51 }
52
53 int nPoints = fragA.getJGraphFragIsomorphism().vertexSet().size();
54
55 // Get lowest RMSD among all mappings
56 Iterator<GraphMapping<FragIsomorphNode, FragIsomorphEdge>>
57 mapingIterator = fii.getMappings();
58 if (mapingIterator == null)
59 {
60 throw new DENOPTIMException("Mapping of isomorphism timed-out!");
61 }
62
63 while (mapingIterator.hasNext())
64 {
65 GraphMapping<FragIsomorphNode, FragIsomorphEdge> mapping =
66 mapingIterator.next();
67
68 // Translate graph nodes/vertexes into points to align
69 Point3d[] ptsA = new Point3d[nPoints];
70 Point3d[] ptsB = new Point3d[nPoints];
71 int index = -1;
72 for (FragIsomorphNode nA : fragA.getJGraphFragIsomorphism().vertexSet())
73 {
74 index++;
75 FragIsomorphNode nB = mapping.getVertexCorrespondence(nA,
76 true);
77 ptsA[index] = nA.getPoint3d();
78 ptsB[index] = nB.getPoint3d();
79 }
80
81 // Align atoms
82 SuperPositionSVD svd = new SuperPositionSVD(false);
83 double rmsd = svd.getRmsd(ptsA,ptsB);
84 if (rmsd < minRMSD)
85 {
86 minRMSD = rmsd;
87 bestMapping = mapping;
88 }
89 }
90 }
91
92//------------------------------------------------------------------------------
93
99 public GraphMapping<FragIsomorphNode, FragIsomorphEdge> getLowestRMSDMapping()
100 {
101 return bestMapping;
102 }
103
104//------------------------------------------------------------------------------
105
110 public double getMinimumRMSD()
111 {
112 return minRMSD;
113 }
114
115//------------------------------------------------------------------------------
116
117}
Class performing the alignment of Fragments.
FragmentAlignement(Fragment fragA, Fragment fragB)
Constructor for an alignment of two fragments.
GraphMapping< FragIsomorphNode, FragIsomorphEdge > getLowestRMSDMapping()
Returns the mapping leading to the lowest RMSD that could be found among all isomorphic mappings.
double minRMSD
Lowest RMSD upon alignment.
double getMinimumRMSD()
Returns the lowest RMSD that could be found among all isomorphic mappings.
GraphMapping< FragIsomorphNode, FragIsomorphEdge > bestMapping
Mapping of nodes leading to lowest RMSD upon alignment.
Class representing a continuously connected portion of chemical object holding attachment points.
Definition: Fragment.java:61
boolean isomorphismExists()
Checks if an isomorphism exists between the two fragments.
Iterator< GraphMapping< FragIsomorphNode, FragIsomorphEdge > > getMappings()