/** * Checks whether the given element exists. * * @param elementName The element name to test * @return True is the element exists, false otherwise */ public boolean isElement(String elementName) { return (getElement(elementName) != null); }
/** * Checks whether the given element exists. * * @param elementName The element name to test * @return True is the element exists, false otherwise */ public boolean isElement(String elementName) { return (getElement(elementName) != null); }
public void parseAtomElements(XMLStreamReader parser, IAtomContainer molecule) throws Exception { while (parser.next() != XMLEvent.END_DOCUMENT) { if (parser.getEventType() == XMLEvent.END_ELEMENT) { if (EL_ATOMSELEMENT.equals(parser.getLocalName())) { break; // done parsing the atom elements } } else if (parser.getEventType() == XMLEvent.START_ELEMENT) { if (EL_ELEMENT.equals(parser.getLocalName())) { int atomicNumber = Integer.parseInt(parser.getElementText()); IElement element = factory.getElement(atomicNumber); if (element == null) { IAtom atom = molecule.getBuilder().newInstance(IPseudoAtom.class); molecule.addAtom(atom); } else { IAtom atom = molecule.getBuilder().newInstance(IAtom.class, element.getSymbol()); atom.setAtomicNumber(element.getAtomicNumber()); molecule.addAtom(atom); } } } } }
public void parseAtomElements(XMLStreamReader parser, IAtomContainer molecule) throws Exception { while (parser.next() != XMLEvent.END_DOCUMENT) { if (parser.getEventType() == XMLEvent.END_ELEMENT) { if (EL_ATOMSELEMENT.equals(parser.getLocalName())) { break; // done parsing the atom elements } } else if (parser.getEventType() == XMLEvent.START_ELEMENT) { if (EL_ELEMENT.equals(parser.getLocalName())) { int atomicNumber = Integer.parseInt(parser.getElementText()); IElement element = factory.getElement(atomicNumber); if (element == null) { IAtom atom = molecule.getBuilder().newInstance(IPseudoAtom.class); molecule.addAtom(atom); } else { IAtom atom = molecule.getBuilder().newInstance(IAtom.class, element.getSymbol()); atom.setAtomicNumber(element.getAtomicNumber()); molecule.addAtom(atom); } } } } }
IAtom atom = ac.getAtom(i); symbol = ac.getAtom(i).getSymbol(); element = ifac.getElement(symbol); atomicNumber = element.getAtomicNumber(); if (modified) {
IAtom atom = ac.getAtom(i); symbol = ac.getAtom(i).getSymbol(); element = ifac.getElement(symbol); atomicNumber = element.getAtomicNumber(); if (modified) {
@Test public void testGetElement_String() throws Exception { IsotopeFactory elfac = Isotopes.getInstance(); IElement element = elfac.getElement("Br"); Assert.assertEquals(35, element.getAtomicNumber().intValue()); }
@Test public void testGetElement_Nonelement() throws Exception { IsotopeFactory isofac = Isotopes.getInstance(); IElement element = isofac.getElement("E"); assertNull(element); }
@Override public DescriptorValue calculate(IBond bond, IAtomContainer ac) { ensureIsotopeFactory(); if (bond.getAtomCount() != 2) { return new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), new DoubleResult( Double.NaN), NAMES, new CDKException("Only 2-center bonds are considered")); } IAtom[] atoms = BondManipulator.getAtomArray(bond); return new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), new DoubleResult( Math.abs(factory.getElement(atoms[0].getSymbol()).getAtomicNumber() - factory.getElement(atoms[1].getSymbol()).getAtomicNumber())), NAMES); }
@Test public void testGetElement_int() throws Exception { IsotopeFactory elfac = Isotopes.getInstance(); IElement element = elfac.getElement(6); Assert.assertEquals("C", element.getSymbol()); }
private ValidationReport validatePseudoAtom(IAtom atom) { ValidationReport report = new ValidationReport(); ValidationTest isElementOrPseudo = new ValidationTest(atom, "Non-element atom must be of class PseudoAtom."); if (atom instanceof IPseudoAtom) { // that's fine report.addOK(isElementOrPseudo); } else { // check whether atom is really an element try { IsotopeFactory isotopeFactory = Isotopes.getInstance(); IElement element = isotopeFactory.getElement(atom.getSymbol()); if (element == null) { isElementOrPseudo.setDetails("Element " + atom.getSymbol() + " does not exist."); report.addError(isElementOrPseudo); } else { report.addOK(isElementOrPseudo); } } catch (Exception exception) { // well... don't throw an error then. isElementOrPseudo.setDetails(exception.toString()); report.addCDKError(isElementOrPseudo); } } return report; }
element0 = ifac.getElement(symbol0); element1 = ifac.getElement(symbol1); atomicNumber0 = element0.getAtomicNumber(); atomicNumber1 = element1.getAtomicNumber(); IElement elem = ifac.getElement(atom.getSymbol()); int atnum = elem.getAtomicNumber(); difference = Math.abs(polarizabilities[atnum] - polarizabilities[1]) * impH;
element0 = ifac.getElement(symbol0); element1 = ifac.getElement(symbol1); atomicNumber0 = element0.getAtomicNumber(); atomicNumber1 = element1.getAtomicNumber(); IElement elem = ifac.getElement(atom.getSymbol()); int atnum = elem.getAtomicNumber(); difference = Math.abs(polarizabilities[atnum] - polarizabilities[1]) * impH;
for (IAtom atom : container.atoms()) { symbol = atom.getSymbol(); element = ifac.getElement(symbol); atomicNumber = element.getAtomicNumber(); apol += polarizabilities[atomicNumber];
for (IAtom atom : container.atoms()) { symbol = atom.getSymbol(); element = ifac.getElement(symbol); atomicNumber = element.getAtomicNumber(); apol += polarizabilities[atomicNumber];