def get_rmsd(initparas): global idxs, mcresids2, atompairs #Modify the C4 terms in the prmtop file for i in range(0, len(idxs)): prmtop.parm_data['LENNARD_JONES_CCOEF'][idxs[i]] = initparas[i] #Overwrite the prmtop file prmtop.write_parm('OptC4.top') #Perform the OpenMM optimization #Use AmberParm function to transfer the topology and #coordinate file to the object OpenMM can use Ambermol = AmberParm('OptC4.top', options.cfile) # Create the OpenMM system print('Creating OpenMM System') if options.simupha == 'gas': system = Ambermol.createSystem(nonbondedMethod=app.NoCutoff) elif options.simupha == 'liquid': system = Ambermol.createSystem(nonbondedMethod=app.PME, nonbondedCutoff=8.0*u.angstroms, constraints=app.HBonds,) #Add restraints force = mm.CustomExternalForce("k*((x-x0)^2+(y-y0)^2+(z-z0)^2)") force.addGlobalParameter("k", 200.0) force.addPerParticleParameter("x0") force.addPerParticleParameter("y0") force.addPerParticleParameter("z0") #for i in range(0, len(Ambermol.atoms)): for i, atom_crd in enumerate(Ambermol.positions): #if (Ambermol.atoms[i].residue.number+1 not in mcresids2) and \ if (i+1 not in mcresids2) and \ (Ambermol.atoms[i].residue.name not in ['WAT', 'HOH']) and \ (Ambermol.atoms[i].name in ['CA', 'C', 'N']): force.addParticle(i, atom_crd.value_in_unit(u.nanometers)) system.addForce(force) # Create the integrator to do Langevin dynamics # Temperature of heat bath, Friction coefficient, Time step integrator = mm.LangevinIntegrator(300*u.kelvin, 1.0/u.picoseconds, 1.0*u.femtoseconds,) # Define the platform to use; CUDA, OpenCL, CPU, or Reference. Or do not # specify the platform to use the default (fastest) platform # Create the Simulation object if options.platf == 'ref': platform = mm.Platform.getPlatformByName('Reference') sim = app.Simulation(Ambermol.topology, system, integrator, platform) elif options.platf == 'cpu': platform = mm.Platform.getPlatformByName('CPU') sim = app.Simulation(Ambermol.topology, system, integrator, platform) elif options.platf == 'cuda': platform = mm.Platform.getPlatformByName('CUDA') prop = dict(CudaPrecision='mixed') sim = app.Simulation(Ambermol.topology, system, integrator, platform, prop) elif options.platf == 'opencl': platform = mm.Platform.getPlatformByName('OpenCL') prop = dict(CudaPrecision='mixed') sim = app.Simulation(Ambermol.topology, system, integrator, platform, prop) # Set the particle positions sim.context.setPositions(Ambermol.positions) # Output the rst file restrt = RestartReporter(options.rfile, 100, write_velocities=False) sim.reporters.append(restrt) # Minimize the energy print('Minimizing energy ' + str(options.maxsteps) + ' steps.') sim.minimizeEnergy(maxIterations=options.maxsteps) # Overwrite the final file state = sim.context.getState(getPositions=True, enforcePeriodicBox=True) restrt.report(sim, state) val_aft_min = [] crds_aft_min = read_rstf(options.rfile) for i in atompairs: if len(i) == 2: crd1 = crds_aft_min[i[0]-1] crd2 = crds_aft_min[i[1]-1] bond = calc_bond(crd1, crd2) val_aft_min.append(('bond', bond)) elif len(i) == 3: crd1 = crds_aft_min[i[0]-1] crd2 = crds_aft_min[i[1]-1] crd3 = crds_aft_min[i[2]-1] angle = calc_angle(crd1, crd2, crd3) val_aft_min.append(('angle', angle)) elif len(i) == 4: crd1 = crds_aft_min[i[0]-1] crd2 = crds_aft_min[i[1]-1] crd3 = crds_aft_min[i[2]-1] crd4 = crds_aft_min[i[3]-1] dih = calc_dih(crd1, crd2, crd3, crd4) val_aft_min.append(('dih', dih)) valdiffs = [] for i in range(0, len(atompairs)): if val_bf_min[i][0] == 'bond': valdiff = abs(val_aft_min[i][1] - val_bf_min[i][1]) * 1.0 / 100.0 elif val_bf_min[i][0] == 'angle': valdiff = abs(val_aft_min[i][1] - val_bf_min[i][1]) * 1.0 / 2.0 elif val_bf_min[i][0] == 'dih': valdiff = abs(val_aft_min[i][1] - val_bf_min[i][1]) if (360.0 - valdiff < valdiff): valdiff = 360.0 - valdiff valdiffs.append(valdiff) fnldiff = numpy.sum(valdiffs) print(fnldiff) return fnldiff
def get_ang_fc_with_sem(crds, fcmatrix, nat1, nat2, nat3, scalef, angavg): #get the angle value crd1 = crds[3 * nat1 - 3:3 * nat1] crd2 = crds[3 * nat2 - 3:3 * nat2] crd3 = crds[3 * nat3 - 3:3 * nat3] dis12 = calc_bond(crd1, crd2) #unit is bohr dis32 = calc_bond(crd3, crd2) #unit is bohr #get the unit vector vec12 = array(crd2) - array(crd1) #vec12 is vec2 - vec1 vec32 = array(crd2) - array(crd3) vec12 = array([i / dis12 for i in vec12]) vec32 = array([i / dis32 for i in vec32]) angval = calc_angle(crd1, crd2, crd3) #get the normalized vector vecUNp = cross(vec32, vec12) vecUN = array([i / norm(vecUNp) for i in vecUNp]) #vecUN is the vector #perpendicular to the plance of ABC vecPA = cross(vecUN, vec12) vecPC = cross(vec32, vecUN) afcmatrix12 = array([[float(0) for x in range(3)] for x in range(3)]) afcmatrix32 = array([[float(0) for x in range(3)] for x in range(3)]) #1. First way to chose the matrix---------------------------------- for i in range(0, 3): for j in range(0, 3): afcmatrix12[i][j] = -fcmatrix[3 * (nat1 - 1) + i][3 * (nat2 - 1) + j] for i in range(0, 3): for j in range(0, 3): afcmatrix32[i][j] = -fcmatrix[3 * (nat3 - 1) + i][3 * (nat2 - 1) + j] eigval12, eigvector12 = eig(afcmatrix12) eigval32, eigvector32 = eig(afcmatrix32) contri12 = 0.0 contri32 = 0.0 for i in range(0, 3): ev12 = eigvector12[:, i] ev32 = eigvector32[:, i] contri12 = contri12 + eigval12[i] * abs(dot(vecPA, ev12)) contri32 = contri32 + eigval32[i] * abs(dot(vecPC, ev32)) contri12 = 1.0 / (contri12 * dis12 * dis12) contri32 = 1.0 / (contri32 * dis32 * dis32) fcfinal1 = (1.0 / (contri12 + contri32)) * H_TO_KCAL_MOL * 0.5 if angavg == 1: #2. Second way to chose the matrix---------------------------------- for i in range(0, 3): for j in range(0, 3): afcmatrix12[i][j] = -fcmatrix[3 * (nat2 - 1) + i][3 * (nat1 - 1) + j] for i in range(0, 3): for j in range(0, 3): afcmatrix32[i][j] = -fcmatrix[3 * (nat3 - 1) + i][3 * (nat2 - 1) + j] eigval12, eigvector12 = eig(afcmatrix12) eigval32, eigvector32 = eig(afcmatrix32) contri12 = 0.0 contri32 = 0.0 for i in range(0, 3): ev12 = eigvector12[:, i] ev32 = eigvector32[:, i] contri12 = contri12 + eigval12[i] * abs(dot(vecPA, ev12)) contri32 = contri32 + eigval32[i] * abs(dot(vecPC, ev32)) contri12 = 1.0 / (contri12 * dis12 * dis12) contri32 = 1.0 / (contri32 * dis32 * dis32) fcfinal2 = (1.0 / (contri12 + contri32)) * H_TO_KCAL_MOL * 0.5 #Hatree to kcal/mol #Times 0.5 factor since AMBER use k(r-r0)^2 but not 1/2*k*(r-r0)^2 #3. Third way to chose the matrix---------------------------------- for i in range(0, 3): for j in range(0, 3): afcmatrix12[i][j] = -fcmatrix[3 * (nat1 - 1) + i][3 * (nat2 - 1) + j] for i in range(0, 3): for j in range(0, 3): afcmatrix32[i][j] = -fcmatrix[3 * (nat2 - 1) + i][3 * (nat3 - 1) + j] eigval12, eigvector12 = eig(afcmatrix12) eigval32, eigvector32 = eig(afcmatrix32) contri12 = 0.0 contri32 = 0.0 for i in range(0, 3): ev12 = eigvector12[:, i] ev32 = eigvector32[:, i] contri12 = contri12 + eigval12[i] * abs(dot(vecPA, ev12)) contri32 = contri32 + eigval32[i] * abs(dot(vecPC, ev32)) contri12 = 1.0 / (contri12 * dis12 * dis12) contri32 = 1.0 / (contri32 * dis32 * dis32) fcfinal3 = (1.0 / (contri12 + contri32)) * H_TO_KCAL_MOL * 0.5 #4. Fourth way to chose the matrix---------------------------------- for i in range(0, 3): for j in range(0, 3): afcmatrix12[i][j] = -fcmatrix[3 * (nat2 - 1) + i][3 * (nat1 - 1) + j] for i in range(0, 3): for j in range(0, 3): afcmatrix32[i][j] = -fcmatrix[3 * (nat2 - 1) + i][3 * (nat3 - 1) + j] eigval12, eigvector12 = eig(afcmatrix12) eigval32, eigvector32 = eig(afcmatrix32) contri12 = 0.0 contri32 = 0.0 for i in range(0, 3): ev12 = eigvector12[:, i] ev32 = eigvector32[:, i] contri12 = contri12 + eigval12[i] * abs(dot(vecPA, ev12)) contri32 = contri32 + eigval32[i] * abs(dot(vecPC, ev32)) contri12 = 1.0 / (contri12 * dis12 * dis12) contri32 = 1.0 / (contri32 * dis32 * dis32) fcfinal4 = (1.0 / (contri12 + contri32)) * H_TO_KCAL_MOL * 0.5 fcfinal = average([fcfinal1, fcfinal2, fcfinal3, fcfinal4]) stdv = std([fcfinal1, fcfinal2, fcfinal3, fcfinal4]) fcfinal = fcfinal * scalef * scalef stdv = stdv * scalef * scalef return angval, fcfinal, stdv elif angavg == 0: fcfinal = fcfinal1 * scalef * scalef return angval, fcfinal
mcids.append(j) #Calculate the distances between metal ion and ligating atoms val_bf_min = [] crds_bf_min = read_rstf(options.cfile) for i in atompairs: if len(i) == 2: crd1 = crds_bf_min[i[0]-1] crd2 = crds_bf_min[i[1]-1] bond = calc_bond(crd1, crd2) val_bf_min.append(('bond', bond)) elif len(i) == 3: crd1 = crds_bf_min[i[0]-1] crd2 = crds_bf_min[i[1]-1] crd3 = crds_bf_min[i[2]-1] angle = calc_angle(crd1, crd2, crd3) val_bf_min.append(('angle', angle)) elif len(i) == 4: crd1 = crds_bf_min[i[0]-1] crd2 = crds_bf_min[i[1]-1] crd3 = crds_bf_min[i[2]-1] crd4 = crds_bf_min[i[3]-1] dih = calc_dih(crd1, crd2, crd3, crd4) val_bf_min.append(('dih', dih)) print("Bond, angle and dihedral before minimization...") print(val_bf_min) #-----------------------------------------------------------------------------# #Get the Amber mask of the metal center complex and print it into ptraj.in file #-----------------------------------------------------------------------------#
def gene_by_empirical_way(smpdbf, ionids, stfpf, pref, finf): print("******************************************************************") print("* *") print("*===========Using the empirical way to solve the problem=========*") print("* *") print("******************************************************************") #Read from small pdb mol, atids, resids = get_atominfo_fpdb(smpdbf) blist = get_mc_blist(mol, atids, ionids, stfpf) alist = get_alist(mol, blist) attypdict = get_attypdict(stfpf, atids) missbondtyps, missangtyps = get_misstyps(pref) finalparmdict = {} #for bond print("=======================Generate the bond parameters===============") for misbond in missbondtyps: bondlen = [] bfconst = [] for bond in blist: at1 = bond[0] at2 = bond[1] bondtyp = (attypdict[at1], attypdict[at2]) if bondtyp == misbond or bondtyp[::-1] == misbond: crd1 = mol.atoms[at1].crd crd2 = mol.atoms[at2].crd dis = calc_bond(crd1, crd2) dis = round(dis, 4) bondlen.append(dis) #get the atom number elmt1 = mol.atoms[at1].element elmt2 = mol.atoms[at2].element elmts = [elmt1, elmt2] elmts = sorted(elmts) fcfinal = fcfit_ep_bond(dis, elmts) bfconst.append(fcfinal) #Get average bond parameters misbondat12 = misbond[0] + '-' + misbond[1] bond_para = avg_bond_para(misbondat12, bondlen, bfconst) #get the force constant finalparmdict[misbondat12] = bond_para #for angle print("=======================Generate the angle parameters==============") for misang in missangtyps: angvals = [] afconst = [] for ang in alist: at1 = ang[0] at2 = ang[1] at3 = ang[2] angtyp = (attypdict[at1], attypdict[at2], attypdict[at3]) if angtyp == misang or angtyp[::-1] == misang: crd1 = mol.atoms[at1].crd crd2 = mol.atoms[at2].crd crd3 = mol.atoms[at3].crd angval = calc_angle(crd1, crd2, crd3) angvals.append(angval) elmt1 = mol.atoms[at1].element elmt2 = mol.atoms[at2].element elmt3 = mol.atoms[at3].element elmts = [elmt1, elmt2, elmt3] fcfinal = fcfit_ep_angle(elmts) afconst.append(fcfinal) #Get average angle parameters misangat123 = misang[0] + '-' + misang[1] + '-' + misang[2] ang_para = avg_angle_para(misangat123, angvals, afconst) finalparmdict[misangat123] = ang_para #Print out the final frcmod file print_frcmod_file(pref, finf, finalparmdict, 'empirical')
def get_ang_fc_with_sem(crds, fcmatrix, nat1, nat2, nat3, scalef, angavg): #get the angle value crd1 = crds[3*nat1-3:3*nat1] crd2 = crds[3*nat2-3:3*nat2] crd3 = crds[3*nat3-3:3*nat3] dis12 = calc_bond(crd1, crd2) #unit is bohr dis32 = calc_bond(crd3, crd2) #unit is bohr #get the unit vector vec12 = array(crd2) - array(crd1) #vec12 is vec2 - vec1 vec32 = array(crd2) - array(crd3) vec12 = array([i/dis12 for i in vec12]) vec32 = array([i/dis32 for i in vec32]) angval = calc_angle(crd1, crd2, crd3) #get the normalized vector vecUNp = cross(vec32, vec12) vecUN = array([i/norm(vecUNp) for i in vecUNp]) #vecUN is the vector #perpendicular to the plance of ABC vecPA = cross(vecUN, vec12) vecPC = cross(vec32, vecUN) afcmatrix12 = array([[float(0) for x in range(3)] for x in range(3)]) afcmatrix32 = array([[float(0) for x in range(3)] for x in range(3)]) #1. First way to chose the matrix---------------------------------- for i in range(0, 3): for j in range(0, 3): afcmatrix12[i][j] = -fcmatrix[3*(nat1-1)+i][3*(nat2-1)+j] for i in range(0, 3): for j in range(0, 3): afcmatrix32[i][j] = -fcmatrix[3*(nat3-1)+i][3*(nat2-1)+j] eigval12, eigvector12 = eig(afcmatrix12) eigval32, eigvector32 = eig(afcmatrix32) contri12 = 0.0 contri32 = 0.0 for i in range(0, 3): ev12 = eigvector12[:,i] ev32 = eigvector32[:,i] contri12 = contri12 + eigval12[i] * abs(dot(vecPA, ev12)) contri32 = contri32 + eigval32[i] * abs(dot(vecPC, ev32)) contri12 = 1.0 / (contri12 * dis12 * dis12) contri32 = 1.0 / (contri32 * dis32 * dis32) fcfinal1 = (1.0 / (contri12 + contri32)) * H_TO_KCAL_MOL * 0.5 if angavg == 1: #2. Second way to chose the matrix---------------------------------- for i in range(0, 3): for j in range(0, 3): afcmatrix12[i][j] = -fcmatrix[3*(nat2-1)+i][3*(nat1-1)+j] for i in range(0, 3): for j in range(0, 3): afcmatrix32[i][j] = -fcmatrix[3*(nat3-1)+i][3*(nat2-1)+j] eigval12, eigvector12 = eig(afcmatrix12) eigval32, eigvector32 = eig(afcmatrix32) contri12 = 0.0 contri32 = 0.0 for i in range(0, 3): ev12 = eigvector12[:,i] ev32 = eigvector32[:,i] contri12 = contri12 + eigval12[i] * abs(dot(vecPA, ev12)) contri32 = contri32 + eigval32[i] * abs(dot(vecPC, ev32)) contri12 = 1.0 / (contri12 * dis12 * dis12) contri32 = 1.0 / (contri32 * dis32 * dis32) fcfinal2 = (1.0 / (contri12 + contri32)) * H_TO_KCAL_MOL * 0.5 #Hatree to kcal/mol #Times 0.5 factor since AMBER use k(r-r0)^2 but not 1/2*k*(r-r0)^2 #3. Third way to chose the matrix---------------------------------- for i in range(0, 3): for j in range(0, 3): afcmatrix12[i][j] = -fcmatrix[3*(nat1-1)+i][3*(nat2-1)+j] for i in range(0, 3): for j in range(0, 3): afcmatrix32[i][j] = -fcmatrix[3*(nat2-1)+i][3*(nat3-1)+j] eigval12, eigvector12 = eig(afcmatrix12) eigval32, eigvector32 = eig(afcmatrix32) contri12 = 0.0 contri32 = 0.0 for i in range(0, 3): ev12 = eigvector12[:,i] ev32 = eigvector32[:,i] contri12 = contri12 + eigval12[i] * abs(dot(vecPA, ev12)) contri32 = contri32 + eigval32[i] * abs(dot(vecPC, ev32)) contri12 = 1.0 / (contri12 * dis12 * dis12) contri32 = 1.0 / (contri32 * dis32 * dis32) fcfinal3 = (1.0 / (contri12 + contri32)) * H_TO_KCAL_MOL * 0.5 #4. Fourth way to chose the matrix---------------------------------- for i in range(0, 3): for j in range(0, 3): afcmatrix12[i][j] = -fcmatrix[3*(nat2-1)+i][3*(nat1-1)+j] for i in range(0, 3): for j in range(0, 3): afcmatrix32[i][j] = -fcmatrix[3*(nat2-1)+i][3*(nat3-1)+j] eigval12, eigvector12 = eig(afcmatrix12) eigval32, eigvector32 = eig(afcmatrix32) contri12 = 0.0 contri32 = 0.0 for i in range(0, 3): ev12 = eigvector12[:,i] ev32 = eigvector32[:,i] contri12 = contri12 + eigval12[i] * abs(dot(vecPA, ev12)) contri32 = contri32 + eigval32[i] * abs(dot(vecPC, ev32)) contri12 = 1.0 / (contri12 * dis12 * dis12) contri32 = 1.0 / (contri32 * dis32 * dis32) fcfinal4 = (1.0 / (contri12 + contri32)) * H_TO_KCAL_MOL * 0.5 fcfinal = average([fcfinal1, fcfinal2, fcfinal3, fcfinal4]) stdv = std([fcfinal1, fcfinal2, fcfinal3, fcfinal4]) fcfinal = fcfinal * scalef * scalef stdv = stdv * scalef * scalef return angval, fcfinal, stdv elif angavg == 0: fcfinal = fcfinal1 * scalef * scalef return angval, fcfinal
def get_rmsd(initparas): global idxs, mcresids2, atompairs #Modify the C4 terms in the prmtop file for i in range(0, len(idxs)): prmtop.parm_data['LENNARD_JONES_CCOEF'][idxs[i]] = initparas[i] #Overwrite the prmtop file prmtop.write_parm('OptC4.top') #Perform the OpenMM optimization #Use AmberParm function to transfer the topology and #coordinate file to the object OpenMM can use Ambermol = AmberParm('OptC4.top', options.cfile) # Create the OpenMM system print('Creating OpenMM System') if options.simupha == 'gas': system = Ambermol.createSystem(nonbondedMethod=app.NoCutoff) elif options.simupha == 'liquid': system = Ambermol.createSystem( nonbondedMethod=app.PME, nonbondedCutoff=8.0 * u.angstroms, constraints=app.HBonds, ) #Add restraints force = mm.CustomExternalForce("k*((x-x0)^2+(y-y0)^2+(z-z0)^2)") force.addGlobalParameter("k", 200.0) force.addPerParticleParameter("x0") force.addPerParticleParameter("y0") force.addPerParticleParameter("z0") #for i in range(0, len(Ambermol.atoms)): for i, atom_crd in enumerate(Ambermol.positions): #if (Ambermol.atoms[i].residue.number+1 not in mcresids2) and \ if (i+1 not in mcresids2) and \ (Ambermol.atoms[i].residue.name not in ['WAT', 'HOH']) and \ (Ambermol.atoms[i].name in ['CA', 'C', 'N']): force.addParticle(i, atom_crd.value_in_unit(u.nanometers)) system.addForce(force) # Create the integrator to do Langevin dynamics # Temperature of heat bath, Friction coefficient, Time step integrator = mm.LangevinIntegrator( 300 * u.kelvin, 1.0 / u.picoseconds, 1.0 * u.femtoseconds, ) # Define the platform to use; CUDA, OpenCL, CPU, or Reference. Or do not # specify the platform to use the default (fastest) platform # Create the Simulation object if options.platf == 'ref': platform = mm.Platform.getPlatformByName('Reference') sim = app.Simulation(Ambermol.topology, system, integrator, platform) elif options.platf == 'cpu': platform = mm.Platform.getPlatformByName('CPU') sim = app.Simulation(Ambermol.topology, system, integrator, platform) elif options.platf == 'cuda': platform = mm.Platform.getPlatformByName('CUDA') prop = dict(CudaPrecision=options.presn) sim = app.Simulation(Ambermol.topology, system, integrator, platform, prop) elif options.platf == 'opencl': platform = mm.Platform.getPlatformByName('OpenCL') prop = dict(OpenCLPrecision=options.presn) sim = app.Simulation(Ambermol.topology, system, integrator, platform, prop) # Set the particle positions sim.context.setPositions(Ambermol.positions) # Output the rst file restrt = RestartReporter(options.rfile, 100, write_velocities=False) sim.reporters.append(restrt) # Minimize the energy print('Minimizing energy ' + str(options.maxsteps) + ' steps.') sim.minimizeEnergy(maxIterations=options.maxsteps) # Overwrite the final file state = sim.context.getState(getPositions=True, enforcePeriodicBox=True) restrt.report(sim, state) val_aft_min = [] crds_aft_min = read_rstf(options.rfile) for i in atompairs: if len(i) == 2: crd1 = crds_aft_min[i[0] - 1] crd2 = crds_aft_min[i[1] - 1] bond = calc_bond(crd1, crd2) val_aft_min.append(('bond', bond)) elif len(i) == 3: crd1 = crds_aft_min[i[0] - 1] crd2 = crds_aft_min[i[1] - 1] crd3 = crds_aft_min[i[2] - 1] angle = calc_angle(crd1, crd2, crd3) val_aft_min.append(('angle', angle)) elif len(i) == 4: crd1 = crds_aft_min[i[0] - 1] crd2 = crds_aft_min[i[1] - 1] crd3 = crds_aft_min[i[2] - 1] crd4 = crds_aft_min[i[3] - 1] dih = calc_dih(crd1, crd2, crd3, crd4) val_aft_min.append(('dih', dih)) valdiffs = [] for i in range(0, len(atompairs)): if val_bf_min[i][0] == 'bond': valdiff = abs(val_aft_min[i][1] - val_bf_min[i][1]) * 1.0 / 100.0 elif val_bf_min[i][0] == 'angle': valdiff = abs(val_aft_min[i][1] - val_bf_min[i][1]) * 1.0 / 2.0 elif val_bf_min[i][0] == 'dih': valdiff = abs(val_aft_min[i][1] - val_bf_min[i][1]) if (360.0 - valdiff < valdiff): valdiff = 360.0 - valdiff valdiffs.append(valdiff) fnldiff = numpy.sum(valdiffs) print(fnldiff) return fnldiff
mcids.append(j) #Calculate the distances between metal ion and ligating atoms val_bf_min = [] crds_bf_min = read_rstf(options.cfile) for i in atompairs: if len(i) == 2: crd1 = crds_bf_min[i[0] - 1] crd2 = crds_bf_min[i[1] - 1] bond = calc_bond(crd1, crd2) val_bf_min.append(('bond', bond)) elif len(i) == 3: crd1 = crds_bf_min[i[0] - 1] crd2 = crds_bf_min[i[1] - 1] crd3 = crds_bf_min[i[2] - 1] angle = calc_angle(crd1, crd2, crd3) val_bf_min.append(('angle', angle)) elif len(i) == 4: crd1 = crds_bf_min[i[0] - 1] crd2 = crds_bf_min[i[1] - 1] crd3 = crds_bf_min[i[2] - 1] crd4 = crds_bf_min[i[3] - 1] dih = calc_dih(crd1, crd2, crd3, crd4) val_bf_min.append(('dih', dih)) #print("Bond, angle and dihedral before minimization...") #print(val_bf_min) #-----------------------------------------------------------------------------# #Get the Amber mask of the metal center complex and print it into ptraj.in file #-----------------------------------------------------------------------------#