Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Using oxDNA from Python

Here I will show you how to run an oxDNA simulation, visualising configurations with oxView and analysing the results.

  • Download oxDNA

  • Compile it:

cd oxDNA
mkdir build
cd build
cmake .. -DPython=On
make install -j6

If you want to run this notebook, download the oxDNA_input, hairpin.conf and hairpin.top files (and rename them so that they retain their original name).

rm: cannot remove 'trajectory.dat': No such file or directory
zsh:1: no matches found: *.pyidx
rm: cannot remove 'relax_energy.dat': No such file or directory
zsh:1: no matches found: bonds*

We can visualise the initial configuration using oxView.

WARNING: The old topology format is depreciated and future tools may not support it.  Please update to the new topology format for future simulations.
Loading...

Our system is a short strand that can form a hairpin. We will run a short relaxation simulation. Note that the simulation is run on a separate thread, so during the run it is possible to run the analysis cells down the book. In principle, this also allows to run more than one replica at a time.

WARNING: Overwriting key `diff_coeff' (`2.5' to `2.5')
WARNING: Overwriting key `steps' (`1000000' to `2000000')
WARNING: Overwriting key `print_conf_interval' (`10000' to `10000')
WARNING: Overwriting key `print_energy_every' (`10000' to `10000')
WARNING: Overwriting key `dt' (`0.003' to `0.003')
WARNING: Overwriting key `T' (`60.85C' to `10C')
WARNING: Overwriting key `energy_file' (`energy.dat' to `relax_energy.dat')

Since the simulation is run on a different thread, we can plot the energy while the simulation is running. W will be runnin a MD relaxation simulation, so the energy file format is:

[time (steps)] [Total Energy] [Potential Energy] [Kinetic Energy]

We add at the end a vertical line to indicate the length of the simulation, and since we are looking at an unformed hairpin, a “good” relaxed energy would be around -1, which is the green line.

The cell can be reloaded multiple times during the running simulation to see progress.

Relaxation is running: True
<Figure size 1500x300 with 1 Axes>

Now we can have a look at the last configuration

WARNING: The old topology format is depreciated and future tools may not support it.  Please update to the new topology format for future simulations.
Loading...

The melting temperature of this specific hairpin is 60.85 C, which means that at this temperature it is most probable that the hairpin will transition between a fully bonded state and fully melted.

WARNING: 
<Process name='Process-5' pid=1548511 parent=1538542 started>
Overwriting key `diff_coeff' (`2.5' to `2.5')
WARNING: Overwriting key `conf_file' (`hairpin.conf' to `last_conf.dat')
WARNING: Overwriting key `steps' (`1000000' to `60000000')
WARNING: Overwriting key `print_conf_interval' (`10000' to `50000')
WARNING: Overwriting key `print_energy_every' (`10000' to `50000')
WARNING: Overwriting key `dt' (`0.003' to `0.003')
INFO: seeding the RNG with 1503251921
INFO: Initializing backend 
INFO: Simulation type: MD
INFO: The generator will try to take into account bonded interactions by choosing distances between bonded neighbours no larger than 2.000000
INFO: Converting temperature from Celsius (60.850000 C°) to simulation units (0.111333)
INFO: Running Debye-Huckel at salt concentration =  1
INFO: Using different widths for major and minor grooves
INFO: Temperature change detected (new temperature: 60.85 C, 334.00 K), re-initialising the DNA interaction
DEBUG: Debye-Huckel parameters: Q=0.054300, lambda_0=0.361646, lambda=0.381589, r_high=1.144767, cutoff=2.679947
DEBUG: Debye-Huckel parameters: debye_huckel_RC=1.717150e+00, debye_huckel_B=7.208180e-03
INFO: The Debye length at this temperature and salt concentration is 0.381589
INFO: pid: 1548511
DEBUG: Debye-Huckel parameters: Q=0.054300, lambda_0=0.361646, lambda=0.381589, r_high=1.144767, cutoff=2.679947
DEBUG: Debye-Huckel parameters: debye_huckel_RC=1.717150e+00, debye_huckel_B=7.208180e-03
INFO: The Debye length at this temperature and salt concentration is 0.381589
INFO: (Cells.cpp) N_cells_side: 4, 4, 4; rcut=3.07995, IS_MC: 0
INFO: N: 18, N molecules: 1
INFO: Using randomly distributed velocities
INFO: Initial kinetic energy: 5.571667
INFO: diffusion fixed.. -14.8859 -14.8859
INFO: diffusion fixed.. -12.6048 -12.6048
INFO: diffusion fixed.. -10.8525 -10.8525
INFO: diffusion fixed.. -11.3755 -11.3755
INFO: diffusion fixed.. -12.8351 -12.8351
INFO: diffusion fixed.. -11.3582 -11.3582
INFO: diffusion fixed.. -13.8222 -13.8222

Here we can monitor the energy as before, but I add two lines to the output, to distinguish the two possibilities:

  • Energy ≈−1\approx -1 corresponds to the open structure (blue line)

  • Energy ≈−1.2\approx -1.2 is a fully bonded hairpin (green line)

The visualization will appear only if the simulation has completed, and it is the last configuration with computed bond energy per nucleotide

Simulation is running: False
<Figure size 1500x300 with 1 Axes>
Last configuration is:
INFO: oxDNA_analysis_tools version: 2.5.0
INFO: running config.py installed at: /home/lorenzo/.local/lib/python3.11/site-packages/oxDNA_analysis_tools/config.py
INFO: Python version: 3.11.9
INFO: Package Numpy found. Version: 1.26.4
INFO: Package oxpy found. Version: 3.6.2.dev78+ga20df96a.d20241108
INFO: No dependency issues found.
INFO: no units specified, assuming oxDNA su
WARNING: Overwriting key `diff_coeff' (`2.5' to `2.5')
WARNING: Overwriting key `trajectory_file' (`trajectory.dat' to `/home/lorenzo/Dropbox/ROMA/INSEGNAMENTO/COMPUTATIONAL_BIOPHYSICS/LEZIONI/comp_bio_notes/notebooks/last_conf.dat')
INFO: The generator will try to take into account bonded interactions by choosing distances between bonded neighbours no larger than 2.000000
INFO: Converting temperature from Celsius (60.850000 C°) to simulation units (0.111333)
INFO: Running Debye-Huckel at salt concentration =  1
INFO: Using different widths for major and minor grooves
DEBUG: Debye-Huckel parameters: Q=0.054300, lambda_0=0.361646, lambda=0.381589, r_high=1.144767, cutoff=2.679947
DEBUG: Debye-Huckel parameters: debye_huckel_RC=1.717150e+00, debye_huckel_B=7.208180e-03
INFO: The Debye length at this temperature and salt concentration is 0.381589
INFO: (Cells.cpp) N_cells_side: 4, 4, 4; rcut=2.67995, IS_MC: 0
INFO: N: 18, N molecules: 1

Please cite at least the following publication for any work that uses the oxDNA simulation package
  * E. Poppleton et al., J. Open Source Softw. 8, 4693 (2023), DOI: 10.21105/joss.04693
INFO: Aggregated I/O statistics (set debug=1 for file-wise information)
	  0.000  B written to files
	  0.000  B written to stdout/stderr
INFO: Processing in blocks of 20 configurations
INFO: You can modify this number by running oat config -n <number>, which will be persistent between analyses.
INFO: Starting up 2 processes for 1 chunks
INFO: All spawned, waiting for results
WARNING: Overwriting key `diff_coeff' (`2.5' to `2.5')
WARNING: Overwriting key `trajectory_file' (`trajectory.dat' to `/home/lorenzo/Dropbox/ROMA/INSEGNAMENTO/COMPUTATIONAL_BIOPHYSICS/LEZIONI/comp_bio_notes/notebooks/last_conf.dat')
WARNING: The old topology format is depreciated and future tools may not support it.  Please update to the new topology format for future simulations.
INFO: The generator will try to take into account bonded interactions by choosing distances between bonded neighbours no larger than 2.000000
INFO: Running Debye-Huckel at salt concentration =  1
INFO: Using different widths for major and minor grooves
DEBUG: Debye-Huckel parameters: Q=0.054300, lambda_0=0.361646, lambda=0.381589, r_high=1.144767, cutoff=2.679947
DEBUG: Debye-Huckel parameters: debye_huckel_RC=1.717150e+00, debye_huckel_B=7.208180e-03
INFO: The Debye length at this temperature and salt concentration is 0.381589
INFO: (Cells.cpp) N_cells_side: 4, 4, 4; rcut=2.67995, IS_MC: 0
INFO: N: 18, N molecules: 1

Please cite at least the following publication for any work that uses the oxDNA simulation package
  * E. Poppleton et al., J. Open Source Softw. 8, 4693 (2023), DOI: 10.21105/joss.04693
INFO: Aggregated I/O statistics (set debug=1 for file-wise information)
	  0.000  B written to files
	  0.000  B written to stdout/stderr
finished 1/1
INFO: Wrote oxView overlay to: bonds_FENE.json
INFO: Wrote oxView overlay to: bonds_BEXC.json
INFO: Wrote oxView overlay to: bonds_STCK.json
INFO: Wrote oxView overlay to: bonds_NEXC.json
INFO: Wrote oxView overlay to: bonds_HB.json
INFO: Wrote oxView overlay to: bonds_CRSTCK.json
INFO: Wrote oxView overlay to: bonds_CXSTCK.json
INFO: Wrote oxView overlay to: bonds_DH.json
INFO: Wrote oxView overlay to: bonds_total.json
Loading...