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 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 ransacIteration(log,WorkingDir,n,SymmetryGroup,Xdim,Xdim2,NumGrids,NumSamples,DimRed,InitialVolume,AngularSampling,UseSA, NIterRandom,Rejection): fnBase="ransac%05d"%n TmpDir=os.path.join(WorkingDir,"tmp") fnRoot=os.path.join(TmpDir,fnBase) fnOutputReducedClass = os.path.join(WorkingDir,"extra/reducedClasses.xmd") if (DimRed=='Yes'): # Get a random sample of images runJob(log,"xmipp_transform_dimred","-i %s --randomSample %s.xmd %d -m LTSA "%(fnOutputReducedClass,fnRoot,NumGrids)) else: runJob(log,"xmipp_metadata_utilities","-i %s -o %s.xmd --operate random_subset %d --mode overwrite "%(fnOutputReducedClass,fnRoot,NumSamples)) runJob(log,"xmipp_metadata_utilities","-i %s.xmd --fill angleRot rand_uniform -180 180 "%(fnRoot)) runJob(log,"xmipp_metadata_utilities","-i %s.xmd --fill angleTilt rand_uniform 0 180 "%(fnRoot)) runJob(log,"xmipp_metadata_utilities","-i %s.xmd --fill anglePsi rand_uniform 0 360 "%(fnRoot)) # If there is an initial volume, assign angles if (InitialVolume != ''): fnGallery=os.path.join(TmpDir,'gallery_InitialVolume.stk') runJob(log,"xmipp_angular_projection_matching", "-i %s.xmd -o %s.xmd --ref %s --Ri 0 --Ro %s --max_shift %s --append"\ %(fnRoot,fnRoot,fnGallery,str(Xdim/2),str(Xdim/20))) # Reconstruct with the small sample reconstruct(log,fnRoot,SymmetryGroup,Xdim2/2) fnVol = fnRoot+'.vol' # Simulated annealing if UseSA: smallIter=int(min(floor(NIterRandom/5.0),0)); runJob(log,"xmipp_volume_initial_simulated_annealing","-i %s --initial %s --oroot %s_sa --sym %s --randomIter %d --rejection %f --dontApplyPositive" %(fnRoot+".xmd",fnVol,fnRoot,SymmetryGroup,smallIter,Rejection)) moveFile(log, fnRoot+"_sa.vol", fnVol) deleteFile(log, fnRoot+"_sa.xmd") # Generate projections from this reconstruction fnGallery=os.path.join(TmpDir,'gallery_'+fnBase+'.stk') runJob(log,"xmipp_angular_project_library", "-i %s -o %s --sampling_rate %f --sym %s --method fourier 1 0.25 bspline --compute_neighbors --angular_distance -1 --experimental_images %s"\ %(fnVol,fnGallery,float(AngularSampling),SymmetryGroup,fnOutputReducedClass)) # Assign angles to the rest of images fnAngles=os.path.join(TmpDir,'angles_'+fnBase+'.xmd') runJob(log,"xmipp_angular_projection_matching", "-i %s -o %s --ref %s --Ri 0 --Ro %s --max_shift %s --append"\ %(fnOutputReducedClass,fnAngles,fnGallery,str(Xdim/2),str(Xdim/20))) # Delete intermediate files deleteFile(log,fnGallery) deleteFile(log,os.path.join(TmpDir,'gallery_'+fnBase+'_sampling.xmd')) deleteFile(log,os.path.join(TmpDir,'gallery_'+fnBase+'.doc')) deleteFile(log,fnVol) deleteFile(log,os.path.join(TmpDir,fnBase+'.xmd'))
def runCrop(log, stack, cropSize, tmpStack): runJob(log,"xmipp_transform_window","-i %(stack)s --size %(cropSize)d -o %(tmpStack)s" % locals()) moveFile(log, tmpStack, stack)