# Adding hydrogens to multiple pdb files using Openbabel GUI software [duplicate]

I am completely new to using OpenBabel software.

I have about 9000 pdb files to which, I want to add hydrogens. It will be a very hectic task to open all of them 1 by 1 and then convert each of them. Is there any way I could convert all of them simultaneously.

Also, can you please tell me how to correctly select the output file? It asks for a destination file to which, it appends/overwrites the output. Is there a way I could choose the destination where it would create another .pdb file and save the output in it? I guess I am missing something here while choosing the output file.

Thanks in advance. Also, I asked a similar question before which was closed. Considering I am new with OpenBabel, if any further information is required or if there is some issue, please tell me so that I may improve my question.

If you got an installation of openbabel's GUI, you equally have an installation of openbabel for the terminal (e.g., in Linuxes) / command line cmd.exe (in Windows). There is nothing wrong using the GUI for an edit on one file or a few data -- your instructions set are right -- however using the CLI is closer to the engine, thus often more powerful.

• Enter the directory containing the .pdb to work with from the command line.

• The instruction babel *.pdb -opdb *_h.pdb -h will request babel to look for all *.pdb there and write new .pdb with hydrogens added. Each file by name in pattern of example.pdb will have its edit recorded in a file named in pattern of example_h.pdb. While the CLI will report the progress of this conversion, I recommend to slice the task into smaller batches than just one of 9k. How many .pdb per batch depends on the computing power available on your machine.

• The new files written are both discernable by name and time stamp from the retained input. So you have two criteria to sort and discern the files. Assuming you subsequently moved the new ones into their own folder, you may rename them en bloc back to the pattern of example.pdb. If you work with Windows, a program like Ant Renamer may considerably accelerate this task.

Commands and grammar openbabel uses are documented in depth. For commands accessible from the CLI, just a few are compiled here. As perspective: note its use may be automated (scripted), for example with Python like the portable WinPython.

• 1. Is there an option to save the example_h.pdb files in another folder, in the same directory in which the folder containing the actual example.pdb files exist. – Tapasvi Bhatt Mar 17 '20 at 11:03
• 2. Also, can you please elaborate on Ant Renamer and how can it help accelerating the process. Thank you. – Tapasvi Bhatt Mar 17 '20 at 11:03
• @TapasviBhatt For 1) There is if you know some CLI commands applicable for the operating system. Inside the folder with the .pdb to work with, create a sub-folder, e.g. by mkdir stash. Then redirect openbabel's output «with Windows syntax» to this sub-folder by babel *.pdb -opdb .\stash\*_h.pdb -h. Somewhere with Windows 7, «the Linux-like syntax» using forward-slashes became something Windows now equally accepts to denote a file path, which then equates to babel *.pdb -opdb ./stash/*_h.pdb -h. – Buttonwood Mar 17 '20 at 12:43
• @TapasviBhatt For 2) With said program you may select files, or complete folders of files to rename. Here, you possibly would like to truncate two characters in the file names to convert any edited file named in pattern example_h.pdb into a file named example.pdb, and such a file name truncation is one of the actions offered by the program. If you opt for a babel action like babel *.pdb -opdb ./stash/*.pdb -h you may well overwrite the original files lacking Hs with those now containing Hs, especially if you trace changes with a version control like git (e.g., curating a database). – Buttonwood Mar 17 '20 at 12:50