Skip to main content

Package for reading of .xyz files and constructing of molecular graphs from atomic coordinates.

Project description

xyz2graph

PyPI version Python Version License

PyPI Downloads GitHub Stars GitHub Forks

"Buy Me A Coffee" Stand With Ukraine

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.

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')
fig = mg.to_plotly()
iplot(fig)

Command Line Interface

Quickly visualize molecules from XYZ files:

# Save visualization as HTML
xyz2graph molecule.xyz

# Specify output file
xyz2graph molecule.xyz --output 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 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.

Citation

If you use xyz2graph in your research, please cite:

@misc{xyz2graph,
  author       = {Zotko, Mykola},
  title        = {xyz2graph: Molecular Structure Visualization},
  year         = {2018},
  publisher    = {GitHub},
  url          = {https://github.com/zotko/xyz2graph}
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xyz2graph-3.0.2.tar.gz (663.2 kB view details)

Uploaded Source

Built Distribution

xyz2graph-3.0.2-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

Details for the file xyz2graph-3.0.2.tar.gz.

File metadata

  • Download URL: xyz2graph-3.0.2.tar.gz
  • Upload date:
  • Size: 663.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.13.0

File hashes

Hashes for xyz2graph-3.0.2.tar.gz
Algorithm Hash digest
SHA256 b01d20875c4e17182c9629a25f7d38aa4e91eca2e1b3da884774f9967185ebe5
MD5 4529534fc9e0af5c5739aace4f5d23ad
BLAKE2b-256 e71b7064c856e3ffa6bd3979a457d4dd53f17488f84b98ae85ac0628cb52a111

See more details on using hashes here.

File details

Details for the file xyz2graph-3.0.2-py3-none-any.whl.

File metadata

  • Download URL: xyz2graph-3.0.2-py3-none-any.whl
  • Upload date:
  • Size: 10.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.13.0

File hashes

Hashes for xyz2graph-3.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f6afbb4782d8b4a280edb5cec0aeb4ca75920527253a841b3cf8332ae190a1a9
MD5 9a4f73bb17e0686d74070ddc85519712
BLAKE2b-256 b67ab224bea65130240a6312b6e15c888fb7db1e8245564e029fcc3cdeebc1d4

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page