ChemAxon 25dcd765a3
21-10-2013 15:14:50
I have a monomer DNA/RNA dictionary which are drawn as it is, sometimes the phosphate group is on the right sometimes on the left, see the attached examples (A.png, T.png).
I want to arrange my structures uniformly such a way to able to connect them nicely. So I rotate and flip them to have the phosphate group on the left and the hydroxyl group on the right so if I connect and move them one bond away the result will look nice.
/**
* Rotate the monomer to have attach1 and attach2 atoms on a horizontal line
* and attach1 at right, attach2 at left side.
* @param m
* @param attach1
* @param attach2
*/
private static void rotateMonomer(Molecule m, MolAtom attach1, MolAtom attach2){
if (attach2.getX() < attach1.getX()){
// flip
CTransform3D flip = new CTransform3D();
flip.m00 = -1;
flip.m22 = -1;
m.transform(flip);
}
DPoint3 p_point = attach2.getLocation();
double angle = p_point.angle2D(attach1.getX(), attach1.getY());
CTransform3D T = new CTransform3D();
T.setRotationCenter(p_point);
T.setRotation(0, 0, 1, -angle);
m.transform(T);
}