@Override public boolean areRootAtomsDefined() { for (Integer rgpNum : rGroupDefinitions.keySet()) { boolean represented = false; rootLoop: for (IAtom rootAtom : this.getRootStructure().atoms()) { if (rootAtom instanceof IPseudoAtom && rootAtom.getSymbol().startsWith("R")) { IPseudoAtom pseudo = (IPseudoAtom) rootAtom; if (pseudo.getLabel().length() > 1) { int rootAtomRgrpNumber = Integer.valueOf(pseudo.getLabel().substring(1)); if (rootAtomRgrpNumber == rgpNum) { represented = true; break rootLoop; } } } } if (!represented) { return false; } } return true; }
IAtomContainer root = this.getRootStructure(); IAtomContainer rootClone = null; try {
/** * Test parsing of RGFile rgfile.7.mol. * This RGFile has APO lines with value 3: both attachment points.<P> * * Also, R32 appears twice, but with different numbers of attachment. * The parser should not trip over this, and make nice configurations. */ @Test public void testRgroupQueryFile7() throws Exception { String filename = "data/mdl/rgfile.7.mol"; logger.info("Testing: " + filename); InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename); RGroupQueryReader reader = new RGroupQueryReader(ins); RGroupQuery rGroupQuery = (RGroupQuery) reader.read(new RGroupQuery(DefaultChemObjectBuilder.getInstance())); reader.close(); Assert.assertNotNull(rGroupQuery); Assert.assertEquals(rGroupQuery.getRGroupDefinitions().size(), 1); Assert.assertEquals(rGroupQuery.getRootStructure().getAtomCount(), 9); Assert.assertEquals(rGroupQuery.getAllConfigurations().size(), 20); }
Assert.assertNotNull(rGroupQuery); Assert.assertEquals(rGroupQuery.getRGroupDefinitions().size(), 1); Assert.assertEquals(rGroupQuery.getRootStructure().getAtomCount(), 10); Assert.assertEquals(rGroupQuery.getRootAttachmentPoints().size(), 2);
/** * Test parsing of RGFile rgfile.6.mol. * This RGFile is incomplete, RGP lines are missing. We still want to * accept it (Symyx/ChemAxon software accepts it too). */ @Test(expected = CDKException.class) public void testRgroupQueryFile6() throws Exception { String filename = "data/mdl/rgfile.6.mol"; logger.info("Testing: " + filename); InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename); RGroupQueryReader reader = new RGroupQueryReader(ins); RGroupQuery rGroupQuery = (RGroupQuery) reader.read(new RGroupQuery(DefaultChemObjectBuilder.getInstance())); reader.close(); Assert.assertNotNull(rGroupQuery); Assert.assertEquals(rGroupQuery.getRGroupDefinitions().size(), 3); Assert.assertEquals(rGroupQuery.getRootStructure().getAtomCount(), 14); // This file has missing $RGP blocks. You could argue that this is // thus not a legal query (ie missing query specifications) Assert.assertFalse(rGroupQuery.areSubstituentsDefined()); //Getting for all configurations won't happen, because not all groups were set rGroupQuery.getAllConfigurations(); // Will raise exception }
Assert.assertNotNull(rGroupQuery); Assert.assertEquals(rGroupQuery.getRGroupDefinitions().size(), 1); Assert.assertEquals(rGroupQuery.getRootStructure().getAtomCount(), 6);
Assert.assertNotNull(rGroupQuery); Assert.assertEquals(rGroupQuery.getRGroupDefinitions().size(), 1); Assert.assertEquals(rGroupQuery.getRootStructure().getAtomCount(), 7); Assert.assertEquals(apoBonds.size(), 1); for (IBond bond : rGroupQuery.getRootStructure().bonds()) { if (bond.contains(at)) { Assert.assertEquals(bond, apoBonds.get(1));
Assert.assertNotNull(rGroupQuery); Assert.assertEquals(rGroupQuery.getRGroupDefinitions().size(), 3); Assert.assertEquals(rGroupQuery.getRootStructure().getAtomCount(), 14); Assert.assertEquals(rGroupQuery.getRootAttachmentPoints().size(), 4);