/** * copy node . * * @return Node */ public Node copy() { return new CMLAtom(this); }
/** * Construct a new CMLAtom element with immutable id. * @param id */ public CMLAtom(String id) { super(); this.setId(id); }
/** * Sets chemical element of all atoms in set. * * @param elementType */ public void setChemicalElements(String elementType) { List<CMLAtom> atoms = this.getAtoms(); for (int i = 0; i < atoms.size(); i++) { CMLAtom atom = atoms.get(i); atom.setElementType(elementType); } }
/** * increase x2 and y2 coordinates. * * if x2 or y2 is unset, no action (to avoid a default of zero) * * @param dx * amount to add * @param dy * amount to add */ public void increaseXY2(double dx, double dy) { if (hasCoordinates(CoordinateType.TWOD)) { this.setX2(this.getX2() + dx); this.setY2(this.getY2() + dy); } }
/** * increase x3, y3 and z3 coordinates. * * if x3, y3 or z3 is unset, no action * * @param dx * amount to add * @param dy * amount to add * @param dz * amount to add */ public void increaseXYZFract(double dx, double dy, double dz) { if (hasCoordinates(CoordinateType.CARTESIAN)) { this.setXFract(this.getXFract() + dx); this.setYFract(this.getYFract() + dy); this.setZFract(this.getZFract() + dz); } }
/** * increase x3, y3 and z3 coordinates. * * if x3, y3 or z3 is unset, no action * * @param dx * amount to add * @param dy * amount to add * @param dz * amount to add */ public void increaseXYZ3(double dx, double dy, double dz) { if (hasCoordinates(CoordinateType.CARTESIAN)) { this.setX3(this.getX3() + dx); this.setY3(this.getY3() + dy); this.setZ3(this.getZ3() + dz); } }
&& this.hasCoordinates(CoordinateType.TWOD)) { i = (int) (this.getX2() * factor); this.setX2(((double) i) * epsilon); i = (int) (this.getY2() * factor); this.setY2(((double) i) * epsilon); && this.hasCoordinates(CoordinateType.CARTESIAN)) { i = (int) (this.getX3() * factor); this.setX3(((double) i) * epsilon); i = (int) (this.getY3() * factor); this.setY3(((double) i) * epsilon); i = (int) (this.getZ3() * factor); this.setZ3(((double) i) * epsilon); && this.hasCoordinates(CoordinateType.FRACTIONAL)) { i = (int) (this.getXFract() * factor); this.setXFract(((double) i) * epsilon); i = (int) (this.getYFract() * factor); this.setYFract(((double) i) * epsilon); i = (int) (this.getZFract() * factor); this.setZFract(((double) i) * epsilon);
public CMLAtom cdkAtomToCMLAtom(IAtomContainer container, IAtom cdkAtom) { CMLAtom cmlAtom = new CMLAtom(); this.checkPrefix(cmlAtom); addAtomID(cdkAtom, cmlAtom); addDictRef(cdkAtom, cmlAtom); cmlAtom.setElementType(cdkAtom.getSymbol()); if (cdkAtom instanceof IPseudoAtom) { String label = ((IPseudoAtom) cdkAtom).getLabel(); if (label != null) cmlAtom.setTitle(label); cmlAtom.setElementType("Du"); if (formalCharge != null) cmlAtom.setFormalCharge(formalCharge); cmlAtom.setHydrogenCount(totalHydrogen); if (!(cdkAtom instanceof IPseudoAtom)) { if (massNumber != null) { cmlAtom.setIsotopeNumber(massNumber); cmlAtom.addScalar(scalar); CMLScalar aromAtom = new CMLScalar(); aromAtom.setDictRef("cdk:aromaticAtom"); cmlAtom.appendChild(aromAtom);
/** * translate molecule in 3D. * * @param delta3 * add to all 3D coordinates */ public void translate3D(Vector3 delta3) { List<CMLAtom> atoms = this.getAtoms(); for (int i = 0; i < atoms.size(); i++) { CMLAtom atom = atoms.get(i); if (atom.getX3Attribute() != null && atom.getY3Attribute() != null && atom.getZ3Attribute() != null) { atom.setX3(atom.getX3() + delta3.getArray()[0]); atom.setY3(atom.getY3() + delta3.getArray()[1]); atom.setZ3(atom.getZ3() + delta3.getArray()[2]); } } }
/** * translate molecule in 2D. * * @param delta2 * add to all 2D coordinates */ public void translate2D(Real2 delta2) { List<CMLAtom> atoms = this.getAtoms(); for (int i = 0; i < atoms.size(); i++) { CMLAtom atom = atoms.get(i); if (atom.getX2Attribute() != null && atom.getY2Attribute() != null) { atom.setX2(atom.getX2() + delta2.getX()); atom.setY2(atom.getY2() + delta2.getY()); } } }
if (atom.getOccupancyAttribute() != null) { occupancy = atom.getOccupancy(); String elementType = atom.getElementType(); if (elementType == null || ChemicalElement.getChemicalElement(elementType) == null) { throw new RuntimeException( "Missing or invalid elementType for atom : "+atom.getId()+" .. " + elementType); if (atom.getFormalChargeAttribute() != null) { formalCharge += atom.getFormalCharge(); int hydrogenCount = atom.getHydrogenCount(); if (hydrogenCount > 0) { this.add(AS.H.value, hydrogenCount); List<CMLAtom> oatoms = atom.getLigandAtoms(); boolean countit = true; for (CMLAtom chk : oatoms) { String ctype = chk.getElementType(); if ( !AS.H.equals(ctype)) { countit = false; if (atom.getFormalChargeAttribute() != null) { formalCharge += atom.getFormalCharge();
CMLAtom cmlAtom = new CMLAtom(); cmlAtom.setRef(residue.getAtom(i).getID()); cmlAtom.setId(rprefix + "_" + residue.getAtom(i).getID()); ar.addAtom(cmlAtom); CMLAtom cmlAtom = new CMLAtom(); cmlAtom.setRef(chargeGroup.getAtom(i).getID()); cmlAtom.setId(cprefix + "_" + chargeGroup.getAtom(i).getID()); CMLScalar scalar = new CMLScalar(); scalar.setDictRef("md:switchingAtom"); cmlAtom.addScalar(scalar);
String elementType = atom.getElementType(); double occupancy = (atom.getOccupancyAttribute() == null) ? 1.0 : atom.getOccupancy(); int multiplicity = (atom.getSpaceGroupMultiplicityAttribute() == null) ? 1 : atom.getSpaceGroupMultiplicity(); if (AS.H.equals(elementType)) { if (CMLMolecule.HydrogenControl.USE_EXPLICIT_HYDROGENS if (CMLMolecule.HydrogenControl.USE_HYDROGEN_COUNT .equals(control)) { hCount += atom.getHydrogenCount() * occupancy;
/** * Calculates the hydrogen count of a molecule. Includes hydrogenCount * attribute and does not double count bridging hydrogens. */ public int calculateHydrogenCount() { /* beware bridging hydrogens - simply returning the sum of the atom * hydrogen counts may not work! */ int totalImplicitHydrogenCount = 0; Set <CMLAtom> uniqueHydrogens = new HashSet<CMLAtom>(); for (CMLAtom atom : getAtoms()) { int hydrogenCount = atom.getHydrogenCount(); List <CMLAtom> explicitHydrogens = atom.getLigandHydrogenAtoms(); int implicitHydrogenCount = hydrogenCount - explicitHydrogens.size(); if (implicitHydrogenCount > 0) { totalImplicitHydrogenCount += implicitHydrogenCount; } uniqueHydrogens.addAll(explicitHydrogens); } return totalImplicitHydrogenCount + uniqueHydrogens.size(); }
/** An array of formalCharges. * * Used in CML2 Array mode. NOT the calculated charge or oxidation state. No formal defaults, but assumed to be zero if omitted. It may become good practice to include it. * --type info-- * * Array of formalCharges. * Used for electron-bookeeping. This has no relation to its calculated (fractional) charge or oxidation state. * @param value formalCharge value * @throws RuntimeException attribute wrong value/type */ public void setFormalCharge(String[] value) throws RuntimeException { if (value == null) { throw new RuntimeException("null formalCharge"); } List<CMLAtom> atomList = this.getAtoms(value.length, "formalCharge"); int i = 0; for (CMLAtom atom : atomList) { atom.setFormalCharge(Integer.parseInt(value[i++])); } } /** Array of hydrogenCounts.
/** Array of hydrogenCounts. * * Normally used in CML2 array mode. The total number of hydrogens bonded to the atom or molecule. It is preferable to include hydrogens explicitly, and where this is done their count represents the minimum (and may thus override this attribute). It is dangerous to use this attribute for electron-deficient molecules (e.g. diborane) or hydrogen bonds. There is NO DEFAULT and the absence of this attribute must not be given any meaning. * --type info-- * * Array of hydrogenCounts. * The total number of hydrogen atoms bonded to an atom or contained in a molecule, whether explicitly included as atoms or not. It is an error to have hydrogen count less than the explicit hydrogen count. There is no default value and no assumptions about hydrogen Count can be made if it is not given. If hydrogenCount is given on every atom, then the values can be summed to give the total hydrogenCount for the (sub)molecule. Because of this hydrogenCount should not be used where hydrogen atoms bridge 2 or more atoms. * @param value hydrogenCount value * @throws RuntimeException attribute wrong value/type */ public void setHydrogenCount(String[] value) throws RuntimeException { if (value == null) { throw new RuntimeException("null hydrogenCount"); } List<CMLAtom> atomList = this.getAtoms(value.length, "hydrogenCount"); int i = 0; for (CMLAtom atom : atomList) { atom.setHydrogenCount(Integer.parseInt(value[i++])); } } /** Array of occupancies.
/** Array of fractional x coordinate. * * normally xFract, yFract and zFract should all be present or absent. If present a _crystal_ element should also occur. * --type info-- * * An array of coordinateComponents for a single coordinate. * An array of coordinateComponents for a single coordinate * where these all refer to an X-coordinate (NOT x,y,z).Instances of this type will be * used in array-style representation of 2-D or 3-D coordinates. Currently no machine * validation. Currently not used in STMML, but re-used by CML (see example). * @param value xFract value * @throws RuntimeException attribute wrong value/type */ public void setXFract(double[] value) throws RuntimeException { if (value == null) { throw new RuntimeException("null xFract"); } List<CMLAtom> atomList = this.getAtoms(value.length, "xFract"); int i = 0; for (CMLAtom atom : atomList) { atom.setXFract(value[i++]); } } /** Array of fractional y coordinate.