def animateModes(log,WorkingDir,LastMode,Amplitude,NFrames,Downsample,PseudoAtomThreshold,PseudoAtomRadius,Sampling,StructureType): createDir(log,os.path.join(WorkingDir,"extra/animations")) currentDir=os.getcwd() changeDir(log,WorkingDir) if StructureType=="EM": fn="pseudoatoms.pdb" runJob(log,"nma_animate_pseudoatoms.py","%s extra/vec_ani.pkl 7 %d %f extra/animations/animated_mode %d %d %f"%\ (fn,LastMode,Amplitude,NFrames,Downsample,PseudoAtomThreshold)) else: fn="atoms.pdb" runJob(log,"nma_animate_atoms.py","%s extra/vec_ani.pkl 7 %d %f extra/animations/animated_mode %d"%\ (fn,LastMode,Amplitude,NFrames)) for mode in range(7,LastMode+1): fnAnimation="extra/animations/animated_mode_%03d"%mode fhCmd=open(fnAnimation+".vmd",'w') fhCmd.write("mol new "+os.path.join(WorkingDir,fnAnimation)+".pdb\n") fhCmd.write("animate style Loop\n") fhCmd.write("display projection Orthographic\n") if StructureType=="EM": fhCmd.write("mol modcolor 0 0 Beta\n") fhCmd.write("mol modstyle 0 0 Beads %f 8.000000\n"%(PseudoAtomRadius*Sampling)) else: fhCmd.write("mol modcolor 0 0 Index\n") fhCmd.write("mol modstyle 0 0 Beads 1.000000 8.000000\n") fhCmd.write("animate speed 0.5\n") fhCmd.write("animate forward\n") fhCmd.close(); changeDir(log,currentDir)
def reformatOutputPDB(log,WorkingDir,NumberOfModes): currentDir=os.getcwd() changeDir(log,WorkingDir) createDir(log,"modes") Natoms=countAtoms("atoms.pdb") fhIn=open('diagrtb.eigenfacs') fhAni=open('vec_ani.txt','w') for n in range(NumberOfModes): # Skip two lines fhIn.readline() fhIn.readline() fhOut=open('modes/vec.%d'%(n+1),'w') for i in range(Natoms): line=fhIn.readline() fhOut.write(line) fhAni.write(line.rstrip().lstrip()+" ") fhOut.close() if n!=(NumberOfModes-1): fhAni.write("\n") fhIn.close() fhAni.close() runJob(log,"nma_prepare_for_animate.py","") runJob(log,"rm","vec_ani.txt") moveFile(log,'vec_ani.pkl','extra/vec_ani.pkl') changeDir(log,currentDir)
def computeSAXS(log, WorkingDir,NumberOfHarmonics,MaxFreq, NumberOfSamples, OtherCrysol, ExperimentalSAXS): if ExperimentalSAXS!="": ExperimentalSAXS=os.path.abspath(ExperimentalSAXS) currentDir=os.getcwd() changeDir(log,WorkingDir) if ExperimentalSAXS!="": ExperimentalSAXS=os.path.relpath(ExperimentalSAXS) runJob(log,"crysol","pseudoatoms.pdb %s /lm %d /sm %f /ns %d %s"%(ExperimentalSAXS,NumberOfHarmonics,MaxFreq,NumberOfSamples,OtherCrysol)) runJob(log,"mv","*log *txt extra") if ExperimentalSAXS=="": runJob(log,"mv","*alm extra") changeDir(log,currentDir)
def qualifyModes(log,WorkingDir,NumberOfModes,StructureType,CollectivityThreshold): currentDir=os.getcwd() changeDir(log,WorkingDir) fnVec=glob.glob("modes/vec.*") if len(fnVec)<NumberOfModes: fhWarning=open("warnings.xmd",'w') fhWarning.write(redStr("There are only "+str(len(fnVec))+" modes instead of "+str(NumberOfModes)+". Check the number of modes you asked to compute and/or consider increasing cut-off distance. The maximum number of modes allowed by the method for atomic normal mode analysis is 6 times the number of RTB blocks and for pseudoatomic normal mode analysis 3 times the number of pseudoatoms. However, the protocol allows only up to 200 modes as 20-100 modes are usually enough. If the number of modes is below the minimum between these two numbers, consider increasing cut-off distance.")+"\n") fhWarning.close() fnDiag="diagrtb.eigenfacs" if StructureType=="EM": runJob(log,"nma_reformatForElNemo.sh","%d"%NumberOfModes) fnDiag="diag_arpack.eigenfacs" runJob(log,"echo","%s | nma_check_modes"%fnDiag) deleteFile(log,fnDiag) fh=open("Chkmod.res") MDout=MetaData() collectivityList=[] for n in range(NumberOfModes): line=fh.readline() collectivity=float(line.split()[1]) collectivityList.append(collectivity) id=MDout.addObject() MDout.setValue(MDL_NMA_MODEFILE,os.path.join(WorkingDir,"modes/vec.%d"%(n+1)),id) MDout.setValue(MDL_ORDER,long(n+1),id) if n>=6: MDout.setValue(MDL_ENABLED,1,id) else: MDout.setValue(MDL_ENABLED,-1,id) MDout.setValue(MDL_NMA_COLLECTIVITY,collectivity,id) if collectivity<CollectivityThreshold: MDout.setValue(MDL_ENABLED,-1,id) fh.close() idxSorted=[i[0] for i in sorted(enumerate(collectivityList), key=lambda x:x[1])] score=[0]*NumberOfModes for i in range(NumberOfModes): score[i]+=i+1 score[idxSorted[i]]+=NumberOfModes-i i=0 for id in MDout: score_i=float(score[i])/(2.0*NumberOfModes) MDout.setValue(MDL_NMA_SCORE,score_i,id) i+=1 MDout.write("modes.xmd") deleteFile(log,"Chkmod.res") changeDir(log,currentDir)
def reformatOutput(log,WorkingDir): currentDir=os.getcwd() changeDir(log,WorkingDir) Natoms=countAtoms("pseudoatoms.pdb") runJob(log,"nma_reformat_vector_foranimate.pl","%d fort.11"%Natoms) runJob(log,"cat","vec.1* > vec_ani.txt") runJob(log,"rm","-f vec.1*") runJob(log,"nma_reformat_vector.pl","%d fort.11"%Natoms) createDir(log,"modes") runJob(log,"mv","-f vec.* modes") runJob(log,"nma_prepare_for_animate.py","") runJob(log,"rm","vec_ani.txt fort.11 matrice.sdijf") moveFile(log,'vec_ani.pkl','extra/vec_ani.pkl') changeDir(log,currentDir)
def computeModesPDB(log, WorkingDir, NumberOfModes, CutoffMode, Rc, RcPercentage, RTBblockSize, RTBForceConstant): if CutoffMode=="Relative": Rc=computeCutoff(WorkingDir,os.path.join(WorkingDir,"extra/atoms_distance.hist"),RcPercentage) currentDir=os.getcwd() changeDir(log,WorkingDir) runJob(log,"nma_record_info_PDB.py","%d %d atoms.pdb %f %f"%(NumberOfModes,RTBblockSize,Rc,RTBForceConstant)) runJob(log,"nma_elnemo_pdbmat","") runJob(log,"nma_diagrtb","") if not os.path.exists("diagrtb.eigenfacs"): fhWarning=open("warnings.xmd",'w') fhWarning.write(redStr("Modes cannot be computed. Check the number of modes you asked to compute and/or consider increasing cut-off distance. The maximum number of modes allowed by the method for atomic normal mode analysis is 6 times the number of RTB blocks but the protocol allows only up to 200 modes as 20-100 modes are usually enough. If the number of modes is below the minimum between 200 and 6 times the number of RTB blocks, consider increasing cut-off distance.")+"\n") fhWarning.close() runJob(log,"rm","*.dat_run diagrtb.dat pdbmat.xyzm pdbmat.sdijf pdbmat.dat") changeDir(log,currentDir)
def computeModes(log, WorkingDir, NumberOfModes, CutoffMode, Rc, RcPercentage): if CutoffMode=="Relative": Rc=computeCutoff(WorkingDir,os.path.join(WorkingDir,"extra/pseudoatoms_distance.hist"),RcPercentage) currentDir=os.getcwd() changeDir(log,WorkingDir) runJob(log,"nma_record_info.py","%d pseudoatoms.pdb %d"%(NumberOfModes,int(Rc))) runJob(log,"nma_pdbmat.pl","pdbmat.dat") runJob(log,"nma_diag_arpack","") if not os.path.exists("fort.11"): fhWarning=open("warnings.xmd",'w') fhWarning.write(redStr("Modes cannot be computed. Check the number of modes you asked to compute and/or consider increasing cut-off distance. The maximum number of modes allowed by the method for pseudoatomic normal mode analysis is 3 times the number of pseudoatoms but the protocol allows only up to 200 modes as 20-100 modes are usually enough. If the number of modes is below the minimum between 200 and 3 times the number of pseudoatoms, consider increasing cut-off distance.")+"\n") fhWarning.close() runJob(log,"rm","diag_arpack.in pdbmat.dat") changeDir(log,currentDir)