protected static IAtomContainer clone(IAtomContainer mol) { try { return mol.clone(); } catch (CloneNotSupportedException e) { throw new IllegalStateException("Could not clone AtomContainer!"); } }
private synchronized double getRingMatchScore(List<IAtomContainer> list) throws CloneNotSupportedException { double lScore = 0; IAtomContainer listMap = list.get(0).clone(); IAtomContainer subGraph = list.get(1).clone(); try { Cycles cycles = Cycles.all(subGraph); lScore = getRingMatch(cycles.toRingSet(), listMap); } catch (Intractable ex) { Logger.getLogger(StereoFilter.class.getName()).log(Level.SEVERE, null, ex); } return lScore; }
@Override public IFragmentAtom clone() throws CloneNotSupportedException { IFragmentAtom cpy = (IFragmentAtom) super.clone(); cpy.setFragment(fragment.clone()); cpy.setExpanded(isExpanded); return cpy; } }
@Override public IFragmentAtom clone() throws CloneNotSupportedException { IFragmentAtom cpy = (IFragmentAtom) super.clone(); cpy.setFragment(fragment.clone()); cpy.setExpanded(isExpanded); return cpy; } }
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; }
@Override public IFragmentAtom clone() throws CloneNotSupportedException { IFragmentAtom cpy = (IFragmentAtom) super.clone(); cpy.setFragment(fragment.clone()); cpy.setExpanded(isExpanded); return cpy; } }
@Override public IFragmentAtom clone() throws CloneNotSupportedException { IFragmentAtom cpy = (IFragmentAtom) super.clone(); cpy.setFragment(fragment.clone()); cpy.setExpanded(isExpanded); return cpy; } }
public ArrayFingerprint computeFingerprint(IAtomContainer molecule) { try { return new BooleanFingerprint(cdkFingerprintVersion, new FixedFingerprinterInstance(molecule.clone()).getAsBooleanArray()).asArray(); } catch (CloneNotSupportedException e) { throw new RuntimeException(e); } }
/** * Only test whether the atoms are correctly cloned. */ @Test @Override public void testClone() throws Exception { IAtomContainer molecule = (IAtomContainer) newChemObject(); Object clone = molecule.clone(); assertTrue(clone instanceof IAtomContainer); }
@Test @Override public void testClone() throws Exception { IAtomContainer molecule = (IAtomContainer) newChemObject(); Object clone = molecule.clone(); Assert.assertTrue(clone instanceof IAtomContainer); Assert.assertNotSame(molecule, clone); }
private boolean showIt(IAtomContainer molecule, String name) throws Exception { StructureDiagramGenerator sdg = new StructureDiagramGenerator(); sdg.setMolecule((IAtomContainer) molecule.clone()); sdg.generateCoordinates(new Vector2d(0, 1)); return true; }
@Test public void testReadingIDs() throws Exception { String filename = "data/mol2/fromWebsite.mol2"; InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename); Mol2Reader reader = new Mol2Reader(ins); IAtomContainer molecule = (IAtomContainer) reader.read(new AtomContainer()); reader.close(); Assert.assertNotNull(molecule); IAtomContainer reference = (IAtomContainer) molecule.clone(); Assert.assertEquals("C1", reference.getAtom(0).getID()); }
@Test public void testCalculate_NoModifications() throws Exception { IAtomContainer mol = someoneBringMeSomeWater(DefaultChemObjectBuilder.getInstance()); IAtomContainer clone = (IAtomContainer) mol.clone(); descriptor.calculate(mol); String diff = AtomContainerDiff.diff(clone, mol); Assert.assertEquals("The descriptor must not change the passed molecule in any respect, but found this diff: " + diff, 0, diff.length()); }
@Test public void testClone_AtomlessISingleElectron() throws Exception { IAtomContainer molecule = (IAtomContainer) newChemObject(); ISingleElectron singleElectron = molecule.getBuilder().newInstance(ISingleElectron.class); molecule.addSingleElectron(singleElectron); Assert.assertEquals(singleElectron, molecule.getSingleElectron(0)); IAtomContainer clone = (IAtomContainer) molecule.clone(); Assert.assertNotNull(clone.getSingleElectron(0)); }
@Test public void testClone_AtomlessILonePair() throws Exception { IAtomContainer molecule = (IAtomContainer) newChemObject(); ILonePair lonePair = molecule.getBuilder().newInstance(ILonePair.class); molecule.addLonePair(lonePair); Assert.assertEquals(lonePair, molecule.getLonePair(0)); IAtomContainer clone = (IAtomContainer) molecule.clone(); Assert.assertNotNull(clone.getLonePair(0)); }
@Test public void testCloneButKeepOriginalsIntact() throws Exception { IAtomContainer molecule = (IAtomContainer) newChemObject(); IAtom atom = molecule.getBuilder().newInstance(IAtom.class); molecule.addAtom(atom); Assert.assertEquals(atom, molecule.getAtom(0)); Object clone = molecule.clone(); Assert.assertNotSame(molecule, clone); // after the cloning the IAtom on the original IAtomContainer should be unchanged Assert.assertEquals(atom, molecule.getAtom(0)); }
@Test public void testClone_AtomlessIBond() throws Exception { IAtomContainer molecule = (IAtomContainer) newChemObject(); IBond bond = molecule.getBuilder().newInstance(IBond.class); molecule.addBond(bond); Assert.assertEquals(bond, molecule.getBond(0)); IAtomContainer clone = (IAtomContainer) molecule.clone(); Assert.assertEquals(0, clone.getBond(0).getAtomCount()); }
@Test public void testClone_IAtom2() throws Exception { IAtomContainer molecule = (IAtomContainer) newChemObject(); IAtom carbon = molecule.getBuilder().newInstance(IAtom.class, "C"); carbon.setPoint2d(new Point2d(2, 4)); molecule.addAtom(carbon); // 1 // test cloning of Atoms IAtomContainer clonedMol = (IAtomContainer) molecule.clone(); carbon.setPoint2d(new Point2d(3, 1)); Assert.assertEquals(clonedMol.getAtom(0).getPoint2d().x, 2.0, 0.001); }
@Test public void testCloneButKeepOriginalsIntact_ISingleElectron() throws Exception { IAtomContainer molecule = (IAtomContainer) newChemObject(); molecule.addAtom(molecule.getBuilder().newInstance(IAtom.class)); ISingleElectron singleElectron = molecule.getBuilder().newInstance(ISingleElectron.class, molecule.getAtom(0)); molecule.addSingleElectron(singleElectron); Assert.assertEquals(singleElectron, molecule.getSingleElectron(0)); Object clone = molecule.clone(); Assert.assertNotSame(molecule, clone); // after the cloning the ISingleElectron on the original IAtomContainer should be unchanged Assert.assertEquals(singleElectron, molecule.getSingleElectron(0)); }
@Test public void testCloneButKeepOriginalsIntact_ILonePair() throws Exception { IAtomContainer molecule = (IAtomContainer) newChemObject(); molecule.addAtom(molecule.getBuilder().newInstance(IAtom.class)); ILonePair lonePair = molecule.getBuilder().newInstance(ILonePair.class, molecule.getAtom(0)); molecule.addLonePair(lonePair); Assert.assertEquals(lonePair, molecule.getLonePair(0)); Object clone = molecule.clone(); Assert.assertNotSame(molecule, clone); // after the cloning the ILonePair on the original IAtomContainer should be unchanged Assert.assertEquals(lonePair, molecule.getLonePair(0)); }