<filename>data/ar20.5ab_solvated/amber/step3_charmm2amber.rest.py
"""
Generated by CHARMM-GUI (http://www.charmm-gui.org)

step5_charmm2amber_rest.py

This program is for generating AMBER restraints file.

Correspondance: <EMAIL> or <EMAIL>
Last update: February 27, 2015
"""

import sys

infile  = sys.argv[1]
outfile = []
outfile.append(open('amber/step4.0_minimization.rest', 'w'))
outfile.append(open('amber/step4.1_equilibration.rest', 'w'))

fc_dihe  = [1.0, 1.0]

for line in open(infile.lower(), 'r'):
	line = line.strip()
	if len(line) > 0:
		segments = line.split()
		atom1 = int(segments[0])
		atom2 = int(segments[1])
		atom3 = int(segments[2])
		atom4 = int(segments[3])
		phi0  = float(segments[4])
		dphi  = float(segments[5])
		for cnt in range(2):
			outfile[cnt].write("\n")
			outfile[cnt].write("&rst\n")
			outfile[cnt].write("    iat=%d, %d, %d, %d,\n" % (atom1, atom2, atom3, atom4))
			outfile[cnt].write("    r1=%.1f, r2=%.1f,\n" % (phi0-dphi-10.0, phi0-dphi))
			outfile[cnt].write("    r3=%.1f, r4=%.1f,\n" % (phi0+dphi, phi0+dphi+10.0))
			outfile[cnt].write("    rk2=%.1f,\n" % fc_dihe[cnt])
			outfile[cnt].write("    rk3=%.1f,\n" % fc_dihe[cnt])
			outfile[cnt].write("/\n")

