<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 <h1>Compare shapes of molecules
Step1:  We'd like to compare the shape of heroin with other molecules.
ODDT supports three methods of molecular shape comparison
Step2:  To compute the shape using USR we need the molecule's 3D coordinates.
Step3:  Now we can use the usr function.
Step4:  USR represents shape with 12 descriptors, which summarize the distribution of atomic distances in the molecule. For more details see Ballester & Richards (2007).<br/>
USR-CAT and Electroshape use more descriptors, 60 and 15 respectively.
Let's see how similar it is to a different molecule.
Step5:  The similarity function returns a number in range (0, 1], where a higher number means that the molecules are more similar and 1 means that the molecules have identical shapes.<br/>
All methods (USR, USR-CAT and Electroshape) use the same similarity function.
We will find a molecule similar to oxamide.
Step6:  Heroin
Step7:  The most similar molecule
Step8:  The least similar molecule
Similarity between these molecules
<ASSISTANT_TASK:>
Python Code:
from __future__ import print_function, division, unicode_literals
import oddt
from oddt.shape import usr, usr_similarity
print(oddt.__version__)
Explanation: <h1>Compare shapes of molecules
End of explanation
heroin = oddt.toolkit.readstring('smi', 
    'CC(=O)Oc1ccc2c3c1O[C@@H]4[C@]35CC[NH+]([C@H](C2)[C@@H]5C=C[C@@H]4OC(=O)C)C')
smiles = ['CC(=O)Oc1ccc2c3c1O[C@@H]4[C@]35CC[NH+]([C@H](C2)[C@@H]5C=C[C@@H]4OC(=O)Cc6cccnc6)C',
          'CC(=O)O[C@@H]1C=C[C@@H]2[C@H]3Cc4ccc(c5c4[C@]2([C@H]1O5)CC[NH+]3C)OC', 
          'C[N+]1(CC[C@@]23c4c5ccc(c4O[C@H]2[C@@H](C=C[C@@H]3[C@@H]1C5)O)OC)C', 
          'C[NH2+][C@@H]1Cc2ccc(c3c2[C@]4([C@@H]1CC=C([C@H]4O3)OC)C=C)OC',
          'CCOC(=O)CNC(=O)O[C@H]1C=C[C@H]2[C@H]3Cc4ccc(c5c4[C@]2([C@H]1O5)CC[NH+]3C)OCOC',
          'CC(=O)OC1=CC[C@H]2[C@@H]3Cc4ccc(c5c4[C@@]2([C@@H]1O5)CC[NH+]3C)OC',
          'C[NH+]1CC[C@]23c4c5cc(c(c4O[C@H]2[C@H](C=C[C@H]3[C@H]1C5)O)O)c6cc7c8c(c6O)O[C@@H]9[C@]81CC[NH+]([C@H](C7)[C@@H]1C=C[C@@H]9O)C']
molecules = [oddt.toolkit.readstring('smi', smi) for smi in smiles]
Explanation: We'd like to compare the shape of heroin with other molecules.
ODDT supports three methods of molecular shape comparison: USR, USRCAT and Electroshape.<br/>
USR looks only at the shape of molecule.<br/>
USR-CAT considers the shape and type of atoms.<br/>
Electroshape accounts for the shape and charge of atoms.<br/>
All those methods have the same API.<br/>
We will use USR, because it's the simplest and the fastest.
End of explanation
heroin.make3D()
heroin.removeh()
for mol in molecules:
    mol.make3D()
    mol.removeh()
Explanation: To compute the shape using USR we need the molecule's 3D coordinates.
End of explanation
usr_heroin = usr(heroin)
usr_heroin
Explanation: Now we can use the usr function.
End of explanation
usr_similarity(usr_heroin, usr(molecules[0]))
Explanation: USR represents shape with 12 descriptors, which summarize the distribution of atomic distances in the molecule. For more details see Ballester & Richards (2007).<br/>
USR-CAT and Electroshape use more descriptors, 60 and 15 respectively.
Let's see how similar it is to a different molecule.
End of explanation
similar_mols = []
for i, mol in enumerate(molecules):
    sim = usr_similarity(usr_heroin, usr(mol))
    similar_mols.append((i, sim))
similar_mols.sort(key=lambda similarity: similarity[1], reverse=True)
similar_mols
heroin
Explanation: The similarity function returns a number in range (0, 1], where a higher number means that the molecules are more similar and 1 means that the molecules have identical shapes.<br/>
All methods (USR, USR-CAT and Electroshape) use the same similarity function.
We will find a molecule similar to oxamide.
End of explanation
idx_most = similar_mols[0][0] 
molecules[idx_most]
Explanation: Heroin
End of explanation
idx_least = similar_mols[-1][0] 
molecules[idx_least]
Explanation: The most similar molecule
End of explanation
usr_most = usr(molecules[idx_most])
usr_least = usr(molecules[idx_least])
usr_similarity(usr_most, usr_least)
Explanation: The least similar molecule
Similarity between these molecules:
End of explanation
<END_TASK>