boolean isAmino,
boolean isRelativeAlias,
OutputStringBuffer pdbATOM, StringBuffer pdbCONECT) {
String prefix = (derivType > 0 ? "dq" + (derivType == 2 ? "2" : "") : "q");
Quaternion q;
Atom aprev = null;
Quaternion qprev = null;
Quaternion dq = null;
Quaternion dqprev = null;
Quaternion qref = null;
Atom atomLast = null;
float x = 0, y = 0, z = 0, w = 0;
String strExtra = "";
float val1 = Float.NaN;
float val2 = Float.NaN;
int dm = (mStep <= 1 ? 1 : mStep);
for (int m = m0; m < p.monomerCount; m += dm) {
Monomer monomer = p.monomers[m];
if (bsAtoms == null || bsAtoms.get(monomer.leadAtomIndex)) {
Atom a = monomer.getLeadAtom();
String id = monomer.getUniqueID();
if (isRamachandran) {
if (ctype == 'S')
monomer.setGroupParameter(Token.straightness, Float.NaN);
x = monomer.getGroupParameter(Token.phi);
y = monomer.getGroupParameter(Token.psi);
z = monomer.getGroupParameter(Token.omega);
if (z < -90)
z += 360;
z -= 180; // center on 0
if (Float.isNaN(x) || Float.isNaN(y) || Float.isNaN(z)) {
if (bsAtoms != null)
bsAtoms.clear(a.getIndex());
continue;
}
float angledeg = (writeRamachandranStraightness ? p
.calculateRamachandranHelixAngle(m, qtype) : 0);
float straightness = (calcRamachandranStraightness || writeRamachandranStraightness ? getStraightness((float) Math
.cos(angledeg / 2 / 180 * Math.PI)): 0);
if (ctype == 'S') {
monomer.setGroupParameter(Token.straightness, straightness);
continue;
}
if (isDraw) {
if (bsSelected != null && !bsSelected.get(a.getIndex()))
continue;
// draw arrow arc {3.N} {3.ca} {3.C} {131 -131 0.5} "phi -131"
// draw arrow arc {3.CA} {3.C} {3.N} {0 133 0.5} "psi 133"
// as looked DOWN the bond, with {pt1} in the back, using
// standard dihedral/Jmol definitions for anticlockwise positive
// angles
AminoMonomer aa = (AminoMonomer) monomer;
pdbATOM.append("draw phi" + id + " ARROW ARC ").append(
Escape.escape(aa.getNitrogenAtom())).append(
Escape.escape(a)).append(
Escape.escape(aa.getCarbonylCarbonAtom())).append(
"{" + (-x) + " " + x + " 0.5} \"phi = " + (int) x + "\"")
.append(" color ").append(qColor[2]).append('\n');
pdbATOM.append("draw psi" + id + " ARROW ARC ").append(
Escape.escape(a)).append(
Escape.escape(aa.getCarbonylCarbonAtom())).append(
Escape.escape(aa.getNitrogenAtom())).append(
"{0 " + y + " 0.5} \"psi = " + (int) y + "\"")
.append(" color ").append(qColor[1]).append('\n');
pdbATOM.append("draw planeNCC" + id + " ").append(
Escape.escape(aa.getNitrogenAtom())).append(Escape.escape(a))
.append(Escape.escape(aa.getCarbonylCarbonAtom())).append(
" color ").append(qColor[0]).append('\n');
pdbATOM.append("draw planeCNC" + id + " ").append(
Escape.escape(((AminoMonomer) p.monomers[m - 1])
.getCarbonylCarbonAtom())).append(
Escape.escape(aa.getNitrogenAtom())).append(Escape.escape(a))
.append(" color ").append(qColor[1]).append('\n');
pdbATOM.append("draw planeCCN" + id + " ").append(Escape.escape(a))
.append(Escape.escape(aa.getCarbonylCarbonAtom())).append(
Escape.escape(((AminoMonomer) p.monomers[m + 1])
.getNitrogenAtom())).append(" color ")
.append(qColor[2]).append('\n');
continue;
}
if (Float.isNaN(angledeg)) {
strExtra = "";
if (writeRamachandranStraightness)
continue;
} else {
q = new Quaternion(new Point3f(1, 0, 0), angledeg);
strExtra = q.getInfo();
if (writeRamachandranStraightness) {
z = angledeg;
w = straightness;
} else {
w = a.getPartialCharge();
}
}
} else {
// quaternion
q = monomer.getQuaternion(qtype);
if (q != null) {
q.setRef(qref);
qref = new Quaternion(q);
}
if (derivType == 2)
monomer.setGroupParameter(Token.straightness, Float.NaN);
if (q == null) {
qprev = null;
qref = null;
} else if (derivType > 0) {
Atom anext = a;
Quaternion qnext = q;
if (qprev == null) {
q = null;
dqprev = null;
} else {