Hi All,<div><br></div><div>Right now, Chemical JSON uses a 1D list for all of the multidimensional information including 3d coordinates for atoms and bonds.</div><div><br></div><div>When parsing the format, this results in the following:</div>
<div><br></div><div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">ethane["atoms"]["coords"]["3d"]<br>
</blockquote><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">[1.18508, -0.003838, 0.987524, 0.751621, -0.022441, -0.020839, 1.166929, 0.833015, -0.569312, 1.115519, -0.932892, -0.514525, -0.751587, 0.022496, 0.020891, -1.166882, -0.833372, 0.568699, -1.115691, 0.932608, 0.515082, -1.184988, 0.004424, -0.987522]</blockquote>
</div><div><br></div><div>Getting the x, y, z coordinates of the first atom is overcomplicated in both javascript and python. A reasonable use case might be looping through ethane["atoms"] and drawing based on the location of each.</div>
<div><br></div><div>In python, this would look like:</div><div><br></div><div>for i in range(len(ethane["atoms"]["elements"]["number"])):</div><div>    start = 0+i</div><div>    end = 3*(1+i)</div>
<div>    x, y, z = ethane["atoms"]["coords"]["3d"][start:end]</div><div>    draw(x,y,z)</div><div><br></div><div>If the list was nested, it would look like the following:</div><div><br></div>
<div>for i in range(len(ethane["atoms"]["elements"]["number"])):</div><div>    x, y, z = ethane["atoms"]["coords"]["3d"][i]</div><div>   draw(x, y, z)</div><div>
<br></div><div>Fewer things to keep track of, fewer places to screw up, more implicit information. Everyone wins.</div><div><br></div><div>Not sure what sort of performance hit you get with nested array serialization, but this might let you remove the "3d" subobject as dimensionality of coordinates would be explicit.</div>
<div><br></div><div>The same argument applies to the "bonds" subobject.</div><div><br></div><div>Best!<br>--</div><div>Ian</div><div><br></div><div><br></div>