當前位置: 首頁>>代碼示例>>Python>>正文


Python EMAN.merge_lstfiles方法代碼示例

本文整理匯總了Python中EMAN.merge_lstfiles方法的典型用法代碼示例。如果您正苦於以下問題:Python EMAN.merge_lstfiles方法的具體用法?Python EMAN.merge_lstfiles怎麽用?Python EMAN.merge_lstfiles使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在EMAN的用法示例。


在下文中一共展示了EMAN.merge_lstfiles方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: main

# 需要導入模塊: import EMAN [as 別名]
# 或者: from EMAN import merge_lstfiles [as 別名]

#.........這裏部分代碼省略.........
			mapfile2o = None
			subsetlste = None
			subsetlsto = None
			fscfile = None

		if not os.path.exists(mapfile):
			print "ERROR: cannot find 3D map \"%s\"" % (mapfile)
			sys.exit()
		else:
			d = EMAN.EMData()
			d.readImage(rawimage,0,1)	# read header
			rnx = d.xSize()
			rny = d.ySize()
			d.readImage(mapfile,-1,1)	# read header
			mnx = d.xSize()
			mny = d.ySize()
			mnz = d.zSize()
			if rnx!=mnx or rny!=mny:
				print "ERROR: raw images (%s) sizes (%dx%d) are different from the 3D map (%s) sizes (%dx%dx%d)" % 	(rawimage, rnx, rny, mapfile, mnx, mny, mnz)
				sys.exit()
		
		if not os.path.exists(cmplstfile):
			runpar_file = "runpar.%d.ortcen.txt" % (iter+1)
			n = imagenum/options.batchsize
			if imagenum%n: n+=1
			if n<options.cpus: 
				n=options.cpus
				options.batchsize=imagenum/n+1
				if options.batchsize==1: 
					n = imagenum
					options.batchsize=1
			
			num_tries = 0
			max_tries = 3
			while not os.path.exists(ortlstfile) and num_tries < max_tries:
				runparfp = open(runpar_file, "w")
				num_tries += 1
				todo_num = 0
				sublstfiles = []
				cmpsublstfiles = []
				for i in range(n):
					cmplstfile_tmp = "cmp.%d.%d.lst" % (iter+1, i)
					ortlstfile_tmp = "ort.%d.%d.lst" % (iter+1, i)
					startNum = i * options.batchsize
					endNum = (i+1) * options.batchsize
					if startNum>=imagenum: break
					if endNum>imagenum: endNum=imagenum
					sublstfiles.append(ortlstfile_tmp)
					cmpsublstfiles.append(cmplstfile_tmp)
					if os.path.exists(ortlstfile_tmp):	continue
					else: todo_num += 1
					
					cmd  = "symrelax.py %s %s " % (rawimage, mapfile)
					if options.sffile: cmd += "--sf=%s " % ( options.sffile )
					if options.phasecorrected: cmd += "--phasecorrected "
					cmd += "--verbose=%d " % (options.verbose )
					cmd += "--mask=%d " % (options.mask)
					cmd += "--startSym=%s " % (options.startSym)
					cmd += "--endSym=%s " % (options.endSym)
					cmd += "--first=%d --last=%d " % (startNum, endNum)
					cmd += "--shrink=%d " % (options.shrink)
					cmd += "--ortlstfile=%s " % (ortlstfile_tmp)
					cmd += "--score=%s " % (options.scorefunc)
					if options.saveprojection:
						cmd += "--projection=%s " % (projfile)
						cmd += "--cmplstfile=%s " % (cmplstfile_tmp)					
					if i: cmd += "--nocmdlog "
						
					if i == 0: print cmd
					
					runparfp.write("%s\n" % (cmd))
				runparfp.close()
				if todo_num:
					cmd = "runpar proc=%d,%d file=%s" % (options.cpus, options.cpus, runpar_file)
					print cmd
					os.system(cmd)
			
				#now merge all sublst file
				# first test if all jobs are done properly
				done = 1
				for lstfile_tmp in sublstfiles:
					if not os.path.exists(lstfile_tmp): done = 0
				
				if done:
					EMAN.merge_lstfiles(sublstfiles, ortlstfile, delete_lstfiles = 1)
					# pool the cmplstfiles
					if options.saveprojection:
						EMAN.merge_lstfiles(cmpsublstfiles, cmplstfile, delete_lstfiles = 1)

			if not os.path.exists(ortlstfile) or (os.path.exists(ortlstfile) and os.path.getsize(ortlstfile)<=5):
				print "ERROR: raw image new orientation results lst file \"%s\" is not generated properly" % (ortlstfile)
				sys.exit()
	
		if not os.path.exists(mapfile2):
			reconstruction_by_make3d(ortlstfile, mapfile2, options=options, mapfile2e=mapfile2e, mapfile2o=mapfile2o, fscfile=fscfile)
			if not (os.path.exists(mapfile2) and os.path.getsize(mapfile2)):
				print "ERROR: 3D map \"%s\" is not generated properly" % (mapfile2)
				sys.exit()
		
	EMAN.LOGend()
開發者ID:,項目名稱:,代碼行數:104,代碼來源:


注:本文中的EMAN.merge_lstfiles方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。