I need to "build" an organometallic molecule in Blender/Python then represent it resting on a crystal surface.
I'm looking at a PubChem summary for Chloroaluminum phthalocyanine and I can download some JSON files and generate a crude plot for it.
According to the description this is a calculated shape and size and for my purposes that sounds like it should be close enough for me for now, as much as +/-5 % is acceptable at the moment. I just want to see roughly how large this molecule is.
I am assuming that the coordinates are in Angstroms, but I can not find anything that says that explicitly here.
The problem is that the 2D JSON shows it to be about 11 Angstroms from one end to the other, but the 3D JSON shows a molecule that will be more like 16 Angstroms when stretched out.
That substantial difference suggests I can't yet assume those coordinates are what I think they are, so I'd like to ask:
Question: How can I interpret the 2D and 3D coordinates of atom locations from a PubChem summary of an organometallic molecule? Which of these JSON files should I use? The molecule's "arms" are shown bent in the 3D representation, am I free to "flatten" them to show the molecule laying flat?
note: This is for illustration/animation purposes, not for deriving information about interaction.
above: Structure2D_CID_123667.json
below: Conformer3D_CID_5282330.json
A three-dimensional representation of the compound. The 3D structure is not experimentally determined, but computed by PubChem. More detailed information on this conformer model is described in the PubChem3D thematic series published in the Journal of Cheminformatics.
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import json
# https://pubchem.ncbi.nlm.nih.gov/compound/Chloroaluminum-phthalocyanine
fnames = ('Conformer3D_CID_5282330.json',
'Structure2D_CID_123667.json')
molecule = dict()
for fname in fnames:
if '3D' in fname:
dim = '3D'
else:
dim = '2D'
with open(fname, 'r') as infile:
info = json.load(infile)
data = info['PC_Compounds'][0]
atoms = data['atoms']
atom_id = atoms['aid']
element_id = atoms['element']
coords = data['coords'][0]['conformers'][0]
if dim == '3D':
x, y, z = [coords[axis] for axis in 'xyz']
else:
x, y = [coords[axis] for axis in 'xy']
z = len(x) * [0]
things = zip(atom_id, element_id, x, y, z)
mol = dict()
molecule[dim] = mol
for thing in things:
try:
mol[thing[1]].append(thing)
except:
mol[thing[1]] = [thing]
with open('molecule', 'w') as outfile:
json.dump(molecule, outfile)
if True:
# plot 2D
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1, projection='3d')
for elem, data in molecule['2D'].items():
atom_id, element_id, x, y, z = zip(*data)
ax.plot(x, y, z, 'o', markersize=16)
print('elem: ', elem, len(x))
plt.show()
# plot 3D
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1, projection='3d')
for elem, data in molecule['3D'].items():
atom_id, element_id, x, y, z = zip(*data)
ax.plot(x, y, z, 'o', markersize=16)
print('elem: ', elem, len(x))
plt.show()