Skip to content

Commit 3d20a9f

Browse files
committed
Fix bug with dihedral axis calculation #558
1 parent 4e2567f commit 3d20a9f

File tree

5 files changed

+54
-18
lines changed

5 files changed

+54
-18
lines changed

biojava-integrationtest/src/test/java/org/biojava/nbio/structure/test/symmetry/TestQuatSymmetryDetectorExamples.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,30 @@ public void testNMR() throws IOException, StructureException {
6868
assertFalse(symmetry.isPseudoStoichiometric());
6969

7070
}
71+
72+
/**
73+
* Test a dihedral symmetry: 2VML
74+
*/
75+
@Test
76+
public void testDihedral() throws IOException, StructureException {
77+
78+
Structure pdb = StructureIO.getStructure("BIO:2vml:1");
79+
80+
SubunitClustererParameters clusterParams = new SubunitClustererParameters();
81+
clusterParams.setClustererMethod(SubunitClustererMethod.SEQUENCE);
82+
QuatSymmetryParameters symmParams = new QuatSymmetryParameters();
83+
QuatSymmetryResults symmetry = QuatSymmetryDetector.calcGlobalSymmetry(
84+
pdb, symmParams, clusterParams);
85+
86+
// D3 symmetry non pseudosymmetric
87+
assertEquals("D3", symmetry.getSymmetry());
88+
assertEquals("A6B6", symmetry.getStoichiometry());
89+
90+
}
7191

7292
/**
7393
* Hemoglobin has both symmetry and pseudosymmetry: 4HHB
94+
* TODO pseudosymmetry in hemoglobin fails
7495
*
7596
* @throws StructureException
7697
* @throws IOException

biojava-structure-gui/src/main/java/demo/DemoQuatSymmetryJmol.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public class DemoQuatSymmetryJmol {
6161
public static void main(String[] args) throws IOException,
6262
StructureException {
6363

64-
String name = "1VYM";
64+
String name = "2vml";
6565

6666
// Download the biological assembly
6767
AtomCache cache = new AtomCache();
@@ -72,7 +72,6 @@ public static void main(String[] args) throws IOException,
7272
SubunitClustererParameters cp = new SubunitClustererParameters();
7373
cp.setClustererMethod(SubunitClustererMethod.SEQUENCE); // normal
7474
// cp.setClustererMethod(SubunitClustererMethod.STRUCTURE); // pseudo
75-
// cp.setClustererMethod(SubunitClustererMethod.INTERNAL_SYMMETRY);
7675
cp.setCoverageThreshold(0.9);
7776

7877
// Calculate and display the global symmetry

biojava-structure/src/main/java/org/biojava/nbio/structure/symmetry/core/C2RotationSolver.java

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,12 @@
2222
package org.biojava.nbio.structure.symmetry.core;
2323

2424
import org.biojava.nbio.structure.geometry.CalcPoint;
25-
import org.biojava.nbio.structure.geometry.SuperPositions;
25+
import org.biojava.nbio.structure.geometry.UnitQuaternions;
2626

2727
import javax.vecmath.AxisAngle4d;
2828
import javax.vecmath.Matrix4d;
2929
import javax.vecmath.Point3d;
30+
import javax.vecmath.Quat4d;
3031
import javax.vecmath.Vector3d;
3132

3233
import java.util.ArrayList;
@@ -78,12 +79,15 @@ private void solve() {
7879
Point3d[] y = CalcPoint.clonePoint3dArray(traces.get(1));
7980
CalcPoint.translate(new Point3d(trans), y);
8081

81-
Matrix4d transformation = SuperPositions.superposeAndTransformAtOrigin(
82-
y, x);
82+
// TODO implement this piece of code using at origin superposition
83+
Quat4d quat = UnitQuaternions.relativeOrientation(
84+
x, y);
8385
AxisAngle4d axisAngle = new AxisAngle4d();
86+
Matrix4d transformation = new Matrix4d();
87+
88+
transformation.set(quat);
89+
axisAngle.set(quat);
8490

85-
// TODO Peter what is this piece of code doing? - Aleix 09.2016
86-
axisAngle.set(transformation);
8791
Vector3d axis = new Vector3d(axisAngle.x, axisAngle.y, axisAngle.z);
8892
if (axis.lengthSquared() < 1.0E-6) {
8993
axisAngle.x = 0;
@@ -96,6 +100,8 @@ private void solve() {
96100
axisAngle.y = axis.y;
97101
axisAngle.z = axis.z;
98102
}
103+
104+
CalcPoint.transform(transformation, y);
99105

100106
// if rmsd or angle deviation is above threshold, stop
101107
double angleThresholdRadians = Math.toRadians(parameters.getAngleThreshold());

biojava-structure/src/main/java/org/biojava/nbio/structure/symmetry/core/RotationSolver.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,14 @@
2323

2424
import org.biojava.nbio.structure.geometry.CalcPoint;
2525
import org.biojava.nbio.structure.geometry.MomentsOfInertia;
26-
import org.biojava.nbio.structure.geometry.SuperPositions;
26+
import org.biojava.nbio.structure.geometry.UnitQuaternions;
2727
import org.biojava.nbio.structure.symmetry.geometry.DistanceBox;
2828
import org.biojava.nbio.structure.symmetry.geometry.SphereSampler;
2929

3030
import javax.vecmath.AxisAngle4d;
3131
import javax.vecmath.Matrix4d;
3232
import javax.vecmath.Point3d;
33+
import javax.vecmath.Quat4d;
3334
import javax.vecmath.Vector3d;
3435

3536
import java.util.ArrayList;
@@ -167,13 +168,16 @@ private boolean evaluatePermutation(List<Integer> permutation) {
167168

168169
int fold = PermutationGroup.getOrder(permutation);
169170

170-
// get optimal transformation and axisangle by superimposing subunits
171-
Matrix4d transformation = SuperPositions.superposeAndTransformAtOrigin(
171+
// get optimal transformation and axisangle by subunit superposition
172+
// TODO implement this piece of code using at origin superposition
173+
Quat4d quat = UnitQuaternions.relativeOrientation(
172174
originalCoords, transformedCoords);
173175
AxisAngle4d axisAngle = new AxisAngle4d();
176+
Matrix4d transformation = new Matrix4d();
177+
178+
transformation.set(quat);
179+
axisAngle.set(quat);
174180

175-
// TODO Peter what is this piece of code doing? - Aleix 09.2016
176-
axisAngle.set(transformation);
177181
Vector3d axis = new Vector3d(axisAngle.x, axisAngle.y, axisAngle.z);
178182
if (axis.lengthSquared() < 1.0E-6) {
179183
axisAngle.x = 0;
@@ -187,6 +191,7 @@ private boolean evaluatePermutation(List<Integer> permutation) {
187191
axisAngle.z = axis.z;
188192
}
189193

194+
CalcPoint.transform(transformation, transformedCoords);
190195
double subunitRmsd = CalcPoint.rmsd(transformedCoords, originalCoords);
191196

192197
if (subunitRmsd < parameters.getRmsdThreshold()) {
@@ -270,7 +275,6 @@ private boolean isAllowedPermutation(List<Integer> permutation) {
270275
}
271276
/**
272277
* Adds translational component to rotation matrix
273-
* @param rotTrans
274278
* @param rotation
275279
* @return
276280
*/

biojava-structure/src/main/java/org/biojava/nbio/structure/symmetry/core/SystematicSolver.java

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,13 @@
2222
package org.biojava.nbio.structure.symmetry.core;
2323

2424
import org.biojava.nbio.structure.geometry.CalcPoint;
25-
import org.biojava.nbio.structure.geometry.SuperPositions;
25+
import org.biojava.nbio.structure.geometry.UnitQuaternions;
2626
import org.biojava.nbio.structure.symmetry.utils.PermutationGenerator;
2727

2828
import javax.vecmath.AxisAngle4d;
2929
import javax.vecmath.Matrix4d;
3030
import javax.vecmath.Point3d;
31+
import javax.vecmath.Quat4d;
3132
import javax.vecmath.Vector3d;
3233

3334
import java.util.ArrayList;
@@ -189,13 +190,16 @@ private boolean evaluatePermutation(List<Integer> permutation) {
189190
}
190191

191192
int fold = PermutationGroup.getOrder(permutation);
192-
// get optimal transformation and axisangle by superimposing subunits
193-
Matrix4d transformation = SuperPositions.superposeAndTransformAtOrigin(
193+
194+
// TODO implement this piece of code using at origin superposition
195+
Quat4d quat = UnitQuaternions.relativeOrientation(
194196
originalCoords, transformedCoords);
195197
AxisAngle4d axisAngle = new AxisAngle4d();
198+
Matrix4d transformation = new Matrix4d();
199+
200+
transformation.set(quat);
201+
axisAngle.set(quat);
196202

197-
// TODO Peter what is this piece of code doing? - Aleix 09.2016
198-
axisAngle.set(transformation);
199203
Vector3d axis = new Vector3d(axisAngle.x, axisAngle.y, axisAngle.z);
200204
if (axis.lengthSquared() < 1.0E-6) {
201205
axisAngle.x = 0;
@@ -209,6 +213,8 @@ private boolean evaluatePermutation(List<Integer> permutation) {
209213
axisAngle.z = axis.z;
210214
}
211215

216+
CalcPoint.transform(transformation, transformedCoords);
217+
212218
double subunitRmsd = CalcPoint.rmsd(transformedCoords, originalCoords);
213219

214220
if (subunitRmsd <parameters.getRmsdThreshold()) {

0 commit comments

Comments
 (0)