If you have a list of atoms and coordinates and want to create a molecule or list of molecules from it, you should use the XYZ importer for it. An XYZ file has only atoms and coordinates, and there are built-in routines for perceiving bonds and assigning bond types.
Start with a set of 10 randomly oriented and translated water molecules
In[]:=
randomTransform[n_,range_:10]:=Table[Composition[RotationTransform[RandomReal[2Pi],RandomReal[1,3]],TranslationTransform[RandomReal[range,3]]],n]
In[]:=
mol=Molecule["water"];mols=MoleculeModify[mol,{"TransformAtomCoordinates",#}]&/@randomTransform[20];
In[]:=
Show[MoleculePlot3D/@%]
Out[]=
Now generate a string with the atomic symbols and coordinates,
In[]:=
listOfAtomsAndCoordinates=Module[{coords=QuantityMagnitude@MoleculeValue[mols,"AtomCoordinates"],atoms=mols[[1]]["AtomicSymbol"]},coords=MapThread[Prepend,{#,atoms}]&/@coords;StringRiffle[StringRiffle/@coords,"\n"]]
Out[]=
O 0.266938 2.81835 8.61991H -0.395092 2.12092 8.50043H 1.11153 2.36739 8.47071O 7.92528 10.7494 5.18829H 7.05971 10.3153 5.15208H 8.40836 10.2522 5.86532O 2.86516 2.16417 -3.06492H 1.94635 2.08008 -2.76882H 3.38546 1.89845 -2.29185O 3.53391 -1.69393 1.85343H 2.72483 -2.16493 1.6034H 4.11968 -1.81381 1.09089O -3.5268 5.00303 -5.31362H -3.03663 4.1999 -5.08197H -3.6488 4.93441 -6.27246O 9.80447 7.63941 5.31409H 9.11214 6.96145 5.31307H 10.6138 7.14782 5.1083O 3.26879 0.803933 7.70711H 2.73052 0.130883 7.26414H 4.1356 0.728375 7.28063O 8.28712 5.47678 8.94121H 7.35599 5.47585 8.67296H 8.34705 4.75168 9.5812O 7.50051 4.02273 -2.32134H 7.16125 3.11595 -2.28114H 8.00511 4.0474 -3.14822O 6.52707 4.54593 5.87896H 5.78632 3.92348 5.82602H 7.3122 3.98044 5.82646O 0.593974 0.35519 10.8242H 0.569558 0.225993 9.86418H 0.802248 1.29577 10.9286O 9.27099 1.27338 6.44592H 9.23277 0.871926 5.56482H 9.11018 2.21468 6.28142O 1.97579 0.819458 10.9215H 1.83068 0.347921 10.0875H 2.77587 1.34144 10.7591O 1.17959 6.53644 5.50634H 0.386458 6.09709 5.16446H 1.73782 5.80621 5.8131O -1.44606 4.90901 -0.0867894H -0.76854 4.22638 -0.204928H -1.12764 5.65021 -0.62363O 0.793051 5.31541 9.10354H 0.267538 4.55324 8.81738H 1.64175 5.19774 8.65096O 0.561352 6.66943 0.748516H -0.23384 6.36971 0.282904H 0.375721 6.47305 1.67907O 2.88179 4.0404 3.21951H 2.50419 3.15308 3.31459H 3.79553 3.87735 2.94121O 4.09028 3.36177 9.87077H 3.31197 3.51034 9.31298H 3.72212 3.02471 10.7013O 8.79154 7.11951 3.28453H 8.60046 6.18607 3.46102H 8.70336 7.19871 2.32281
Now all you need to do is use the importer on this string
In[]:=
reimported=ImportString[listOfAtomsAndCoordinates,"XYZ"]
Out[]=
Molecule
Visualize the result:
In[]:=
MoleculePlot3D@%
Out[]=
And recover the individual components:
In[]:=
ConnectedMoleculeComponents@reimported
Out[]=
