Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikPoppleton committed Feb 2, 2024
2 parents b9563f0 + e967b71 commit 5404bb0
Show file tree
Hide file tree
Showing 27 changed files with 402 additions and 449 deletions.
2 changes: 1 addition & 1 deletion analysis/tests/cleanup.sh
Original file line number Diff line number Diff line change
@@ -1 +1 @@
rm align* angle* *.json *.pyidx *.png *.npy *.mp4 centroid* cluster* forces.txt gen_pairs.txt mean* min.dat sub*
rm -f align* angle* *.json *.pyidx *.png *.npy *.mp4 centroid* cluster* forces.txt gen_pairs.txt mean* min.dat sub*
203 changes: 53 additions & 150 deletions analysis/tests/test.sh
Original file line number Diff line number Diff line change
@@ -1,175 +1,78 @@
#!/bin/bash

echo "Testing align..."
if
python ../src/oxDNA_analysis_tools/align.py minitraj.dat aligned.dat 2>&1 >/dev/null | grep -y "ERROR"
then
echo "AN ERROR OCCURED"
else
echo "OK"
fi

echo ""
echo "Testing oat"
echo "-----------"

echo "Testing backbone_flexibility..."
if
python ../src/oxDNA_analysis_tools/backbone_flexibility.py rna_tile.top minitraj.dat 2>&1 >/dev/null | grep -y "ERROR"
if [ $# -gt 0 ];
then
echo "AN ERROR OCCURED"
PYTHON=$1
else
echo "OK"
PYTHON="python"
fi

echo ""
test() {
tmpfile=$(mktemp)
$PYTHON $1 &> $tmpfile
local code_res=$?
grep_out=$(grep -i "ERROR" $tmpfile)
local grep_res=$?

echo "Testing bond_analysis..."
if
python ../src/oxDNA_analysis_tools/bond_analysis.py -p2 input_rna minitraj.dat pairs.txt 2>&1 >/dev/null | grep -y "ERROR"
then
echo "AN ERROR OCCURED"
else
echo "OK"
fi
if [ $code_res -eq 0 ] && [ $grep_res -eq 1 ]
then
echo " OK"
else
echo ""
echo $grep_out
echo "--> AN ERROR OCCURRED <--"
fi
}

echo ""
echo -n "Testing align..."
test "../src/oxDNA_analysis_tools/align.py minitraj.dat aligned.dat"

echo "Testing mean and deviations..."
if
python ../src/oxDNA_analysis_tools/mean.py -p 2 -d devs.json minitraj.dat 2>&1 >/dev/null | grep -y "ERROR"
then
echo "AN ERROR OCCURED"
else
echo "OK"
fi
echo -n "Testing backbone_flexibility..."
test "../src/oxDNA_analysis_tools/backbone_flexibility.py rna_tile.top minitraj.dat"

echo ""
echo -n "Testing bond_analysis..."
test "../src/oxDNA_analysis_tools/bond_analysis.py -p2 input_rna minitraj.dat pairs.txt"

echo "Testing centroid with indexing..."
if
python ../src/oxDNA_analysis_tools/centroid.py -i index.txt mean.dat minitraj.dat 2>&1 >/dev/null | grep -y "ERROR"
then
echo "AN ERROR OCCURED"
else
echo "OK"
fi
echo -n "Testing mean and deviations..."
test "../src/oxDNA_analysis_tools/mean.py -p 2 -d devs.json minitraj.dat"

echo ""
echo -n "Testing centroid with indexing..."
test "../src/oxDNA_analysis_tools/centroid.py -i index.txt mean.dat minitraj.dat"

echo "Testing contact_map..."
if
python ../src/oxDNA_analysis_tools/contact_map.py minitraj.dat 2>&1 >/dev/null | grep -y "ERROR"
then
echo "AN ERROR OCCURED"
else
echo "OK"
fi
echo -n "Testing contact_map..."
test "../src/oxDNA_analysis_tools/contact_map.py minitraj.dat"

echo ""
echo -n "Testing distance and clustering (this one takes a while because of the plot)..."
test "../src/oxDNA_analysis_tools/distance.py -c -i minitraj.dat 1 3 5 67 34 56"

echo "Testing distance and clustering (this one takes a while because of the plot)..."
if
python ../src/oxDNA_analysis_tools/distance.py -c -i minitraj.dat 1 3 5 67 34 56 2>&1 >/dev/null | grep -y "ERROR"
then
echo "AN ERROR OCCURED"
else
echo "OK"
fi
echo -n "Testing duplex_finder..."
test "../src/oxDNA_analysis_tools/duplex_finder.py input_rna minitraj.dat"

echo ""
echo -n "Testing duplex_angle_plotter..."
test "../src/oxDNA_analysis_tools/duplex_angle_plotter.py -o angle.png -i angles.txt 7 37"

echo "Testing duplex_finder..."
if
python ../src/oxDNA_analysis_tools/duplex_finder.py input_rna minitraj.dat 2>&1 >/dev/null | grep -y "ERROR"
then
echo "AN ERROR OCCURED"
else
echo "OK"
fi
echo -n "Testing generate_force..."
test "../src/oxDNA_analysis_tools/generate_force.py -f gen_pairs.txt input_rna minitraj.dat"

echo ""
echo -n "Testing minify..."
test "../src/oxDNA_analysis_tools/minify.py -a -d2 minitraj.dat min.dat"

echo "Testing duplex_angle_plotter..."
if
python ../src/oxDNA_analysis_tools/duplex_angle_plotter.py -o angle.png -i angles.txt 7 37 2>&1 >/dev/null | grep -y "ERROR"
then
echo "AN ERROR OCCURED"
else
echo "OK"
fi
echo -n "Testing multidimensional_scaling_mean..."
test "../src/oxDNA_analysis_tools/multidimensional_scaling_mean.py minitraj.dat -o meanM -d devsM"

echo ""
echo -n "Testing output_bonds..."
test "../src/oxDNA_analysis_tools/output_bonds.py -v energy.json input_rna minitraj.dat"

echo "Testing generate_force..."
if
python ../src/oxDNA_analysis_tools/generate_force.py -f gen_pairs.txt input_rna minitraj.dat 2>&1 >/dev/null | grep -y "ERROR"
then
echo "AN ERROR OCCURED"
else
echo "OK"
fi
echo -n "Testing pca"
test "../src/oxDNA_analysis_tools/pca.py minitraj.dat mean.dat pca.json"

echo ""
echo -n "Testing subset_trajectory..."
test "../src/oxDNA_analysis_tools/subset_trajectory.py minitraj.dat rna_tile.top -i index.txt sub.dat"

echo "Testing minify..."
if
python ../src/oxDNA_analysis_tools/minify.py -a -d2 minitraj.dat min.dat 2>&1 >/dev/null | grep -y "ERROR"
then
echo "AN ERROR OCCURED"
else
echo "OK"
fi

echo ""

echo "Testing multidimensional_scaling_mean..."
if
python ../src/oxDNA_analysis_tools/multidimensional_scaling_mean.py minitraj.dat -o meanM -d devsM 2>&1 >/dev/null | grep -y "ERROR"
then
echo "AN ERROR OCCURED"
else
echo "OK"
fi

echo ""

echo "Testing output_bonds..."
if
python ../src/oxDNA_analysis_tools/output_bonds.py -v energy.json input_rna minitraj.dat 2>&1 >/dev/null | grep -y "ERROR"
then
echo "AN ERROR OCCURED"
else
echo "OK"
fi

echo ""

echo "Testing pca"
if
python ../src/oxDNA_analysis_tools/pca.py minitraj.dat mean.dat pca.json 2>&1 >/dev/null | grep -y "ERROR"
then
echo "AN ERROR OCCURED"
else
echo "OK"
fi

echo "Testing subset_trajectory..."
if
python ../src/oxDNA_analysis_tools/subset_trajectory.py minitraj.dat rna_tile.top -i index.txt sub.dat 2>&1 >/dev/null | grep -y "ERROR"
then
echo "AN ERROR OCCURED"
else
echo "OK"
fi

echo ""

echo "Testing superimpose..."
if
python ../src/oxDNA_analysis_tools/superimpose.py mean.dat centroid.dat 2>&1 >/dev/null | grep -y "ERROR"
then
echo "AN ERROR OCCURED"
else
echo "OK"
fi
echo -n "Testing superimpose..."
test "../src/oxDNA_analysis_tools/superimpose.py mean.dat centroid.dat"

echo ""
echo ""
61 changes: 31 additions & 30 deletions contrib/tostiguerra/src/CGNucleicAcidsInteraction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ void CGNucleicAcidsInteraction::get_settings(input_file &inp) {
getInputNumber(&inp, "DPS_3b_sigma", &_3b_sigma, 0);
getInputNumber(&inp, "DPS_3b_range", &_3b_range, 0);
getInputNumber(&inp, "DPS_3b_lambda", &_3b_lambda, 0);
getInputNumber(&inp, "DPS_mu", &_mu, 1.0);
getInputNumber(&inp, "DPS_tC", &_tC, 37.0);
getInputNumber(&inp, "DPS_dS_mod", &dS_mod, 1.0);
getInputNumber(&inp, "DPS_alpha_mod", &alpha_mod, 1.0);
getInputNumber(&inp, "DPS_bdG_threshold", &bdG_threshold, 1.0);
Expand Down Expand Up @@ -80,7 +80,8 @@ void CGNucleicAcidsInteraction::get_settings(input_file &inp) {
void CGNucleicAcidsInteraction::init() {
_sqr_rfene = SQR(_rfene);
_PS_sqr_rep_rcut = pow(2. * _WCA_sigma, 2. / _PS_n);
_WCA_sigma_unbonded = _WCA_sigma * (6.0 / _bead_size - _3b_sigma) / 2.0;
// _WCA_sigma_unbonded = _WCA_sigma * (6.0 / _bead_size - _3b_sigma) / 2.0; // disabled for now
_WCA_sigma_unbonded = _WCA_sigma;

OX_LOG(Logger::LOG_INFO, "CGNA: WCA sigma = %lf, WCA sigma unbonded = %lf", _WCA_sigma, _WCA_sigma_unbonded);

Expand Down Expand Up @@ -631,38 +632,38 @@ void CGNucleicAcidsInteraction::allocate_particles(std::vector<BaseParticle*> &p
}

void CGNucleicAcidsInteraction::_parse_interaction_matrix() {
// parse the interaction matrix file
input_file inter_matrix_file;
inter_matrix_file.init_from_filename(_interaction_matrix_file);
const number _t37_ = 310.15;
const number _kB_ = 1.9872036;
//const number dS_mod = 1.87;
if(inter_matrix_file.state == ERROR) {
throw oxDNAException("Caught an error while opening the interaction matrix file '%s'", _interaction_matrix_file.c_str());
}
// parse the interaction matrix file
input_file inter_matrix_file;
inter_matrix_file.init_from_filename(_interaction_matrix_file);
const number _t37_ = 310.15;
const number _kB_ = 1.9872036;
number _mu = _t37_ / (_tC+273.15);
if(inter_matrix_file.state == ERROR) {
throw oxDNAException("Caught an error while opening the interaction matrix file '%s'", _interaction_matrix_file.c_str());
}

_interaction_matrix_size = _N_attractive_types + 1;
_3b_epsilon.resize(_interaction_matrix_size * _interaction_matrix_size, 0.);

ofstream myfile;
myfile.open("beta_eps_matrix.dat");
for(int i = 1; i <= _N_attractive_types; i++) {
for(int j = 1; j <= _N_attractive_types; j++) {
number valueH;
number valueS;
std::string keyH = Utils::sformat("dH[%d][%d]", i, j);
std::string keyS = Utils::sformat("dS[%d][%d]", i, j);
if(getInputNumber(&inter_matrix_file, keyH.c_str(), &valueH, 0) == KEY_FOUND && getInputNumber(&inter_matrix_file, keyS.c_str(), &valueS, 0) == KEY_FOUND) {
number beta_dG = (_mu * valueH * 1000 / _t37_ - valueS) / _kB_;
number beta_eps = -(beta_dG + dS_mod) / alpha_mod;
if(beta_dG < bdG_threshold && abs(i - j) > 2) {
_3b_epsilon[i + _interaction_matrix_size * j] = _3b_epsilon[j + _interaction_matrix_size * i] = beta_eps;
myfile << "beta_eps[" << i << "][" << j << "]=" << beta_eps << "\n";
}
}
}
}
myfile.close();
ofstream myfile;
myfile.open("beta_eps_matrix.dat");
for(int i = 1; i <= _N_attractive_types; i++) {
for(int j = 1; j <= _N_attractive_types; j++) {
number valueH;
number valueS;
std::string keyH = Utils::sformat("dH[%d][%d]", i, j);
std::string keyS = Utils::sformat("dS[%d][%d]", i, j);
if(getInputNumber(&inter_matrix_file, keyH.c_str(), &valueH, 0) == KEY_FOUND && getInputNumber(&inter_matrix_file, keyS.c_str(), &valueS, 0) == KEY_FOUND) {
number beta_dG = (_mu * valueH * 1000 / _t37_ - valueS)/_kB_;
number beta_eps = -(beta_dG + dS_mod) / alpha_mod;
if(beta_dG<bdG_threshold && abs(i - j) > 1) {
_3b_epsilon[i + _interaction_matrix_size * j] = _3b_epsilon[j + _interaction_matrix_size * i] = beta_eps;
myfile << "beta_eps[" << i << "][" << j << "]=" << beta_eps << "\n";
}
}
}
}
myfile.close();
}

void CGNucleicAcidsInteraction::read_topology(int *N_strands, std::vector<BaseParticle*> &particles) {
Expand Down
2 changes: 1 addition & 1 deletion contrib/tostiguerra/src/CGNucleicAcidsInteraction.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class CGNucleicAcidsInteraction: public BaseInteraction {
number _sqr_rfene;
number _WCA_sigma = 1.0, _WCA_sigma_unbonded;
number _PS_sqr_rep_rcut;
number _mu = 1.0;
number _tC = 37.0;
number dS_mod = 1.0;
number alpha_mod = 1.0;
number bdG_threshold = 1.0;
Expand Down
22 changes: 15 additions & 7 deletions docs/docs_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
Sphinx==3.4.1
sphinx_rtd_theme==0.5.0
myst_parser==0.17.2
docutils==0.16
Jinja2<3.1
sphinx-argparse>=0.3.1
ipython>=7.26.0
Sphinx==7.0.1
sphinx-argparse==0.3.2
sphinx-rtd-theme==2.0.0
sphinxcontrib-applehelp==1.0.2
sphinxcontrib-bibtex==2.5.0
sphinxcontrib-devhelp==1.0.2
sphinxcontrib-htmlhelp==2.0.0
sphinxcontrib-jquery==4.1
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==1.0.3
sphinxcontrib-serializinghtml==1.1.5
myst_parser==2.0.0
docutils==0.20.1
Jinja2==3.0.3
ipython>=7.26.0
3 changes: 2 additions & 1 deletion docs/source/input.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ These options control the behaviour of MD simulations.

* `sim_type = MD|FFS_MD`: run either an MD or an FFS simulation.
* `backend = CPU|CUDA`: MD simulations can be run either on single CPU cores or on single CUDA-enabled GPUs.
* `backend_precision = <any>`: by default CPU simulations are run with `double` precision, CUDA with `mixed` precision (see [here](https://doi.org/10.1002/jcc.23763) for details). The CUDA backend also supports single precision (`backend_precision = float`), but we do not recommend to use it. Optionally, [by using CMake switches](install.md#CMake-options) it is possible to run CPU simulations in single precision or CUDA simulations in double precision.
* `backend_precision = <any>`: by default CPU simulations are run with `double` precision, CUDA with `mixed` precision (see [here](https://doi.org/10.1002/jcc.23763) for details). The CUDA backend also supports single precision (`backend_precision = float`), but we do not recommend to use it. Optionally, [by using CMake switches](install.md#cmake-options) it is possible to run CPU simulations in single precision or CUDA simulations in double precision.
* `dt`: the simulation time step. The higher this value, the longer time a simulation of a given number of time steps will correspond to. However, a value that is too large will result in numerical instabilities. Typical values range between 0.001 and 0.005.
* `refresh_vel = <bool>`: if `true` the velocities of the particles in the initial configuration will be randomly sampled from a Boltzmann distribution corresponding to `T`. If `false`, the velocities in the `conf_file` will be used (or an error will be thrown if the `conf_file` doesn't include initialized velocities).
* `[reset_initial_com_momentum = <bool>]`: if `true` the momentum of the centre of mass of the initial configuration will be set to 0. Defaults to `false` to enforce the reproducibility of the trajectory.
Expand Down Expand Up @@ -152,6 +152,7 @@ The following options control the behaviour of MC simulations.
## Common options for `DNA2` and `RNA2` simulations

* `[dh_lambda = <float>]`: the value that lambda, which is a function of temperature (T) and salt concentration (I), should take when T = 300K and I = 1M. Defaults to the value from Debye-Huckel theory, 0.3616455.
* `[debye_huckel_rhigh]`: the distance at which the smoothing of the Debye-Hucker repulsion begins. Defaults to three times the Debye screening length.
* `[dh_strength = <float>]`: the value that scales the overall strength of the Debye-Huckel interaction. Defaults to 0.0543.
* `[dh_half_charged_ends = <bool>]`: if `false`, nucleotides at the end of a strand carry a full charge, if `true` their charge is halved. Defaults to `true`.

Expand Down
10 changes: 6 additions & 4 deletions docs/source/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,6 @@ If you are on your own machine or you installed Python via Anaconda, the `-DOxpy
* `make rovigatti` Compiles the observables and interactions in contrib/rovigatti
* `make romano` Compiles the observables and interactions in contrib/romano

### Known issues

The list of known issues can be browsed online [here](https://github.com/lorenzo-rovigatti/oxDNA/issues).

#### CMake compiler choice

CMake searches your $PATH for compatible C and C++ compilers and uses the first ones it finds. If you want to use a different set than the default, you can override the compiler choice as follows:
Expand Down Expand Up @@ -105,6 +101,12 @@ cmake -DPython=1 -DPYTHON_EXECUTABLE=$HOME/miniconda3/bin/python -DPYTHON_INCLUD
`python -m pip install ./analysis --no-build-isolation`
* Sometimes installation will fail with `TypeError: expected string or bytes-like object`. This error is usually caused by older versions of either `oxpy` or `oxDNA-analysis-tools` somewhere in your `$PATH`. Remove them with `pip uninstall oxpy` and `pip uninstall oxDNA-analysis-tools` and try installing again.

## Known issues

* An `illegal instruction` is sometimes issued when the code is compiled on a CPU architecture and run on another, or when specific combinations of CPU architecture and compiler are used. Invoke CMake with `-DNATIVE_COMPILATION=Off` and re-compile the code to fix the issue.
* A list of other known issues can be browsed online [here](https://github.com/lorenzo-rovigatti/oxDNA/issues).


## Using `oxpy` with old Python versions

`oxpy` interfaces with oxDNA using [Pybind11](https://github.com/pybind/pybind11). In September 2023 we updated the version of pybind11 included with oxDNA from 2.2 to 2.11 due to changes to the Python C API which made older versions of Pybind11 incompatible with the current Python 3.11. This new version of pybind11 is only compatible with Python > 3.8. If, for some reason, you need to use an older version of Python 3 and cannot install a newer version in a virtual environment via, for example, [Conda](https://docs.conda.io/projects/miniconda/en/latest/miniconda-install.html), this can be done by using an older version of pybind11:
Expand Down
Loading

0 comments on commit 5404bb0

Please sign in to comment.