Skip to content

Commit 54f4c2b

Browse files
committed
dedicated test for SuperPositionQCP issues (#914)
1 parent 83cf763 commit 54f4c2b

1 file changed

Lines changed: 26 additions & 8 deletions

File tree

biojava-structure/src/test/java/org/biojava/nbio/structure/geometry/TestSuperPositionQCP.java

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,19 @@
2020
*/
2121
package org.biojava.nbio.structure.geometry;
2222

23-
import static org.junit.Assert.*;
24-
25-
import java.util.Random;
23+
import org.junit.Ignore;
24+
import org.junit.Test;
25+
import org.slf4j.Logger;
26+
import org.slf4j.LoggerFactory;
2627

2728
import javax.vecmath.AxisAngle4d;
2829
import javax.vecmath.Matrix4d;
2930
import javax.vecmath.Point3d;
3031
import javax.vecmath.Vector3d;
32+
import java.util.Random;
3133

32-
import org.biojava.nbio.structure.geometry.SuperPositionQuat;
33-
import org.biojava.nbio.structure.geometry.SuperPositionQCP;
34-
import org.junit.Test;
35-
import org.slf4j.Logger;
36-
import org.slf4j.LoggerFactory;
34+
import static org.junit.Assert.assertEquals;
35+
import static org.junit.Assert.assertTrue;
3736

3837
/**
3938
* Test the Quaternion-Based Characteristic Polynomial {@link SuperPositionQCP}
@@ -166,4 +165,23 @@ public void testAlternativeUsageQCP() {
166165

167166
}
168167

168+
@Ignore("test for https://github.com/biojava/biojava/issues/914")
169+
@Test
170+
public void shouldHandleTwoFoldSymmetry() {
171+
Matrix4d operator = new Matrix4d(-1, 0, 0, 0,
172+
0, 1, 0, 0,
173+
0, 0, -1, 0,
174+
0, 0, 0, 1);
175+
176+
// add some jitter - otherwise rotation matrix will contain NaN
177+
Point3d[] original = new Point3d[] { new Point3d(0, 0, 0), new Point3d(1.001, 0, 0) };
178+
Point3d[] transformed = new Point3d[] { new Point3d(0, 0, 0), new Point3d(-1, 0, 0) };
179+
180+
SuperPosition sqcp = new SuperPositionQCP(false);
181+
182+
// operator 2 is a 2-fold, trace should be == -1
183+
Matrix4d m = sqcp.superposeAndTransform(original, transformed);
184+
assertEquals(-1.0, m.m00 + m.m11 + m.m22, 0.001);
185+
assertEquals(0.0, CalcPoint.rmsd(original, transformed), 0.001);
186+
}
169187
}

0 commit comments

Comments
 (0)