https://github.com/zotko/xyz2graph
Convert an xyz file into a molecular graph and create a 3D visualisation of the graph.
https://github.com/zotko/xyz2graph
3d-plot atomic-coordinates chemical-structures chemistry chemoinformatics computational-chemistry data-visualization molecular-graph molecular-modeling molecule molecule-visualization networkx plotly scientific-computing xyz-files xyz-reader
Last synced: 17 days ago
JSON representation
Convert an xyz file into a molecular graph and create a 3D visualisation of the graph.
- Host: GitHub
- URL: https://github.com/zotko/xyz2graph
- Owner: zotko
- License: isc
- Created: 2018-08-11T12:05:10.000Z (over 6 years ago)
- Default Branch: main
- Last Pushed: 2025-03-10T21:41:27.000Z (about 1 month ago)
- Last Synced: 2025-03-28T17:08:16.476Z (24 days ago)
- Topics: 3d-plot, atomic-coordinates, chemical-structures, chemistry, chemoinformatics, computational-chemistry, data-visualization, molecular-graph, molecular-modeling, molecule, molecule-visualization, networkx, plotly, scientific-computing, xyz-files, xyz-reader
- Language: Python
- Homepage:
- Size: 7.61 MB
- Stars: 85
- Watchers: 1
- Forks: 23
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# xyz2graph
[](https://pypi.org/project/xyz2graph/)
[](https://pypi.org/project/xyz2graph/)
[](https://github.com/zotko/xyz2graph/blob/master/LICENSE)
[](https://zotko.github.io/xyz2graph)
[](https://doi.org/10.5281/zenodo.14569337)
[](https://mybinder.org/v2/gh/zotko/xyz2graph/main?urlpath=%2Fdoc%2Ftree%2Fbinder%2Fxyz2graph.ipynb)[](https://pepy.tech/projects/xyz2graph)
[](https://github.com/zotko/xyz2graph/stargazers)
[](https://github.com/zotko/xyz2graph/network/members)[](https://stand-with-ukraine.pp.ua)
A Python package to convert XYZ molecular files into NetworkX graphs with interactive 3D visualization using Plotly.
Try it live 🚀: [Binder](https://mybinder.org/v2/gh/zotko/xyz2graph/main?urlpath=%2Fdoc%2Ftree%2Fbinder%2Fxyz2graph.ipynb) | [GESIS Notebooks](https://notebooks.gesis.org/binder/v2/gh/zotko/xyz2graph/main?urlpath=%2Fdoc%2Ftree%2Fbinder%2Fxyz2graph.ipynb)
## Features
- [Interactive 3D molecular visualization using Plotly](https://zotko.github.io/xyz2graph/demo)
- NetworkX graph conversion for analysis
- Command-line interface## Installation
```bash
pip install xyz2graph
```## Requirements
- Python 3.8+
- Dependencies: NumPy, Plotly, NetworkX## Quick Start
```python
import numpy as np
from xyz2graph import MolGraph# Create molecular graph and read XYZ file
mg = MolGraph()
mg.read_xyz('molecule.xyz')# Generate interactive 3D visualization
fig = mg.to_plotly()
fig.show()# Convert to NetworkX graph
G = mg.to_networkx()G.nodes[0]
# Output: {'element': 'C', 'xyz': (0.1718396797, 1.4440789224, 0.2473852864)}G.edges[(0, 1)]
# Output: {'length': np.float64(1.49623)}
```## Command Line
```bash
# Save visualization as HTML
xyz2graph molecule.xyz# Specify output file
xyz2graph molecule.xyz --output viz.html# Open directly in browser
xyz2graph molecule.xyz --browser
```## Documentation
Read the [documentation](https://zotko.github.io/xyz2graph) for guides, API reference, and examples.
## Help & Discussion
🪲 [Report a bug](https://github.com/zotko/xyz2graph/issues)
✨ [Request a feature](https://github.com/zotko/xyz2graph/discussions)## Contributing
Contributions are welcome! Please see the [Contributing Guide](https://github.com/zotko/xyz2graph/tree/main/CONTRIBUTING.md) for guidelines.
## Citation
If you use xyz2graph in your research, please cite:
```bibtex
@misc{zotko2018xyz2graph,
author = {Zotko, Mykola},
title = {xyz2graph: Molecular Structure Visualization},
year = {2018},
publisher = {GitHub},
url = {https://github.com/zotko/xyz2graph}
}
```