TPSADescriptor extends AbstractMolecularDescriptor implements IMolecularDescriptor { @Override public DescriptorValue calculate(IAtomContainer atomContainer) { IAtomContainer ac; try { ac = (IAtomContainer) atomContainer.clone(); } catch (CloneNotSupportedException e) { return getDummyDescriptorValue(e); } List<String> profiles = new ArrayList<String>(); IRingSet rs; try { rs = (new AllRingsFinder()).findAllRings(ac); } catch (CDKException e) { return getDummyDescriptorValue(e); } if (checkAromaticity) { try { AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(ac); Aromaticity.cdkLegacy().apply(ac); } catch (CDKException e) { return getDummyDescriptorValue(e); } } for (IAtom atom : ac.atoms()) { if (atom.getAtomicNumber() == IElement.N || atom.getAtomicNumber() == IElement.O || atom.getAtomicNumber() == IElement.S || atom.getAtomicNumber() == IElement.P) { int singleBondCount = 0; int doubleBondCount = 0; int tripleBondCount = 0; int aromaticBondCount = 0; double maxBondOrder = 0; double bondOrderSum = 0; int hCount = 0; int isIn3MemberRing = 0; List<IBond> connectedBonds = ac.getConnectedBondsList(atom); for (IBond connectedBond : connectedBonds) { if (connectedBond.getFlag(CDKConstants.ISAROMATIC)) aromaticBondCount++; else if (connectedBond.getOrder() == Order.SINGLE) singleBondCount++; else if (connectedBond.getOrder() == Order.DOUBLE) doubleBondCount++; else if (connectedBond.getOrder() == Order.TRIPLE) tripleBondCount++; } int formalCharge = atom.getFormalCharge(); List<IAtom> connectedAtoms = ac.getConnectedAtomsList(atom); int numberOfNeighbours = connectedAtoms.size(); for (int neighbourIndex = 0; neighbourIndex < numberOfNeighbours; neighbourIndex++) if (((IAtom) connectedAtoms.get(neighbourIndex)).getAtomicNumber() == IElement.H) hCount++; Integer implicitHAtoms = atom.getImplicitHydrogenCount(); if (implicitHAtoms == CDKConstants.UNSET) { implicitHAtoms = 0; } for (int hydrogenIndex = 0; hydrogenIndex < implicitHAtoms; hydrogenIndex++) { hCount++; numberOfNeighbours++; singleBondCount++; } bondOrderSum += singleBondCount * 1.0; bondOrderSum += doubleBondCount * 2.0; bondOrderSum += tripleBondCount * 3.0; bondOrderSum += aromaticBondCount * 1.5; if (singleBondCount > 0) maxBondOrder = 1.0; if (aromaticBondCount > 0) maxBondOrder = 1.5; if (doubleBondCount > 0) maxBondOrder = 2.0; if (tripleBondCount > 0) maxBondOrder = 3.0; if (rs.contains(atom)) { IRingSet rsAtom = rs.getRings(atom); for (int ringSetIndex = 0; ringSetIndex < rsAtom.getAtomContainerCount(); ringSetIndex++) { IRing ring = (IRing) rsAtom.getAtomContainer(ringSetIndex); if (ring.getRingSize() == 3) isIn3MemberRing = 1; } } String profile = atom.getSymbol() + "+" + maxBondOrder + "+" + bondOrderSum + "+" + numberOfNeighbours + "+" + hCount + "+" + formalCharge + "+" + aromaticBondCount + "+" + isIn3MemberRing + "+" + singleBondCount + "+" + doubleBondCount + "+" + tripleBondCount; profiles.add(profile); } } double tpsa = 0; for (int profileIndex = 0; profileIndex < profiles.size(); profileIndex++) { if (map.containsKey(profiles.get(profileIndex))) { tpsa += (Double) map.get(profiles.get(profileIndex)); } } profiles.clear(); return new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), new DoubleResult(tpsa), getDescriptorNames()); } TPSADescriptor(); @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 testTPSA1() throws Exception { IAtomContainer mol = sp.parseSmiles("O=C(O)CC"); addExplicitHydrogens(mol); Assert.assertEquals(37.29, ((DoubleResult) descriptor.calculate(mol).getValue()).doubleValue(), 0.01); }
@Test public void testTPSA2() throws Exception { IAtomContainer mol = sp.parseSmiles("C=NC(CC#N)N(C)C"); addExplicitHydrogens(mol); Assert.assertEquals(39.39, ((DoubleResult) descriptor.calculate(mol).getValue()).doubleValue(), 0.01); }
@Test public void testTPSA3() throws Exception { IAtomContainer mol = sp.parseSmiles("CCCN(=O)=O"); addExplicitHydrogens(mol); Assert.assertEquals(45.82, ((DoubleResult) descriptor.calculate(mol).getValue()).doubleValue(), 0.01); }
@Test public void testTPSA4() throws Exception { IAtomContainer mol = sp.parseSmiles("C#N=CC(CNC)N1CC1"); addExplicitHydrogens(mol); Assert.assertEquals(28.632, ((DoubleResult) descriptor.calculate(mol).getValue()).doubleValue(), 0.01); }
@Test public void testTPSA5() throws Exception { IAtomContainer mol = sp.parseSmiles("c1ccncc1"); addExplicitHydrogens(mol); Assert.assertEquals(12.892, ((DoubleResult) descriptor.calculate(mol).getValue()).doubleValue(), 0.01); }
@Test public void testTPSA6() throws java.lang.Exception { IAtomContainer mol = sp.parseSmiles("[H][N+]([H])(C)C"); addExplicitHydrogens(mol); Assert.assertEquals(16.61, ((DoubleResult) descriptor.calculate(mol).getValue()).doubleValue(), 0.1); }
@Test public void testTPSA7() throws java.lang.Exception { IAtomContainer mol = sp.parseSmiles("C(I)I"); addExplicitHydrogens(mol); Assert.assertEquals(0.0, ((DoubleResult) descriptor.calculate(mol).getValue()).doubleValue(), 0.1); }
@Test public void testTPSA8() throws java.lang.Exception { IAtomContainer mol = sp.parseSmiles("C(O)O"); addExplicitHydrogens(mol); Assert.assertEquals(40.45, ((DoubleResult) descriptor.calculate(mol).getValue()).doubleValue(), 0.1); }
@Test public void testRing() throws Exception { sp = new SmilesParser(SilentChemObjectBuilder.getInstance()); IAtomContainer mol = sp.parseSmiles("C1CCCC1CCC2CCCNC2"); addExplicitHydrogens(mol); DescriptorValue dv = descriptor.calculate(mol); Assert.assertNotNull(dv); }