Package for reading of .xyz files and constructing of molecular graphs from atomic coordinates.
Project description
xyz2graph
A lightweight Python package for reading XYZ files and creating interactive molecular visualizations. Convert molecular structures into 3D visualizations using Plotly or analyze them as NetworkX graphs.
picture
Features
- Read and parse XYZ molecular structure files
- Generate interactive 3D molecular visualizations using Plotly
- Convert molecular structures to NetworkX graphs for analysis
- Command-line interface for quick visualizations
Installation
pip install xyz2graph
Requirements
- Python 3.8+
- numpy
- networkx
- plotly
Usage
Python API
from xyz2graph import MolGraph
from plotly.offline import plot
# Create molecular graph and read XYZ file
mg = MolGraph()
mg.read_xyz('molecule.xyz')
# Generate interactive 3D visualization
fig = mg.to_plotly()
plot(fig)
# Convert to NetworkX graph for analysis
G = mg.to_networkx()
Jupyter Notebook
from xyz2graph import MolGraph
from plotly.offline import init_notebook_mode, iplot
# Initialize Plotly for notebook
init_notebook_mode(connected=True)
# Create and display molecular visualization
mg = MolGraph()
mg.read_xyz('molecule.xyz')
iplot(mg.to_plotly())
Command Line Interface
Quickly visualize molecules from XYZ files:
# Save visualization as HTML
xyz2graph molecule.xyz
# Specify output file
xyz2graph molecule.xyz -o visualization.html
# Open directly in browser
xyz2graph molecule.xyz --browser
Customization
Customize atomic properties for visualization:
mg = MolGraph()
# Customize atomic radius
mg.set_element_radius('C', 0.75)
# Customize element color
mg.set_element_color('O', 'red')
# Set default color for unlisted elements
mg.set_default_color('pink')
Examples
Example XYZ files and usage demonstrations can be found in the examples
directory.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file xyz2graph-3.0.1.tar.gz
.
File metadata
- Download URL: xyz2graph-3.0.1.tar.gz
- Upload date:
- Size: 671.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.13.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 94f7ad544c1d23c66308512122633d3d2c0df42b41345a39feebe6b90ec1a66c |
|
MD5 | c8f3ec47f28ff50cbd227c7dfb8ae80f |
|
BLAKE2b-256 | 9973b217d243b5c01d66877c96c64d88f7a985d65fbf18c2788902ecfeb15845 |
File details
Details for the file xyz2graph-3.0.1-py3-none-any.whl
.
File metadata
- Download URL: xyz2graph-3.0.1-py3-none-any.whl
- Upload date:
- Size: 9.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.13.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 882c49bd1aeacb94e33922fe4fb4de79df6bdd8dd3d43197c081eb3f0fb98c90 |
|
MD5 | a2bb0342d17c42904854a9570d4835c4 |
|
BLAKE2b-256 | c9e13349f21957db2eb7a9b19ee9b0adfb1428f8c9b10efc43f61d687bcdcf2b |