Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix and unit test for #715
  • Loading branch information
josemduarte committed Dec 7, 2017
commit bc9011a2d048ed0a40e44ff4cecd82796ac01eae
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,11 @@ public static final void transform(Chain chain, Matrix4d m) {
for (Atom atom : g.getAtoms()) {
transform(atom, m);
}
for (Group altG : g.getAltLocs()) {
for (Atom atom : altG.getAtoms()) {
transform(atom, m);
}
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,53 @@ public void testVecmathTransformation() {

assertEquals(expected, actual);
}

/**
* Issue https://github.com/biojava/biojava/issues/715
*/
@Test
public void testChainTransform() {
Group g = new AminoAcidImpl();
Atom a = new AtomImpl();
a.setName("CA");
a.setX(1);
a.setY(1);
a.setZ(1);
g.addAtom(a);
Group altLocG = new AminoAcidImpl();
Atom a2 = new AtomImpl();
a2.setName("CA");
a2.setX(2);
a2.setY(2);
a2.setZ(2);
altLocG.addAtom(a2);

g.addAltLoc(altLocG);

Chain c = new ChainImpl();
c.addGroup(g);

Matrix4d m = new Matrix4d(1,0,0,1, 0,1,0,0, 0,0,1,0, 0,0,0,1); // shift of 1 in x axis
Calc.transform(c, m);

Group thegroup = c.getAtomGroup(0);
Group thealtlocgroup = thegroup.getAltLocs().get(0);

Atom atom1 = thegroup.getAtom("CA");
Atom atom2 = thealtlocgroup.getAtom("CA");

// x should be shitfted by 1
assertEquals(2, atom1.getX(), 0.00001);
assertEquals(1, atom1.getY(), 0.00001);
assertEquals(1, atom1.getZ(), 0.00001);

// x should be shitfted by 1
assertEquals(3, atom2.getX(), 0.00001);
assertEquals(2, atom2.getY(), 0.00001);
assertEquals(2, atom2.getZ(), 0.00001);


}

private static Atom getAtom(double x, double y, double z) {
Atom a = new AtomImpl();
Expand Down