Joos,
In your second loop, could you "print repr(prop)"as opposed to "print prop"
It could be that the name actually has a space in it which the sd format
supports and can drive one to distraction.
----
Brian Kelley
> On Jan 21, 2016, at 2:11 AM, Joos Kiener <joos.kie...@gmail.com> wrote:
>
> Hi all,
>
> I have a strange issue. I'm trying to display pairs of molecules (the pair
> has a certain similarity threshold) and show a property for both molecules.
> This is in IPyhton Notebook.
>
> The weird thing is the first molecule of the pair loses all properties:
>
> toShow=[]
> lbls=[]
> for idx in pairs:
> did=dindices[idx]
> mol1=und[did[0]] # und = list of molecules loaded from sd-file
> mol2=und[did[1]]
> toShow.append(mol1)
> toShow.append(mol2)
> lbls.append('Active: %.2f'%mol1.GetProp('Activ'))
> lbls.append('Active: %.2f'%mol2.GetProp('Activ'))
> Draw.MolsToGridImage(toShow,molsPerRow=2,legends=lbls)
> ---------------------------------------------------------------------------
> KeyError Traceback (most recent call last)
> <ipython-input-35-c0b7b4dd1606> in <module>()
> 7 toShow.append(mol1)
> 8 toShow.append(mol2)
> ----> 9 lbls.append('Active: %.2f'%mol1.GetProp('Activ'))
> 10 lbls.append('Active: %.2f'%mol2.GetProp('Activ'))
> 11 Draw.MolsToGridImage(toShow,molsPerRow=2,legends=lbls)
>
> KeyError: 'Activ'
>
>
> If I change the code (remove the label) and print all properties of mol1, the
> are displayed correctly.
>
> toShow=[]
> lbls=[]
> for idx in pairs:
> did=dindices[idx]
> mol1=und[did[0]]
> mol2=und[did[1]]
> toShow.append(mol1)
> toShow.append(mol2)
> for prop in mol1.GetPropNames():
> print prop + ": " + mol1.GetProp(prop)
> #lbls.append('Active: %.2f'%mol1.GetProp('Activ'))
> #lbls.append('Active: %.2f'%mol2.GetProp('Activ'))
> Draw.MolsToGridImage(toShow,molsPerRow=2)
>
> This shows all the properties of mol1 plus draws the grid. No error.
>
> However directly accessing the property by name fails with key error:
> toShow=[]
> lbls=[]
> for idx in pairs:
> did=dindices[idx]
> mol1=und[did[0]]
> mol2=und[did[1]]
> toShow.append(mol1)
> toShow.append(mol2)
> print mol1.GetProp('Activ')
> #lbls.append('Active: %.2f'%mol1.GetProp('Activ'))
> #lbls.append('Active: %.2f'%mol2.GetProp('Activ'))
> Draw.MolsToGridImage(toShow,molsPerRow=2)
> ---------------------------------------------------------------------------
> KeyError Traceback (most recent call last)
> <ipython-input-46-b8538426dd74> in <module>()
> 7 toShow.append(mol1)
> 8 toShow.append(mol2)
> ----> 9 print mol1.GetProp('Activ')
> 10 #lbls.append('Active: %.2f'%mol1.GetProp('Activ'))
> 11 #lbls.append('Active: %.2f'%mol2.GetProp('Activ'))
>
> KeyError: 'Activ'
>
> This all works fine for mol2:
>
>
> toShow=[]
> lbls=[]
> for idx in pairs:
> did=dindices[idx]
> mol1=und[did[0]]
> mol2=und[did[1]]
> toShow.append(mol1)
> toShow.append(mol2)
> print mol2.GetProp('Activ')
> #lbls.append('Active: %.2f'%mol1.GetProp('Activ'))
> #lbls.append('Active: %.2f'%mol2.GetProp('Activ'))
> Draw.MolsToGridImage(toShow,molsPerRow=2)
> 2.5
> 7.7
> 10.93
> 2.0434
> 190.0
> 25.0
> ...
> What is going on here??? How can I resolve this?
> Best Regards,
>
> Joos
> ------------------------------------------------------------------------------
> Site24x7 APM Insight: Get Deep Visibility into Application Performance
> APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
> Monitor end-to-end web transactions and take corrective actions now
> Troubleshoot faster and improve end-user experience. Signup Now!
> http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140
> _______________________________________________
> Rdkit-discuss mailing list
> Rdkit-discuss@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140
_______________________________________________
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss