[Rdkit-discuss] SMARTS pattern replacement inside a ring; without breaking the ring open...

2021-01-07 Thread Francois Berenger

Dear list,

I have been trying to replace this SMARTS pattern in a ring:

'c(=O)[nH]'

By this SMILES fragment:

'c(O)n'

My trials using a single SMARTS pattern search then replace
break open the ring, which is not what I want.

My not working trial code:
---
mol = Chem.MolFromSmiles('O=c1[nH]1')
pat = Chem.MolFromSmarts('c(=O)[nH]')
rep = Chem.MolFromSmarts('c(O)n')
res = AllChem.ReplaceSubstructs(mol,pat,rep)
Chem.MolToSmiles(res[0])
'c(n)O'
---

The example molecule is just an example; the ring might be smaller
and/or have more heteroatoms.

Should I use a chemical reaction for this?

Am I forced to describe full rings in both SMARTS patterns?!
I don't want to have to enumerate all the possibilities...

I can make it ~work~ using two replacements:
first 'c(=O)' to 'c(O)'
then
'[nH]' to 'n'
But this is less precise than what I really want
and I believe it will change molecules or places I don't want to change.

Thanks a lot and happy new year!
F.


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


[Rdkit-discuss] Atom object comparison in python

2021-01-07 Thread Brian Peterson
Hello all. When traversing a molecule's atoms with atom.GetNeighbors(), 
the object returned for an atom is not necessarily the same object 
returned when the atom is indexed directly from the molecule. This means 
one can't directly compare two atoms as objects found while traversing a 
molecule via neighbors to see if they are the same atom. It seems a new 
object is created for the atom returned by .GetNeighbors(). Is this 
expected behavior and what is the reason for this? I've found that the 
comparison can be done by using atom.GetIdx(), but wanted to use the 
objects themselves for various reasons. Thanks.


Example:
-

from rdkit import Chem

m = Chem.MolFromSmiles('C(F)(Cl)(Br)(I)')
atoms = [myatom for myatom in m.GetAtoms()]
for myatom in atoms:
    print(myatom.GetIdx(),myatom.GetSymbol(),myatom)

print("The neighbors of {} are:".format(atoms[1].GetSymbol()))
for newatom in atoms[1].GetNeighbors():
    print(newatom.GetIdx(),newatom.GetSymbol(),newatom)

print("C0 == C0 ?")
print(atoms[0] == newatom)

Output:

0 C 
1 F 
2 Cl 
3 Br 
4 I 
The neighbors of F are:
0 C 
C0 == C0 ?
False






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


Re: [Rdkit-discuss] From MW to structure

2021-01-07 Thread Peter S. Shenkin
Are you starting with an integral molecular weight or an experimentally
determined value, perhaps even a set of values from mass spec?

If it's an integral value then, if you are willing to settle for known
compounds, it might not be too hard. You could derive a bunch of empirical
formulas consistent with that molecular weight, given a list you would
supply of allowed elements. Then you could simply look up known compounds
with those formulas.

Actually, you could probably just look up the known compounds with the
specified molecular weight.

If it's a high-precision experimentally determined average molecular
weight, you could rule out some empirical formulas because many empirical
formulas would be inconsistent with the elements' known isotopic ratios.

If you are looking at high-res mass spec data, you could be even more
precise.

If you are actually trying to propose structures de-novo, that is a much
harder problem, per the Rdkit discussion thread cited by Nils. It probably
still makes sense to proceed via empirical formulas as an intermediate
result, but that would be a small fraction of the work it would take to get
you there. Going from empirical formulas to all consistent structures is
the hard part, and if you insist on stable structures or readily
synthesizable structures, that makes it harder.

-P.

On Thu, Jan 7, 2021 at 2:06 PM BOURG Stephane 
wrote:

> Dear all,
>
>
>
> I'm looking for a tool that can generate chemical structures from the
> molecular weight of the compound.
>
> Do you know RDKit functions or other tools able to offer that service ?
>
>
>
> Best regards,
>
>
>
>
>
>
>
> Stéphane BOURG, Ph. D.
>
> Equipe Bioinformatique Structurale et Chémoinformatique (SBC)
>
>
>
> Institut de Chimie Organique et Analytique (ICOA)
>
> UMR CNRS-Université d’Orléans 7311
>
> Pôle de Chimie
>
> Rue de Chartres – BP 6759
>
> 45 067 Orléans Cedex 2
>
>
>
> Tél : +33 (0)2 38 49 45 89
>
> E-mail : stephane.bo...@cnrs.fr
>
>
>
>
>
>
> ___
> Rdkit-discuss mailing list
> Rdkit-discuss@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
>
___
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss


Re: [Rdkit-discuss] Get conformers as independent mols?

2021-01-07 Thread Omar H94
Dear  Gustavo,

The show_rdkit function has a "conf_id" keyword argument that takes the id
of the conformer to display. You may see the documentation:
http://nglviewer.org/nglview/latest/api.html#nglview.show_rdkit

To get a conformer of a mol as an independent mol, you may use the
following function which takes a mol and a conformer id then returns a new
mol that has only the specified conformer:

def ConfToMol(mol, conf_id):
conf = mol.GetConformer(conf_id)
new_mol = Chem.Mol(mol)
new_mol.RemoveAllConformers()
new_mol.AddConformer(Chem.Conformer(conf))
return new_mol

I hope this works for you.
Best regards,
Omar



On Fri, Jan 8, 2021 at 1:58 AM Gustavo Seabra 
wrote:

> Hi all,
>
> Could anyone please help me with ideas on how to visualize
> molecule conformers inside a Jupyter notebook?
>
> I generate the conformers, for example, using:
> AllChem.EmbedMultipleConfs(mol, numConfs=5)
>
> And would like to see them in 3D inside the notebook.
>
> I tried using NGLView(https://github.com/nglviewer/nglview), but it
> only shows what I believe is the first conformer in the molecule. How can I
> change the conformer shown? or maybe is there a way to convert the
> conformers to Mol objects?
>
> Any idea would be greatly appreciated.
>
> Thank you!
> --
> Gustavo Seabra.
> ___
> Rdkit-discuss mailing list
> Rdkit-discuss@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
>
___
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss


[Rdkit-discuss] Get conformers as independent mols?

2021-01-07 Thread Gustavo Seabra
Hi all,

Could anyone please help me with ideas on how to visualize
molecule conformers inside a Jupyter notebook?

I generate the conformers, for example, using:
AllChem.EmbedMultipleConfs(mol, numConfs=5)

And would like to see them in 3D inside the notebook.

I tried using NGLView(https://github.com/nglviewer/nglview), but it
only shows what I believe is the first conformer in the molecule. How can I
change the conformer shown? or maybe is there a way to convert the
conformers to Mol objects?

Any idea would be greatly appreciated.

Thank you!
--
Gustavo Seabra.
___
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss


Re: [Rdkit-discuss] From MW to structure

2021-01-07 Thread Nils Weskamp

Dear Stephane,

you may want to take a look at this older thread:

https://sourceforge.net/p/rdkit/mailman/rdkit-discuss/thread/8b455d6f-7817-5046-1f72-449954132621%40gmx.net/#msg37036275

Starting from just a molecular weight instead of a sum formula is 
probably not making things easier.


Hope this helps,
Nils

Am 07.01.2021 um 19:45 schrieb BOURG Stephane:

Dear all,

I'm looking for a tool that can generate chemical structures from the 
molecular weight of the compound.


Do you know RDKit functions or other tools able to offer that service ?

Best regards,

Stéphane BOURG, Ph. D.

Equipe Bioinformatique Structurale et Chémoinformatique (SBC)

Institut de Chimie Organique et Analytique (ICOA)

UMR CNRS-Université d’Orléans 7311

Pôle de Chimie

Rue de Chartres – BP 6759

45 067 Orléans Cedex 2

Tél : +33 (0)2 38 49 45 89

E-mail : stephane.bo...@cnrs.fr 



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





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


[Rdkit-discuss] From MW to structure

2021-01-07 Thread BOURG Stephane
Dear all,

I'm looking for a tool that can generate chemical structures from the molecular 
weight of the compound.
Do you know RDKit functions or other tools able to offer that service ?

Best regards,



Stéphane BOURG, Ph. D.
Equipe Bioinformatique Structurale et Chémoinformatique (SBC)

Institut de Chimie Organique et Analytique (ICOA)
UMR CNRS-Université d’Orléans 7311
Pôle de Chimie
Rue de Chartres – BP 6759
45 067 Orléans Cedex 2

Tél : +33 (0)2 38 49 45 89
E-mail : stephane.bo...@cnrs.fr



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