def runExperiment(): import Go PdbName = sys.argv[2] FFType = sys.argv[3] OutDir = os.path.abspath(sys.argv[4]) NReplica = int(sys.argv[5]) if len(sys.argv) > 5 else 8 # parse paths etc OutDir = os.path.join(OutDir, PdbName) if not os.path.isdir(OutDir): os.system('mkdir -p %s' % OutDir) NativePdb = utils.parseNative(PdbName, MasterDir = os.path.expanduser('~/Go/native_struct/mapped')) try: AATopClustPdb = utils.parseNative(PdbName, MasterDir = os.path.expanduser('~/Go/native_struct/ff96_igb5_glghs_topclust_mapped')) except IOError: print 'Utils Error: Requested Top clust pdb does not exist' AATopClustPdb = None Prefix = 'prot_' + PdbName # parse forcefield parameters GoFF_File, FFMetadata = utils.parseGoFF(FFType) # backbone BBType = FFMetadata['BBType'] BBFF_File = utils.parseBBFF(BBType)[0] MinBondOrd = FFMetadata['MinBondOrd'] NKnot = FFMetadata['NKnot'] Cut = FFMetadata['Cut'] # sidechain NCOSType = FFMetadata['NCOSType'] GoType = FFMetadata['GoType'] NonNativeType = FFMetadata['NonNativeType'] # get LJ / spline params # Note: NonNative params are recorded from the given # forcefield file but not used currently, as these vary # depending on the sequence if not os.path.isfile(GoFF_File): print 'I/O Error: forcefield file does not exist' exit() # single LJ/Sigma for all native interactions if GoType == 1: NativeSigma = FFMetadata['NativeSigma'] NativeEpsilon = FFMetadata['NativeEpsilon'] NativeCut = FFMetadata['NativeCut'] # LJ matrix for native interactions if GoType == 2: print 'Error: Not implemented yet' exit() # splined potential for all native interactions if GoType == 3: NativeKnots = FFMetadata['NativeKnots'] NativeNKnot = len(NativeKnots) NativeCut = FFMetadata['NativeCut'] if NonNativeType == 0: print 'Error: Will generate too much repulsion' exit() if NonNativeType == 1: NonNativeSigma = FFMetadata['NonNativeSigma'] NonNativeEpsilon = FFMetadata['NonNativeEpsilon'] NonNativeCut = FFMetadata['NonNativeCut'] if NonNativeType == 2: NonNativeKnots = FFMetadata['NonNativeKnots'] NonNativeNKnot = len(NonNativeKnots) NonNativeCut = FFMetadata['NonNativeCut'] # temp schedule TLow = 270. THigh = 500. Temps = np.logspace(np.log10(TLow), np.log10(THigh), NReplica) TempInd = np.argmin(abs(Temps - RoomTemp)) TempSet = Temps[TempInd] # time-step Delta_T = FFMetadata['TimeStep'] # femto-seconds # MD iterations NStepsMin = int(10000 / Delta_T) # 10 ps NStepsEquil = int(50000000 / Delta_T) # 50 ns NStepsProd = int(20000000 / Delta_T) # 20 ns NStepsSwap = int(1000 / Delta_T) # 1 ps StepFreq = int(NStepsProd / 10000) # need 10000 frames, 2 ps # REMD setup template mdstr_setup = ''' #!/usr/bin/env python import os, sys, numpy as np, time import Go, utils # check if only analysis needs to be done FullPrefix = os.path.join(os.getcwd(), "%(PREFIX)s") isDone = utils.checkGoREMD(FullPrefix, [%(TEMPSET)3.2f]) if isDone: exit() #### REMD #### # basic settings Go.Prefix = "%(PREFIX)s" Go.InPdb ="%(NATIVEPDB)s" Go.Temps = np.logspace(np.log10(%(TLOW)3.2f), np.log10(%(THIGH)3.2f), %(NREPLICA)d) Go.TempSet = %(TEMPSET)3.2f # backbone settings Go.MinBondOrd = %(MINBONDORD)d Go.NKnot = %(NKNOT)d Go.SPCut = %(CUT)g Go.BB_forcefield_file = "%(BBFF_FILE)s" Go.NCOSType = %(NCOSTYPE)d # md iterations Go.NStepsMin = %(NSTEPSMIN)d Go.NStepsEquil = %(NSTEPSEQUIL)d Go.NStepsProd = %(NSTEPSPROD)d Go.NStepsSwap = %(NSTEPSSWAP)d Go.StepFreq = %(STEPFREQ)d ''' # side-chain interactions template mdstr_sidechain = { 'native_LJ': ''' # native contacts Go.GoType = 1 Go.NativeSigma = None if %(AUTOSIGMA)d else %(NATIVESIGMA)g Go.NativeEpsilon = %(NATIVEEPSILON)g Go.NativeCut = %(NATIVECUT)g ''', 'native_Spline': ''' # native contacts Go.GoType = 3 Go.NativeNKnot = %(NATIVENKNOT)d Go.NativeKnots = %(NATIVEKNOTS)s Go.NativeCut = %(NATIVECUT)g ''', 'nonnative_LJ': ''' # non-native contacts Go.NonNativeType = 1 Go.NonNativeSigma = %(NONNATIVESIGMA)g Go.NonNativeEpsilon = %(NONNATIVEEPSILON)g Go.NonNativeCut = %(NONNATIVECUT)g ''', 'nonnative_Spline': ''' # non-native contacts Go.NonNativeType = 2 Go.NonNativeNKnot = %(NONNATIVENKNOT)d Go.NonNativeKnots = %(NONNATIVEKNOTS)s Go.NonNativeCut = %(NONNATIVECUT)g '''} # run template mdstr_run = ''' # compile Sys object Sys = Go.makeGoSys() for m in Sys.Int.Methods: m.TimeStep *= %(TIMESTEP)g # run REMD t1 = time.time() TrajFile, LogFile = Go.runREMD(Sys) t2 = time.time() # reorder by temperature only at room temp Go.reorderTraj(ReorderTemps = [%(TEMPSET)3.2f] ) t3 = time.time() # print stats print "REMD time: ", (t2-t1), " seconds" print "Reordering time: ", (t3-t2), " seconds" ''' # job script template jobstr = ''' #!/bin/bash # #$ -V #$ -cwd #$ -j y #$ -S /bin/bash #$ -N %(JOBNAME)s export PYTHONPATH=$PYTHONPATH:~/Go date python remd.py mkdir -p ./NativeAnalysis mkdir -p ./AATopClustAnalysis python ~/Go/analyze_go.py %(NATIVEPDB)s %(PREFIX)s ./ ./NativeAnalysis python ~/Go/analyze_go.py %(AATOPCLUSTPDB)s %(PREFIX)s ./ ./AATopClustAnalysis date ''' # dict for filling md script template d_setup_run = { 'PREFIX' : Prefix, 'NATIVEPDB' : NativePdb, 'TLOW' : TLow, 'THIGH' : THigh, 'NREPLICA' : NReplica, 'TEMPSET' : TempSet, 'TEMPIND' : TempInd, 'BBFF_FILE' : BBFF_File, 'MINBONDORD' : MinBondOrd, 'NKNOT' : NKnot, 'CUT' : Cut, 'NCOSTYPE' : NCOSType, 'TIMESTEP' : Delta_T, 'NSTEPSMIN' : NStepsMin, 'NSTEPSEQUIL' : NStepsEquil, 'NSTEPSPROD' : NStepsProd, 'NSTEPSSWAP' : NStepsSwap, 'STEPFREQ' : StepFreq } if GoType == 1: d_native = { 'AUTOSIGMA' : int(AutoSigma), 'NATIVESIGMA' : NativeSigma, 'NATIVEEPSILON' : NativeEpsilon, 'NATIVECUT' : NativeCut, } if GoType == 2: print 'Error: Not yet implemented' exit() if GoType == 3: d_native = { 'NATIVENKNOT' : NativeNKnot, 'NATIVEKNOTS' : str(NativeKnots), 'NATIVECUT' : NativeCut } if NonNativeType == 0: # verified this with simulations of protein-G print 'Error: Will generate too much non-native repulsion' exit() if NonNativeType == 1: d_nonnative = { 'NONNATIVESIGMA' : NativeSigma, 'NONNATIVEEPSILON' : NativeEpsilon, 'NONNATIVECUT' : NonNativeCut, } if NonNativeType == 2: d_nonnative = { 'NONNATIVENKNOT' : NonNativeNKnot, 'NONNATIVEKNOTS' : NonNativeKnots, 'NONNATIVECUT' : NonNativeCut } # extract complete dic d1 = {} for x in [d_setup_run, d_native, d_nonnative]: for k, v in x.iteritems(): d1[k] = v # dict for filling job script template d2 = {'JOBNAME': Prefix, 'NATIVEPDB': NativePdb, 'AATOPCLUSTPDB': AATopClustPdb, 'PREFIX': Prefix} # extract complete template s = mdstr_setup if GoType == 1: s += mdstr_sidechain['native_LJ'] if GoType == 2: print 'Error: Not implemented yet' exit() if GoType == 3: s += mdstr_sidechain['native_Spline'] if NonNativeType == 0: print 'Error: Will generate too much non-native repulsion' exit() if NonNativeType == 1: s += mdstr_sidechain['nonnative_LJ'] if NonNativeType == 2: s += mdstr_sidechain['nonnative_Spline'] s += mdstr_run # fill template and submit job print 'Using backbone type:' , BBType print 'Using GoType: ', GoType print 'Using Non-Native Type: ', NonNativeType mdscript = os.path.join(OutDir, 'remd.py') jobscript = os.path.join(OutDir, 'remdjob.sh') if not os.path.isfile(mdscript): file(mdscript, 'w').write(s % d1) file(jobscript, 'w').write(jobstr % d2) os.chdir(OutDir) os.system('qsub remdjob.sh') os.chdir(CURRDIR) return
def runExperiment(): import Go PdbName = sys.argv[2] BBType = sys.argv[3] OutDir = os.path.abspath(sys.argv[4]) NReplica = int(sys.argv[5]) if len(sys.argv) > 5 else 8 # parse paths etc OutDir = os.path.join(OutDir, PdbName) if not os.path.isdir(OutDir): os.system('mkdir -p %s' % OutDir) NativePdb = utils.parseNative(PdbName, MasterDir = os.path.expanduser('~/Go/native_struct/mapped')) try: AATopClustPdb = utils.parseNative(PdbName, MasterDir = os.path.expanduser('~/Go/native_struct/ff96_igb5_glghs_topclust_mapped')) except IOError: print 'Utils Error: Requested Top clust pdb does not exist' AATopClustPdb = None FF_File, FFMetadata = utils.parseBBFF(BBType) Prefix = 'prot_' + PdbName # parse forcefield parameters MinBondOrd = FFMetadata['MinBondOrd'] NKnot = FFMetadata['NKnot'] Cut = FFMetadata['Cut'] # Go parameters HarmonicFluct = np.sqrt(2.) # used to tune the force constant in s-s bias # temp schedule TLow = 270. THigh = 500. Temps = np.logspace(np.log10(TLow), np.log10(THigh), NReplica) TempInd = np.argmin(abs(Temps - RoomTemp)) TempSet = Temps[TempInd] # time-step Delta_T = FFMetadata['TimeStep'] # femto-seconds # MD iterations NStepsMin = int(10000 / Delta_T) # 10 ps NStepsEquil = int(50000000 / Delta_T) # 50 ns NStepsProd = int(20000000 / Delta_T) # 20 ns NStepsSwap = int(1000 / Delta_T) # 1 ps StepFreq = int(NStepsProd / 10000) # need 10000 frames, 2 ps # REMD script template mdstr = ''' #!/usr/bin/env python import os, sys, numpy as np, time import Go, utils # check if only analysis needs to be done FullPrefix = os.path.join(os.getcwd(), "%(PREFIX)s") isDone = utils.checkGoREMD(FullPrefix, [%(TEMPSET)3.2f]) if isDone: exit() #### REMD #### # basic settings Go.Prefix = "%(PREFIX)s" Go.InPdb ="%(NATIVEPDB)s" Go.Temps = np.logspace(np.log10(%(TLOW)3.2f), np.log10(%(THIGH)3.2f), %(NREPLICA)d) Go.TempSet = %(TEMPSET)3.2f # forcefield settings Go.MinBondOrd = %(MINBONDORD)d Go.NKnot = %(NKNOT)d Go.SPCut = %(CUT)g Go.BB_forcefield_file = "%(FF_FILE)s" # native harmonic restraints Go.GoType = 4 Go.HarmonicFluct = %(HARMONICFLUCT)g # no non-native interactions Go.NonNativeType = -1 # md iterations Go.NStepsMin = %(NSTEPSMIN)d Go.NStepsEquil = %(NSTEPSEQUIL)d Go.NStepsProd = %(NSTEPSPROD)d Go.NStepsSwap = %(NSTEPSSWAP)d Go.StepFreq = %(STEPFREQ)d # compile Sys object Sys = Go.makeGoSys() for m in Sys.Int.Methods: m.TimeStep *= %(TIMESTEP)g # run REMD t1 = time.time() TrajFile, LogFile = Go.runREMD(Sys) t2 = time.time() # reorder by temperature only at room temp Go.reorderTraj(ReorderTemps = [%(TEMPSET)3.2f] ) t3 = time.time() # print stats print "REMD time: ", (t2-t1), " seconds" print "Reordering time: ", (t3-t2), " seconds" ''' # job script template jobstr = ''' #!/bin/bash # #$ -V #$ -cwd #$ -j y #$ -S /bin/bash #$ -N %(JOBNAME)s export PYTHONPATH=$PYTHONPATH:~/Go date python remd.py mkdir -p ./NativeAnalysis mkdir -p ./AATopClustAnalysis python ~/Go/analyze_go.py %(NATIVEPDB)s %(PREFIX)s ./ ./NativeAnalysis python ~/Go/analyze_go.py %(AATOPCLUSTPDB)s %(PREFIX)s ./ ./AATopClustAnalysis date ''' # dict for filling md script template d1 = { 'PREFIX': Prefix, 'NATIVEPDB': NativePdb, 'FF_FILE': FF_File, 'MINBONDORD': MinBondOrd, 'NKNOT' : NKnot, 'CUT' : Cut, 'HARMONICFLUCT': HarmonicFluct, 'TLOW' : TLow, 'THIGH' : THigh, 'NREPLICA': NReplica, 'TEMPSET' : TempSet, 'TEMPIND' : TempInd, 'TIMESTEP' : Delta_T, 'NSTEPSMIN': NStepsMin, 'NSTEPSEQUIL': NStepsEquil, 'NSTEPSPROD' : NStepsProd, 'NSTEPSSWAP' : NStepsSwap, 'STEPFREQ': StepFreq } # dict for filling job script template d2 = {'JOBNAME': Prefix, 'NATIVEPDB': NativePdb, 'AATOPCLUSTPDB': AATopClustPdb, 'PREFIX': Prefix} # run REMD job print 'Using backbone type:' , BBType print 'Using harmonic restraints on side chains of native contacts' mdscript = os.path.join(OutDir, 'remd.py') jobscript = os.path.join(OutDir, 'remdjob.sh') if not os.path.isfile(mdscript): file(mdscript, 'w').write(mdstr % d1) file(jobscript, 'w').write(jobstr % d2) os.chdir(OutDir) os.system('qsub remdjob.sh') os.chdir(CURRDIR) return