Re: [Rdkit-discuss] Deuterium/Tritium labels in Molfile
Many thanks again, Wim I was just moving in that direction, modifying directly the resulting molfile. Regards Santiago [http://www.mestrelab.com/mestrelab/wp-content/uploads/signs/line3.jpg] [http://www.mestrelab.com/mestrelab/wp-content/uploads/signs/M-red-200pxb.jpg]<http://www.mestrelab.com> SANTIAGO FRAGA Software Developer [email protected]<mailto:%[email protected]> MESTRELAB RESEARCH S.L. PHONE +34881976775 FAX +34981941079 Feliciano Barrera, 9B-Bajo 15706 Santiago de Compostela (SPAIN) Follow us: [Mestrelab Twitter]<https://twitter.com/mestrelab> [Mestrelab Linkedin] <https://www.linkedin.com/company/mestrelab-research> [Canal de YouTube Mestrelab] <https://www.youtube.com/channel/UCf3MVnd3XZflv0acvTv14ww> [MestreBlog] <http://mestrelab.com/blog/> De: Wim Dehaen Enviado: martes, 11 de abril de 2023 11:25 Para: Santiago Fraga Cc: [email protected] Asunto: Re: [Rdkit-discuss] Deuterium/Tritium labels in Molfile Sorry for not reading your question properly. I am personally not aware of a way to export molfiles in this way in rdkit, but I might just be unaware. I think the easiest solution would be probably changing the molblock string post hoc by reading the M ISO line. for example like this in python: ``` mol=Chem.MolFromSmiles("c1c21[3H].[2H]2") def MolToMolfileDT(mol,path): mb=Chem.MolToMolBlock(mol).split("\n") iso=[x for x in mb[-3].split(" ") if len(x)>0] if iso[1]=="ISO": #check if theres isotope info for i in range(int(iso[2])): isotope=int(iso[4+2*i]) idx=int(iso[3+2*i])+3 if isotope in [2,3]: #only D and T mb[idx]=mb[idx].replace("H",{2:"D",3:"T"}[isotope]) #replace only H (to not have issues like [3Li]) with open(path, "w") as molfile: molfile.write("\n".join(mb)) return MolToMolfileDT(mol,"mol.mol")``` this returns: RDKit 2D 8 8 0 0 0 0 0 0 0 0999 V2000 1.50000.0. C 0 0 0 0 0 0 0 0 0 0 0 0 0.7500 -1.29900. C 0 0 0 0 0 0 0 0 0 0 0 0 -0.7500 -1.29900. C 0 0 0 0 0 0 0 0 0 0 0 0 -1.50000.0. C 0 0 0 0 0 0 0 0 0 0 0 0 -0.75001.29900. C 0 0 0 0 0 0 0 0 0 0 0 0 0.75001.29900. C 0 0 0 0 0 0 0 0 0 0 0 0 1.50002.59810. T 0 0 0 0 0 0 0 0 0 0 0 0 1.5000 -2.59810. D 0 0 0 0 0 0 0 0 0 0 0 0 1 2 2 0 2 3 1 0 3 4 2 0 4 5 1 0 5 6 2 0 6 7 1 0 6 1 1 0 8 2 1 0 M ISO 2 7 3 8 2 M END best wishes wim On Tue, Apr 11, 2023 at 9:14 AM Santiago Fraga mailto:[email protected]>> wrote: Many thanks for your examples, Wim. But I was checking the option to save the labels D and T in the molfile for the hydrogen isotopes, as other tools can do. Regards Santiago [http://www.mestrelab.com/mestrelab/wp-content/uploads/signs/line3.jpg] [http://www.mestrelab.com/mestrelab/wp-content/uploads/signs/M-red-200pxb.jpg]<http://www.mestrelab.com> SANTIAGO FRAGA Software Developer [email protected]<mailto:[email protected]> MESTRELAB RESEARCH S.L. PHONE +34881976775 FAX +34981941079 Feliciano Barrera, 9B-Bajo 15706 Santiago de Compostela (SPAIN) Follow us: [Mestrelab Twitter]<https://twitter.com/mestrelab> [Mestrelab Linkedin] <https://www.linkedin.com/company/mestrelab-research> [Canal de YouTube Mestrelab] <https://www.youtube.com/channel/UCf3MVnd3XZflv0acvTv14ww> [MestreBlog] <http://mestrelab.com/blog/> De: Wim Dehaen mailto:[email protected]>> Enviado: lunes, 10 de abril de 2023 18:07 Para: Santiago Fraga mailto:[email protected]>> Cc: [email protected]<mailto:[email protected]> mailto:[email protected]>> Asunto: Re: [Rdkit-discuss] Deuterium/Tritium labels in Molfile rdkit outputs a molfile with correct isotope labels for me using just: mol=Chem.MolFromSmiles("[3H]c1c1[2H]") Chem.MolToMolFile(mol,"test.mol") or labelling the atoms post hoc: mol=Chem.MolFromSmiles("c1c1") mol=Chem.AddHs(mol) mol.GetAtomWithIdx(6).SetIsotope(3) mol.GetAtomWithIdx(7).SetIsotope(2) mol=Chem.RemoveHs(mol) Chem.MolToMolFile(mol,"test2.mol") I hope this helps best wishes wim On Mon, Apr 10, 2023 at 4:43 PM Santiago Fraga mailto:[email protected]>> wrote: Good afternoon! I am a relatively new user of RDKit, and mainly the C++ API. I am trying to save in a molfile the labels D and T for the hydrogen isotopes. Like in the following molfile: MJ230401
Re: [Rdkit-discuss] Deuterium/Tritium labels in Molfile
Dear Santiago,Using D and T symbols for deuterium and tritium in MDL molfiles is outside the file format specification.Nonetheless, RDKit correctly parses those non-standard D and T symbols when reading an MDL molfile that contains them, as you can verify yourself through a simple test and also looking at the source code:rdkit/MolFileParser.cpp at 36c4ec9e2ba4f5edba39f452cb7458230d9d99bc · rdkit/rdkitgithub.comhttps://github.com/rdkit/rdkit/blob/36c4ec9e2ba4f5edba39f452cb7458230d9d99bc/Code/GraphMol/FileParsers/MolFileParser.cpp#L2179However, when writing the molfile, RDKit will write it according to specifications, i.e. using the H symbol and adding a “M ISO” entry. Any MDL molfile parser should be able to correctly parse such a file. ChemDraw will even automatically label the atoms as D and T, while MarvinJS will add the “2” and “3” superscript prefixes.To me, it seems a bit overkill to add a flag to preserve non-standard features in MDL molfile writing. Why would you be interested in doing that?Cheers,p.On 11 Apr 2023, at 11:50, Santiago Fraga wrote: Many thanks for your examples, Wim. But I was checking the option to save the labels D and T in the molfile for the hydrogen isotopes, as other tools can do. Regards Santiago SANTIAGO FRAGA Software Developer [email protected] MESTRELAB RESEARCH S.L. PHONE +34881976775 FAX +34981941079 Feliciano Barrera, 9B-Bajo 15706 Santiago de Compostela (SPAIN) Follow us: De: Wim Dehaen Enviado: lunes, 10 de abril de 2023 18:07 Para: Santiago Fraga Cc: [email protected] Asunto: Re: [Rdkit-discuss] Deuterium/Tritium labels in Molfile rdkit outputs a molfile with correct isotope labels for me using just: mol=Chem.MolFromSmiles("[3H]c1c1[2H]") Chem.MolToMolFile(mol,"test.mol") or labelling the atoms post hoc: mol=Chem.MolFromSmiles("c1c1") mol=Chem.AddHs(mol) mol.GetAtomWithIdx(6).SetIsotope(3) mol.GetAtomWithIdx(7).SetIsotope(2) mol=Chem.RemoveHs(mol) Chem.MolToMolFile(mol,"test2.mol") I hope this helps best wishes wim On Mon, Apr 10, 2023 at 4:43 PM Santiago Fraga <[email protected]> wrote: Good afternoon! I am a relatively new user of RDKit, and mainly the C++ API. I am trying to save in a molfile the labels D and T for the hydrogen isotopes. Like in the following molfile: MJ230401 8 8 0 0 0 0 0 0 0 0999 V2000 -0.3572 0.4125 0. C 0 0 0 0 0 0 0 0 0 0 0 0 -1.0716 0. 0. C 0 0 0 0 0 0 0 0 0 0 0 0 -1.0716 -0.8250 0. C 0 0 0 0 0 0 0 0 0 0 0 0 -0.3572 -1.2375 0. C 0 0 0 0 0 0 0 0 0 0 0 0 0.3572 -0.8250 0. C 0 0 0 0 0 0 0 0 0 0 0 0 0.3572 0. 0. C 0 0 0 0 0 0 0 0 0 0 0 0 -0.3572 1.2375 0. T 0 0 0 0 0 0 0 0 0 0 0 0 1.0717 0.4125 0. D 0 0 0 0 0 0 0 0 0 0 0 0 3 4 2 0 0 0 0 4 5 1 0 0 0 0 5 6 2 0 0 0 0 6 1 1 0 0 0 0 1 2 2 0 0 0 0 2 3 1 0 0 0 0 6 8 1 0 0 0 0 1 7 1 0 0 0 0 M END I am trying to set directly the labels in the hydrogen atoms: atom->setProp("atomLabel", "D"); or atom->setProp("_displayLabel", "D"); But when the molfile is generated the labels are not transferred. It seems also that when reading a mofile including the labels, they are discarded. Many thanks in advance Santiago Fraga ___ Rdkit-discuss mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/rdkit-discuss ___Rdkit-discuss mailing [email protected]://lists.sourceforge.net/lists/listinfo/rdkit-discuss___ Rdkit-discuss mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
Re: [Rdkit-discuss] Deuterium/Tritium labels in Molfile
Many thanks for your examples, Wim. But I was checking the option to save the labels D and T in the molfile for the hydrogen isotopes, as other tools can do. Regards Santiago [http://www.mestrelab.com/mestrelab/wp-content/uploads/signs/line3.jpg] [http://www.mestrelab.com/mestrelab/wp-content/uploads/signs/M-red-200pxb.jpg]<http://www.mestrelab.com> SANTIAGO FRAGA Software Developer [email protected]<mailto:%[email protected]> MESTRELAB RESEARCH S.L. PHONE +34881976775 FAX +34981941079 Feliciano Barrera, 9B-Bajo 15706 Santiago de Compostela (SPAIN) Follow us: [Mestrelab Twitter]<https://twitter.com/mestrelab> [Mestrelab Linkedin] <https://www.linkedin.com/company/mestrelab-research> [Canal de YouTube Mestrelab] <https://www.youtube.com/channel/UCf3MVnd3XZflv0acvTv14ww> [MestreBlog] <http://mestrelab.com/blog/> De: Wim Dehaen Enviado: lunes, 10 de abril de 2023 18:07 Para: Santiago Fraga Cc: [email protected] Asunto: Re: [Rdkit-discuss] Deuterium/Tritium labels in Molfile rdkit outputs a molfile with correct isotope labels for me using just: mol=Chem.MolFromSmiles("[3H]c1c1[2H]") Chem.MolToMolFile(mol,"test.mol") or labelling the atoms post hoc: mol=Chem.MolFromSmiles("c1c1") mol=Chem.AddHs(mol) mol.GetAtomWithIdx(6).SetIsotope(3) mol.GetAtomWithIdx(7).SetIsotope(2) mol=Chem.RemoveHs(mol) Chem.MolToMolFile(mol,"test2.mol") I hope this helps best wishes wim On Mon, Apr 10, 2023 at 4:43 PM Santiago Fraga mailto:[email protected]>> wrote: Good afternoon! I am a relatively new user of RDKit, and mainly the C++ API. I am trying to save in a molfile the labels D and T for the hydrogen isotopes. Like in the following molfile: MJ230401 8 8 0 0 0 0 0 0 0 0999 V2000 -0.35720.41250. C 0 0 0 0 0 0 0 0 0 0 0 0 -1.07160.0. C 0 0 0 0 0 0 0 0 0 0 0 0 -1.0716 -0.82500. C 0 0 0 0 0 0 0 0 0 0 0 0 -0.3572 -1.23750. C 0 0 0 0 0 0 0 0 0 0 0 0 0.3572 -0.82500. C 0 0 0 0 0 0 0 0 0 0 0 0 0.35720.0. C 0 0 0 0 0 0 0 0 0 0 0 0 -0.35721.23750. T 0 0 0 0 0 0 0 0 0 0 0 0 1.07170.41250. D 0 0 0 0 0 0 0 0 0 0 0 0 3 4 2 0 0 0 0 4 5 1 0 0 0 0 5 6 2 0 0 0 0 6 1 1 0 0 0 0 1 2 2 0 0 0 0 2 3 1 0 0 0 0 6 8 1 0 0 0 0 1 7 1 0 0 0 0 M END I am trying to set directly the labels in the hydrogen atoms: atom->setProp("atomLabel", "D"); or atom->setProp("_displayLabel", "D"); But when the molfile is generated the labels are not transferred. It seems also that when reading a mofile including the labels, they are discarded. Many thanks in advance Santiago Fraga ___ Rdkit-discuss mailing list [email protected]<mailto:[email protected]> https://lists.sourceforge.net/lists/listinfo/rdkit-discuss ___ Rdkit-discuss mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
Re: [Rdkit-discuss] Deuterium/Tritium labels in Molfile
Sorry for not reading your question properly. I am personally not aware of
a way to export molfiles in this way in rdkit, but I might just be unaware.
I think the easiest solution would be probably changing the molblock string
post hoc by reading the M ISO line.
for example like this in python:
```
mol=Chem.MolFromSmiles("c1c21[3H].[2H]2")
def MolToMolfileDT(mol,path):
mb=Chem.MolToMolBlock(mol).split("\n")
iso=[x for x in mb[-3].split(" ") if len(x)>0]
if iso[1]=="ISO": #check if theres isotope info
for i in range(int(iso[2])):
isotope=int(iso[4+2*i])
idx=int(iso[3+2*i])+3
if isotope in [2,3]: #only D and T
mb[idx]=mb[idx].replace("H",{2:"D",3:"T"}[isotope])
#replace only H (to not have issues like [3Li])
with open(path, "w") as molfile:
molfile.write("\n".join(mb))
return
MolToMolfileDT(mol,"mol.mol")```
this returns:
RDKit 2D
8 8 0 0 0 0 0 0 0 0999 V2000
1.50000.0. C 0 0 0 0 0 0 0 0 0 0 0 0
0.7500 -1.29900. C 0 0 0 0 0 0 0 0 0 0 0 0
-0.7500 -1.29900. C 0 0 0 0 0 0 0 0 0 0 0 0
-1.50000.0. C 0 0 0 0 0 0 0 0 0 0 0 0
-0.75001.29900. C 0 0 0 0 0 0 0 0 0 0 0 0
0.75001.29900. C 0 0 0 0 0 0 0 0 0 0 0 0
1.50002.59810. T 0 0 0 0 0 0 0 0 0 0 0 0
1.5000 -2.59810. D 0 0 0 0 0 0 0 0 0 0 0 0
1 2 2 0
2 3 1 0
3 4 2 0
4 5 1 0
5 6 2 0
6 7 1 0
6 1 1 0
8 2 1 0
M ISO 2 7 3 8 2
M END
best wishes
wim
On Tue, Apr 11, 2023 at 9:14 AM Santiago Fraga
wrote:
> Many thanks for your examples, Wim.
> But I was checking the option to save the labels D and T in the molfile
> for the hydrogen isotopes,
> as other tools can do.
>
> Regards
> Santiago
>
> <http://www.mestrelab.com>
>
> SANTIAGO FRAGA
> *Software Developer*
> [email protected] <[email protected]>
>
> *MESTRELAB RESEARCH S.L.*
> PHONE *+34881976775*
> FAX *+34981941079*
> Feliciano Barrera, 9B-Bajo 15706
> Santiago de Compostela (SPAIN)
>
> Follow us:
> [image: Mestrelab Twitter] <https://twitter.com/mestrelab> [image:
> Mestrelab Linkedin] <https://www.linkedin.com/company/mestrelab-research>
> [image: Canal de YouTube Mestrelab]
> <https://www.youtube.com/channel/UCf3MVnd3XZflv0acvTv14ww> [image:
> MestreBlog] <http://mestrelab.com/blog/>
>
>
>
> --------------
> *De:* Wim Dehaen
> *Enviado:* lunes, 10 de abril de 2023 18:07
> *Para:* Santiago Fraga
> *Cc:* [email protected] <
> [email protected]>
> *Asunto:* Re: [Rdkit-discuss] Deuterium/Tritium labels in Molfile
>
> rdkit outputs a molfile with correct isotope labels for me using just:
>
> mol=Chem.MolFromSmiles("[3H]c1c1[2H]")
> Chem.MolToMolFile(mol,"test.mol")
>
> or labelling the atoms post hoc:
>
> mol=Chem.MolFromSmiles("c1c1")
> mol=Chem.AddHs(mol)
> mol.GetAtomWithIdx(6).SetIsotope(3)
> mol.GetAtomWithIdx(7).SetIsotope(2)
> mol=Chem.RemoveHs(mol)
> Chem.MolToMolFile(mol,"test2.mol")
>
> I hope this helps
>
> best wishes
> wim
>
>
> On Mon, Apr 10, 2023 at 4:43 PM Santiago Fraga
> wrote:
>
> Good afternoon!
>
> I am a relatively new user of RDKit, and mainly the C++ API.
>
> I am trying to save in a molfile the labels D and T for the hydrogen
> isotopes.
> Like in the following molfile:
>
> MJ230401
>
> 8 8 0 0 0 0 0 0 0 0999 V2000
>-0.35720.41250. C 0 0 0 0 0 0 0 0 0 0 0 0
>-1.07160.0. C 0 0 0 0 0 0 0 0 0 0 0 0
>-1.0716 -0.82500. C 0 0 0 0 0 0 0 0 0 0 0 0
>-0.3572 -1.23750. C 0 0 0 0 0 0 0 0 0 0 0 0
> 0.3572 -0.82500. C 0 0 0 0 0 0 0 0 0 0 0 0
> 0.35720.0. C 0 0 0 0 0 0 0 0 0 0 0 0
>-0.35721.23750. T 0 0 0 0 0 0 0 0 0 0 0 0
> 1.07170.41250. D 0 0 0 0 0 0 0 0 0 0 0 0
> 3 4 2 0 0 0 0
> 4 5 1 0 0 0 0
> 5 6 2 0 0 0 0
> 6 1 1 0 0 0 0
> 1 2 2 0 0 0 0
> 2 3 1 0 0 0 0
> 6 8 1 0 0 0 0
> 1 7 1 0 0 0 0
> M END
>
> I am trying to set directly the labels in the hydrogen atoms:
>
> atom->setProp("a
Re: [Rdkit-discuss] Deuterium/Tritium labels in Molfile
rdkit outputs a molfile with correct isotope labels for me using just:
mol=Chem.MolFromSmiles("[3H]c1c1[2H]")
Chem.MolToMolFile(mol,"test.mol")
or labelling the atoms post hoc:
mol=Chem.MolFromSmiles("c1c1")
mol=Chem.AddHs(mol)
mol.GetAtomWithIdx(6).SetIsotope(3)
mol.GetAtomWithIdx(7).SetIsotope(2)
mol=Chem.RemoveHs(mol)
Chem.MolToMolFile(mol,"test2.mol")
I hope this helps
best wishes
wim
On Mon, Apr 10, 2023 at 4:43 PM Santiago Fraga
wrote:
> Good afternoon!
>
> I am a relatively new user of RDKit, and mainly the C++ API.
>
> I am trying to save in a molfile the labels D and T for the hydrogen
> isotopes.
> Like in the following molfile:
>
> MJ230401
>
> 8 8 0 0 0 0 0 0 0 0999 V2000
>-0.35720.41250. C 0 0 0 0 0 0 0 0 0 0 0 0
>-1.07160.0. C 0 0 0 0 0 0 0 0 0 0 0 0
>-1.0716 -0.82500. C 0 0 0 0 0 0 0 0 0 0 0 0
>-0.3572 -1.23750. C 0 0 0 0 0 0 0 0 0 0 0 0
> 0.3572 -0.82500. C 0 0 0 0 0 0 0 0 0 0 0 0
> 0.35720.0. C 0 0 0 0 0 0 0 0 0 0 0 0
>-0.35721.23750. T 0 0 0 0 0 0 0 0 0 0 0 0
> 1.07170.41250. D 0 0 0 0 0 0 0 0 0 0 0 0
> 3 4 2 0 0 0 0
> 4 5 1 0 0 0 0
> 5 6 2 0 0 0 0
> 6 1 1 0 0 0 0
> 1 2 2 0 0 0 0
> 2 3 1 0 0 0 0
> 6 8 1 0 0 0 0
> 1 7 1 0 0 0 0
> M END
>
> I am trying to set directly the labels in the hydrogen atoms:
>
> atom->setProp("atomLabel", "D");
> or
> atom->setProp("_displayLabel", "D");
>
>But when the molfile is generated the labels are not transferred.
>It seems also that when reading a mofile including the labels, they
> are discarded.
>
>
> Many thanks in advance
> Santiago Fraga
>
>
> ___
> Rdkit-discuss mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
>
___
Rdkit-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss

