Dear Paolo,

many thanks for this regex-based answer to my question.

Best,

Jean-Marc


Le 26/08/2020 à 23:34, Paolo Tosco a écrit :
Hi Jean-Marc,

You can strip the valence field from the MolBlock with a regex:

import re

regex = re.compile(r"^(\s*\d+\.\d{4}\s*\d+\.\d{4}\s*\d+\.\d{4} ... \d  \d  \d  \d  \d  )(\d)(.*)$") print("\n".join(regex.sub(r"\g<1>0\g<3>", ...: line) for line in Chem.MolToMolBlock(Chem.    ...: MolFromSmiles("[NH4+]")).split("\n")))
     RDKit          2D

  1  0  0  0  0  0  0  0  0  0999 V2000
    0.0000    0.0000    0.0000 N   0  0  0  0  0  0  0  0  0  0  0  0
M  CHG  1   1   1
M  END

HTH, cheers
p.

On Wed, Aug 26, 2020 at 5:00 PM Jean-Marc Nuzillard <jm.nuzill...@univ-reims.fr <mailto:jm.nuzill...@univ-reims.fr>> wrote:

    Dear all,

    the atom block of the Connection Table produced by RDKit
    (Chem.MolToMolBlock() function)
    from the '[NH4+]' SMILES chain is
          0.0000    0.0000    0.0000 N   0  0  0  0  0  4  0  0 0  0  0

    in which the '4' in column 10 indicates that the number of bonds
    of the
    N atoms (implicit Hs included) is 4.
    This makes sense but may be not necessary because the electric charge
    information is brought by the
    "M  CHG  1   1   1" line.
    My ctfile.pdf file (by accelrys, dated 2011, any more recent version
    around?) shows the example of alanine
    in zwitterionic form and the valence column in the atom block only
    contains '0' values.
    Having this '4' for any organic ammonium ion is misinterpreted by the
    ACDLabs software
    I use for NMR chemical shift prediction. Replacing the '4' by a '0'
    solves the problem.

    Apart editing by myself the atom block (by hand or by scripting), is
    there a way
    to keep the value of the valence field to 0 for electrically charged
    atoms when writing sdf files?

    Best,

    Jean-Marc


-- Jean-Marc Nuzillard
    Directeur de Recherches au CNRS

    Institut de Chimie Moléculaire de Reims
    CNRS UMR 7312
    Moulin de la Housse
    CPCBAI, Bâtiment 18
    BP 1039
    51687 REIMS Cedex 2
    France

    Tel : 03 26 91 82 10
    Fax : 03 26 91 31 66
    http://www.univ-reims.fr/icmr
    http://eos.univ-reims.fr/LSD/CSNteam.html
    <http://eos.univ-reims.fr/LSD/CSNteam.html>

    http://www.univ-reims.fr/LSD/
    http://www.univ-reims.fr/LSD/JmnSoft/
    <http://www.univ-reims.fr/LSD/JmnSoft/>



    _______________________________________________
    Rdkit-discuss mailing list
    Rdkit-discuss@lists.sourceforge.net
    <mailto:Rdkit-discuss@lists.sourceforge.net>
    https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
    <https://lists.sourceforge.net/lists/listinfo/rdkit-discuss>



--
Jean-Marc Nuzillard
Directeur de Recherches au CNRS

Institut de Chimie Moléculaire de Reims
CNRS UMR 7312
Moulin de la Housse
CPCBAI, Bâtiment 18
BP 1039
51687 REIMS Cedex 2
France

Tel : 03 26 91 82 10
Fax : 03 26 91 31 66
http://www.univ-reims.fr/icmr
http://eos.univ-reims.fr/LSD/CSNteam.html

http://www.univ-reims.fr/LSD/
http://www.univ-reims.fr/LSD/JmnSoft/

_______________________________________________
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss

Reply via email to