Here's what I see:

IChemObjectBuilder bldr = SilentChemObjectBuilder.getInstance();
SmilesParser parser = new SmilesParser(bldr);
IAtomContainer mol1 = parser.parseSmiles("CCO");
IAtomContainer mol2 = parser.parseSmiles("CCO ethanol");
SDFWriter sdf = new SDFWriter(System.out);
sdf.write(mol1);
sdf.write(mol2);

Outputs:


  CDK 0626170823

  3 2 0 0 0 0 0 0 0 0999 V2000
  0.0000 0.0000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
  0.0000 0.0000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
  0.0000 0.0000 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
  1 2 1 0 0 0 0
  2 3 1 0 0 0 0
M END
<cdk:Title>
null

$$$$
ethanol
  CDK 0626170823

  3 2 0 0 0 0 0 0 0 0999 V2000
  0.0000 0.0000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
  0.0000 0.0000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
  0.0000 0.0000 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
  1 2 1 0 0 0 0
  2 3 1 0 0 0 0
M END
<cdk:Title>
ethanol

$$$$

Note that for mol1 no title is set but a property named cdk:Title is output with a value of "null". For mol2 the title is set and output correctly, but the property cdk:Title is also output.
This is with version 1.5.14.

Tim



On 25/06/2017 15:40, John Mayfield wrote:
I'm planning on rewriting the CTab readers to fix issues like the cdk:Remark nastyness but the title lines should still be working.

    IChemObjectBuilder bldr = SilentChemObjectBuilder.getInstance();
    SmilesParser smipar = new SmilesParser(bldr);
    IAtomContainer mol = smipar.parseSmiles("CCO ethanol");
    new MDLV2000Writer(System.out).write(mol);
    System.out.println("//");
    try (SDFWriter sdf = new SDFWriter(System.out)) {
    sdf.write(mol);
    }


Result:

        ethanol

          CDK     0625171540


          3  2  0  0  0  0  0  0  0  0999 V2000

            0.0000    0.0000  0.0000 C   0  0  0  0  0  0  0  0  0  0
         0  0

            0.0000    0.0000  0.0000 C   0  0  0  0  0  0  0  0  0  0
         0  0

            0.0000    0.0000  0.0000 O   0  0  0  0  0  0  0  0  0  0
         0  0

1 2 1 0 0 0 0 2 3 1 0 0 0 0
        M  END

        //

        ethanol

          CDK     0625171540


          3  2  0  0  0  0  0  0  0  0999 V2000

            0.0000    0.0000  0.0000 C   0  0  0  0  0  0  0  0  0  0
         0  0

            0.0000    0.0000  0.0000 C   0  0  0  0  0  0  0  0  0  0
         0  0

            0.0000    0.0000  0.0000 O   0  0  0  0  0  0  0  0  0  0
         0  0

1 2 1 0 0 0 0 2 3 1 0 0 0 0
        M  END

        $$$$


How are you using them Tim?

John

On 24 June 2017 at 17:19, Tim Dudgeon <tdudgeon...@gmail.com <mailto:tdudgeon...@gmail.com>> wrote:

    One possibility might be to use the value of IChemObject.getID()
    for the title line.
    Not sure if that would be a good or a bad idea. But I tried it and
    it doesn't work.

    Another thing I noticed is that CDK has a bad habit of adding an
    empty cdk:Remark property for no particular reason.
    But if you know about this then you can remove it before exporting
    so its not a major problem.

    Tim



    On 24/06/2017 15:45, Egon Willighagen wrote:

        Mmm... I'd consider that a regression, as that was the
        intended behavior...

        John, do you agree we should restore that behavior, or do you
        have a
        better solution?

        Egon


        On Sat, Jun 24, 2017 at 4:23 PM, Tim Dudgeon
        <tdudgeon...@gmail.com <mailto:tdudgeon...@gmail.com>> wrote:

            Hi All,

            I'm needing to write the title line (the first line in the
            record) for MDL
            formats.
            I'm using SDFWriter.write(mol) to write out the SD file.
            I've found that you can do this be setting the property
            CDKConstants.TITLE
            (which has a value of "cdk:Title") of the IAtomContainer
            to the value you
            want in the title line , but you also get this written as
            a SD file
            property, which is not what I want.

            Is there a way of better controlling this?

            Tim


            
------------------------------------------------------------------------------
            Check out the vibrant tech community on one of the world's
            most
            engaging tech sites, Slashdot.org! http://sdm.link/slashdot
            _______________________________________________
            Cdk-user mailing list
            Cdk-user@lists.sourceforge.net
            <mailto:Cdk-user@lists.sourceforge.net>
            https://lists.sourceforge.net/lists/listinfo/cdk-user
            <https://lists.sourceforge.net/lists/listinfo/cdk-user>





    
------------------------------------------------------------------------------
    Check out the vibrant tech community on one of the world's most
    engaging tech sites, Slashdot.org! http://sdm.link/slashdot
    _______________________________________________
    Cdk-user mailing list
    Cdk-user@lists.sourceforge.net <mailto:Cdk-user@lists.sourceforge.net>
    https://lists.sourceforge.net/lists/listinfo/cdk-user
    <https://lists.sourceforge.net/lists/listinfo/cdk-user>



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Cdk-user mailing list
Cdk-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/cdk-user

Reply via email to