// quaternionFrame 'c' from
// Sarver M, Zirbel CL, Stombaugh J, Mokdad A, Leontis NB.
// FR3D: finding local and composite recurrent structural motifs in RNA 3D structures.
// J. Math. Biol. (2006) 215-252
// quaternionFrame 'n' same, but with N1/N9 as base atom (only different for DRAW)
Atom ptA = null, ptB = null, ptNorP;
boolean yBased = false;
boolean reverseY = false;
switch (qType) {
case 'a': // alternative C4' - P - C4'
// (C4_i-1 - P_i - C4_i), with Y P_i - C4_i
ptNorP = getP();
if (monomerIndex == 0 || ptNorP == null)
return null;
yBased = true;
ptA = ((NucleicMonomer) bioPolymer.monomers[monomerIndex - 1]).getC4P();
ptB = getC4P();
break;
case 'x':
// P[i]-C4'[i]-P[i+1]
ptNorP = getP();
if (monomerIndex == bioPolymer.monomerCount - 1 || ptNorP == null)
return null;
ptA = ((NucleicMonomer) bioPolymer.monomers[monomerIndex + 1]).getP();
ptB = getC4P();
break;
case 'b': // phosphorus backbone
return super.getQuaternion(qType);
case 'c': // Sarver-defined, with Y in the C1'-N1/9 direction, x toward C2 (W-C edge)
case 'n': // same, just different quaternion center
// N0 = (purine N9, pyrimidine N1):
ptNorP = getN0();
if (ptNorP == null)
return null;
yBased = true;
reverseY = true;
// vB = -(N0-C1P)
// vA = vB x (vB x (N0-C2))
ptA = getAtomFromOffsetIndex(C2);
ptB = getAtomFromOffsetIndex(C1P);
break;
case 'p': // phosphorus tetrahedron
// O1P - P - O2P
ptNorP = getP();
if (ptNorP == null)
return null;
Atom p1 = getAtomFromOffsetIndex(O1P);
Atom p2 = getAtomFromOffsetIndex(O2P);
Bond[] bonds = ptNorP.getBonds();
if (bonds == null)
return null;
Group g = ptNorP.getGroup();
for (int i = 0; i < bonds.length; i++) {
Atom atom = bonds[i].getOtherAtom(ptNorP);
if (p1 != null && atom.index == p1.index)
continue;
if (p2 != null && atom.index == p2.index)
continue;
if (atom.getGroup() == g)
ptB = atom;
else
ptA = atom;
}
break;