Hi all,

I gave it a try, it cause a NullPointerException when writing the deprotonated result back to SMILES. What am I doing wrong?

Kind regards,
Martin

Code:
        String smi = "CCC(O)=O";
        IAtomContainer mol = Converter.parseSmiles(smi);
AtomContainerManipulator.convertImplicitToExplicitHydrogens(mol);
        String carboxylSMARTS = "C(O)=O";
        int oIndexInSMARTS = 1;
SMARTSQueryTool smartsMatch = new SMARTSQueryTool(carboxylSMARTS, SilentChemObjectBuilder.getInstance());
        if (smartsMatch.matches(mol))
        {
            for (List<Integer> match : smartsMatch.getMatchingAtoms())
            {
                IAtom oAtom = mol.getAtom(match.get(oIndexInSMARTS));
                for (IAtom neighborToO : mol.getConnectedAtomsList(oAtom))
                {
                    if (neighborToO.getSymbol().equals("H"))
                    {
                        System.out.println("removing H");
                        mol.removeAtom(neighborToO);
                    }
                }
            }
        }
        System.out.println(new SmilesGenerator().create(mol));

Output:
    removing H
Exception in thread "main" java.lang.NullPointerException
    at org.openscience.cdk.smiles.CDKToBeam.toBeamEdge(CDKToBeam.java:244)
    at org.openscience.cdk.smiles.CDKToBeam.toBeamGraph(CDKToBeam.java:153)
at org.openscience.cdk.smiles.SmilesGenerator.create(SmilesGenerator.java:374) at org.openscience.cdk.smiles.SmilesGenerator.create(SmilesGenerator.java:330)




Am 06.10.2015 um 16:51 schrieb Schmid Emanuel (ID SIS):

Hi

Is there an easy way to deprotonate all carboxyl groups of a molecule?

It's because I need the salts rather than the acids.

Greetings,

Emanuel



------------------------------------------------------------------------------


_______________________________________________
Cdk-user mailing list
Cdk-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/cdk-user
------------------------------------------------------------------------------
_______________________________________________
Cdk-user mailing list
Cdk-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/cdk-user

Reply via email to