Re: [Rdkit-discuss] Removing Hs bonded to sp3 carbons

2021-10-24 Thread Paolo Tosco
Hi Alfredo,

if that's really what you want to do, the following Python function should
help:

from rdkit import Chem

bilastine =
Chem.AddHs(Chem.MolFromSmiles("O=C(O)C(c1ccc(cc1)CCN4CCC(c2nc3c3n2CCOCC)CC4)(C)C"))
bilastine
[image: image.png]
def removeHsBondedToSp3Carbon(mol):
bonds = []
atoms = []
for b in mol.GetBonds():
ba = b.GetBeginAtom()
ea = b.GetEndAtom()
for a in (ba, ea):
oa = b.GetOtherAtom(a)
if (a.GetAtomicNum() == 1 and oa.GetAtomicNum() == 6 and
oa.GetHybridization() == Chem.HybridizationType.SP3):
bonds.append(b.GetIdx())
atoms.append(a.GetIdx())
break
if bonds:
mol = Chem.RWMol(mol)
for bi in sorted(bonds, reverse=True):
b = mol.GetBondWithIdx(bi)
mol.RemoveBond(b.GetBeginAtomIdx(), b.GetEndAtomIdx())
for ai in sorted(atoms, reverse=True):
mol.RemoveAtom(ai)
return mol.GetMol()

bilastine_no_h = removeHsBondedToSp3Carbon(bilastine)
bilastine_no_h
[image: image.png]

Cheers,
p.

On Tue, Oct 19, 2021 at 8:08 PM Alfredo Quevedo 
wrote:

> Dear all,
>
> I am trying to figure out if there is a way to remove all hydrogens bond
> to sp3 carbons in my molecule?
>
> thanks in advance for the help,
>
> kind regards
>
> Alfredo
>
>
>
> ___
> 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] Removing Hs bonded to sp3 carbons

2021-10-23 Thread Tim Dudgeon
Chem.RemoveHs(mol) will remove all Hs.
Do you really want to only remove them from sp3 carbons?

On Tue, Oct 19, 2021 at 7:08 PM Alfredo Quevedo 
wrote:

> Dear all,
>
> I am trying to figure out if there is a way to remove all hydrogens bond
> to sp3 carbons in my molecule?
>
> thanks in advance for the help,
>
> kind regards
>
> Alfredo
>
>
>
> ___
> 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] Removing Hs bonded to sp3 carbons

2021-10-19 Thread Alfredo Quevedo

Dear all,

I am trying to figure out if there is a way to remove all hydrogens bond 
to sp3 carbons in my molecule?


thanks in advance for the help,

kind regards

Alfredo



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