Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'NoneType' object has no attribute 'GetAtoms' #9

Open
Karunakar444 opened this issue Oct 15, 2019 · 13 comments
Open

AttributeError: 'NoneType' object has no attribute 'GetAtoms' #9

Karunakar444 opened this issue Oct 15, 2019 · 13 comments

Comments

@Karunakar444
Copy link

Hello!
I have the following error while executing the code. Please help me with this.
Screenshot from 2019-10-15 16-23-31

@jeherr
Copy link

jeherr commented Oct 15, 2019

Most likely an error when RDKit is trying to read the SMILES string. If RDKit encounters en error trying to turn the SMILES into its internal Mol object, it just returns None, which is why the error says 'NoneType' instead of RDKits internal Mol object. Check the SMILES string that you're trying to load and make sure it's correct.

@Karunakar444
Copy link
Author

Thank you so much for responding!
I tried with different smiles but I am still getting the error!
I have even tried with very simple smiles but of no use.

@connorcoley
Copy link
Owner

connorcoley commented Oct 15, 2019 via email

@Karunakar444
Copy link
Author

First I tried with what u have provided and then I have used the following:
[CH3:26][N:27]1[CH2:28][CH2:29][CH2:30][C:31]1=[O:32].[Cl:1][c:2]1n:3[n:4][c:5]2[cH:6]c:7[cH:8][cH:9][c:10]12.[NH2:19][CH:20]1[CH2:21][CH2:22][CH2:23][CH2:24][CH2:25]1

@jeherr
Copy link

jeherr commented Oct 17, 2019

You have an unclosed ring according to RDKit. You can check it like this from an interactive python shell

import rdkit.Chem as Chem
mol=Chem.MolFromSmiles("[Cl:1][c:2]1n:3[n:4][c:5]2[cH:6]c:7[cH:8][cH:9][c:10]12")

Note that I only included a part of the SMILES string that you provided, because this is the particular part where the error is occurring. I think the error is not that your ring isn't closed, but rather you may be missing some double bonds and/or explicit hydrogens.

@juliocoll
Copy link

could you make an exception line of code?

Iwhen trying to manage 3000 compounds, I tried variations on

I if 'NoneType' : continue

but none of them worked up to now............

@juliocoll
Copy link

I just found it

inserting this line of code before the function:

if not mol: continue

@AE-97
Copy link

AE-97 commented Jun 1, 2021

Could you please elaborate how you did this? I have the same problem with .GetRingInfo()
did you use:
if not 'Mol': continue

because if I use mol, it just tells me the variable is not defined

@connorcoley
Copy link
Owner

You should use mol, not 'Mol' -- 'Mol' always evaluates to True

@DanielRichardBiber
Copy link

This worked as well.

if mol is None: continue

@RitikaKabra
Copy link

I am also getting same error. But, I am trying to read rdf file.

Here is the code that I am using:
suppl = Chem.SDMolSupplier('CAS_sample.rdf') for mol in suppl: print(mol.GetNumAtoms())

Please help me on resolving this error.

@zeynebbenmassoud
Copy link

zeynebbenmassoud commented Jul 2, 2024 via email

@RitikaKabra
Copy link

try this from chatgpt: from rdkit import Chem # Try to read the RDF file try: suppl = Chem.SDMolSupplier('CAS_sample.rdf') if not suppl: raise ValueError("SDMolSupplier failed to read the file. Check if the file path is correct and the file is accessible.") for mol in suppl: if mol is None: print("Error reading a molecule from the RDF file.") else: print(mol.GetNumAtoms()) except Exception as e: print(f"An error occurred: {e}") Le mar. 2 juil. 2024 à 07:45, RitikaKabra @.> a écrit :

I am also getting same error. But, I am trying to read rdf file. Here is the code that I am using: suppl = Chem.SDMolSupplier('CAS_sample.rdf') for mol in suppl: print(mol.GetNumAtoms()) Please help me on resolving this error. — Reply to this email directly, view it on GitHub <#9 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJIN3FBHQKWYJJ6XLIILNNDZKJEB5AVCNFSM6AAAAABKG4D422VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMBSGA3TONRQGA . You are receiving this because you commented.Message ID: @.
>

I Tried your code, its giving me following error:

[14:21:54] ERROR: Counts line too short: '$RXN' on line4
[14:21:54] ERROR: moving to the beginning of the next molecule
Error reading a molecule from the RDF file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants