/** * Constructs an empty by copying the symbol, atomic number, * flags, and identifier from the given IElement. It does * not copy the listeners and properties. * * @param element IElement to copy information from */ public Element(IElement element) { super(element); this.atomicNumber = element.getAtomicNumber(); }
/** * Constructs an empty by copying the symbol, atomic number, * flags, and identifier from the given IElement. It does * not copy the listeners and properties. * * @param element IElement to copy information from */ public Element(IElement element) { super(element); this.atomicNumber = element.getAtomicNumber(); }
/** * Constructs an empty by copying the symbol, atomic number, * flags, and identifier from the given IElement. It does * not copy the listeners and properties. * * @param element IElement to copy information from */ public Element(IElement element) { super(element); this.atomicNumber = element.getAtomicNumber(); }
/** * Constructs an empty by copying the symbol, atomic number, * flags, and identifier from the given IElement. It does * not copy the listeners and properties. * * @param element IElement to copy information from */ public Element(IElement element) { super(element); this.atomicNumber = element.getAtomicNumber(); }
private static void serializeElementFields(Model model, Resource rdfObject, IElement element) { serializeChemObjectFields(model, rdfObject, element); if (element.getSymbol() != null) model.add(rdfObject, CDK.SYMBOL, element.getSymbol()); if (element.getAtomicNumber() != null) model.add(rdfObject, CDK.HASATOMICNUMBER, element.getAtomicNumber().toString()); }
private static void serializeElementFields(Model model, Resource rdfObject, IElement element) { serializeChemObjectFields(model, rdfObject, element); if (element.getSymbol() != null) model.add(rdfObject, CDK.SYMBOL, element.getSymbol()); if (element.getAtomicNumber() != null) model.add(rdfObject, CDK.HASATOMICNUMBER, element.getAtomicNumber().toString()); }
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); } } } } }
@Test public void testMassNumber() { IElement chemObject = new NaturalElement("C", 12); Assert.assertEquals(12, chemObject.getAtomicNumber().intValue()); }
@Test public void testElement_X() { IElement e = new Element("X"); Assert.assertEquals("R", e.getSymbol()); // and it should not throw exceptions Assert.assertNotNull(e.getAtomicNumber()); Assert.assertThat(e.getAtomicNumber(), is(0)); }
@Test public void testElement_X() { IElement e = new Element("X"); Assert.assertEquals("R", e.getSymbol()); // and it should not throw exceptions Assert.assertNotNull(e.getAtomicNumber()); Assert.assertThat(e.getAtomicNumber(), is(0)); }
@Test public void testElement_X() { IElement e = new DebugElement("X"); Assert.assertEquals("R", e.getSymbol()); // and it should not throw exceptions Assert.assertNotNull(e.getAtomicNumber()); Assert.assertThat(e.getAtomicNumber(), is(0)); }
@Test public void testGetAtomicNumber() { IElement e = (IElement) newChemObject(); e.setAtomicNumber(1); Assert.assertEquals(1, e.getAtomicNumber().intValue()); }
@Test public void testSetAtomicNumber_Integer() { IElement e = (IElement) newChemObject(); e.setAtomicNumber(1); Assert.assertEquals(1, e.getAtomicNumber().intValue()); }
@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 testElement_String_Integer() { IElement e = new Element("H", 1); Assert.assertEquals("H", e.getSymbol()); Assert.assertEquals(1, e.getAtomicNumber().intValue()); }
@Test public void testElement_String_Integer() { IElement e = new Element("H", 1); Assert.assertEquals("H", e.getSymbol()); Assert.assertEquals(1, e.getAtomicNumber().intValue()); }
@Test public void testDebugElement_String_int() { IElement e = new DebugElement("H", 1); Assert.assertEquals("H", e.getSymbol()); Assert.assertEquals(1, e.getAtomicNumber().intValue()); }
@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 testClone_IAtomicNumber() throws Exception { IElement elem = (IElement) newChemObject(); elem.setAtomicNumber(6); IElement clone = (IElement) elem.clone(); // test cloning of atomic number elem.setAtomicNumber(5); // don't care about symbol Assert.assertEquals(6, clone.getAtomicNumber().intValue()); }
@Test public void testGetElement_String() throws Exception { XMLIsotopeFactory elfac = XMLIsotopeFactory.getInstance(new ChemObject().getBuilder()); IElement element = elfac.getElement("Br"); Assert.assertEquals(35, element.getAtomicNumber().intValue()); }