# Setup for the type of data, the structural model, dataset and initial search # parameters pre_in = ['pyParaFit.py', 'pre', '../tests/STRUCTURES/2ZTAa_H_only.pdb', '../tests/DATASETS/PRE/PREdata_intra_contribution.pre', '0', '0', '0', '0'] #Build a parser object and parse pre_1 = PREParser(pre_in) pre_1.doParse() #Lets calculate the PRE effect (by building a calcer object)experienced given #these initial search params pre_1_calcer = CalcPara() pre_1_calcer.PRE(pre_1) #Calcing simply populates the data structure with calculated values. We really #need to explore (analyze our dataset)) analysis = ExplorePara() analysis.paraSummary(pre_1) #analysis.paraSummaryPlot(pre_1) #As we can see our initial search params are poor. Now lets perform a non-linear #fit to find more "optimum values"" pre_1_fitter = FitPara() # The additional argument '1' in this case specifies that we want to use a # single model and optimize c res = pre_1_fitter.PRE(pre_1, 1) print "Determined x,y,z and c", res[0], res[1], res[2], res[3] # Now lets update the metal and c value to the optimized values opt_metal = zeros(3) opt_metal[0], opt_metal[1], opt_metal[2] = res[0], res[1], res[2] opt_c = zeros(1) opt_c[0] = res[3] pre_1.setMetalLoc(opt_metal)
# Now lets update the metal and c value to the optimized values opt_metal = zeros(3) opt_metal[0], opt_metal[1], opt_metal[2] = res[0], res[1], res[2] opt_c = zeros(1) opt_c[0] = res[3] pre_1_m1.setMetalLoc(opt_metal) pre_1_m1.setConstant(opt_c) pre_1_m2.setMetalLoc(opt_metal) pre_1_m2.setConstant(opt_c) # Now re-calculate pre_calcer = CalcPara() pre_calcer.PRE(pre_1_m1) pre_calcer.PRE(pre_1_m2) # Do some analysis print "Analysis of PRE agreement for fit to dimer with c optimized" analysis = ExplorePara() analysis.paraSummaryMulti(pre_1_m1, pre_1_m2) # Now, lets look at an optimization with fixed c init_metal = zeros(3) fixed_c = zeros(1) init_metal[0], init_metal[1], init_metal[2] = -7.000, -26.000, 3.000 fixed_c[0] = 680000000 pre_1_m1.setMetalLoc(init_metal) pre_1_m1.setConstant(fixed_c) pre_1_m2.setMetalLoc(init_metal) pre_1_m2.setConstant(fixed_c) res = pre_fitter.PRE(pre_1_m1, 2, pre_1_m2) print "Optimization with c fixed to", fixed_c print "Determined x,y,z and c", res[0], res[1], res[2] opt_metal = zeros(3)
#print res[5], res[6], res[7] #print "A,B,G", FixAngle(res[5]), FixAngle(res[6]), FixAngle(res[7]) ##------------ pre_in = ['pyParaFit.py', 'pre', 'tests/STRUCTURES/2ZTAa_H_only.pdb', 'tests/DATASETS/PRE/PREdata_intra_contribution.pre', '0', '0', '0', '0'] pre_1_m1 = PREParser(pre_in) pre_1_m1.doParse() pre_1_m2 = PREParser(pre_in) pre_1_m2.setModel(1) pre_1_m2.doParse() pre_1_calcer = CalcPara() pre_1_calcer.PRE(pre_1_m1) analysis = ExplorePara() analysis.paraSummary(pre_1_m1) #analysis.plotParaDevs(parsed) pre_fit_calcer = FitPara() #res = pre_fit_calcer.PRE(pre_1_m1, 3, pre_1_m2) res = pre_fit_calcer.PRE(pre_1_m1, 1) print "x,y,z,c", res[0], res[1], res[2], res[3] opt_metal = zeros(3) opt_metal[0], opt_metal[1], opt_metal[2] = res[0], res[1], res[2] opt_c = zeros(1) opt_c[0] = res[3] pre_1_m1.setMetalLoc(opt_metal) pre_1_m1.setConstant(opt_c) pre_1_calcer.PRE(pre_1_m1) analysis.paraSummary(pre_1_m1)
# Test the CalcPara class ############################################################################## #TODO: Generate comparative test data using Numbat and PREfit #TODO: Test all three methods import sys sys.path.append("/home/mscook/Desktop/PhD/Projects/pyParaTools") from ParaParser import * from CalcPara import * from ExplorePara import * import os analysis = ExplorePara() fail = 0 print 80*'-' print "Testing CalcPara.py" print 80*'-' print "PCS" pcs_in = ['PROTOCOL_NAME', 'pcs', 'STRUCTURES/epsilon.pdb', 'DATASETS/PCS/EPSILON/PCS_epsilon_CNH.npc', '-5.866', '-0.253', '3.113', '39.994', '4.526', '111.122', '105.981', '110.256'] pcs = PCSParser(pcs_in) pcs.doParse() pcs_calcer = CalcPara() pcs_calcer.PCS(pcs, 'ZYZ') analysis.buildNumbatTBL(pcs, 'test_pcs.npc') print "Comparing with known..."