GasteigerMarsiliPartialCharges implements IChargeCalculator { public double[] assignGasteigerSigmaMarsiliFactors(IAtomContainer ac) throws CDKException { double[] gasteigerFactors = new double[(ac.getAtomCount() * (STEP_SIZE + 1))]; double[] factors = new double[]{0.0, 0.0, 0.0}; for (int i = 0; i < ac.getAtomCount(); i++) { factors[0] = 0.0; factors[1] = 0.0; factors[2] = 0.0; final IAtom atom = ac.getAtom(i); final String symbol = atom.getSymbol(); final IBond.Order maxBondOrder = ac.getMaximumBondOrder(atom); final Integer charge = atom.getFormalCharge(); switch (symbol) { case "H": factors[0] = 7.17; factors[1] = 6.24; factors[2] = -0.56; break; case "C": if (maxBondOrder == IBond.Order.DOUBLE || (maxBondOrder == IBond.Order.SINGLE && (charge == -1 || charge == +1))) { factors[0] = 8.79; factors[1] = 9.32; factors[2] = 1.51; } else if (maxBondOrder == IBond.Order.SINGLE && charge == 0) { factors[0] = 7.98; factors[1] = 9.18; factors[2] = 1.88; } else if (maxBondOrder == IBond.Order.TRIPLE || maxBondOrder == IBond.Order.QUADRUPLE) { factors[0] = 10.39; factors[1] = 9.45; factors[2] = 0.73; } break; case "N": if ((maxBondOrder == IBond.Order.SINGLE) && (charge != -1)) { factors[0] = 11.54; factors[1] = 10.82; factors[2] = 1.36; } else if ((maxBondOrder == IBond.Order.DOUBLE) || ((maxBondOrder == IBond.Order.SINGLE))) { factors[0] = 12.87; factors[1] = 11.15; factors[2] = 0.85; } else if (maxBondOrder == IBond.Order.TRIPLE || maxBondOrder == IBond.Order.QUADRUPLE) { factors[0] = 17.68; factors[1] = 12.70; factors[2] = -0.27; } break; case "O": if ((maxBondOrder == IBond.Order.SINGLE) && (charge != -1)) { factors[0] = 14.18; factors[1] = 12.92; factors[2] = 1.39; } else if ((maxBondOrder == IBond.Order.DOUBLE) || ((maxBondOrder == IBond.Order.SINGLE))) { factors[0] = 17.07; factors[1] = 13.79; factors[2] = 0.47; } break; case "Si": factors[0] = 8.10; factors[1] = 7.92; factors[2] = 1.78; break; case "P": factors[0] = 8.90; factors[1] = 8.32; factors[2] = 1.58; break; case "S": factors[0] = 10.14; factors[1] = 9.13; factors[2] = 1.38; break; case "F": factors[0] = 14.66; factors[1] = 13.85; factors[2] = 2.31; break; case "Cl": factors[0] = 12.31; factors[1] = 10.84; factors[2] = 1.512; break; case "Br": factors[0] = 11.44; factors[1] = 9.63; factors[2] = 1.31; break; case "I": factors[0] = 9.88; factors[1] = 7.95; factors[2] = 0.945; break; default: throw new CDKException("Partial charge not-supported for element: '" + symbol + "'."); } gasteigerFactors[STEP_SIZE * i + i] = factors[0]; gasteigerFactors[STEP_SIZE * i + i + 1] = factors[1]; gasteigerFactors[STEP_SIZE * i + i + 2] = factors[2]; gasteigerFactors[STEP_SIZE * i + i + 5] = atom.getCharge(); if (factors[0] == 0 && factors[1] == 0 && factors[2] == 0) { gasteigerFactors[STEP_SIZE * i + i + 3] = 1; } else { gasteigerFactors[STEP_SIZE * i + i + 3] = factors[0] + factors[1] + factors[2]; } } return gasteigerFactors; } GasteigerMarsiliPartialCharges(); void setChiCatHydrogen(double chiCat); void setMaxGasteigerDamp(double damp); void setMaxGasteigerIters(double iters); double getChiCatHydrogen(); double getMaxGasteigerDamp(); double getMaxGasteigerIters(); IAtomContainer assignGasteigerMarsiliSigmaPartialCharges(IAtomContainer ac, boolean setCharge); @Override void calculateCharges(IAtomContainer container); int getStepSize(); void setStepSize(int step); double[] assignGasteigerSigmaMarsiliFactors(IAtomContainer ac);  }
@Test public void testAssignGasteigerSigmaMarsiliFactors_IAtomContainer() throws Exception { GasteigerMarsiliPartialCharges peoe = new GasteigerMarsiliPartialCharges(); IAtomContainer molecule = builder.newInstance(IAtomContainer.class); molecule.addAtom(new Atom("C")); molecule.getAtom(0).setCharge(0.0); molecule.addAtom(new Atom("F")); molecule.getAtom(1).setCharge(0.0); molecule.addBond(0, 1, IBond.Order.SINGLE); addExplicitHydrogens(molecule); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(molecule); lpcheck.saturate(molecule); for (IAtom atom : molecule.atoms()) atom.setCharge(0.0); org.hamcrest.MatcherAssert.assertThat(peoe.assignGasteigerSigmaMarsiliFactors(molecule).length, is(not(0))); }