public boolean showCarbon( IAtom atom, IAtomContainer ac, JChemPaintRendererModel model) { Integer massNumber = atom.getMassNumber(); if (massNumber != null) { try { Integer expectedMassNumber = XMLIsotopeFactory.getInstance(ac.getBuilder()) .getMajorIsotope(atom.getSymbol()) .getMassNumber(); if (massNumber != expectedMassNumber) return true; } catch (IOException e) { logger.warn(e); } } return super.showCarbon(atom, ac, model); } }
/** * @cdk.bug 3534288 */ @Test(expected = IllegalArgumentException.class) public void testNonexistingElement() throws Exception { XMLIsotopeFactory isofac = XMLIsotopeFactory.getInstance(new ChemObject().getBuilder()); IAtom xxAtom = new Atom("Xx"); isofac.configure(xxAtom); }
public void applyChanges() { IAtom atom = (IAtom)source; try{ if(XMLIsotopeFactory.getInstance(atom.getBuilder()).getElement(symbolField.getText())!=null){ if(atom.getImplicitHydrogenCount()==null || atom.getImplicitHydrogenCount()!=((Integer)hCountField.getValue()).intValue()) hub.setImplicitHydrogenCount(atom,((Integer)hCountField.getValue()).intValue());
@Test public void testGetIsotopes() throws Exception { XMLIsotopeFactory isofac = XMLIsotopeFactory.getInstance(new ChemObject().getBuilder()); IIsotope[] list = isofac.getIsotopes(); Assert.assertTrue(list.length > 200); }
@Test public void testYeahSure() throws Exception { XMLIsotopeFactory isofac = XMLIsotopeFactory.getInstance(new ChemObject().getBuilder()); IIsotope match = isofac.getIsotope("H", 13.00001, 0.0001); Assert.assertNull(match); }
public void keyReleased(KeyEvent arg0) { JChemPaintRendererModel model = renderPanel.getRenderer().getRenderer2DModel(); ControllerHub relay = renderPanel.getHub(); if (model.getHighlightedAtom() != null) { try { IAtom closestAtom = model.getHighlightedAtom(); char x = arg0.getKeyChar(); if (Character.isLowerCase(x)) x = Character.toUpperCase(x); System.out.println(x); IsotopeFactory ifa; ifa = XMLIsotopeFactory.getInstance(closestAtom.getBuilder()); IIsotope iso = ifa.getMajorIsotope(Character.toString(x)); if (iso != null) { relay.setSymbol(closestAtom, Character.toString(x)); } this.get2DHub().updateView(); } catch (IOException e) { announceError(e); } } }
@Test public void testGetSize() throws Exception { XMLIsotopeFactory isofac = XMLIsotopeFactory.getInstance(new ChemObject().getBuilder()); Assert.assertTrue(isofac.getSize() > 0); }
@Test public void testGetElementSymbol_int() throws Exception { XMLIsotopeFactory elfac = XMLIsotopeFactory.getInstance(new ChemObject().getBuilder()); String symbol = elfac.getElementSymbol(8); Assert.assertEquals("O", symbol); }
@Test public void testIsElement_String() throws Exception { XMLIsotopeFactory isofac = XMLIsotopeFactory.getInstance(new ChemObject().getBuilder()); Assert.assertTrue(isofac.isElement("C")); }
@Test public void testGetNaturalMass_IElement() throws Exception { XMLIsotopeFactory isofac = XMLIsotopeFactory.getInstance(new ChemObject().getBuilder()); Assert.assertEquals(1.0079760, isofac.getNaturalMass(new Element("H")), 0.1); }
@Test public void testConfigureAtoms_IAtomContainer() throws Exception { AtomContainer container = new org.openscience.cdk.AtomContainer(); container.addAtom(new Atom("C")); container.addAtom(new Atom("H")); container.addAtom(new Atom("N")); container.addAtom(new Atom("O")); container.addAtom(new Atom("F")); container.addAtom(new Atom("Cl")); XMLIsotopeFactory isofac = XMLIsotopeFactory.getInstance(new ChemObject().getBuilder()); isofac.configureAtoms(container); for (int i = 0; i < container.getAtomCount(); i++) { Assert.assertTrue(0 < container.getAtom(i).getAtomicNumber()); } }
/** * Returns an IsotopeFactory instance. * * @param builder ChemObjectBuilder used to construct the Isotope's * @return The instance value * @exception IOException if isotopic data files could not be read. */ public static XMLIsotopeFactory getInstance(IChemObjectBuilder builder) throws IOException { if (ifac == null) { ifac = new XMLIsotopeFactory(builder); } return ifac; }
add(isotope); if (debug) logger.debug("Found #isotopes in file: ", isotopes.size());
@Test public void testGetIsotopes_String() throws Exception { XMLIsotopeFactory isofac = XMLIsotopeFactory.getInstance(new ChemObject().getBuilder()); IIsotope[] list = isofac.getIsotopes("He"); Assert.assertEquals(8, list.length); }
@Test public void testGetIsotopeFromExactMass_LargeTolerance() throws Exception { XMLIsotopeFactory isofac = XMLIsotopeFactory.getInstance(new ChemObject().getBuilder()); IIsotope carbon13 = isofac.getIsotope("C", 13); IIsotope match = isofac.getIsotope(carbon13.getSymbol(), carbon13.getExactMass(), 2.0); Assert.assertNotNull(match); Assert.assertEquals(13, match.getMassNumber().intValue()); }
public void undo() throws CannotUndoException { this.atom.setSymbol(formerSymbol); try { IsotopeFactory ifac = XMLIsotopeFactory.getInstance(atom.getBuilder()); this.atom.setMassNumber(ifac.getMajorIsotope(formerSymbol).getMassNumber()); chemModelRelay.updateAtom(atom); ifac.configure(atom); } catch (OptionalDataException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
public void setChemObject(IChemObject object) { if (object instanceof IAtom) { source = object; // update table contents IAtom atom = (IAtom)source; symbolField.setText(atom.getSymbol()); hCountField.setValue(new Integer(atom.getImplicitHydrogenCount()==null ? 0 : atom.getImplicitHydrogenCount())); formalChargeField.setValue(new Integer(atom.getFormalCharge())); if(atom.getProperty(CDKConstants.COMMENT)!=null) commentField.setText((String)(atom.getProperty(CDKConstants.COMMENT))); try { IIsotope isotope = XMLIsotopeFactory.getInstance( atom.getBuilder()).getMajorIsotope( atom.getSymbol()); majorIsotopeNumber = isotope.getMassNumber(); isotopeField.setValue(atom.getMassNumber()-majorIsotopeNumber); } catch (Exception exception) { logger.error("Error while configuring atom"); logger.debug(exception); isotopeField.setValue(0); } } else { throw new IllegalArgumentException("Argument must be an Atom"); } }
@Test public void testGetIsotopes_Nonelement() throws Exception { XMLIsotopeFactory isofac = XMLIsotopeFactory.getInstance(new ChemObject().getBuilder()); IIsotope[] list = isofac.getIsotopes("E"); Assert.assertNotNull(list); Assert.assertEquals(0, list.length); }
@Test public void testConfigure_IAtom() throws Exception { XMLIsotopeFactory isofac = XMLIsotopeFactory.getInstance(new ChemObject().getBuilder()); Atom atom = new Atom("H"); isofac.configure(atom); Assert.assertEquals(1, atom.getAtomicNumber().intValue()); }
@Test public void testGetElement_Nonelement() throws Exception { XMLIsotopeFactory elfac = XMLIsotopeFactory.getInstance(new ChemObject().getBuilder()); IElement element = elfac.getElement("E"); Assert.assertNull(element); }