visualize pymatgen structures in jupyter notebook#552
visualize pymatgen structures in jupyter notebook#552shyuep merged 1 commit intomaterialsproject:masterfrom
Conversation
|
@aykol is there any way to convert We (nglview) would like to support it too? cheers. (or even better, PR to |
|
@hainm thank you, it will be nice if nglview can support pymatgen If these are not helpful, I'll be happy to look into it in 1-2 weeks and write an adaptor. |
|
@aykol
yes please. |
|
@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.:
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"? |
may be the key is here 'to make cif works'? |
|
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. |
|
ping @arose |
|
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. |
|
@arose here is a sample cif file generated by pymatgen. |
|
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. |
Summary
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.