a.GetNumRadicalElectrons() does have the right number.
If it set all the atoms to not have implicit hydrogens with
for atom in mol.GetAtoms():
atom.SetNoImplicit(True)
then I still get a sanitization error with
>>> Chem.SanitizeMol(mol)
ValueError: Sanitization error: Explicit valence for atom # 0 C, 5, is
greater than permitted
But oddly, the MolBlock is now correct:
>>> print(Chem.MolToMolBlock(mol))
...
2.0411 -0.0455 -0.1061 C 0 0 0 0 0 4 0 0 0 0 0 0
...
So I can get the molecule I'm looking for I suppose by calling
>>> mol2 = Chem.MolFromMolBlock(Chem.MolToMolBlock(mol))
¯\_(ツ)_/¯
Thanks for the help!`
On Wed, Nov 14, 2018 at 12:16 PM Paolo Tosco <[email protected]>
wrote:
> Hi Peter,
>
> try a.setNoImplicit(True)
>
> does a.GetNumRadicalElectrons() report the correct figure?
>
> Cheers,
> p.
>
> On 11/14/18 18:35, Peter St. John wrote:
>
> I have a molecule with radicals for which I'm trying to correct the bond
> orders.
> The mol block I have currently is shown below.
>
> Ultimately it thinks the first carbon (which is supposed to have 2
> explicit hydrogens, 1 C-C bond, and 1 radical electron) has a valence of 5.
> So when I try to call `SanitizeMol`, it errors out with too high a valence.
>
> for the problematic atom 'a',
>
> >>> a.GetNumImplicitHs()
>
> RuntimeError: Pre-condition Violation
> getNumImplicitHs() called without preceding call to
> calcImplicitValence()
>
> >>> a.GetTotalValence()
>
> 3 (odd, since this is what I want)
>
> >>> a.UpdatePropertyCache()
>
> ValueError: Sanitization error: Explicit valence for atom # 0 C, 5, is
> greater than permitted
>
> And when I print the mol block, it clearly thinks that first carbon as a
> valence of 5.
>
> Any suggestions how to fix this?
>
> >>> print(Chem.MolToMolBlock(mol))
>
> 9572
> RDKit 3D
>
> 15 14 0 0 0 0 0 0 0 0999 V2000
> 2.0411 -0.0455 -0.1061 C 0 0 0 0 0 *5* 0 0 0 0 0 0
> 0.8127 -0.5644 0.2519 N 0 0 0 0 0 0 0 0 0 0 0 0
> -0.3953 0.0049 -0.3294 C 0 0 0 0 0 0 0 0 0 0 0 0
> -0.6511 1.4326 0.1487 C 0 0 0 0 0 0 0 0 0 0 0 0
> -1.5741 -0.9060 -0.0263 C 0 0 0 0 0 0 0 0 0 0 0 0
> 2.1578 0.2387 -1.1430 H 0 0 0 0 0 0 0 0 0 0 0 0
> 2.9032 -0.4021 0.4366 H 0 0 0 0 0 0 0 0 0 0 0 0
> 0.7154 -0.7889 1.2330 H 0 0 0 0 0 0 0 0 0 0 0 0
> -0.2282 0.0219 -1.4109 H 0 0 0 0 0 0 0 0 0 0 0 0
> -0.8463 1.4378 1.2242 H 0 0 0 0 0 0 0 0 0 0 0 0
> 0.2197 2.0597 -0.0426 H 0 0 0 0 0 0 0 0 0 0 0 0
> -1.5161 1.8651 -0.3565 H 0 0 0 0 0 0 0 0 0 0 0 0
> -1.7375 -0.9640 1.0535 H 0 0 0 0 0 0 0 0 0 0 0 0
> -1.3932 -1.9131 -0.4005 H 0 0 0 0 0 0 0 0 0 0 0 0
> -2.4874 -0.5194 -0.4787 H 0 0 0 0 0 0 0 0 0 0 0 0
> 1 2 1 0
> 1 7 1 0
> 2 8 1 0
> 3 5 1 0
> 3 4 1 0
> 3 2 1 0
> 4 10 1 0
> 5 13 1 0
> 6 1 1 0
> 9 3 1 0
> 11 4 1 0
> 12 4 1 0
> 14 5 1 0
> 15 5 1 0
> M RAD 1 1 2
> M END
>
> Thanks!
>
> -- Peter St. John
>
>
>
>
>
> _______________________________________________
> Rdkit-discuss mailing
> [email protected]https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
>
>
>
_______________________________________________
Rdkit-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss