SpiroAtomCountDescriptor extends AbstractMolecularDescriptor implements IMolecularDescriptor { @Override public DescriptorValue calculate(IAtomContainer atomContainer) { int nSpiro = 0; try { IAtomContainer local = atomContainer.clone(); Cycles.markRingAtomsAndBonds(local); for (IAtom atom : local.atoms()) { if (getSpiroDegree(local, atom) != 0) nSpiro++; } return new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), new IntegerResult(nSpiro), getDescriptorNames()); } catch (CloneNotSupportedException e) { return getDummyDescriptorValue(e); } } SpiroAtomCountDescriptor(); @Override void initialise(IChemObjectBuilder builder); @Override DescriptorSpecification getSpecification(); @Override void setParameters(Object[] params); @Override Object[] getParameters(); @Override String[] getDescriptorNames(); @Override DescriptorValue calculate(IAtomContainer atomContainer); @Override IDescriptorResult getDescriptorResultType(); @Override String[] getParameterNames(); @Override Object getParameterType(String name);  }
@Test public void testNorbornane() throws Exception { IAtomContainer mol = sp.parseSmiles("C1CC2CCC1C2"); DescriptorValue value = descriptor.calculate(mol); Assert.assertEquals(0, ((IntegerResult) value.getValue()).intValue()); }
@Test public void testSpiroUndecane() throws Exception { IAtomContainer mol = sp.parseSmiles("C1CCC2(CC1)CCCCC2"); DescriptorValue value = descriptor.calculate(mol); Assert.assertEquals(1, ((IntegerResult) value.getValue()).intValue()); }
@Test public void testDiSpiroPentane() throws Exception { IAtomContainer mol = sp.parseSmiles("CC1C[C]11(CC1)[C]123CC1.C2C3"); DescriptorValue value = descriptor.calculate(mol); Assert.assertEquals(2, ((IntegerResult) value.getValue()).intValue()); }
@Test public void testSpiroNaphthalene() throws Exception { SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer mol = sp.parseSmiles("C1CCC2(CC1)CC=C1C=CC=CC1=C2"); DescriptorValue value = descriptor.calculate(mol); Assert.assertEquals(1, ((IntegerResult) value.getValue()).intValue()); }
@Test public void testTriSpiro() throws Exception { IAtomContainer mol = sp.parseSmiles("C1OOC[Fe]1123COOC1.C2OOC3"); DescriptorValue value = descriptor.calculate(mol); Assert.assertEquals(1, ((IntegerResult) value.getValue()).intValue()); }