@Override public int compare(IAtomContainer a, IAtomContainer b) { return -Integer.compare(a.getBondCount(), b.getBondCount()); } });
/** * Create a map with enough space for all the bonds in the molecule, * {@code container}. Note - the map is not filled by this method. * * @param container the container * @return a map with enough space for the container */ public static EdgeToBondMap withSpaceFor(IAtomContainer container) { return new EdgeToBondMap(container.getBondCount()); } }
public static int getBondCount(IAtomContainerSet set) { int count = 0; for (IAtomContainer atomContainer : set.atomContainers()) { count += (atomContainer).getBondCount(); } return count; }
private boolean validate(IAtomContainer mol) { return mol.getAtomCount() == numAtoms && mol.getBondCount() == numBonds && (System.nanoTime() - tInit) < MAX_AGE; } }
/** * Create a map with enough space for all the bonds in the molecule, * {@code container}. Note - the map is not filled by this method. * * @param container the container * @return a map with enough space for the container */ public static EdgeToBondMap withSpaceFor(IAtomContainer container) { return new EdgeToBondMap(container.getBondCount()); } }
/** * Constructs an array of Bond objects from an AtomContainer. * @param container The original AtomContainer. * @return The array of Bond objects. */ public static IBond[] getBondArray(IAtomContainer container) { IBond[] ret = new IBond[container.getBondCount()]; for (int i = 0; i < ret.length; ++i) ret[i] = container.getBond(i); return ret; }
IBond addBond(IAtom atom, IBond bond) { if (atom.equals(bond.getBegin())) { mol.addBond(bond); bond = mol.getBond(mol.getBondCount() - 1); } LocalNbrs nbrs = local.get(atom); if (nbrs == null) local.put(atom, nbrs = new LocalNbrs(false)); nbrs.bonds.add(bond); return bond; }
public IAtomContainer removeLoopBonds(IAtomContainer molecule, int position) { for (int i = 0; i < molecule.getBondCount(); i++) { IBond bond = molecule.getBond(i); if (bond.getBegin().equals(bond.getEnd())) { System.out.println("Loop found! Molecule:" + position); molecule.removeBond(bond); } } return molecule; }
private IBond getBond(int i) { if (molecule.getBondCount() <= i) { molecule.addBond(molecule.getBuilder().newInstance(IBond.class)); } return molecule.getBond(i); }
/** * clean the flags CDKConstants.REACTIVE_CENTER from the molecule. * * @param ac */ private void cleanFlagReactiveCenter(IAtomContainer ac) { for (int j = 0; j < ac.getAtomCount(); j++) ac.getAtom(j).setFlag(CDKConstants.REACTIVE_CENTER, false); for (int j = 0; j < ac.getBondCount(); j++) ac.getBond(j).setFlag(CDKConstants.REACTIVE_CENTER, false); } }
@Test public void testFusedRingFragments() { RingSearch search = new RingSearch(hexaphenylene); List<IAtomContainer> fused = search.fusedRingFragments(); assertThat(fused.size(), is(1)); assertThat(fused.get(0).getAtomCount(), is(hexaphenylene.getAtomCount())); assertThat(fused.get(0).getBondCount(), is(hexaphenylene.getBondCount())); }
@Test public void testFusedRingFragments() { List<IAtomContainer> fragments = new RingSearch(bicyclo).fusedRingFragments(); assertThat(fragments.size(), is(1)); IAtomContainer fragment = fragments.get(0); assertThat(fragment.getAtomCount(), is(bicyclo.getAtomCount())); assertThat(fragment.getBondCount(), is(bicyclo.getBondCount())); }
@Test public void testMolecule() throws Exception { String filename = "data/owl/molecule.n3"; logger.info("Testing: " + filename); InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename); CDKOWLReader reader = new CDKOWLReader(new InputStreamReader(ins)); IAtomContainer mol = reader.read(new AtomContainer()); reader.close(); Assert.assertNotNull(mol); Assert.assertEquals(2, mol.getAtomCount()); Assert.assertEquals(1, mol.getBondCount()); }
@Test public void testExtractSubstructure() throws CloneNotSupportedException { IAtomContainer source = TestMoleculeFactory.makeEthylCyclohexane(); IAtomContainer ringSubstructure = AtomContainerManipulator.extractSubstructure(source, 0, 1, 2, 3, 4, 5); Assert.assertEquals(6, ringSubstructure.getAtomCount()); Assert.assertEquals(6, ringSubstructure.getBondCount()); }
@Test public void testConvertToAtomContainer_IRingSet() { IAtomContainer molecule = TestMoleculeFactory.makeAlphaPinene(); IRingSet ringSet = Cycles.sssr(molecule).toRingSet(); IAtomContainer ac = RingPartitioner.convertToAtomContainer(ringSet); Assert.assertEquals(7, ac.getAtomCount()); Assert.assertEquals(8, ac.getBondCount()); }
@Test public void testMolecule_int_int_int_int() { IAtomContainer m = new AtomContainer(5, 5, 1, 1); Assert.assertNotNull(m); Assert.assertEquals(0, m.getAtomCount()); Assert.assertEquals(0, m.getBondCount()); Assert.assertEquals(0, m.getLonePairCount()); Assert.assertEquals(0, m.getSingleElectronCount()); }
@Test public void testConnectedByRingClosure_TwoAtom() throws Exception { String methanol = "C1.O1"; IAtomContainer mol = sp.parseSmiles(methanol); Assert.assertEquals(2, mol.getAtomCount()); Assert.assertEquals(1, mol.getBondCount()); IAtomContainerSet fragments = ConnectivityChecker.partitionIntoMolecules(mol); int fragmentCount = fragments.getAtomContainerCount(); Assert.assertEquals(1, fragmentCount); IAtomContainer mol1 = fragments.getAtomContainer(0); Assert.assertEquals(2, mol1.getAtomCount()); }
@Test public void testBondAromatic() throws Exception { String cmlString = "<molecule id='m1'><atomArray atomID='a1 a2'/><bondArray atomRef1='a1' atomRef2='a2' order='A'/></molecule>"; IChemFile chemFile = parseCMLString(cmlString); IAtomContainer mol = checkForSingleMoleculeFile(chemFile); Assert.assertEquals(2, mol.getAtomCount()); Assert.assertEquals(1, mol.getBondCount()); org.openscience.cdk.interfaces.IBond bond = mol.getBond(0); Assert.assertEquals(Order.SINGLE, bond.getOrder()); Assert.assertTrue(bond.getFlag(CDKConstants.ISAROMATIC)); }
@Test public void testBondAromatic() throws Exception { String cmlString = "<molecule id='m1'><atomArray atomID='a1 a2'/><bondArray atomRef1='a1' atomRef2='a2' order='A'/></molecule>"; IChemFile chemFile = parseCMLString(cmlString); IAtomContainer mol = checkForSingleMoleculeFile(chemFile); Assert.assertEquals(2, mol.getAtomCount()); Assert.assertEquals(1, mol.getBondCount()); org.openscience.cdk.interfaces.IBond bond = mol.getBond(0); Assert.assertEquals(Order.SINGLE, bond.getOrder()); Assert.assertTrue(bond.getFlag(CDKConstants.ISAROMATIC)); }
@Test public void makeEdgeTest_singleBond() { MoleculeFromSignatureBuilder builder = new MoleculeFromSignatureBuilder(SilentChemObjectBuilder.getInstance()); builder.makeGraph(); builder.makeVertex("C"); builder.makeVertex("C"); builder.makeEdge(0, 1, "C", "C", ""); IAtomContainer product = builder.getAtomContainer(); Assert.assertEquals(2, product.getAtomCount()); Assert.assertEquals(1, product.getBondCount()); Assert.assertEquals(IBond.Order.SINGLE, product.getBond(0).getOrder()); }