ProtonTotalPartialChargeDescriptor extends AbstractAtomicDescriptor implements IAtomicDescriptor { @Override public DescriptorValue calculate(IAtom atom, IAtomContainer ac) { neighboors = ac.getConnectedAtomsList(atom); IAtomContainer clone; try { clone = (IAtomContainer) ac.clone(); } catch (CloneNotSupportedException e) { return getDummyDescriptorValue(e); } try { peoe = new GasteigerMarsiliPartialCharges(); peoe.setMaxGasteigerIters(6); peoe.assignGasteigerMarsiliSigmaPartialCharges(clone, true); } catch (Exception exception) { return getDummyDescriptorValue(exception); } IAtom localAtom = clone.getAtom(ac.indexOf(atom)); neighboors = clone.getConnectedAtomsList(localAtom); DoubleArrayResult protonPartialCharge = new DoubleArrayResult(MAX_PROTON_COUNT); assert (neighboors.size() < MAX_PROTON_COUNT); protonPartialCharge.add(localAtom.getCharge()); int hydrogenNeighbors = 0; for (IAtom neighboor : neighboors) { if (neighboor.getSymbol().equals("H")) { hydrogenNeighbors++; protonPartialCharge.add(neighboor.getCharge()); } } int remainder = MAX_PROTON_COUNT - (hydrogenNeighbors + 1); for (int i = 0; i < remainder; i++) protonPartialCharge.add(Double.NaN); return new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), protonPartialCharge, getDescriptorNames()); } ProtonTotalPartialChargeDescriptor(); @Override DescriptorSpecification getSpecification(); @Override void setParameters(Object[] params); @Override Object[] getParameters(); @Override String[] getDescriptorNames(); @Override DescriptorValue calculate(IAtom atom, IAtomContainer ac); @Override String[] getParameterNames(); @Override Object getParameterType(String name);  }
@Test public void testNaNs() throws java.lang.Exception { IAtomicDescriptor descriptor = new ProtonTotalPartialChargeDescriptor(); SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer mol = sp.parseSmiles("C(F)(F)"); addExplicitHydrogens(mol); DoubleArrayResult retval = (DoubleArrayResult) descriptor.calculate(mol.getAtom(0), mol).getValue(); Assert.assertEquals(5, retval.length()); Assert.assertTrue(Double.isNaN(retval.get(3))); Assert.assertTrue(Double.isNaN(retval.get(4))); }