Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Depiction of large structures makes Python crash on Windows #11

Open
OBrink opened this issue Nov 30, 2022 · 4 comments
Open

Depiction of large structures makes Python crash on Windows #11

OBrink opened this issue Nov 30, 2022 · 4 comments

Comments

@OBrink
Copy link
Contributor

OBrink commented Nov 30, 2022

Hey there!

We have run into a problem with the depiction functionalities in PIKAChU. When depicting large molecules, Python simply crashes. We don't get an exception that can be caught or something like that. If I execute the code below in my Python shell, the Python shell simply closes.

Minimal example for the reproduction of the problem:

from pikachu.general import read_smiles
from pikachu.drawing import drawing

smiles = 'CC(=O)N[C@H]1[C@H]([C@H](O)[C@H](O)CO)O[C@@](O[C@H](CO)[C@@H](O)[C@@H]2O[C@@](O[C@H](CO)[C@@H](O)[C@@H]3O[C@@](O[C@H](CO)[C@@H](O)[C@@H]4O[C@@](O[C@H](CO)[C@@H](O)[C@@H]5O[C@@](O[C@H](CO)[C@@H](O)[C@@H]6O[C@@](O[C@H](CO)[C@@H](O)[C@@H]7O[C@@](O[C@H](CO)[C@@H](O)[C@@H]8O[C@@](O[C@H](CO)[C@@H](O)[C@@H]9O[C@@](O[C@H](CO)[C@@H](O)[C@@H]%10O[C@@](O[C@H](CO)[C@@H](O)[C@@H]%11O[C@@](O[C@H](CO)[C@@H](O)[C@@H]%12O[C@@](O[C@H](CO)[C@@H](O)[C@@H]%13O[C@@](O[C@H](CO)[C@@H](O)[C@@H]%14O[C@@](O)(C(=O)O)C[C@H](O)[C@H]%14NC(C)=O)(C(=O)O)C[C@H](O)[C@H]%13NC(C)=O)(C(=O)O)C[C@H](O)[C@H]%12NC(C)=O)(C(=O)O)C[C@H](O)[C@H]%11NC(C)=O)(C(=O)O)C[C@H](O)[C@H]%10NC(C)=O)(C(=O)O)C[C@H](O)[C@H]9NC(C)=O)(C(=O)O)C[C@H](O)[C@H]8NC(C)=O)(C(=O)O)C[C@H](O)[C@H]7NC(C)=O)(C(=O)O)C[C@H](O)[C@H]6NC(C)=O)(C(=O)O)C[C@H](O)[C@H]5NC(C)=O)(C(=O)O)C[C@H](O)[C@H]4NC(C)=O)(C(=O)O)C[C@H](O)[C@H]3NC(C)=O)(C(=O)O)C[C@H](O)[C@H]2NC(C)=O)(C(=O)O)C[C@@H]1O'

mol = read_smiles(smiles)
drawer = drawing.Drawer(mol)

Expected behaviour:

  • Instantiation of a Drawer object.

Observed behaviour:

  • Python crashes.

We will build a workaround and simply not use PIKAChU for large structures in our application, but I think it may make sense to look into this.

Have a nice day!
Otto

OBrink added a commit to OBrink/RanDepict that referenced this issue Nov 30, 2022
@BTheDragonMaster
Copy link
Owner

BTheDragonMaster commented Nov 30, 2022

Hi Otto,

Thank you for reporting this!

On my personal laptop (Mac with M1 chip), PIKAChU (1.0.10) does draw the structure (although admittedly it takes around half a minute):

from pikachu.general import svg_from_smiles
svg_from_smiles(r"CC(=O)N[C@H]1[C@H]([C@H](O)[C@H](O)CO)O[C@@](O[C@H](CO)[C@@H](O)[C@@H]2O[C@@](O[C@H](CO)[C@@H](O)[C@@H]3O[C@@](O[C@H](CO)[C@@H](O)[C@@H]4O[C@@](O[C@H](CO)[C@@H](O)[C@@H]5O[C@@](O[C@H](CO)[C@@H](O)[C@@H]6O[C@@](O[C@H](CO)[C@@H](O)[C@@H]7O[C@@](O[C@H](CO)[C@@H](O)[C@@H]8O[C@@](O[C@H](CO)[C@@H](O)[C@@H]9O[C@@](O[C@H](CO)[C@@H](O)[C@@H]%10O[C@@](O[C@H](CO)[C@@H](O)[C@@H]%11O[C@@](O[C@H](CO)[C@@H](O)[C@@H]%12O[C@@](O[C@H](CO)[C@@H](O)[C@@H]%13O[C@@](O[C@H](CO)[C@@H](O)[C@@H]%14O[C@@](O)(C(=O)O)C[C@H](O)[C@H]%14NC(C)=O)(C(=O)O)C[C@H](O)[C@H]%13NC(C)=O)(C(=O)O)C[C@H](O)[C@H]%12NC(C)=O)(C(=O)O)C[C@H](O)[C@H]%11NC(C)=O)(C(=O)O)C[C@H](O)[C@H]%10NC(C)=O)(C(=O)O)C[C@H](O)[C@H]9NC(C)=O)(C(=O)O)C[C@H](O)[C@H]8NC(C)=O)(C(=O)O)C[C@H](O)[C@H]7NC(C)=O)(C(=O)O)C[C@H](O)[C@H]6NC(C)=O)(C(=O)O)C[C@H](O)[C@H]5NC(C)=O)(C(=O)O)C[C@H](O)[C@H]4NC(C)=O)(C(=O)O)C[C@H](O)[C@H]3NC(C)=O)(C(=O)O)C[C@H](O)[C@H]2NC(C)=O)(C(=O)O)C[C@@H]1O", 'large_mol.svg')

large_mol

I've also run the snippet of code you sent, and while it takes some time to run, it does return the drawer object which behaves normally on my end. I appreciate that the performance of the M1 chip is not really comparable with a lot of processors out there, so I will test PIKAChU's performance on a range of other processors to see what happens.

I will have some time to work on PIKAChU later in December, and will look at this issue more deeply then. Again, thank you for pointing this out!

Kind regards

@OBrink
Copy link
Contributor Author

OBrink commented Nov 30, 2022

Thanks for the quick reply. I am running this on my laptop with an Intel(R) Core(TM) i7-10750H CPU @ 2.60GHz 2.59 GHz processor and 32 GB RAM. I doubt that this is hardware-related, and I have found something that supports this claim:

When I run the code snippet above under Windows 11, everything crashes. @Mar-Gol observed the same behaviour under similar conditions. When I run it in my Ubuntu subsystem in the WSL shell, everything works fine. I just ran it remotely on an Ubuntu server, and it also works fine. This seems to be a Windows-specific problem, but I have absolutely no idea what the root of it is.

@OBrink OBrink changed the title Depiction of large structures makes Python crash Depiction of large structures makes Python crash on Windows Nov 30, 2022
@BTheDragonMaster
Copy link
Owner

Thank you for testing this - I will have a look at what might cause the different behaviours across different operating systems.

@DocMinus
Copy link

Hi - I can chime in that it works under Ubuntu on a Xeon multicore system.
On mine,both examples take about 60-65 secs.
Tested also on Python 3.11 which is supposed to be faster, and yes, there it takes about 40ish secs.

Finally did a quick test on a win10 machine, and yes, it doesn't work there. Doesn't crash my terminal, but the script ends within a few seconds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants