
----------- Conversion between SDA and BrownDye input ---------

convert-to-browndye.sh is a script for the purpose of converting the input files from SDA to Browndye2. The script currently supports:

1. Conversion of the sda.in input file to a BrownDye input.xml file (input file for bd_top)
2. Conversion and rescaling of the electrostatic interaction and desolvation grids in UHBD format with units of kcal/mol/e used in SDA to electrostatic grids in OpenDX format with kTi/e units used by BrownDye2
3. Conversion of the reaction criteria file
4. Conversion of effective charge file used in SDA to xml file used in Browndye2

12.2023: The script was tested using the pre-compiled binary package of Browndye (version 3.5.4) for Ubuntu 22.04 and SDA7
Author: Jakob Niessner; Validation and editing: Riccardo Beccaria, Stefan Richter, Rebecca Wade  (HITS, Heidelberg).

Release: 01.2024.


----- PRELIMINARIES -----

* Create folder "./data" in the current directory
* In data create two subdirectories:
	1. "./data/assoc" 	which should contain the SDA input file under the name 'sda.in'
	2. "./data/data_grid"	which should contains the pqr files of the two solutes p1 and p2 (under the names 'p1.pqr', 'p2.pqr'),
				the files of the electrostatic grids ('p1.apbs-PE0.grd', 'p2.apbs-PE0.grd'), the effective charges 
				files ('p1.echa', 'p2.echa'), the SDA file for reaction criteria ('prot12.rxna') and the files
				for the electrostatic desolvation grids of the two solutes ('p1.ed.grd' and 'p2.ed.grd')
* You need to have Browndye already installed

------- USAGE -----------

First, add the bin directory of Browndye to your path. If you use a bash shell this can be done by typing:

PATH=$PATH:fullpath/browndye/bin

where fullpath is the full path name of the directory containing the Browndye distribution.
The script convert_sda_to_browndye.sh for the conversion of the SDA input files into Browndye input files accepts the following input:

1 "./data": 		the name of the folder where data are stored
2 ions:    		the ionic strength of the system (in Molar units)
3 temp:     		the temperature of the system (in Kelvin)
4 p1_name:  		the name of the protein (name used to define files in "./data/data_grid" folder (i.e if the files for the first solute are called p1.pqr, p1.echa,... the name of the protein should simply be p1. Otherwise if you saved the files with a different name you should use that prefix instead) 
5 p2_name:  		the name of the other protein or the ligand (same as before)
6 flag:     		a true or false flag to specify wheter the ligand is a protein
7 num:      		the number of required contacts to call a trajectory sucessful
8 dist      		the required distance for the contact (in Angstrom units)

Once those inputs are defined, the script for the conversion can be called:

./convert_sda_to_browndye.sh ./data ions temp p1_name p2_name flag num dist

The outputs of the conversion will be written in the new directory "./data/Browndye" where all the input files for a Browndye simulation can be found. To perform the single-trajectory simulation using the nam algorithm, you should type into the "./data/BrownDye" folder the command:

nam_simulation p1_p2_simulation.xml

The results of the simulation will be written in the results.xml file. At any point of the simulation, you can use the compute_rate_constant command to analyze the results and compute the reaction rate constant of the system.

compute_rate_constant < results.xml

This will output the rate constant results to standard output.


---------- TUTORIAL --------------

In the examples folder, you can find an example for this conversion script where the SDA input files for the diffusional association rate constant calculation for the Barnase-Barstar system are converted into Browndye input files. 
APBS and BrownDye2 are needed for this tutorial.
To generate the SDA input electrostatic grids, in the directory "examples/convert-bnbs-to-browndye" enter the command:

./generate_grids.sh

This script is simply used to recreate the SDA input grid files. In a realistic case, you will already have these grids so you don't need it.
Then to convert all SDA input files into BrownDye input files, in the "examples/convert-bnbs-to-browndye" folder run the command:

../../auxi/convert-to-browndye/convert_sda_to_browndye.sh ./data 0.1 298 barnase barstar true 2 6.5


Once the conversion is finished, a simulation with the nam algorithm can be run in the "data/BrownDye" folder with the command:

nam_simulation barnase_barstar_simulation.xml

To compute the reaction rate for the system,  in the "data/BrownDye" folder enter the command:

compute_rate_constant < results.xml

This will output the rate constant results to standard output.

---------- PYTHON SCRIPT DESCRIPTIONS -----------

The different parts of the ./convert_sda_to_browndye.sh script can also be used individually. For this purpose, here is a brief description of the python scripts used during the conversion:

* convertinputfiles.py : converts the sda.in input file for SDA into the input.xml input file for Browndye
* rxna2xml.py : converts the rxna file for the reaction criteria in SDA into the xml reaction criteria file for Browndye
* chargeconversion.py : converts the echa files for the effective charges of the solutes used in SDA into the xml effective charges file for Browndye


---------- REFERENCES -----------

Details on Browndye input files and tools can be found at the following webpage:

https://browndye.ucsd.edu/

--------------------------------


