Skip to content

visualize pymatgen structures in jupyter notebook#552

Merged
shyuep merged 1 commit intomaterialsproject:masterfrom
aykol:master
Jan 24, 2017
Merged

visualize pymatgen structures in jupyter notebook#552
shyuep merged 1 commit intomaterialsproject:masterfrom
aykol:master

Conversation

@aykol
Copy link
Copy Markdown
Contributor

@aykol aykol commented Jan 24, 2017

Summary

  • A handy function for quick visualization of pymatgen structures in jupyter notebook.

Additional dependencies introduced (if any)

Optional dependency on an external package called chemview (https://github.com/gabrielelanaro/chemview). Will raise a proper import error upon use if chemview is not installed.

@shyuep shyuep merged commit 15625a8 into materialsproject:master Jan 24, 2017
@hainm
Copy link
Copy Markdown

hainm commented Mar 26, 2017

@aykol is there any way to convert Structure to a pdb file (or string)?

We (nglview) would like to support it too? cheers.

(or even better, PR to nglview is welcome: https://github.com/arose/nglview/blob/master/nglview/adaptor.py)

@aykol
Copy link
Copy Markdown
Contributor Author

aykol commented Mar 27, 2017

@hainm thank you, it will be nice if nglview can support pymatgen Structure. It can be written to a string using the to method in "cif", "poscar", "cssr" or as "json".

If these are not helpful, I'll be happy to look into it in 1-2 weeks and write an adaptor.

@hainm
Copy link
Copy Markdown

hainm commented Mar 27, 2017

@aykol nglview can read cif from rcsb but for some reasons, it (nglview) can not read from pymatgen.

If these are not helpful, I'll be happy to look into it in 1-2 weeks and write an adaptor.

yes please.

@aykol
Copy link
Copy Markdown
Contributor Author

aykol commented Apr 3, 2017

@hainm I looked into some of the options. Writing an adaptor doesn't seem straightforward because other than "cif", there seems to be no common format supported by nglview (pdb, gro, cif, mol2, sdf) and pymatgen.Structure. I can verify that "cif" option does not work for some reason.

One option is to create support for pymatgen.Molecule, for which pymatgen provides "xyz", "gjf" and "g03" output formats natively. In this case "pdb" is supported through the optional OpenBabel dependency. And support for pymatgen.Structure could be further provided via creating an intermediate Molecule object for visualization purposes as in e.g.:

_pmg_molecule = pymatgen.Molecule.from_sites(pmg_structure.sites)
structure_string = _pmg_molecule.to(fmt='pdb')

However, I personally don't think this option is efficient because of OpenBabel dependency. Are there any plans on nglview side to support "xyz", "gjf" or "g03"?

@hainm
Copy link
Copy Markdown

hainm commented Apr 3, 2017

I can verify that "cif" option does not work for some reason.

may be the key is here 'to make cif works'?

@shyuep
Copy link
Copy Markdown
Member

shyuep commented Apr 3, 2017

I agree. Note that pmg's CIF parsing is reasonably robust. If nglview does not work, the likelihood is that ngl's parsing is not robust.

@hainm
Copy link
Copy Markdown

hainm commented Apr 3, 2017

ping @arose

@arose
Copy link
Copy Markdown

arose commented Apr 3, 2017

There are different cif dictonaries, ngl does support the macromolecular dictionary (e.g. atom_site cetegory) and the one for chemical components (e.g. chem_comp_atom category). Can you give me an example cif file outputted by pymatgen? Thanks.

What format would retain the most information from pymatgen? I guess xyz would contain the least. Never hear of gjf and g03. I am happy to look into writing parsers if there is specific benefit.

@aykol
Copy link
Copy Markdown
Contributor Author

aykol commented Apr 3, 2017

@arose here is a sample cif file generated by pymatgen.
mp-1143.cif.zip

@arose
Copy link
Copy Markdown

arose commented Apr 3, 2017

thanks @aykol, that is a crystallographic cif file using the core dictionary (http://www.iucr.org/resources/cif/dictionaries/cif_core). Need to think about how I want to support fractional coordinates. Maybe for starters just calculate cartesian ones during parsing.

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

Successfully merging this pull request may close these issues.

4 participants