Hi,

Just wondering is there anyway to convert MOF structure into SMILES coding? I tried to assign the bond type to MOF molecules, however when I print the component.bond and component.smiles, it returns all of the bonds for components, but for SMILES ,it returns NONE.

Thanks for your help!

Frank

HI Frank,

can you give me a REFCODE where the SMILES fails?  In general the smiles property of a molecule will return None if there are unknown atoms or unknown bonds in the structure.

Best wishes

Richard

Hi Richard,

Sure, I tested two MOFs, they are ABACUF, and ABEMIF.

Thanks,

Frank

 

 

Hi Frank,

the problem is with the delocalised bonds in these structures, and we do not have any method in the API to replace them.

You can get a SMILES representation of the molecule by replacing the delocalised bonds with aromatic bonds:

from ccdc import io, utilities
csd = io.EntryReader('csd')

m = csd.molecule('ABACUF')
m.assign_bond_types()

deloc = [b.atoms for b in m.bonds if b.bond_type == 'Delocalised']
m.remove_bonds(b for b in m.bonds if b.bond_type == 'Delocalised')
for b in deloc:
    m.add_bond('Aromatic', *b)
print m.smiles

[O][Ba]12([OH2])([OH2][Cu]3([OH2][Ba]4([O])([OH2])(oco4)O3C=O)(oco[Ba])(oco[Ba])O1C=O)oco2

I'm not perfectly convinced that the SMILES is legitimate, so I would be very wary of submitting it to other programs.

Best wishes

Richard

Hi Richard,

In your code:

for b in deloc:
    m.add_bond('Aromatic', *b)
print m.smiles

The second line, could you explain the function of the "*" in front of b. I know that in deloc, it returns a nested list, with two atoms in each element. Here b is actually two atoms, why there is a asterisk in front of b?

Thank you,

Frank

Hi Frank,

putting the * before an argument essentially says 'treat the expression after the * as the remaining positional arguments to the function'.  Here I used it as a shorthand for:

m.add_bond('Aromatic', b[0], b[1])

Mostly because I'm lazy.

Here is a good explanation of the basics behind *args, **kwargs:

https://thepythonguru.com/python-args-and-kwargs/

Best wishes

Richard

You must be signed in to post in this forum.