/** * {@inheritDoc} */ @Override public void setSymbol(String symbol) { atom.setSymbol(symbol); }
/** * {@inheritDoc} */ @Override public void setSymbol(String symbol) { atom.setSymbol(symbol); }
private void processAtomsBlock(int lineCount, IAtomContainer container) throws IOException { for (int i = 0; i < lineCount; i++) { String line = input.readLine(); int atomicNumber = Integer.parseInt(line.substring(7, 10).trim()); IAtom atom = container.getBuilder().newInstance(IAtom.class); atom.setAtomicNumber(atomicNumber); atom.setSymbol(PeriodicTable.getSymbol(atomicNumber)); container.addAtom(atom); } }
private void processAtomsBlock(int lineCount, IAtomContainer container) throws IOException { for (int i = 0; i < lineCount; i++) { String line = input.readLine(); int atomicNumber = Integer.parseInt(line.substring(7, 10).trim()); IAtom atom = container.getBuilder().newInstance(IAtom.class); atom.setAtomicNumber(atomicNumber); atom.setSymbol(PeriodicTable.getSymbol(atomicNumber)); container.addAtom(atom); } }
public IAtomContainer createAnyAtomAtomContainer(IAtomContainer atomContainer) throws Exception { IAtomContainer query = (IAtomContainer) atomContainer.clone(); // System.out.println("createAnyAtomAtomContainer"); for (int i = 0; i < query.getAtomCount(); i++) { // System.out.print(" "+i); query.getAtom(i).setSymbol("C"); } return query; }
private synchronized IAtomContainer convertRGroupsToMetals(IAtomContainer mol) { try { IAtomContainer convertedMol = mol.clone(); for (IAtom atom : convertedMol.atoms()) { if (isR(atom)) { atom.setSymbol(R_Group_replacement_String); } } return convertedMol; } catch (CloneNotSupportedException c) { return mol; } }
/** * Create a new atom for the provided symbol. The atom is created by cloning * an existing 'template'. Unfortunately IChemObjectBuilders really show a * slow down when SMILES processing. * * @param element Beam element * @return new atom with configured symbol and atomic number */ private IAtom createAtom(Element element) { IAtom atom = builder.newAtom(); atom.setSymbol(element.symbol()); atom.setAtomicNumber(element.atomicNumber()); return atom; } }
@Test public void writeCarbon13AtomProps() throws Exception { IAtomContainer mol = builder.newAtomContainer(); IAtom atom = builder.newAtom(); atom.setSymbol("C"); atom.setMassNumber(13); mol.addAtom(atom); StringWriter sw = new StringWriter(); try (MDLV2000Writer mdlw = new MDLV2000Writer(sw)) { mdlw.write(mol); } assertThat(sw.toString(), containsString("C 1")); }
@Test public void writeCarbon12() throws Exception { IAtomContainer mol = builder.newAtomContainer(); IAtom atom = builder.newAtom(); atom.setSymbol("C"); atom.setMassNumber(12); mol.addAtom(atom); StringWriter sw = new StringWriter(); try (MDLV2000Writer mdlw = new MDLV2000Writer(sw)) { mdlw.write(mol); } assertThat(sw.toString(), containsString("M ISO 1 1 12")); }
@Test public void writeChargeAtomProps() throws Exception { IAtomContainer mol = builder.newAtomContainer(); IAtom atom = builder.newAtom(); atom.setSymbol("C"); atom.setFormalCharge(+1); mol.addAtom(atom); StringWriter sw = new StringWriter(); try (MDLV2000Writer mdlw = new MDLV2000Writer(sw)) { mdlw.write(mol); } assertThat(sw.toString(), containsString("C 0 3")); }
@Test public void highAtomicNoElementCount() { IAtomContainer container = TestMoleculeFactory.makeBenzene(); container.getAtom(0).setAtomicNumber(34); container.getAtom(0).setSymbol("Se"); int[] freq = RingBondOffsetComparator.countLightElements(container); assertThat(freq[6], is(5)); }
@Test public void writeDimensionField() throws Exception { IAtomContainer mol = builder.newAtomContainer(); IAtom atom = builder.newAtom(); atom.setSymbol("C"); atom.setImplicitHydrogenCount(4); atom.setPoint2d(new Point2d(0.5, 0.5)); mol.addAtom(atom); StringWriter sw = new StringWriter(); try (MDLV2000Writer mdlw = new MDLV2000Writer(sw)) { mdlw.write(mol); } assertThat(sw.toString(), containsString("2D")); }
@Test public void writeDimensionField3D() throws Exception { IAtomContainer mol = builder.newAtomContainer(); IAtom atom = builder.newAtom(); atom.setSymbol("C"); atom.setImplicitHydrogenCount(4); atom.setPoint3d(new Point3d(0.5, 0.5, 0.1)); mol.addAtom(atom); StringWriter sw = new StringWriter(); try (MDLV2000Writer mdlw = new MDLV2000Writer(sw)) { mdlw.write(mol); } assertThat(sw.toString(), containsString("3D")); }
@Test public void testOverwriteStaticValues() throws Exception { IAtom hydrogen = new ImmutableHydrogen(); hydrogen.setSymbol("C"); hydrogen.setAtomicNumber(12); hydrogen.setMassNumber(13); Assert.assertEquals("H", hydrogen.getSymbol()); Assert.assertEquals(1, hydrogen.getAtomicNumber().intValue()); Assert.assertEquals(1, hydrogen.getMassNumber().intValue()); }
/** * @cdk.bug 1879589 */ @Test public void testChargedSulphurSpecies() throws Exception { String[] expectedTypes = {"C.sp2", "N.sp2", "C.sp2", "C.sp2", "S.plus", "C.sp2"}; IAtomContainer molecule = TestMoleculeFactory.makePyridine(); molecule.getAtom(4).setSymbol("S"); molecule.getAtom(4).setFormalCharge(+1); assertAtomTypes(testedAtomTypes, expectedTypes, molecule); }
@Test public void testIsStereo_IAtomContainer_IAtom_forinvalid() throws Exception { String filename = "data/mdl/trigonal_bipyramidal.mol"; InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename); MDLV2000Reader reader = new MDLV2000Reader(ins); ChemFile chemFile = (ChemFile) reader.read((ChemObject) new ChemFile()); IAtomContainer mol = chemFile.getChemSequence(0).getChemModel(0).getMoleculeSet().getAtomContainer(0); for (int i = 1; i < 6; i++) { mol.getAtom(i).setSymbol("C"); } Assert.assertFalse(BondTools.isStereo(mol, mol.getAtom(0))); Assert.assertFalse(BondTools.isStereo(mol, mol.getAtom(1))); }
@Test public void furaneComparedToThiophene() { IAtomContainer furane = TestMoleculeFactory.makePyrrole(); IAtomContainer thiophene = TestMoleculeFactory.makePyrrole(); assert furane.getAtom(1).getAtomicNumber() == 7; assert thiophene.getAtom(1).getAtomicNumber() == 7; furane.getAtom(1).setAtomicNumber(8); furane.getAtom(1).setSymbol("O"); thiophene.getAtom(1).setAtomicNumber(16); thiophene.getAtom(1).setSymbol("S"); assertThat(new RingBondOffsetComparator().compare(furane, thiophene), is(-1)); assertThat(new RingBondOffsetComparator().compare(thiophene, furane), is(+1)); }
@Test public void furaneComparedToPyrrole() { IAtomContainer furane = TestMoleculeFactory.makePyrrole(); IAtomContainer pyrrole = TestMoleculeFactory.makePyrrole(); assert furane.getAtom(1).getAtomicNumber() == 7; furane.getAtom(1).setAtomicNumber(8); furane.getAtom(1).setSymbol("O"); assertThat(new RingBondOffsetComparator().compare(pyrrole, furane), is(-1)); assertThat(new RingBondOffsetComparator().compare(furane, pyrrole), is(+1)); }
/** * Test for the structure in XLogPDescriptorTest.testno937(). */ @Test public void testno937() throws Exception { String[] expectedTypes = {"C.sp2", "N.planar3", "C.sp2", "N.sp2", "C.sp2", "C.sp3"}; IAtomContainer molecule = TestMoleculeFactory.makePyrrole(); molecule.getAtom(3).setSymbol("N"); molecule.addAtom(molecule.getBuilder().newInstance(IAtom.class, "C")); molecule.addBond(1, 5, IBond.Order.SINGLE); assertAtomTypes(testedAtomTypes, expectedTypes, molecule); }
/** * Tests if a template matches if just an element is non-carbon. */ @Test public void testOtherElements() throws Exception { boolean itIsInThere = false; TemplateHandler th = new TemplateHandler(DefaultChemObjectBuilder.getInstance()); IAtomContainer mol = TestMoleculeFactory.makeSteran(); itIsInThere = th.mapTemplates(mol); Assert.assertTrue(itIsInThere); mol.getAtom(0).setSymbol("N"); itIsInThere = th.mapTemplates(mol); Assert.assertTrue(itIsInThere); }