MolOp { public static void perceiveDativeBonds(IAtomContainer mol) { for (IBond bond : mol.bonds()) { IAtom beg = bond.getBegin(); IAtom end = bond.getEnd(); if (isDativeDonor(end) && isDativeAcceptor(beg)) { bond.setDisplay(IBond.Display.ArrowBeg); } else if (isDativeDonor(beg) && isDativeAcceptor(end)) { bond.setDisplay(IBond.Display.ArrowEnd); } else if (isPosDativeDonor(end) && isNegDativeAcceptor(beg)) { bond.setDisplay(IBond.Display.ArrowBeg); beg.setFormalCharge(beg.getFormalCharge()+1); end.setFormalCharge(end.getFormalCharge()-1); } else if (isPosDativeDonor(beg) && isNegDativeAcceptor(end)) { bond.setDisplay(IBond.Display.ArrowEnd); beg.setFormalCharge(beg.getFormalCharge()-1); end.setFormalCharge(end.getFormalCharge()+1); } } }  static void perceiveRadicals(IAtomContainer mol); static void perceiveDativeBonds(IAtomContainer mol);  }
@Test public void NO2() throws InvalidSmilesException { SmilesParser smipar = new SmilesParser(SilentChemObjectBuilder.getInstance()); IAtomContainer mol = smipar.parseSmiles("[Co][N+]([O-])(=O)"); MolOp.perceiveDativeBonds(mol); int count = 0; for (IBond bond : mol.bonds()) { if (bond.getDisplay() != IBond.Display.Solid) count++; } assertThat(count, CoreMatchers.is(1)); }
@Test public void NO3() throws InvalidSmilesException { SmilesParser smipar = new SmilesParser(SilentChemObjectBuilder.getInstance()); IAtomContainer mol = smipar.parseSmiles("[O-][N+]([O-])=O"); MolOp.perceiveDativeBonds(mol); int count = 0; for (IBond bond : mol.bonds()) { if (bond.getDisplay() != IBond.Display.Solid) count++; } assertThat(count, CoreMatchers.is(1)); }