Skip to content
This repository has been archived by the owner on Mar 9, 2024. It is now read-only.
forked from zotko/xyz2graph

Convert an xyz file into a molecular graph and create a 3D visualisation of the graph.

License

Notifications You must be signed in to change notification settings

general-synthesis/xyz2graph

 
 

Repository files navigation

xyz2graph

xyz2graph is a Python package for reading of .xyz files and constructing of molecular graphs from atomic coordinates. The molecular graph can be converted into NetworkX graph or Plotly figure for 3D visualization in a browser window or in a Jupyter notebook.

Requirements

Installation

python -m pip install git+https://github.com/zotko/xyz2graph.git

Usage

from xyz2graph import MolGraph, to_networkx_graph, to_plotly_figure
from plotly.offline import offline

# Create the MolGraph object
mg = MolGraph()

# Read the data from the .xyz file
mg.read_xyz('path/molecule.xyz')

# Create the Plotly figure object
fig = to_plotly_figure(mg)

# Plot the figure
offline.plot(fig)

# Convert the molecular graph to the NetworkX graph
G = to_networkx_graph(mg)

Usage in Jupyter Notebook

from xyz2graph import MolGraph, to_networkx_graph, to_plotly_figure
from plotly.offline import init_notebook_mode, iplot

# Initiate the Plotly notebook mode
init_notebook_mode(connected=True)

# Create the MolGraph object
mg = MolGraph()

# Read the data from the .xyz file
mg.read_xyz('path/molecule.xyz')

# Create the Plotly figure object
fig = to_plotly_figure(mg)

# Plot the figure
iplot(fig)

About

Convert an xyz file into a molecular graph and create a 3D visualisation of the graph.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Jupyter Notebook 99.7%
  • Python 0.3%