gabrielelanaro / chemview

The new generation molecular viewer for IPython notebook
GNU Lesser General Public License v2.1
81 stars 17 forks source link

Display MOL data #38

Closed bergwerf closed 7 years ago

bergwerf commented 7 years ago

So for a course we want to instruct students to write a piece of python that retrieves mol files from PubChem or other services (like the NIH resolver), and display those in 3D. How do I accomplish that in chemview? I think I might need chemlab, but installing it from conda gives a dependency issue with python 3. I also could not find the repository to install from source.

gabrielelanaro commented 7 years ago

There's a variety of ways to accomplish the task you mention.

chemview is more of graphics library (like matplotlib but for molecules) and it doesn't include interfaces to file formats. You can basically use any other python library (examples are mdtraj, pytraj, chemlab, ase, cclib, mdanalysis) that read data from those files (coordinates, bonds etc) and then use the MolecularViewer class to display them (https://chemview.readthedocs.io/en/latest/quick.html#quick-start).

chemlab is one (convenient) way to download and parse those files, and is well integrated with chemview. Next week I'll make a new chemlab conda package for ease of installation. A chemlab System / Molecule class has a display() method that displays automatically using chemview.

If the purpose of the course is familiarize students with text processing techniques and chemistry file formats, the students could also download the file using urllib and write a small parser (for mol-files it's pretty easy https://github.com/chemlab/chemlab/blob/master/chemlab/io/handlers/mol.py#L29-L61). Once you get coordinates and atom types in a numpy array it's pretty easy to display it with chemview.

bergwerf commented 7 years ago

I see, that makes sense. I put used the molfile parser from your link and I think what you propose would indeed be a terrific demo or assignment, thanks!