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

2021-01-11 Thread Fiorella Ruggiu
Hi Francois,

not sure if you have solved this yet. I believe it won't be possible to use
AllChem.ReplaceSubstructs without breaking the rings or enumerating them.
You can however use reactions for this problem. Here's an example based on
yours:

mol = Chem.MolFromSmiles('O=c1[nH]1')
rxn = AllChem.ReactionFromSmarts('[c:1](=[O:2])[nH:3]>>[c:1]([O:2])[nH0:3]')
ps = rxn.RunReactants([Chem.MolFromSmiles('O=c1[nH]1')])
Chem.MolToSmiles(ps[0][0])

'Oc1n1'


Hope this helps!

Best,

Fio



On Thu, Jan 7, 2021 at 10:33 PM Francois Berenger  wrote:

> 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 mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss


Re: [Rdkit-discuss] Molecular weight function

2021-01-11 Thread Navid Shervani-Tabar
One more question. Is the unit for this function in Daltons?

Regards,
Navid

On Wed, Apr 8, 2020 at 10:00 PM Navid Shervani-Tabar 
wrote:

> Thank you!
>
> Navid
>
> On Wed, Apr 8, 2020 at 9:47 PM Peter S. Shenkin  wrote:
>
>> It is probably best to say that it is the sum of atomic weights for the
>> atoms in the molecule, where each element gets an atomic weight computed by
>> summing the products of its isotope atomic weights with the natural
>> fractional abundance of the isotope.
>>
>> For some elements, this is not terribly well defined, because for those
>> elements, the isotopic composition varies considerably with origin.
>>
>> -P.
>>
>> On Wed, Apr 8, 2020 at 4:35 PM Navid Shervani-Tabar 
>> wrote:
>>
>>> Hello,
>>>
>>> I was wondering if the word "average" in the following function and
>>> description:
>>>
>>> rdkit.Chem.Descriptors.MolWt(**x*, ***y*)
>>> 
>>>
>>> The average molecular weight of the molecule
>>>
>>> is referring to average over all possible molecule with
>>> different isotopes of the atoms in the molecule (including hydrogen).
>>>
>>> Thanks,
>>> Navid
>>> ___
>>> 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