CMLAngle getNewAngle(CMLAngle ang) { String[] a = ang.getAtomRefs3(); CMLAngle angle = new CMLAngle(ang); if (finalAtomSet.contains(a[2])) { String[] aa = new String[3]; aa[0] = a[2]; aa[1] = a[1]; aa[2] = a[0]; angle.setAtomRefs3(aa); } return angle; }
/** create key from atomRefs3 attribute and atomHash * * @return the hash null if no atomRefs3 */ public String atomHash() { String[] a = this.getAtomRefs3(); return (a == null) ? null : atomHash(a[0], a[1], a[2]); }
/** * gets value calculated from coordinates. requires atomRefs3 ro be set and * valid. then gets the angle between atomRefs3 0-1-2 * * @param molecule * owning molecule (all atoms must be in this) * @return the angle in degrees (NaN if cannot calculate) */ public double getCalculatedAngle(CMLMolecule molecule) { List<CMLAtom> atomList = this.getAtoms(molecule); return this.getCalculatedAngle(atomList); }
/** get string. * * @return the string */ public String getString() { String s = S_EMPTY; String[] a = getAtomRefs3(); if (a != null) { s += Util.concatenate(a, S_MINUS); } s += S_SPACE; s += this.getXMLContent(); return s; } }
w.write("</tr>\n"); for (CMLAngle angle : angleList) { List<CMLAtom> atoms = angle.getAtoms(molecule); w.write("<tr>"); for (int i = 0; i < 3; i++) { w.write("</td>"); String s = ""+angle.getXMLContent(); w.write("<td>"+s.substring(0, Math.min(6, s.length()))+"</td>"); w.write("</tr>\n");
/** * copy node . * * @return Node */ public Node copy() { return new CMLAngle(this); }
/** to string. * @return string */ public String toString() { return "Sprout: "+atom+"; "+length.getString()+"; "+ angle.getString()+"; "+torsion.getString(); } };
/** * gets atomIds as list. * * @return the atomIds (null if no atomRefs3) */ public List<String> getAtomIds() { List<String> idList = null; String[] atomRefs3 = getAtomRefs3(); if (atomRefs3 != null) { idList = new ArrayList<String>(); for (String s : atomRefs3) { idList.add(s); } } return idList; }
Sprout getSprout(CMLTorsion t, String atom) { String[] atomRefs4 = t.getAtomRefs4(); CMLLength length = null; CMLAngle angle = null; if (atom.equals(atomRefs4[0])) { // LOG.debug("00000000000000000"); length = lengthByAtomHashMap.get( CMLBond.atomHash(atomRefs4[0], atomRefs4[1])); angle = angleByAtomHashMap.get( CMLAngle.atomHash(atomRefs4[0], atomRefs4[1], atomRefs4[2])); } else if (atom.equals(atomRefs4[3])) { // LOG.debug("3... "+Util.concatenate(atomRefs4, S_SPACE+S_MINUS+S_SPACE)); length = lengthByAtomHashMap.get( CMLBond.atomHash(atomRefs4[2], atomRefs4[3])); if (length == null) { // for (String key : lengthByAtomHashMap.keySet()) { // LOG.debug("...K..."+key); // } } angle = angleByAtomHashMap.get( CMLAngle.atomHash(atomRefs4[1], atomRefs4[2], atomRefs4[3])); } else { throw new RuntimeException("Sprout cannot be in middle of torsion"); } // LOG.debug("L "+length+" -- A "+angle); return (length != null && angle != null) ? new Sprout(atom, length, angle, t) : null; }
/** set atomRefs3 attribute. * * @param atom0 * @param atom1 * @param atom2 */ public void setAtomRefs3( CMLAtom atom0, CMLAtom atom1, CMLAtom atom2) { this.setAtomRefs3( new String[]{ atom0.getId(), atom1.getId(), atom2.getId() }); }
Vector3 v12a = v12.normalize(); double len = length.getXMLContent(); double ang = angle.getXMLContent()*Math.PI / 180.; p3 = new Point3(p2); p3 = p3.plus(cross3.multiplyBy(len * Math.sin(ang)));
int i2 = -1; if (CMLBond.atomHash(length0.getAtomRefs2()).equals(CMLBond.atomHash( angle.getAtomRefs3()[0], angle.getAtomRefs3()[1]))) { i0 = 0; i2 = 2; } else if (CMLBond.atomHash(length0.getAtomRefs2()).equals(CMLBond.atomHash( angle.getAtomRefs3()[2], angle.getAtomRefs3()[1]))) { i0 = 2; i2 = 0; String id = angle.getAtomRefs3()[i0]; CMLAtom atom0 = molecule.getAtomById(id); if (atom0 == null) { throw new RuntimeException("Cannot find atom: "+id); id = angle.getAtomRefs3()[1]; CMLAtom atom1 = molecule.getAtomById(id); if (atom1 == null) { throw new RuntimeException("Cannot find atom: "+id); id = angle.getAtomRefs3()[i2]; CMLAtom atom2 = molecule.getAtomById(id); atom0.setXYZ3(new Point3(0, 0, 0)); atom1.setXYZ3(new Point3(l0, 0, 0)); double l1 = length1.getXMLContent(); double anglex = angle.getXMLContent()*Math.PI / 180.; double sina = Math.sin(anglex); double cosa = Math.cos(anglex);
/** * create new instance in context of parent, overridable by subclasses. * * @param parent * parent of element to be constructed (ignored by default) * @return CMLAngle */ public CMLElement makeElementInContext(Element parent) { return new CMLAngle(); }
/** * gets atoms as array of atoms. * * @param molecule * @return the atoms (null if no atomRefs3) */ public List<CMLAtom> getAtoms(CMLMolecule molecule) { List<CMLAtom> atomList = new ArrayList<CMLAtom>(); for (String atomRef : getAtomRefs3()) { CMLAtom atom = molecule.getAtomById(atomRef); if (atom == null) { throw new RuntimeException("cannot find atom: "+atomRef); } if (atomList.contains(atom)) { throw new RuntimeException("duplicate atom in angle: "+atomRef); } atomList.add(atom); } return atomList; }
/** * gets a Map of angles indexed by atoms. the map has the keys of atomHashs * for the angles * * @param angleList * list of the angles * @return the indexed table (keyed on atomHash) */ public static Map<String, CMLAngle> getIndexedAngles(List<CMLAngle> angleList) { Map<String, CMLAngle> angleTable = new HashMap<String, CMLAngle>(); for (CMLAngle angle : angleList) { String[] id = angle.getAtomRefs3(); String key = atomHash(id[0], id[1], id[2]); angleTable.put(key, angle); } return angleTable; }