jeudi 16 juillet 2020

If success for a python statement

I am using some builtin python libraries for chemistry and run the following line of code for a variable smiles

Chem.MolFromSmiles(smiles)

For some smiles it runs successfully, but for some smiles values, it gives the following type of error.

RDKit ERROR: [16:33:58] non-ring atom 12 marked aromatic

smiles is a list as follows.

smiles=['CCC','hgjn','hghfg']

I want to do something as follows.

for items in smiles:
    if Chem.MolFromSmiles(smiles) results in success:
        Do Something
    elif Chem.MolFromSmiles(smiles)  gives error:
         ignore the current item of the list and loop over to get the next item in the smiles list.

Is there any way I can use if the statement of successful execution of statement in python?

Aucun commentaire:

Enregistrer un commentaire