Hi Rocco & Norwid,
Actually, this is expected given the fact that Python translates
object.method() to method(object). Hence, m.Compute2DCoords(), although
"incorrect" (because Compute2DCoords() is not a method of the Mol class),
is valid Python code and is understood as Compute2DCoords(m). And this
won't work unless AllChem is loaded.
Best,
Michal Krompiec
Merck KGaA

On Wed, 23 Sep 2020 at 16:56, Rocco Moretti <rmoretti...@gmail.com> wrote:

> Hi Norwid,
>
> There's a subtle but significant difference between the two examples:
>
> >>> AllChem.Compute2DCoords(m)
> versus
> >>> m.Compute2DCoords()
>
> For the former, it's pretty standard Python behavior not to be able to see
> a function from a module if you haven't loaded the module yet. That's
> expected behavior, and something you'll learn early on when working with
> Python modules.
>
> For the latter, it's not standard Python behavior to have methods which
> aren't visible until some other module is loaded. Generally, if you have an
> object of a class, you have access to all the methods of that class. Just
> having part of the class and then needing to import a separate module to
> get the rest of the methods is certainly not something you typically expect
> in Python.
>
> Regards,
> -Rocco
>
>
> On Wed, Sep 23, 2020 at 5:35 AM Norwid Behrnd via Rdkit-discuss <
> rdkit-discuss@lists.sourceforge.net> wrote:
>
>> Hi Thomas,
>>
>> could your report be already backed by the section titled «Working with
>> 2D molecules: Generating Depictions» of the upper half of page
>>
>> https://www.rdkit.org/docs/GettingStartedInPython.htm
>>
>> about the 2020.03.1 documentation with the following example?
>>
>> ---- 8>< begin snippet --- ----
>> >>> m = Chem.MolFromSmiles('c1nccc2n1ccc2')
>> >>> AllChem.Compute2DCoords(m)
>> 0
>> ---- 8>< end snippet --- ----
>>
>> Because this snippet is part of a show case, a minimal working example
>> (at least for a bit old RDKit 2019.9.1) translates into
>>
>> ---- 8>< begin snippet --- ----
>> from rdkit import Chem
>> from rdkit.Chem import AllChem
>> m = Chem.MolFromSmiles('c1ccccc1')
>> AllChem.Compute2DCoords(m)
>> ---- 8>< end snippet --- ----
>>
>> to yield "0" (zero).
>>
>> However, possibly contributing to your struggle, note an entry on page
>>
>> https://www.rdkit.org/docs/GettingStartedInPython.html#chem-vs-allchem
>>
>> with the snippet
>>
>> ---- 8>< begin snippet --- ----
>> >>> from rdkit.Chem import AllChem as Chem
>> >>> m = Chem.MolFromSmiles('CCC')
>> ---- 8>< end snippet --- ----
>>
>> equivalent to a MWE of
>>
>> ---- 8>< begin snippet --- ----
>> import rdkit
>> from rdkit.Chem import AllChem as Chem
>> m = Chem.MolFromSmiles('CCC')
>> Chem.Compute2DCoords(m)
>> ---- 8>< end snippet --- ----
>>
>> to equally yield "0" (zero).
>>
>> I only recall this part of the manual because one of my yesterday's
>> problems caused me to revisit the beginner's page again.
>>
>> Norwid
>>
>>
>> _______________________________________________
>> Rdkit-discuss mailing list
>> Rdkit-discuss@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
>>
> _______________________________________________
> Rdkit-discuss mailing list
> Rdkit-discuss@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
>
_______________________________________________
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss

Reply via email to