com.actelion.research.chem.conf.AtomAssembler Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of openchemlib Show documentation
Show all versions of openchemlib Show documentation
Open Source Chemistry Library
package com.actelion.research.chem.conf;
import com.actelion.research.chem.Coordinates;
import com.actelion.research.chem.Molecule;
import com.actelion.research.chem.StereoMolecule;
public class AtomAssembler {
private StereoMolecule mMol;
public AtomAssembler(StereoMolecule mol) {
mMol = mol;
}
public int addImplicitHydrogens() {
mMol.ensureHelperArrays(Molecule.cHelperRings);
int total = 0;
for (int atom=0; atom Math.PI)
dihedral -= 2*Math.PI;
addAtomWithConstraints(mMol.getCoordinates(atomSequence[0]), mMol.getCoordinates(atomSequence[1]),
mMol.getCoordinates(atomSequence[2]), atom, 1, angle, dihedral, length);
if (count != 1) {
dihedral += Math.PI*2/3;
if (dihedral > Math.PI)
dihedral -= 2*Math.PI;
addAtomWithConstraints(mMol.getCoordinates(atomSequence[0]), mMol.getCoordinates(atomSequence[1]),
mMol.getCoordinates(atomSequence[2]), atom, 1, angle, dihedral, length);
}
return count;
}
}
}
// no competing atoms
// if we have a single bonded option for atomSequence[0], then take that
for (int i=i0+1; inewAtom, angle c2->c3->newAtom and dihedral c1->c2->c3->newAtom are met.
* @param c1
* @param c2
* @param c3
* @param rootAtom
* @param angle
* @param dihedral
* @param bondLength
*/
private void addAtomWithConstraints(Coordinates c1, Coordinates c2, Coordinates c3, int rootAtom, int atomicNo, double angle, double dihedral, double bondLength) {
double r = bondLength * Math.sin(Math.PI - angle);
double x = -r * Math.sin(dihedral);
double y = r * Math.cos(dihedral);
double z = bondLength * Math.cos(Math.PI - angle);
Coordinates axisZ = c3.subC(c2).unit();
Coordinates axisX = c1.subC(c2).cross(axisZ).unit(); // needs to be mapped to x-axis
Coordinates axisY = axisX.cross(axisZ).unit(); // needs to be mapped to y-axis
double[][] m = new double[3][3];
m[0][0] = -axisX.x;
m[0][1] = -axisX.y;
m[0][2] = -axisX.z;
m[1][0] = -axisY.x;
m[1][1] = -axisY.y;
m[1][2] = -axisY.z;
m[2][0] = axisZ.x;
m[2][1] = axisZ.y;
m[2][2] = axisZ.z;
Coordinates p = new Coordinates(x, y, z).rotate(m).add(c3);
int hydrogen = mMol.addAtom(atomicNo);
mMol.addBond(rootAtom, hydrogen, Molecule.cBondTypeSingle);
mMol.setAtomX(hydrogen, p.x);
mMol.setAtomY(hydrogen, p.y);
mMol.setAtomZ(hydrogen, p.z);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy