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

Molecule.__repr__ effectively hangs for large molecules #2013

Open
mattwthompson opened this issue Feb 6, 2025 · 0 comments
Open

Molecule.__repr__ effectively hangs for large molecules #2013

mattwthompson opened this issue Feb 6, 2025 · 0 comments

Comments

@mattwthompson
Copy link
Member

Describe the bug

The implementation of repr for the Molecule class effectively hangs for large molecules because of (at least) an attempt to convert it to SMILES which waits for a returned value before doing any error handling. The Python docs for this record more or less say that it should return something that can re-create the object if passed to eval or summary info if that's not feasible. I suggest that for larger molecules (somewhere around 100-1000 atoms) there be no attempt to convert into SMILES, which isn't a particularly useful representation of macromolecules.

To Reproduce

Create a large Molecule from any source like a PDB file or external tool

In [24]: seq = "MNRHLCVWLFRHPSLNGYLQCHIQLHSHQFRQIHLDTRLQVFRQNRNCILHLLSKNWSRRYCHQDTKMLWKHKALQKYMENLSKEYQTLEQCLQHIPVNEENRRSLNRRHA
    ...: ELAPLAAIYQEIQETEQAIEELESMCKSLNKQDEKQLQELALEERQTIDQKINMLYNELFQSLVPKEKYDKNDVILEVTAGRTTGGDICQQFTREIFDMYQNYSCYKHWQFELLNYTP
    ...: ADYGGLHHAAARISGDGVYKHLKYEGGIHRVQRIPEVGLSSRMQRIHTGTMSVIVLPQPDEVDVKLDPKDLRIDTFRAKGAGGQHVNKTDSAVRLVHIPTGLVVECQQERSQIKNKEI
    ...: AFRVLRARLYQQIIEKDKRQQQSARKLQVGTRAQSERIRTYNFTQDRVSDHRIAYEVRDIKEFLCGGKGLDQLIQRLLQSADEEAIAELLDEHLKSAK"

In [25]: Molecule.from_rdkit(Chem.MolFromSequence(seq), allow_undefined_stereo=True)

Output

Basically stalls; if I didn't know this codebase better I'd be confused and/or think that the molecule loading failed.

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

No branches or pull requests

1 participant