zotko / xyz2graph Goto Github PK
View Code? Open in Web Editor NEWConvert an xyz file into a molecular graph and create a 3D visualisation of the graph.
License: MIT License
Convert an xyz file into a molecular graph and create a 3D visualisation of the graph.
License: MIT License
I cannot read the xyz file in the zip file attached.
The error log is
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
<ipython-input-21-50342b599ab0> in <module>
3
4 # Read the data from the .xyz file
----> 5 mg.read_xyz('train/99/geometry.xyz')
~/miniconda3/envs/chem/lib/python3.7/site-packages/xyz2graph/xyz2graph.py in read_xyz(self, file_path)
37 self.y.append(float(y))
38 self.z.append(float(z))
---> 39 self.atomic_radii = [atomic_radii[element] for element in self.elements]
40 self._generate_adjacency_list()
41
~/miniconda3/envs/chem/lib/python3.7/site-packages/xyz2graph/xyz2graph.py in <listcomp>(.0)
37 self.y.append(float(y))
38 self.z.append(float(z))
---> 39 self.atomic_radii = [atomic_radii[element] for element in self.elements]
40 self._generate_adjacency_list()
41
KeyError: 'tor'
I however, can convert that xyz file to .aims file and read with ASE using
from ase.io import read
import nglview as nv
slab = read("geometry.aims")
nv.show_ase(slab)
from xyz2graph import MolGraph, to_networkx_graph, to_plotly_figure
from plotly.offline import offline
mg = MolGraph()
mg.read_xyz("./xyz2graph/examples/dsgdb9nsd_030472.xyz")
fig = to_plotly_figure(mg)
Hang with 100% CPU consumption by Python 3.10 / 3.11 (macos 12.7.1 (21G920)).
KeyboardInterrupt Traceback (most recent call last)
Cell In[5], line 1
----> 1 fig = to_plotly_figure(mg)
File ~/miniconda3/envs/xyz2graph/lib/python3.11/site-packages/xyz2graph/helpers.py:165, in to_plotly_figure(graph)
99 annotations_bonds.append(
100 dict(
101 text=round(length, 2),
(...)
108 )
109 )
111 updatemenus = list(
112 [
113 dict(
(...)
162 ]
163 )
--> 165 data = [atom_trace(), bond_trace()]
166 axis_params = dict(
167 showgrid=False,
168 showbackground=False,
(...)
171 titlefont=dict(color="white"),
172 )
173 layout = dict(
174 scene=dict(
175 xaxis=axis_params,
(...)
182 updatemenus=updatemenus,
183 )
File ~/miniconda3/envs/xyz2graph/lib/python3.11/site-packages/xyz2graph/helpers.py:81, in to_plotly_figure.<locals>.bond_trace()
79 for i, j in adjascent_atoms:
80 trace["x"] += (graph.x[i], graph.x[j], None)
---> 81 trace["y"] += (graph.y[i], graph.y[j], None)
82 trace["z"] += (graph.z[i], graph.z[j], None)
83 return trace
File ~/miniconda3/envs/xyz2graph/lib/python3.11/site-packages/plotly/basedatatypes.py:4874, in BasePlotlyType.__setitem__(self, prop, value)
4870 self._set_array_prop(prop, value)
4872 # ### Handle simple property ###
4873 else:
-> 4874 self._set_prop(prop, value)
4875 else:
4876 # Make sure properties dict is initialized
4877 self._init_props()
File ~/miniconda3/envs/xyz2graph/lib/python3.11/site-packages/plotly/basedatatypes.py:5213, in BasePlotlyType._set_prop(self, prop, val)
5210 validator = self._get_validator(prop)
5212 try:
-> 5213 val = validator.validate_coerce(val)
5214 except ValueError as err:
5215 if self._skip_invalid:
File ~/miniconda3/envs/xyz2graph/lib/python3.11/site-packages/_plotly_utils/basevalidators.py:410, in DataArrayValidator.validate_coerce(self, v)
408 v = copy_to_readonly_numpy_array(v)
409 elif is_simple_array(v):
--> 410 v = to_scalar_or_list(v)
411 else:
412 self.raise_invalid_val(v)
File ~/miniconda3/envs/xyz2graph/lib/python3.11/site-packages/_plotly_utils/basevalidators.py:40, in to_scalar_or_list(v)
38 return v.item()
39 if isinstance(v, (list, tuple)):
---> 40 return [to_scalar_or_list(e) for e in v]
41 elif np and isinstance(v, np.ndarray):
42 if v.ndim == 0:
File ~/miniconda3/envs/xyz2graph/lib/python3.11/site-packages/_plotly_utils/basevalidators.py:40, in <listcomp>(.0)
38 return v.item()
39 if isinstance(v, (list, tuple)):
---> 40 return [to_scalar_or_list(e) for e in v]
41 elif np and isinstance(v, np.ndarray):
42 if v.ndim == 0:
File ~/miniconda3/envs/xyz2graph/lib/python3.11/site-packages/_plotly_utils/basevalidators.py:37, in to_scalar_or_list(v)
35 np = get_module("numpy", should_load=False)
36 pd = get_module("pandas", should_load=False)
---> 37 if np and np.isscalar(v) and hasattr(v, "item"):
38 return v.item()
39 if isinstance(v, (list, tuple)):
File ~/miniconda3/envs/xyz2graph/lib/python3.11/site-packages/numpy/core/numeric.py:1855, in isscalar(element)
1851 def _frombuffer(buf, dtype, shape, order):
1852 return frombuffer(buf, dtype=dtype).reshape(shape, order=order)
-> 1855 @set_module('numpy')
1856 def isscalar(element):
1857 """
1858 Returns True if the type of `element` is a scalar type.
1859
(...)
1929
1930 """
1931 return (isinstance(element, generic)
1932 or type(element) in ScalarType
1933 or isinstance(element, numbers.Number))
KeyboardInterrupt:```
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.