For a set of molecules, DataWarrior1 can generate conformers
(Chemistry -> Generate Conformers). While exploring these variations,
which includes the interconversion of stereogenic centers, the
conformers are assigned an energy. These results can either be saved in
DataWarrior's native .dwar
format, or exported by DataWarrior in a
tabulator separated text file (File -> Save Special -> Textfile).
The aim of this project is to provide quick access to each isomers' conformer of lowest assigned energy in a form further work with DataWarrior is possible.
The included script best_conformer.py
requires a working installation
of Python. For a greater portability, only modules provided by Python's
standard library are used. There are no additional dependencies.
Copy the script into the same folder which contains DataWarrior's .txt
export of the conformers and run
python3 best_conformers.py input.txt > output.txt
which is going to work on your input data and redirect (>
) the results
from the command line into a new permanent record. Both input and output
filename can be of your choice; to use a file extension .txt
however
facilitates the subsequent import of the results into DataWarrior by
Ctrl + O
. Else you can copy-paste the content of the results into
DataWarrior via the computer's clipboard memory and Edit -> Paste
Special -> New From Data With Header Row in DataWarrior.
Sub folder test_data
contains a test library of random molecules
generated by DataWarrior, Random_Molecules.dwar
which was used to
generate conformers (file conformers.dwar
, and subsequent export
conformers.txt
, respectively). File results.txt
is the permanent
record applying the Python script.
The script reads the first line of DataWarrior's .txt
file and –
assuming it is the table's header – queries the columns to identify
which one contains the structure ID, the tag about the isomers, and the
assigned energy. Subsequent lines are read to check if the combination
of structure ID and isomer tag ("a key") already is a new one; if this
is the case, the the whole line (including the assigned energy) is saved
in a temporary dictionary.
For entries with an already known combination of structure ID and isomer tag, the energy already known is compared with the new value from the list's new line read. The entry in the dictionary is updated – by the line's complete content, including conformation and energy – if the energy reported by the line is lower.
.
├── best_conformer.py
├── LICENSE
├── README.md
├── README.org
└── test_data
├── conformers.dwar
├── conformers.txt
├── Random_Molecules.dwar
└── results.txt
2 directories, 8 files