コード例 #1
0
ファイル: SmilesGeneratorTest.java プロジェクト: jonalv/cdk
 private void fixCarbonHCount(IAtomContainer mol) {
   /*
    *  the following line are just a quick fix for this
    *  particluar carbon-only molecule until we have a proper
    *  hydrogen count configurator
    */
   double bondCount = 0;
   org.openscience.cdk.interfaces.IAtom atom;
   for (int f = 0; f < mol.getAtomCount(); f++) {
     atom = mol.getAtom(f);
     bondCount = mol.getBondOrderSum(atom);
     int correction =
         (int) bondCount - (atom.getCharge() != null ? atom.getCharge().intValue() : 0);
     if (atom.getSymbol().equals("C")) {
       atom.setImplicitHydrogenCount(4 - correction);
     } else if (atom.getSymbol().equals("N")) {
       atom.setImplicitHydrogenCount(3 - correction);
     }
     if (standAlone) {
       System.out.println("Hydrogen count for atom " + f + ": " + atom.getImplicitHydrogenCount());
     }
   }
 }
コード例 #2
0
 public static boolean hasPartialCharges(IAtomContainer molecule) {
   for (IAtom atom : molecule.atoms()) if (atom.getCharge() != 0.0000) return true;
   return false;
 }