Imine condensation
Thermodynamic representations
The files required for the generation of the reaction networks of the imine
condensation example of the rNets' article can be found in the
examples/example_imine_thermo
folder. This folder contains the following
files:
example_imine_thermo
-README.txt
assets
-comps_paper.csv
-reactions_paper.csv
-comps_paper_simple.csv
-reactions_paper_simple.csv
-comps_32.csv
-reactions_32.csv
-comps_32_simple.csv
-reactions_32_simple.csv
-dotfile.py
-run.py
In the assets folder we have 4 different compound-reaction file pairs:
comps_paper_simple.csv
andreactions_paper_simple.csv
comps_32_simple.csv
andreactions_32_simple.csv
comps_paper.csv
andreactions_paper.csv
comps_32.csv
andreactions_32.csv
The files with the termination simple.csv
include the ones required to
generate the figures as presented in the manuscript. The files without the
termination simple.csv
correspond to the full reaction network. All the
numerical values included in these files come from the original publication
(DOI: 10.1021/acs.orglett.0c00367).
Specifically, the files in a
are used to generate a simplified reaction
network with the uncorrected DFT energies, hiding some compounds and species.
The files in b
are used to generate the same representation of the network
but with a corrected set of energies. The files in c
are the uncorrected
full reaction network and the files in d
are used for the corrected full
reaction network.
Preliminary steps
For the present example the only required software is rNets and graphviz. Please follow the installation instructions of rNets.
Quickstart
For convenience we created the run.py
script which facilitates the
generation of all the figures in one go. To execute the code the user will have
to type in the following command:
python run.py
Upon execution two new folders will appear: temp
and res
. The
temp
folder contains the .dot files, which serve as input to graphviz
for the actual image generation. The res
folder will contain the
automatically rendered .png files.
Manual Generation of the network graphs
The procedure for the generation of all images is the same one, only needing to
change the compounds and reactions files. We will use the files in a)
(
uncorrected and simplified reaction network ) to illustrate the procedure.
Warning
The following step by step examples assume a UNIX-like OS. In the case of
Windows OS please adapt accordingly the paths to the files or use the
run.py
script.
First we will generate the .dot file containing the reaction network from the compounds and reactions files. To do so we will execute the following line:
$ python dotfile.py assets/comps_paper_simple.csv assets/reactions_paper_simple.csv figure_3a.dot
This will generate a file named figure_3a.dot in the current directory. Next we will render the figure with graphviz as a .png file, (other formats such as svg are also possible). To do so, we will execute the following command:
$ dot -Tpng figure_3a.dot -o figure_3a.png
With this we have generated the image of the reaction network.
Note
Please note that within dotfile.py, a custom treatment for the
simple.csv
files is included. This is not necessary to generate a
reaction network graph, but it was used to add some control over the final
layout to guarantee that the resulting figure would fit in the manuscript.
It has also been added to the examples to ensure the reproducibility of the
figures in the article.
Kinetic representations
The files required for the generation of the reaction networks of the imine
condensation example of the rNets' article can be found in the
examples/example_imine_kinetic
folder. This folder contains the following
files:
example_imine_kinetic
-README.txt
assets
-comps_draco_42.csv
-reactions_draco_42.csv
-comps_draco_42_simple.csv
-reactions_draco_42_simple.csv
-kinetic_model.py
-kinetic_model.index
-kinetic_snapshots.py
-kinetic_gif.py
-run.py
Here we have 4 different types of files:
assets/comps_draco_42_simple.csv
,assets/reactions_draco_42_simple.csv
,assets/comps_draco_42.csv
,assets/reactions_draco_42.csv
kinetic_model.py
,assets/kinetic_model.index
kinetic_snapshots.py
kinetic_gif.py
run.py
Files in a
are used to create the reaction network and provide the energetics
needed to compute the kinetic constants and thus the net rates of the
reactions. Files in b
are files generated using the pykinetic
software, the .index
file contains similar information to the rNets
compounds and reaction files, to simplify re-creating the input needed for pykinetic.
The kinetic_model.py
contains how to carry out the actual microkinetic
simulation, and will generate a .data
file containing the concentrations
at each time of all species. The file in c
is a script to generate the
.dot
files at different times, which are used in the generation the
static graph figures which are the focus of the present section. The file in
d
is a script to generate all the .dot
files required to
generate the .gif
file which is the focus of the following section.
The file in e
integrates all the workflow within a single script.
Note
The kinetic_model.py
obtained from pykinetic (v0.1.0) has been slighly
modified to facilitate the re-generation of all figures under the
run.py
script (see the Quickstart subsection)
The files with the termination simple.csv
are used to draw a simplified
version of the reaction network. The files without the termination
simple.csv
correspond to the full reaction network. The 42
makes reference to the systematic bias included into the DFT computed energies,
specifically 4.2 kcal/mol
which in kJ is 17.56 kJ/mol
.
Preliminary steps
The first step is to run the microkinetic simulation. For this task we only
require to have installed the python libraries numpy
and scipy
,
(one of the main design features of pykinetic is the generation of
standalone scripts that do not require the pykinetic to run).
After ensuring that we have numpy and scipy installed, we now proceed to run the simulation:
$ python kinetic_model.py
This will generate a kinetic_model.data
file in the assets
2-6 mins depending on the CPU performance of the computer.
Quickstart
For convenience we created the run.py
script which facilitates the
generation of all the figures and gifs in one go. To execute the code the user
will have to type in the following command:
python run.py
Upon execution two new folders will appear: temp
and res
. The
temp
folder contains the .dot files, which serve as input to graphviz
for the actual image generation. The res
folder will contain the
automatically rendered .png files as well as the .gif file.
Manual Generation of the network graphs
Warning
The following step by step examples assume a UNIX-like OS. In the case of
Windows OS please adapt accordingly the paths to the files or use the
run.py
script.
Next, we proceed to generate the reaction network, colored by concentration of
the different species at different times during the simulation. For the example
the simple.csv
files will be used but the files for the full network can
also be used.
$ python kinetic_snapshots.py assets/comps_draco_42_simple.csv assets/reactions_draco_42_simple.csv kinetic_model.data
This will generate 2 .dot
files, snapshot_00600.dot
and
snapshot_02400.dot
. The following step is to use graphviz to render the images:
$ dot -Tpng snapshot_00600.dot -o figure_7a.png
$ dot -Tpng snapshot_02400.dot -o figure_7b.png
An animation of the kinetic evolution
The files required for the generation of the reaction networks of the imine
condensation example of the rNets' article can be found in the
examples/example_imine_kinetic
folder. This folder contains the following
files:
example_imine_kinetic
-README.txt
assets
-comps_draco_42.csv
-reactions_draco_42.csv
-comps_draco_42_simple.csv
-reactions_draco_42_simple.csv
-kinetic_model.py
-kinetic_model.index
-kinetic_snapshots.py
-kinetic_gif.py
-run.py
For a detailed explanation of the purpose of each of this files please look at the previous section. The focus of this section is to generate a gif changing the color of the species as the kinetic simulation progresses.
Warning
The following step by step examples assume a UNIX-like OS. In the case of
Windows OS please adapt accordingly the paths to the files or use the
run.py
script.
Preliminary steps
The first step is to run the microkinetic simulation. For this task we only
require to have installed the python libraries numpy
and scipy
,
(one of the main design features of pykinetic is the generation of
standalone scripts that do not require the pykinetic to run). Finally to
generate the final .gif
we will require a software to merge together
all the frames, for this example GIMP or imagemagick are recommended.
After ensuring that we have numpy and scipy installed, we now proceed to run the simulation:
$ python kinetic_model.py
This will generate a kinetic_model.data
file in 2-6 mins depending on the
CPU performance of the computer.
GIF generation
To generate a GIF file showing the evolution of the species over time we will
start by generating a .dot
file for every 10s of simulation into a
folder named gif_folder
. To preform this task the python script
kinetic_gif.py
is included.
To use it we need to provide the compounds and reactions files and the data from the kinetic simulation:
$ python kinetic_gif.py assets/comps_draco_42.csv assets/reactions_draco_42.csv kinetic_model.data
Our next step is to transform all the generated dot
files into
png
format. We can do that manually or we can use some bash scripting.
The following command will work in a bash shell:
$ for dotfile in gif_folder/*.dot; do dot -Tpng $dotfile -o ${dotfile%.*}.png; done
Finally we need to convert all the .png
files into an animated gif. Specifically
for the manuscript, the GIMP <https://www.gimp.org/> software was used for this task.
An alternative through command line is imagemagick which can provide a
decent-quality gif using the following command:
$ convert -delay 0 -loop 1 gif_folder/*.png imine_graph_animation.gif
Upon successfull completion of the '.png' to '.gif' the imine_graph_animation.gif will contain the desired gif file.