# How do I make a ZMAT or XYZ file from scratch?

From a structure representation like the one below for Bacteriochlorophyll A, how do I make the ZMAT or XYZ file? The closest similar question asked here was about converting a PDB entry into XYZ, but what I have here is not in PDB format, it is just the image of the molecular structure, reported in a paper.

• PDB format per se is not related to proteins, other than historically. (Yes, I know what the "P" stands for.) You may have pretty much any molecule in PDB format. Do you have yours or not? If no, then the referenced question is of no use. In that case start with drawing your structure in some molecular editor, then click "Export as..." and pray. – Ivan Neretin Jun 13 '18 at 19:04
• @IvanNeretin: I do not have any "molecular editor", is there a free one that works well? I downloaded MOLDEN but it is old fashioned and seems hard to use. Do I have to draw this entire ~120 atom structure, or can I just drag and drop the image that I linked to? – user1271772 Jun 13 '18 at 19:14
• See if there is a crystal structure (or something similar). You can get coordinates from that (XYZ) and then tweak by hand in Molden. It saves a lot of time if you have access to a crystal structure database (CCDC) and an appropriate database program (such as ConQuest). – LordStryker Jun 13 '18 at 19:27
• @user1271772 I doubt that is possible. Its unlikely that there is a program that can determine the correct bond distances, angles, etc, even approximately, just from an image file. But I don't think the structure would be too difficult to make in a free software like Avogadro. – Tyberius Jun 13 '18 at 19:48
• I don't know of any way to drag/drop a ChemDraw image to get XYZ coordinates. If there is a way, someone let me know ASAP please. – LordStryker Jun 13 '18 at 19:50

I know of two three ways to do this, but in either case it's quite a bit of work since I don't know any software that can read molecular structures from pictures. The second and third way use freeware only.

1. Draw the structure in Chem3D. For whatever stupid reason Chem3D doesn't support xyz files but you can save as *.pdb. If you need *.xyz then:

• save as Gaussian input
• delete the first 3 lines
• Put the total number of atoms in the resulting first line
• remove any "atoms" labeled as LP (lone pair, Chem3D uses them for force field optimization)
• remove the second column next to the elemental symbol (if you sue Notepad++ you can select that by using ALT)
• change file extension
2. Use openbabel 2.2.0 or higher to convert SMILES into *.xyz or *.pdb using the "gen3d" keyword. Of course for this you need the SMILES so you either have to produce that yourself or you need to draw it in a software that is able to produce SMILES like, again, Chem3D or this free website

3. It turns out this NIH website is also able to produce 3D structures, also in pdb file format, directly from SMILES or drawing the structure in their editor.

• "Bacteriochlorophyl a" has the formula C$_{55}$H$_{74}$MgN$_{4}$O$_6$ – user1271772 Jun 13 '18 at 21:32
• Ok, about 70 "heavy" atoms isn't actually that much, an experienced user could draw that within few minutes. My answer was also about how to solve that for any random structure. In this case there are easier ways. You can go to wikipedia and open the page for that compound and copy the SMILES from there. – DSVA Jun 13 '18 at 21:55
• @user1271772 I tried it. I agree that this one can be tricky due to the coordinated Mg but if you do it without the Mg and insert it afterwards it works very well. Here's a PM6 optimized structure: textuploader.com/dpy6q – DSVA Jun 13 '18 at 22:49
• 55+74+1+4+6 = 140, so why does it say 135 at the top of your XYZ? Also I am very grateful for you spending time on making this XYZ for me. I also want to learn how to do it myself so that in the future I do not need to ask people for help. – user1271772 Jun 13 '18 at 23:11
• Avogadro (free) does support xyz file types, and so using Avogadro saves you a step. Building your molecule with Avogadro should not take more than 15-20 minutes. Avogadro also offers many different templates for common structures, such as amino acids, vitamines, common organic molecule moieties. However, if you end up doing anything "manually", then the bond lengths and bond angles probably end up a little wonky. You can perform (in Avogadro) a geometry optimization with real time visual feedback using simple force-fields, but the final geometry will not of course be extremely accurate. – Yoda Jun 14 '18 at 10:52

Building such large structures can be a nasty task, and as it is quite large, you can easily loose track of parts of it. You should try a couple of molecular editors and find something you are comfortable with, then editing molecules becomes something routine and even a large one like your example is less tedious.

Apart from this very general advice, here are some additional tips. Like DVSA states there are some more or less tedious ways to do it. The most error-prone is obviously trying to build them one atom at the time. That is not only hard work, but it also consumes a lot of time. Using smaller (pre-optimised) fragments can help a lot. Obviously you'll need a molecular editor capable of merging/joining structures.

Probably the best way to built a structure from scratch is to start from something you know, like a literature known structure of a derivative, or a substructure from a database. Unfortunately conversion from InChI or SMILES with open babel does not always work as you might intend it to, especially in those cases, where the SMILES or InChI becomes ambiguous.

Let's take a look at your example: Bacteriochlorophyll A. It is easy enough to find on PubChem, where they provide you with an InChI, and some SMILES.
If you try to convert the following to a 3D structure with openbabel 2.4.1, you will get an error, and I assume this is due to the fact that there are essentially two entities stored in the InChI (the dot . separates those entities).

InChI=1S/C55H75N4O6.Mg/c1-13-39-34(7)41-29-46-48(38(11)60)36(9)43(57-46)27-42-35(8)40(52(58-42)50-51(55(63)64-12)54(62)49-37(10)44(59-53(49)50)28-45(39)56-41)23-24-47(61)65-26-25-33(6)22-16-21-32(5)20-15-19-31(4)18-14-17-30(2)3;/h25,27-32,34-35,39-40,51H,13-24,26H2,1-12H3,(H-,56,57,58,59,60,62);/q-1;+2/p-1/b33-25+;/t31-,32-,34-,35+,39-,40+,51-;/m1./s1


I have executed open babel with the following command, where the above InChI was stored in structure.inchi

obabel -iinchi structure.inchi -oxyz -Ostructure.xyz --gen3d


The result is breathtakingly awful, and I am probably going to file a bug-report later on. The full output is:

*** Open Babel Warning  in InChI code
For InChI=1S/C55H75N4O6.Mg/c1-13-39-34(7)41-29-46-48(38(11)60)36(9)43(57-46)27-42-35(8)40(52(58-42)50-51(55(63)64-12)54(62)49-37(10)44(59-53(49)50)28-45(39)56-41)23-24-47(61)65-26-25-33(6)22-16-21-32(5)20-15-19-31(4)18-14-17-30(2)3;/h25,27-32,34-35,39-40,51H,13-24,26H2,1-12H3,(H-,56,57,58,59,60,62);/q-1;+2/p-1/b33-25+;/t31-,32-,34-,35+,39-,40+,51-;/m1./s1
Problems/mismatches: Mobile-H( Hydrogens: Number; Mobile-H groups: Number; Charge(s): Do not match)
1 molecule converted


The magnesium is somewhere, and the porphyrin ring is all crooked; that does not help at all. (I have also tried SMILES, but that did not work any better.) In some cases you might be luckier, so that approach is something to keep in mind.
I tried the NIH website as DVSA suggested, and apart from the manganese being somewhere, that worked reasonably well. (If you try this approach then you can skip the next sections.)

If you have accesses to the ChemOffice suite things may become a little easier. Copy the InChI into the paste buffer, open ChemDraw, choose Edit > Paste Special > InChI. You will hopefully see something like the Lewis-like structure from your post then. You will need to clean it up a little, you should definitely delete the metal. Now copy the cleaned structure into the paste buffer and open Chem3D. On the right side you should have the ChemDraw - LiveLink, where you can paste your structure. This will create a 3D image on the main screen. I have tried it with the example molecule and it worked reasonably well. (I can only recommend this for organic molecules.) You can already use the implemented force field to optimise it (and you should). Depending on what molecule you are doing, there might be parameters missing (mostly metals, very heavy atoms), charges wrong applied, or other problems. It is basically trial and error, it might not always lead to a success.
Safe the resulting file as something another molecular editor can open. Since ChemOffice handles even common file formats badly, I recommend pdb as the best (still bad) option. (I should really try MarvinSketch or similar software.) It still produces plenty of warnings in open babel, which can mysteriously still recover most of it, and you'll have a somewhat reasonable structure to riff off on.

I was unable to open the pdb directly with molden (unrecognised elements, probably bad formatting), but it was no problem reading it with Chemcraft (payware). Since Avogadro (open source) works on top of open babel, I assume it should be able to read the file, too.
If you edit molecules a lot I recommend spending some money on Chemcraft (that is my personal preference, but I am not affiliated with it), in my experience it is one of the best molecular editors. It has a rather extended fragments database (which you can customise), that may even take care of 'clicking together' a rather huge molecule. It comes with some more nice features, but things like that are better discussed in chat. (I have used it occasionally on the site, so you might find some interesting showcases here, too.) Some people love their GaussView, but I simply cannot see the appeal of that program.

Obviously you can use open babel to transform even the garbage pdb to a xyz file, which you then can view/edit with molden. Unfortunately the zmat interface of molden is quite tedious, but it comes with a few pre-built fragments which makes extending molecules easier. The most tedious thing about that program is, that it does not support drag and drop. In the ZMAT Editor there is an option called 'substitute atom by fragment', I suggest you give that a look. (Chain-like organics can be easily prepared with that starting from methane.)
I believe Avogadro also has a fairly sophisticated molecular editing tool, however I currently have no access to it, so I can't really comment.

There is no harm in trying a few molecular editors and sticking with what works best for you.

Eventually you should have a somewhat good structure to start a calculation on. Keep in mind that whatever you created is only one conformation and likely not the minimum structure. You should use conformation generators to test whether what you have is good or bad.
I have developed a preference for GFN2-xTB from Stefan Grimme's group (semi-empirical program package capable of optimising largen structures) for these tasks.