That doesn't help. They are not implicit hydrogens, they are real (explicit) ones. So presumably they would need to be deleted and then implicit ones adding back?

Tim


On 22/06/2016 11:42, John M wrote:
Well you can just zero all the counts,

for (IAtom atom : mol.atoms())
  atom.setImplicitHydrogenCount(0);

but you can still store contracted forms in mol2 so it's not a general solution,

John

Regards,
John W May
john.wilkinson...@gmail.com <mailto:john.wilkinson...@gmail.com>

On 22 June 2016 at 11:20, Tim Dudgeon <tdudgeon...@gmail.com <mailto:tdudgeon...@gmail.com>> wrote:

    Yes, that's right. They are there in the mol2 file.

    Strange that you need to "add" them again!

    Tim


    On 22/06/2016 11:10, John M wrote:
    Or actually if the hydrogens are explicit in the input they are
    preserved. Looking this up briefly looks to be the case.

    Regards,
    John W May
    john.wilkinson...@gmail.com <mailto:john.wilkinson...@gmail.com>

    On 22 June 2016 at 10:52, John M <john.wilkinson...@gmail.com
    <mailto:john.wilkinson...@gmail.com>> wrote:

        Hmm,

        That shouldn't be the case - if you use the
        ImplicitHydrogenAdder, this would only be if you then
        'convertImplicitToExplicit'.

        John

        Regards,
        John W May
        john.wilkinson...@gmail.com <mailto:john.wilkinson...@gmail.com>

        On 22 June 2016 at 10:41, Tim Dudgeon <tdudgeon...@gmail.com
        <mailto:tdudgeon...@gmail.com>> wrote:

            The bit I didn't like was when I added the implicit
            hydrogens and then exported to smiles then the smiles
            contains all those hydrogens (as
            Explicit/Expanded/Sprouted in your terminology). So to me
            it looks like it added explicit hydrogens.

            Tim


            On 22/06/2016 10:08, John M wrote:
            Sorry could be my bad wording, there are really three
            'levels' of hydrogens representation. This isn't that
            confusing but the terminology is often misnamed in
            toolkits/formats. Even there where i said explicit I
            should have said labelled or something similar:

            Implicit/Undefined -> defined by valence rules -> CCO
            Labelled/Contracted/Suppressed -> explicitly stated in
            format -> [CH3][CH2][OH]
            Explicit/Expanded/Sprouted -> explicit nodes ->
            C][H])([H])([H])C([H])([H])O[H]

            When CDK says 'ImplicitHydrogenAdder' it's not adding
            implicit hydrogens per say but rather taken a molecule
            with some unknown hydrogen counts (implicit) it sets the
            value of these explicitly. They are still contracted on
            the parent atoms. You can take always expand these and
            make them explicit nodes in the graph if so desired
            (AtomContainerManipulator.convertImplicitHydrogensToExplicit)
            or something similar. The reverse is
            'suppressExplicitHydrogens', also for legacy reason
            'removeExplicitHydrogens' but doesn't actually remove
            them so the 'suppress' name is preffered.

            John

            Regards,
            John W May
            john.wilkinson...@gmail.com
            <mailto:john.wilkinson...@gmail.com>

            On 22 June 2016 at 09:55, Tim Dudgeon
            <tdudgeon...@gmail.com <mailto:tdudgeon...@gmail.com>>
            wrote:

                John

                Thanks for that. Adding implicit hydrogens does
                indeed resolve the problem.
                But does this mean that for formats like this you
                MUST add IMPLICIT hydrogens everywhere (there's no
                way for them to be explicit)? That's ugly!

                Tim


                On 21/06/2016 19:04, John M wrote:
                SMILES, InChI, Molfile have explicit valence models
                and thus their hydrogens are set automatically on
                read. For other formats you need to add them. The
                CDK doesn't do this by valence counting but rather
                through more expensive atom typing. Very clunky:

                
AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol);
                
CDKHydrogenAdder.getInstance(mol.getBuilder()).addImplicitHydrogens(mol);
                If someone can point at the Tripos Mol2 valence
                model, am happy to add it. Should be easy right as
                they encode the atom types in the format?

                John

                Regards,
                John W May
                john.wilkinson...@gmail.com
                <mailto:john.wilkinson...@gmail.com>

                On 21 June 2016 at 17:22, Tim Dudgeon
                <tdudgeon...@gmail.com
                <mailto:tdudgeon...@gmail.com>> wrote:

                    I'm having difficulty reading Mol2 format
                    files. Code is:

                    def is = new
                    FileInputStream("../../data/testfiles/ligand.mol2")
                    def reader = new Mol2Reader(is)
                    def file = reader.read(new ChemFile())
                    def mol =
                    ChemFileManipulator.getAllAtomContainers(file).get(0)
                    
AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol)
                    def out = new ByteArrayOutputStream()
                    def writer = new SMILESWriter(out)
                    writer.writeAtomContainer(mol)
                    println new String(out.toByteArray())

                    The file appears to be a valid mol2 format
                    file, but when I try to write it out as smiles
                    it blows up with:

                    java.lang.NullPointerException: One or more
                    atoms had an undefined number of implicit hydrogens
                    at
                    
com.google.common.base.Preconditions.checkNotNull(Preconditions.java:229)
                    at
                    
org.openscience.cdk.smiles.CDKToBeam.toBeamAtom(CDKToBeam.java:195)
                    at
                    
org.openscience.cdk.smiles.CDKToBeam.toBeamGraph(CDKToBeam.java:145)
                    at
                    
org.openscience.cdk.smiles.SmilesGenerator.create(SmilesGenerator.java:369)
                    at
                    
org.openscience.cdk.smiles.SmilesGenerator.create(SmilesGenerator.java:325)
                    at
                    
org.openscience.cdk.io.SMILESWriter.writeAtomContainer(SMILESWriter.java:179)

                    What am I missing?

                    Tim


                    
------------------------------------------------------------------------------
                    Attend Shape: An AT&T Tech Expo July 15-16.
                    Meet us at AT&T Park in San
                    Francisco, CA to explore cutting-edge tech and
                    listen to tech luminaries
                    present their vision of the future. This family
                    event has something for
                    everyone, including kids. Get more information
                    and register today.
                    http://sdm.link/attshape
                    _______________________________________________
                    Cdk-user mailing list
                    Cdk-user@lists.sourceforge.net
                    <mailto:Cdk-user@lists.sourceforge.net>
                    https://lists.sourceforge.net/lists/listinfo/cdk-user




                
------------------------------------------------------------------------------
                Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T 
Park in San
                Francisco, CA to explore cutting-edge tech and listen to tech 
luminaries
                present their vision of the future. This family event has 
something for
                everyone, including kids. Get more information and register 
today.
                http://sdm.link/attshape


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


                
------------------------------------------------------------------------------
                Attend Shape: An AT&T Tech Expo July 15-16. Meet us
                at AT&T Park in San
                Francisco, CA to explore cutting-edge tech and
                listen to tech luminaries
                present their vision of the future. This family
                event has something for
                everyone, including kids. Get more information and
                register today.
                http://sdm.link/attshape
                _______________________________________________
                Cdk-user mailing list
                Cdk-user@lists.sourceforge.net
                <mailto:Cdk-user@lists.sourceforge.net>
                https://lists.sourceforge.net/lists/listinfo/cdk-user




            
------------------------------------------------------------------------------
            Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in 
San
            Francisco, CA to explore cutting-edge tech and listen to tech 
luminaries
            present their vision of the future. This family event has something 
for
            everyone, including kids. Get more information and register today.
            http://sdm.link/attshape


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


            
------------------------------------------------------------------------------
            Attend Shape: An AT&T Tech Expo July 15-16. Meet us at
            AT&T Park in San
            Francisco, CA to explore cutting-edge tech and listen to
            tech luminaries
            present their vision of the future. This family event has
            something for
            everyone, including kids. Get more information and
            register today.
            http://sdm.link/attshape
            _______________________________________________
            Cdk-user mailing list
            Cdk-user@lists.sourceforge.net
            <mailto:Cdk-user@lists.sourceforge.net>
            https://lists.sourceforge.net/lists/listinfo/cdk-user





    
------------------------------------------------------------------------------
    Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
    Francisco, CA to explore cutting-edge tech and listen to tech luminaries
    present their vision of the future. This family event has something for
    everyone, including kids. Get more information and register today.
    http://sdm.link/attshape


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


    
------------------------------------------------------------------------------
    Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park
    in San
    Francisco, CA to explore cutting-edge tech and listen to tech
    luminaries
    present their vision of the future. This family event has
    something for
    everyone, including kids. Get more information and register today.
    http://sdm.link/attshape
    _______________________________________________
    Cdk-user mailing list
    Cdk-user@lists.sourceforge.net <mailto:Cdk-user@lists.sourceforge.net>
    https://lists.sourceforge.net/lists/listinfo/cdk-user



------------------------------------------------------------------------------
Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
Francisco, CA to explore cutting-edge tech and listen to tech luminaries
present their vision of the future. This family event has something for
everyone, including kids. Get more information and register today.
http://sdm.link/attshape
_______________________________________________
Cdk-user mailing list
Cdk-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/cdk-user

Reply via email to