def main():
	
	progname = os.path.basename(sys.argv[0])
	usage = progname + " stack outdir <maskfile> --K=2 --nb_part=5  --th_nobj=10 --rand_seed=10 --opt_method=SSE --maxit=1000 --normalize --CTF  --MPI"
	parser = OptionParser(usage,version=SPARXVERSION)
	parser.add_option("--K",              type="int",          default=2,         help="Number of classes for K-means (default 2)")
	parser.add_option("--nb_part",        type="int",          default=5,         help="Number of partitions used to calculate the stability (default 5)")
	#parser.add_option("--F",              type="float",        default=0.0,       help="Cooling factor in simulated annealing, <1.0")
	#parser.add_option("--T0",             type="float",        default=0.0,       help="Simulated annealing first temperature")
	parser.add_option("--th_nobj",        type="int",          default=1,         help="Cleanning threshold, classes with number of images < th_nobj are removed (default 1)")
	parser.add_option("--rand_seed",      type="int",          default=0,         help="Random seed")
	#parser.add_option("--opt_method",     type='string',       default='SSE',     help="K-means method: SSE (default), cla")
	#parser.add_option("--match",          type='string',       default='bbenum',     help='Algorithm to match partitions: pwa, pair-wise agreement (default), or hh, hierarchical Hungarian algorithm, or bbenum')
	parser.add_option("--maxit",          type="int",          default=1e9,       help="Maximum number of iterations for k-means")
	parser.add_option("--normalize",      action="store_true", default=False,     help="Normalize images under the mask")
	parser.add_option("--CTF",            action="store_true", default=False,     help="Perform classification using CTF information")
	#parser.add_option("--CUDA",           action="store_true", default=False,     help="CUDA version")
	parser.add_option("--MPI",            action="store_true", default=False,     help="Use MPI version ")	
	(options, args) = parser.parse_args()
    	if len(args) < 2 or len(args) > 3:
				print "usage: " + usage
        			print "Please run '" + progname + " -h' for detailed options"
	else:
		if len(args) == 2: mask = None
		else:              mask = args[2]

		if options.K < 2:
			sys.stderr.write('ERROR: K must be > 1 group\n\n')
			sys.exit()

		if options.nb_part < 2:
			sys.stderr.write('ERROR: nb_part must be > 1 partition\n\n')
			sys.exit()
		if global_def.CACHE_DISABLE:
			from utilities import disable_bdb_cache
			disable_bdb_cache()

		global_def.BATCH = True
		if options.MPI:
			from mpi import mpi_init
			sys.argv = mpi_init(len(sys.argv), sys.argv)
			'''if options.CUDA:
				from  development import  k_means_stab_MPICUDA_stream_YANG
				k_means_stab_MPICUDA_stream_YANG(args[0], args[1], mask, options.K, options.nb_part, options.F, options.T0, options.th_nobj, options.rand_seed, options.maxit)
			else:'''
			from  statistics import  k_means_stab_MPI_stream
			k_means_stab_MPI_stream(args[0], args[1], mask, options.K, options.nb_part, 0.0, 0.0, options.th_nobj, options.rand_seed, "SSE", options.CTF, options.maxit)
		else:
			'''if options.CUDA:
				from  development  import  k_means_stab_CUDA_stream
				k_means_stab_CUDA_stream(args[0], args[1], mask, options.K, options.nb_part, options.F, options.T0, options.th_nobj, options.rand_seed, options.maxit)
			else:'''
			
			from  statistics  import  k_means_stab_stream
			k_means_stab_stream(args[0], args[1], mask, options.K, options.nb_part, 0.0, 0.0, options.th_nobj, options.rand_seed, "SSE", options.CTF, options.maxit)
		global_def.BATCH = False

		if options.MPI:
			from mpi import mpi_finalize
			mpi_finalize()
Exemple #2
0
def main():

	import sys
	import os

        arglist = []
        for arg in sys.argv:
		arglist.append( arg )

	progname = os.path.basename(arglist[0])
	usage = progname + " prjstack bufprefix --npad --CTF --verbose"
	parser = OptionParser(usage,version=SPARXVERSION)
	parser.add_option("--CTF",      action="store_true", default=False, help="use CTF")
	parser.add_option("--npad",     type="int",          default=2,     help="times of padding")
	parser.add_option("--verbose",  type="int",          default=0,     help="verbose level: 0 no, 1 yes")

	(options, args) = parser.parse_args( arglist[1:] )

	if( len(args) != 2):
		print "usage: " + usage
		return None

	prjfile = args[0]

	if global_def.CACHE_DISABLE:
		from utilities import disable_bdb_cache
		disable_bdb_cache()

	bufprefix = args[1]
	nprj = EMUtil.get_image_count( prjfile )
	genbuf( prjfile, bufprefix, 0, nprj, options.CTF, options.npad, options.verbose )
Exemple #3
0
def main():
	progname = os.path.basename(sys.argv[0])
	usage = progname + " stack_in  stack_out"
	parser = OptionParser(usage,version=SPARXVERSION)
	(options, args) = parser.parse_args()

	if global_def.CACHE_DISABLE:
		from utilities import disable_bdb_cache
		disable_bdb_cache()
	
	# check length of arguments list. less than 2 is illegal
	if (len(args) < 2):
    		print "usage: " + usage
    		print "Please run '" + progname + " -h' for detailed options"
	# 2 is file to file copying
	elif (2 == len(args)):
		#print "file to file"
		cpy(args[0], args[1])
	# more than 2, this means a wildcard is transformed to a list of filenams
	else:
		#print "list to file"
		#
		# XXX: note that wildcards only work for filenames! wildcards in files
		#    are processed by the shell and read in as a space-delimited list
		#    of filenames. however, this does NOT work for bdb:image1 type names,
		#    since these will not be found and processed by the shell, not being
		#    normal files. globbing of db objects will have to be done here!
		#
		# make sure we only pass the last entry of args as output file name,
		#    since [-1:] pass a list containing only the last entry....
		#
		# application.cpy
		cpy(args[:-1], args[-1:][0])
Exemple #4
0
def main():

    progname = os.path.basename(sys.argv[0])
    usage = (
        progname
        + """ 2Dprojections plot_output

Read projection angles from 2Dprojections file and write a 2D image file
containing their distribution on a hemisphere."""
    )
    parser = OptionParser(usage, version=SPARXVERSION)
    parser.add_option("--wnx", type="int", default=256, help="plot image size (default = 256)")

    (options, args) = parser.parse_args()
    if len(args) != 2:
        print "usage: " + usage
        print "Please run '" + progname + """ -h' for detailed options"""
    else:
        if global_def.CACHE_DISABLE:
            from utilities import disable_bdb_cache

            disable_bdb_cache()
        from applications import plot_projs_distrib

        global_def.BATCH = True
        plot_projs_distrib(args[0], args[1], options.wnx)
        global_def.BATCH = False
Exemple #5
0
def main():
    progname = os.path.basename(sys.argv[0])
    usage = progname + " input_stack start end output_stack  <mask> --rad=mask_radius"
    parser = OptionParser(usage, version=SPARXVERSION)
    parser.add_option("--rad", type="int", default=-1, help="radius of mask")
    parser.add_option("--verbose", type="int", default=0, help="verbose level (0|1)")

    (options, args) = parser.parse_args()

    if len(args) < 4:
        print "usage: " + usage
        print "Please run '" + progname + " -h' for details"
    else:
        from string import atoi

        input_stack = args[0]
        imgstart = atoi(args[1])
        imgend = atoi(args[2]) + 1
        output_stack = args[3]
        if len(args) == 5:
            mask = args[4]
        else:
            mask = None

        if global_def.CACHE_DISABLE:
            from utilities import disable_bdb_cache

            disable_bdb_cache()
        from applications import varimax

        global_def.BATCH = True
        varimax(input_stack, range(imgstart, imgend), output_stack, mask, options.rad, options.verbose)
        global_def.BATCH = False
Exemple #6
0
def main():
	progname = os.path.basename(sys.argv[0])
	usage = progname + " volume stack  <maskfile> --delta=angular_step --method=S --phiEqpsi=Minus --symmetry=c1 --angles=angles.txt --CTF=ctf.txt --noise=s"
	parser = OptionParser(usage,version=SPARXVERSION)
	parser.add_option("--delta",    type="float",   default=2,       help="angular step ")
	parser.add_option("--phiEqpsi", type="string",  default="Minus", help="if Minus, psi is set to minus phi (default), if Zero, set to zero ")
	parser.add_option("--method",   type="string",  default="S",     help="method of quasi-uniformly distributed Eulerian angles S (default) or P")
	parser.add_option("--symmetry", type="string",  default="c1",    help="symmetry group")
	parser.add_option("--angles",   type="string",  default=None,    help="List of angles (phi, theta, psi) or with shifts (phi, theta, psi, tx, ty)")
	parser.add_option("--noise",    type="float",   default=None,    help="add Gaussian noise with standard deviation s and zero mean")
	parser.add_option("--CTF",      type="string",  default=None,    help="list of CTF parameters")
	parser.add_option("--realspace",action="store_true", default=False,   help="real space projection")

	(options, args) = parser.parse_args()
	if(len(args) < 2 or len(args) > 3):
    		print "usage: " + usage
    		print "Please run '" + progname + " -h' for detailed options"
	else:
		if len(args) == 2:
			mask = None
		else:
			mask = args[2]
			
		if global_def.CACHE_DISABLE:
			from utilities import disable_bdb_cache
			disable_bdb_cache()
		from   applications import project3d
		global_def.BATCH = True
		project3d(args[0], args[1], mask, options.delta, options.method, options.phiEqpsi, options.symmetry, options.angles, listctfs=options.CTF, noise=options.noise, realsp=options.realspace)
		global_def.BATCH = False
Exemple #7
0
def main():
	progname = os.path.basename(sys.argv[0])
	usage = progname + " input_filename output_filename --sym=Symmetry group --phi --theta --psi=The 3 Eulerian angles in degrees --r=Radius of mask --phirange --thetarange --psirange=A search scale for each angle --ftol --xtol = convergence criterion the function and angles values"
	parser = OptionParser(usage,version=SPARXVERSION)
	parser.add_option("--sym",        type="string", default="c1", help="  String that specifies the point group symmetry. default = 'c1'")
	parser.add_option("--phi",        type='float',default=0.0, help="  phi angle, default = 0")
	parser.add_option("--theta",      type='float',default=0.0, help=" theta angle, default=0")
	parser.add_option("--psi",        type='float',default=0.0, help=" phi angle, default=0")
	parser.add_option("--r",          type='float',default=None,help=" Input the radius of the mask. default=None")
	parser.add_option("--phirange",   type='float',default=20.0,help=" The search scale for phi angle...default=20")
	parser.add_option("--thetarange", type='float',default=20.0,help=" The search scale for theta angle...default=20")
	parser.add_option("--psirange",   type='float',default=20.0,help=" The search scale for psi angle...default=20")
	parser.add_option("--ftol",       type='float',default=1.e-4,help=" convergence criterion on the function values...default = 1.e-4")
	parser.add_option("--xtol",       type='float',default=1.e-4,help=" convergence criterion on the variable values...default = 1.e-4")
	(options, args) = parser.parse_args()    	
    	if len(args) != 2:
		print "usage: " + usage
        	print "Please run '" + progname + " -h' for detailed options"
		exit(1)
	else:
		if global_def.CACHE_DISABLE:
			from utilities import disable_bdb_cache
			disable_bdb_cache()
		from applications  import  rot_sym
		global_def.BATCH = True
		rot_sym(args[0],args[1],options.sym,options.r,options.phi,options.theta,options.psi,options.phirange,options.thetarange,options.psirange,options.ftol,options.xtol)
		global_def.BATCH = False
Exemple #8
0
def main():
    import os
    import sys
    from optparse import OptionParser

    arglist = []
    for arg in sys.argv:
        arglist.append(arg)

    progname = os.path.basename(arglist[0])
    usage = progname + "  stack1 <stack2> <mask> --ccc --fsc file --inf --rad=r"
    parser = OptionParser(usage, version=SPARXVERSION)

    parser.add_option("--ccc", action="store_true", default=False, help="print cross corelation coefficient")
    parser.add_option("--fsc", type="string", default="", help="calculate resolution curve")
    parser.add_option("--inf", action="store_true", default=False, help="print basic infomation of the img")
    parser.add_option("--rad", type="int", default=-1, help="radius of operation")

    (options, args) = parser.parse_args(arglist[1:])

    if len(args) < 1 or len(args) > 3:
        print "usage: " + usage
        print "Please run '" + progname + " -h' for detailed options"
        sys.exit(-1)

    if global_def.CACHE_DISABLE:
        from utilities import disable_bdb_cache

        disable_bdb_cache()
    from applications import imgstat

    global_def.BATCH = True
    imgstat(args, options.ccc, options.fsc, options.inf, options.rad)
Exemple #9
0
def main():
	progname = os.path.basename(sys.argv[0])
	usage = progname + " stack outdir <maskfile> --ou=outer_radius --br=brackets --center=center_type --eps=epsilon --maxit=max_iter --CTF --snr=SNR --function=user_function_name"
	parser = OptionParser(usage,version=SPARXVERSION)
	parser.add_option("--ou", type="float", default=-1, help="  outer radius for a 2-D mask within which the alignment is performed")
	parser.add_option("--br", type="float", default=1.75, help="  brackets for the search of orientation parameters (each parameter will be checked +/- bracket (set to 1.75)")
	parser.add_option("--center", type="float", default=1, help="  0 - if you do not want the average to be centered, 1 - center the average (default=1)")
	parser.add_option("--eps", type="float", default=0.001, help="  stopping criterion, program will terminate when the relative increase of the criterion is less than epsilon  ")
	parser.add_option("--maxit", type="float", default=10, help="  maximum number of iterations (set to 10) ")
	parser.add_option("--CTF", action="store_true", default=False, help="  Consider CTF correction during the alignment ")
	parser.add_option("--snr", type="float", default=1.0, help="  Signal-to-Noise Ratio of the data")	
	parser.add_option("--function", type="string", default="ref_ali2d", help="  name of the reference preparation function")
	(options, args) = parser.parse_args()
	if len(args) < 2 or len(args) >3:
    		print "usage: " + usage
    		print "Please run '" + progname + " -h' for detailed options"
	else:
		if len(args) == 2:
			mask = None
		else:
			mask = args[2]
		
		from applications import local_ali2d

		if global_def.CACHE_DISABLE:
			from utilities import disable_bdb_cache
			disable_bdb_cache()
		
		global_def.BATCH = True	
		local_ali2d(args[0], args[1], mask, options.ou, options.br, options.center, options.eps, options.maxit, options.CTF, options.snr, options.function)
		global_def.BATCH = False	
Exemple #10
0
def main():
	
	progname = os.path.basename(sys.argv[0])
	usage = progname + " stack dendoname <maskfile> --link=kind_of_link --dist=kind_of_dist --dissimilar"
	parser = OptionParser(usage,version=SPARXVERSION)
	parser.add_option("--link",       type='string',       default="single",     help="Kind of linkage: single, complete, average (default single)")
	parser.add_option("--dist",       type='string',       default="sim_SqEuc",  help="Kind of distance: SqEuc, CCC (default SqEuc)")
	parser.add_option("--dissimilar", action='store_true', default=False,        help="Change the distance to the negative value (default False)")

	chk_link = ['single', 'complete', 'average']
	chk_dist = ['SqEuc', 'CCC']
	
	(options, args) = parser.parse_args()
    	if len(args) < 2 or len(args) > 3:
		print "usage: " + usage
		print "Please run '" + progname + " -h' for detailed options"
	elif options.link not in chk_link:
		sys.stderr.write('ERROR: Kind of linkage unknown.\n\n')
		sys.exit()
	elif options.dist not in chk_dist:
		sys.stderr.write('ERROR: Kind of distance unknown.\n\n')
		sys.exit()
	else:
		if len(args) == 2: maskname = None
		else:              maskname = args[2]

		if global_def.CACHE_DISABLE:
			from utilities import disable_bdb_cache
			disable_bdb_cache()
		from  applications  import  HAC_clustering
		global_def.BATCH = True
		HAC_clustering(args[0], args[1], maskname, options.link, options.dist, options.dissimilar)
		global_def.BATCH = False
Exemple #11
0
def main():
	arglist = []
	for arg in sys.argv:
		arglist.append( arg )
	progname = os.path.basename(sys.argv[0])
	usage = progname + " stack outdir <maskfile> --ou=outer_radius --delta=angular_bracket --maxit=max_iter --chunk=data_chunk_for_update --center --CTF --snr=SNR --sym=symmetry  --function=user_function --MPI"
	parser = OptionParser(usage,version=SPARXVERSION)
	parser.add_option("--ou",       type="float",        default=-1,      help="outer radius of a circular mask that should encompass the particle< int(nx/2)-1 (set to int(nx/2)-1)")
	parser.add_option("--delta",    type="float",        default=2,       help="angular bracket (set to 2)")
	parser.add_option("--ts",       type="float",        default=2,       help="shift bracket (set to 2)")
	parser.add_option("--center",   type="float",        default=0,       help="-1 - average centering method; 0 - no cetnering of template volume (default), 1 - center the volume using center of gravity")
	parser.add_option("--maxit",    type="int",          default=10,      help="maximum number of iterations (set to 10)")
	parser.add_option("--chunk",    type="float",        default=1.0,     help="chunk of data after which the 3-D structure will be updated 0<chunk<=1.0 (set to 1.0)")
	parser.add_option("--CTF",      action="store_true", default=False,   help="Consider CTF correction during the alignments")
	parser.add_option("--snr",      type="float", 	     default=1,       help="SNR > 0.0 (set to 1.0)")
	parser.add_option("--sym",      type="string",       default="c1",    help="symmetry group (set to c1)")
	parser.add_option("--function", type="string",       default="ref_ali3d", help="name of the user-supplied reference preparation function")
	parser.add_option("--npad",     type="int",          default= 2,      help="padding size for 3D reconstruction")
	parser.add_option("--debug",    action="store_true", default=False,   help="Debug printout")
	parser.add_option("--MPI",      action="store_true", default=False,   help="use MPI version")
	parser.add_option("--fourvar",  action="store_true", default=False,   help="compute Fourier variance")
	(options, args) = parser.parse_args(arglist[1:])
	if(len(args) < 2 or len(args) > 3):
		print "usage: " + usage
		print "Please run '" + progname + " -h' for detailed options"
	else:
	
		if(len(args) == 2):
			mask = None
		else:
			mask = args[2]

		if options.MPI:
			from mpi import mpi_init
			sys.argv = mpi_init(len(sys.argv), sys.argv)

		if global_def.CACHE_DISABLE:
			from utilities import disable_bdb_cache
			disable_bdb_cache()

		
		global_def.BATCH = True
		if options.fourvar:
			from development import nlocal_ali3d_MPI
			nlocal_ali3d_MPI(args[0], args[1], mask, options.ou, options.delta, options.ts, options.center, options.maxit,
			options.CTF, options.snr, options.sym, options.chunk, options.function, options.fourvar,
			options.npad, options.debug)
		else:
			from applications import local_ali3d
			local_ali3d(args[0], args[1], mask, options.ou, options.delta, options.ts, options.center, options.maxit,
			options.CTF, options.snr, options.sym, options.chunk, options.function, options.fourvar,
			options.npad, options.debug, options.MPI)
		global_def.BATCH = False

		if options.MPI:
			from mpi import mpi_finalize
			mpi_finalize()
Exemple #12
0
def main():
	from   optparse       import OptionParser
	progname = os.path.basename(sys.argv[0])
	usage = progname + " filelist outdir  --fl=filter_low_value --aa=filter_fall_off --radccc=radius_ccc  -repair=repairfile --pca --pcamask --pcanvec --MPI"
	parser = OptionParser(usage,version=SPARXVERSION)
	parser.add_option("--fl",             type="float",        default=0.0,       help="cut-off frequency of hyperbolic tangent low-pass Fourier filter")
	parser.add_option("--aa",             type="float",        default=0.0,       help="fall-off of hyperbolic tangent low-pass Fourier filter")
	parser.add_option("--radccc",         type="int",          default=-1,        help="radius for ccc calculation")
	parser.add_option("--MPI",            action="store_true", default=False,     help="use MPI version" )
	parser.add_option("--repair",         type="string",       default="default", help="repair original bootstrap volumes: None or repair file name")
	parser.add_option("--pca",            action="store_true", default=False,     help="run pca" )
	parser.add_option("--pcamask",        type="string",       default=None,      help="mask for pca" )
	parser.add_option("--pcanvec",        type="int",          default=2,         help="number of eigvectors computed in PCA")
	parser.add_option("--n",              action="store_true", default=False,     help="new")
	parser.add_option("--scratch",        type="string",       default="./",      help="scratch directory")
	(options, args) = parser.parse_args(sys.argv[1:])

	if len(args)<2 :
		print "usage: " + usage
		print "Please run '" + progname + " -h' for detailed options"
	else:
		files = args[0:-1]
		outdir = args[-1]

		if global_def.CACHE_DISABLE:
			from utilities import disable_bdb_cache
			disable_bdb_cache()
		if options.MPI:
			from mpi import mpi_init
			sys.argv = mpi_init( len(sys.argv), sys.argv )


			arglist = []
			for arg in sys.argv:
				arglist.append( arg )

			global_def.BATCH = True
			
			if(options.n):
				from development import var_mpi_new
				var_mpi_new( files[0], outdir, options.scratch, options.fl, options.aa, options.radccc, False, False, options.repair, options.pca, options.pcamask, options.pcanvec)
			else:
				from applications import var_mpi
				var_mpi( files, outdir, options.fl, options.aa, options.radccc, options.repair, options.pca, options.pcamask, options.pcanvec)

			global_def.BATCH = False
			from mpi import mpi_finalize
			mpi_finalize()
		else:
			global_def.BATCH = True
			ERROR("Please use MPI version","sxvar",1)
			from applications import defvar
			defvar(  files, outdir, options.fl, options.aa, options.radccc, options.repair, options.pca, options.pcamask, options.pcanvec)
			global_def.BATCH = False
Exemple #13
0
def main():
        arglist = []
        for arg in sys.argv:
        	arglist.append( arg )
	progname = os.path.basename(sys.argv[0])
	usage = progname + " data_stack reference_stack outdir <maskfile> --ir=inner_radius --ou=outer_radius --rs=ring_step --xr=x_range --yr=y_range  --ts=translation_step --center=center_type --maxit=max_iteration --CTF --snr=SNR --function=user_function_name --rand_seed=random_seed --MPI"
	parser = OptionParser(usage,version=SPARXVERSION)
	parser.add_option("--ir", type="float", default=1, help="  inner radius for rotational correlation > 0 (set to 1)")
	parser.add_option("--ou", type="float", default=-1, help="  outer radius for rotational correlation < nx/2-1 (set to the radius of the particle)")
	parser.add_option("--rs", type="float", default=1, help="  step between rings in rotational correlation > 0 (set to 1)" )
	parser.add_option("--xr", type="float", default=0, help="  range for translation search in x direction, search is +/-xr ")
	parser.add_option("--yr", type="float", default=0, help="  range for translation search in y direction, search is +/-yr ")
	parser.add_option("--ts", type="float", default=1, help="  step of translation search in both directions")
	parser.add_option("--center", type="float", default=1, help="  0 - if you do not want the average to be centered, 1 - center the average (default=1)")
	parser.add_option("--maxit", type="float", default=10, help="  maximum number of iterations (set to 10) ")
	parser.add_option("--CTF", action="store_true", default=False, help=" Consider CTF correction during multiple reference alignment")
	parser.add_option("--snr", type="float",  default= 1.0, help="  signal-to-noise ratio of the data (set to 1.0)")
	parser.add_option("--function", type="string", default="ref_ali2d", help="  name of the reference preparation function")
	parser.add_option("--rand_seed", type="int", default=1000, help=" random seed of initial (set to 1000)" )
	parser.add_option("--MPI", action="store_true", default=False,     help="  whether to use MPI version ")
	parser.add_option("--EQ", action="store_true", default=False,     help="  equal version ")
	(options, args) = parser.parse_args(arglist[1:])
	if len(args) < 3 or len(args) > 4:
    		print "usage: " + usage
    		print "Please run '" + progname + " -h' for detailed options"
	else:
	
		if len(args) == 3:
			mask = None
		else:
			mask = args[3]

		if global_def.CACHE_DISABLE:
			from utilities import disable_bdb_cache
			disable_bdb_cache()
		
	        if options.MPI:
			from mpi import mpi_init
   			sys.argv = mpi_init(len(sys.argv), sys.argv)

		global_def.BATCH = True
		if options.EQ:
			from development import mrefeq_ali2df
			#print  "  calling MPI",options.MPI,options.function,options.rand_seed
			#print  args
			mrefeq_ali2df(args[0], args[1], mask, options.ir, options.ou, options.rs, options.xr, options.yr, options.ts, options.center, options.maxit, options.CTF, options.snr, options.function, options.rand_seed, options.MPI)
		else:
			from applications import mref_ali2d
			mref_ali2d(args[0], args[1], args[2], mask, options.ir, options.ou, options.rs, options.xr, options.yr, options.ts, options.center, options.maxit, options.CTF, options.snr, options.function, options.rand_seed, options.MPI)
		global_def.BATCH = False
                if options.MPI:
		        from mpi import mpi_finalize
			mpi_finalize()
Exemple #14
0
def main():
	arglist = []
	for arg in sys.argv:
		arglist.append( arg )
	progname = os.path.basename(sys.argv[0])
	usage = progname + " data_stack reference_stack outdir <maskfile> --ir=inner_radius --ou=outer_radius --rs=ring_step --xr=x_range --yr=y_range  --ts=translation_step --center=center_type --maxit=max_iteration --CTF --snr=SNR --function=user_function_name --rand_seed=random_seed --MPI"
	parser = OptionParser(usage,version=SPARXVERSION)
	parser.add_option("--ir", type="float", default=1, help="  inner radius for rotational correlation > 0 (set to 1)")
	parser.add_option("--ou", type="float", default=-1, help="  outer radius for rotational correlation < nx/2-1 (set to the radius of the particle)")
	parser.add_option("--rs", type="float", default=1, help="  step between rings in rotational correlation > 0 (set to 1)" )
	parser.add_option("--xr", type="float", default=0, help="  range for translation search in x direction, search is +/-xr ")
	parser.add_option("--yr", type="float", default=0, help="  range for translation search in y direction, search is +/-yr ")
	parser.add_option("--ts", type="float", default=1, help="  step of translation search in both directions")
	parser.add_option("--center", type="float", default=1, help="  0 - if you do not want the average to be centered, 1 - center the average (default=1)")
	parser.add_option("--maxit", type="float", default=10, help="  maximum number of iterations (set to 10) ")
	parser.add_option("--CTF", action="store_true", default=False, help=" Consider CTF correction during multiple reference alignment")
	parser.add_option("--snr", type="float",  default= 1.0, help="  signal-to-noise ratio of the data (set to 1.0)")
	parser.add_option("--function", type="string", default="ref_ali2d", help="  name of the reference preparation function")
	parser.add_option("--rand_seed", type="int", default=1000, help=" random seed of initial (set to 1000)" )
	parser.add_option("--MPI", action="store_true", default=False,     help="  whether to use MPI version ")
	parser.add_option("--EQ", action="store_true", default=False,     help="  equal version ")
	(options, args) = parser.parse_args(arglist[1:])
	if len(args) < 3 or len(args) > 4:
    		print("usage: " + usage)
    		print("Please run '" + progname + " -h' for detailed options")
	else:
	
		if len(args) == 3:
			mask = None
		else:
			mask = args[3]

		if global_def.CACHE_DISABLE:
			from utilities import disable_bdb_cache
			disable_bdb_cache()
		
		if options.MPI:
			from mpi import mpi_init
			sys.argv = mpi_init(len(sys.argv), sys.argv)

		global_def.BATCH = True
		if options.EQ:
			from development import mrefeq_ali2df
			#print  "  calling MPI",options.MPI,options.function,options.rand_seed
			#print  args
			mrefeq_ali2df(args[0], args[1], mask, options.ir, options.ou, options.rs, options.xr, options.yr, options.ts, options.center, options.maxit, options.CTF, options.snr, options.function, options.rand_seed, options.MPI)
		else:
			from applications import mref_ali2d
			mref_ali2d(args[0], args[1], args[2], mask, options.ir, options.ou, options.rs, options.xr, options.yr, options.ts, options.center, options.maxit, options.CTF, options.snr, options.function, options.rand_seed, options.MPI)
		global_def.BATCH = False
		if options.MPI:
			from mpi import mpi_finalize
			mpi_finalize()
Exemple #15
0
def main():

	import sys

        arglist = []
        for arg in sys.argv:
	    arglist.append( arg )

	progname = os.path.basename(arglist[0])
	usage = progname + " prjstack outdir bufprefix --delta --d --nvol --nbufvol --seedbase --snr --npad --CTF --MPI --verbose"
	parser = OptionParser(usage,version=SPARXVERSION)
	parser.add_option("--nvol",     type="int",                         help="number of resample volumes to be generated")
	parser.add_option("--nbufvol",  type="int",          default=1,     help="number of fftvols in the memory")
	parser.add_option("--delta",    type="float",        default=10.0,  help="angular step for cones")
	parser.add_option("--d",        type="float",        default=0.1,   help="fraction of projections to leave out")
	parser.add_option("--CTF",      action="store_true", default=False, help="use CTF")
	parser.add_option("--snr",      type="float",        default=1.0,   help="Signal-to-Noise Ratio")
	parser.add_option("--npad",     type="int",          default=2,     help="times of padding")
	parser.add_option("--seedbase", type="int",          default=-1,    help="random seed base")
	parser.add_option("--MPI",      action="store_true", default=False, help="use MPI")
	parser.add_option("--verbose",  type="int",          default=0,     help="verbose level: 0 no, 1 yes")

	(options, args) = parser.parse_args( arglist[1:] )

	if( len(args) !=1 and len(args) != 3):
		print "usage: " + usage
		return None

	prjfile = args[0]

	if options.MPI:
		from mpi import mpi_barrier, mpi_comm_rank, mpi_comm_size, mpi_comm_split, MPI_COMM_WORLD
                from mpi import mpi_init
                sys.argv = mpi_init( len(sys.argv), sys.argv )
		myid = mpi_comm_rank( MPI_COMM_WORLD )
		ncpu = mpi_comm_size( MPI_COMM_WORLD )
	else:
		myid = 0
		ncpu = 1

	if global_def.CACHE_DISABLE:
		from utilities import disable_bdb_cache
		disable_bdb_cache()

	outdir = args[1]
	bufprefix = args[2]
	resample( prjfile, outdir, bufprefix, options.nbufvol, options.nvol, options.seedbase,\
	           options.delta, options.d, options.snr, options.CTF, options.npad,\
		   options.MPI, myid, ncpu, options.verbose )
	if options.MPI:
		from mpi import mpi_finalize
		mpi_finalize()
Exemple #16
0
def main():
	progname = os.path.basename(sys.argv[0])
	usage = progname + " stack outdir <maskfile> --ir=inner_radius --ou=outer_radius --rs=ring_step --xr=x_range --yr=y_range --ts=translation_step --dst=delta --center=center --maxit=max_iteration --CTF --snr=SNR --Fourvar=Fourier_variance --Ng=group_number --Function=user_function_name --CUDA --GPUID --MPI"
	parser = OptionParser(usage,version=SPARXVERSION)
	parser.add_option("--ir",       type="float",  default=1,             help="inner radius for rotational correlation > 0 (set to 1)")
	parser.add_option("--ou",       type="float",  default=-1,            help="outer radius for rotational correlation < nx/2-1 (set to the radius of the particle)")
	parser.add_option("--rs",       type="float",  default=1,             help="step between rings in rotational correlation > 0 (set to 1)" ) 
	parser.add_option("--xr",       type="string", default="4 2 1 1",     help="range for translation search in x direction, search is +/xr ")
	parser.add_option("--yr",       type="string", default="-1",          help="range for translation search in y direction, search is +/yr ")
	parser.add_option("--ts",       type="string", default="2 1 0.5 0.25",help="step of translation search in both directions")
	parser.add_option("--dst",      type="float",  default=0.0,           help="delta")
	parser.add_option("--center",   type="float",  default=-1,            help="-1.average center method; 0.not centered; 1.phase approximation; 2.cc with Gaussian function; 3.cc with donut-shaped image 4.cc with user-defined reference 5.cc with self-rotated average")
	parser.add_option("--maxit",    type="float",  default=0,             help="maximum number of iterations (0 means the maximum iterations is 10, but it will automatically stop should the criterion falls")
	parser.add_option("--CTF",      action="store_true", default=False,   help="use CTF correction during alignment ")
	parser.add_option("--snr",      type="float",  default=1.0,           help="signal-to-noise ratio of the data (set to 1.0)")
	parser.add_option("--Fourvar",  action="store_true", default=False,   help="compute Fourier variance")
	parser.add_option("--Ng",       type="int",    default=-1,            help="number of groups in the new CTF filteration")
	parser.add_option("--num_ali",  type="int",    default=3,             help="number of independent alignments to do")
	parser.add_option("--function", type="string", default="ref_ali2d",   help="name of the reference preparation function (default ref_ali2d)")
	parser.add_option("--CUDA",     action="store_true", default=False,   help="use CUDA program")
	parser.add_option("--GPUID",    type="string",    default="",         help="ID of GPUs available")
	parser.add_option("--MPI",      action="store_true", default=False,   help="use MPI version ")
	(options, args) = parser.parse_args()
	if len(args) < 2 or len(args) > 3:
    		print "usage: " + usage
    		print "Please run '" + progname + " -h' for detailed options"
	else:
		if args[1] == 'None': outdir = None
		else:		      outdir = args[1]

		if len(args) == 2: mask = None
		else:              mask = args[2]
		
		from development import multi_ali2d

		if global_def.CACHE_DISABLE:
			from utilities import disable_bdb_cache
			disable_bdb_cache()
		
		if options.MPI:
			from mpi import mpi_init
			sys.argv = mpi_init(len(sys.argv),sys.argv)

		global_def.BATCH = True
		multi_ali2d(args[0], outdir, mask, options.ir, options.ou, options.rs, options.xr, options.yr, options.ts, options.dst, options.center, \
			options.maxit, options.CTF, options.snr, options.Fourvar, options.Ng, options.num_ali, options.function, options.CUDA, options.GPUID, options.MPI)
		global_def.BATCH = False

		if options.MPI:
			from mpi import mpi_finalize
			mpi_finalize()
Exemple #17
0
def main():
        arglist = []
        for arg in sys.argv:
        	arglist.append( arg )
	progname = os.path.basename(sys.argv[0])
	usage = progname + " stack ref_vol outdir <maskfile> --ou=outer_radius --delta=angular_bracket --ts --nassign --nrefine --MPI --function --fourvar --maxit=max_iter ----termprec=percentage_to_stop --npad --debug --CTF --snr=SNR --sym=symmetry"
	parser = OptionParser(usage,version=SPARXVERSION)
	parser.add_option("--ou",       type="float",        default=-1,            help="radius < int(nx/2)-1 (set to int(nx/2)-1)")
	parser.add_option("--delta",    type="float",        default=2,             help="angular bracket (set to 2)")
	parser.add_option("--ts",       type="float",        default=2.0,          help="shift bracket (set to 2)")
	parser.add_option("--maxit",    type="int",          default=2,             help="maximum number of iterations (set to 10) ")
	parser.add_option("--termprec", type="float",        default=0.0,           help="Minimum percentage of assignment change to stop the program")   
	parser.add_option("--nassign",  type="int",          default=4,             help="number of assignment steps in one iteration")
	parser.add_option("--nrefine",  type="int",          default=1,             help="number of refinement steps in one iteration")
	parser.add_option("--CTF",      action="store_true", default=False,         help="Consider CTF correction during the alignment ")
	parser.add_option("--snr",      type="float", 	     default=1,             help="SNR > 0.0 (set to 1.0)")
	parser.add_option("--sym",      type="string",       default="c1",          help="symmetry group (set to c1)")
	parser.add_option("--MPI",      action="store_true", default=False,         help="use MPI version ")
	parser.add_option("--function", type="string",	     default="ref_ali3dm",  help="user function")
	parser.add_option("--fourvar",  action="store_true", default=False,         help="use fourier variance.")
	parser.add_option("--debug",    action="store_true", default=False,         help="debug mode ")
	parser.add_option("--npad",     type="int",          default=2,             help="npad")

	
	(options, args) = parser.parse_args(arglist[1:])
	if(len(args) < 3 or len(args) > 4):
    		print "usage: " + usage
    		print "Please run '" + progname + " -h' for detailed options"
	else:
	
		if(len(args) == 3):
			mask = None
		else:
			mask = args[3]

		if(options.MPI):
			from mpi import mpi_init
   			sys.argv = mpi_init( len(sys.argv), sys.argv )

		if global_def.CACHE_DISABLE:
			from utilities import disable_bdb_cache
			disable_bdb_cache()

		from applications import local_ali3dm_MPI
		global_def.BATCH = True
		if options.MPI:
			local_ali3dm_MPI(args[0], args[1], args[2], mask, options.ou, options.delta,options.ts, options.maxit, options.nassign, options.nrefine, options.CTF, options.snr, options.sym,options.function, options.fourvar, options.npad, options.debug, options.termprec)
		else:
			print 'ali3d_em serial version not implemented'

		global_def.BATCH = False
Exemple #18
0
def main():
	progname = os.path.basename(sys.argv[0])
	usage = progname + " out_averages outdir --ou=outer_radius --xr=x_range --ts=translation_step --maxit=max_iteration --CTF --snr=SNR --function=user_function_name --Fourvar --ali=kind_of_alignment --center=center_type"
	parser = OptionParser(usage,version=SPARXVERSION)
	parser.add_option("--ou",       type="int",        default=-1,             help="outer radius for rotational correlation < nx/2-1 (set to the radius of the particle)")
	parser.add_option("--xr",       type="string",       default="4 2",      help="range for translation search in x direction, search is +/xr ")
	parser.add_option("--ts",       type="string",       default="2 1", help="step of translation search in both directions")
	parser.add_option("--maxit",    type="float",        default=0,              help="maximum number of iterations (0 means the maximum iterations is 10, but it will automatically stop should the criterion falls")
	parser.add_option("--CTF",      action="store_true", default=False,          help="Consider CTF correction during the alignment ")
	parser.add_option("--snr",      type="float",        default=1.0,            help="signal-to-noise ratio of the data (set to 1.0)")
	parser.add_option("--Fourvar",  action="store_true", default=False,          help="compute Fourier variance")
	parser.add_option("--function", type="string",       default="ref_ali2d",    help="name of the reference preparation function")
	parser.add_option('--Ng',	type='int',		default=-1,		help='Ng')
	parser.add_option('--num_ali',	type='int',		default=2,		help='number of alignments')
	parser.add_option('--err_th',	type='float',		default=1.0,		help='')
	parser.add_option('--th_mir',	type='float',		default=0.5,		help='')
	parser.add_option('--th_err',	type='float',		default=1.0,		help='')
	parser.add_option('--K',        type='int',            default=100,             help='number of clusters')
	parser.add_option('--dst',	type='float',		default=0.0,		help='')
	parser.add_option("--center",   type="float",  default=-1,            help="-1.average center method; 0.not centered; 1.phase approximation; 2.cc with Gaussian function; 3.cc with donut-shaped image 4.cc with user-defined reference 5.cc with self-rotated average")
	parser.add_option("--CUDA",     action="store_true", default=False,          help="whether to use CUDA ")
	parser.add_option("--GPUID",      type="string",        default="",            help="the IDs of GPU to use")
	parser.add_option('--MPI',      action='store_true',   default=False,          help='MPI')
	parser.add_option('--old',      action='store_true',   default=False,          help='old')

	(options, args) = parser.parse_args()
	if options.old == False and len(args) != 3 or options.old and len(args) != 4:
    		print "usage: " + usage
    		print "Please run '" + progname + " -h' for detailed options"
	else:
		if global_def.CACHE_DISABLE:
			from utilities import disable_bdb_cache
			disable_bdb_cache()

		if options.MPI:
			from mpi import mpi_init
			sys.argv = mpi_init(len(sys.argv),sys.argv)

		global_def.BATCH = True
		if options.old:
			from development import realid
			realid(args[0], args[1], args[2], args[3], options.ou, options.xr, options.ts, options.maxit, options.function, options.snr, options.CTF, options.Fourvar, options.Ng, options.num_ali, options.th_mir, options.th_err, options.dst, options.center, options.CUDA, options.GPUID, options.MPI)
		else:
			from development import realignment
			realignment(args[0], args[1], args[2], options.ou, options.xr, options.ts, options.maxit, options.function, options.snr, options.CTF, options.Fourvar, options.Ng, options.num_ali, options.err_th, options.K, options.dst, options.center, options.CUDA, options.GPUID, options.MPI)
		global_def.BATCH = False
		
		if options.MPI:
			from mpi import mpi_finalize
			mpi_finalize()
Exemple #19
0
def main():
	progname = os.path.basename(sys.argv[0])
	usage = progname + " stack "
	parser = OptionParser(usage,version=global_def.SPARXVERSION)
	(options, args) = parser.parse_args(sys.argv[1:])
	if len(args) != 1 :
    		print "usage: " + usage
    		print "Please run '" + progname + " -h' for detailed options"
	else:
		if global_def.CACHE_DISABLE:
			from utilities import disable_bdb_cache
			disable_bdb_cache()
		from applications import wrapper_params_3D_to_2D
		global_def.BATCH = True
		wrapper_params_3D_to_2D(args[0])
		global_def.BATCH = False
Exemple #20
0
def main():
	progname = os.path.basename(sys.argv[0])
	usage = progname + " configure_file.cfg"
	
	parser = OptionParser(usage,version=SPARXVERSION)
	parser.add_option("--ir", type="float", default=1, help="  inner radius for rotational correlation (set to 1)")
	parser.add_option("--ou", type="float", default=-1, help="  outer radius for rotational correlation (set to the radius of the particle)")
	parser.add_option("--rs", type="float", default=1, help="  step between rings in rotational correlation (set to 1)" )
	parser.add_option("--xr", type="float", default=0, help="  range for translation search in x direction, search is +/-xr ")
	parser.add_option("--yr", type="float", default=-1, help="  range for translation search in y direction, search is +/-yr ")
	parser.add_option("--ts", type="float", default=1, help="  step of translation search in both directions")
	parser.add_option("--CTF", action="store_true", default=False, help=" Consider CTF correction during multiple reference assignment")
	parser.add_option("--CUDA", action="store_true", default=False, help=" whether to use CUDA")
	parser.add_option("--GPUID", type="string", default="0 1 2 3",  help=" the IDs of GPU to use")
	parser.add_option("--SA",   action="store_true", default=False,  help=" whether to use simulated annealing")
	parser.add_option("--T",   type="float",  default=0.001,  help=" the temperature of simulated annealing")
	parser.add_option("--F",   type="float",  default=0.995,  help=" the temperature cooling rate")
	parser.add_option("--heads_up",   action="store_true", default=False,  help=" whether to give a heads up")
	parser.add_option("--MPI", action="store_true", default=False, help="  whether to use MPI version ")

	(options, args) = parser.parse_args()
	if len(args) < 3 or len(args) > 4:
    		print "usage: " + usage
    		print "Please run '" + progname + " -h' for detailed options"
		sys.exit()
	
	if len(args) == 4:	mask = args[3]
	else:	mask = None

	if global_def.CACHE_DISABLE:
		from utilities import disable_bdb_cache
		disable_bdb_cache()

	if options.MPI:
		from mpi import mpi_init
		sys.argv = mpi_init(len(sys.argv),sys.argv)		
		
	from development import multi_assign
	global_def.BATCH = True
	multi_assign(args[0], args[1], args[2], mask, options.ir, options.ou, options.rs, options.xr, options.yr, options.ts,  
			options.CTF, options.CUDA, options.GPUID, options.SA, options.T, options.F, options.heads_up, options.MPI)
	global_def.BATCH = False

	if options.MPI:
		from mpi import mpi_finalize
		mpi_finalize()
Exemple #21
0
def main():
	import os
	import sys
	from optparse import OptionParser
	from global_def import SPARXVERSION
	import global_def
	arglist = []
	for arg in sys.argv:
		arglist.append( arg )

	progname = os.path.basename( arglist[0] )
	usage = progname + " stack --params='parm1 parm2 parm3 ...' --zero --one --set=number --randomize --rand_alpha --import=file --export=file --print --backup --suffix --restore --delete"
	parser = OptionParser(usage, version=SPARXVERSION)

	parser.add_option("--params",	   type="string",       default=None,    help="parameter list")
	parser.add_option("--zero",	       action="store_true", default=False,   help="set parameter to zero")
	parser.add_option("--one",	       action="store_true", default=False,   help="set parameter to one")
	parser.add_option("--set",	       type="float",        default=0.0,     help="set parameter to a value (different from 0.0)")
	parser.add_option("--randomize",   action="store_true", default=False,   help="set parameter to randomized value")
	parser.add_option("--rand_alpha",  action="store_true", default=False,   help="set all angles to randomized value")
	parser.add_option("--import",	   type="string",       dest="fimport",  default=None, help="import parameters from file")
	parser.add_option("--export",	   type="string",       dest="fexport",  default=None, help="export parameters to file")
	parser.add_option("--print",	   action="store_true", dest="fprint",   default=False, help="print parameters")
	parser.add_option("--backup",	   action="store_true", default=False,   help="backup parameters")
	parser.add_option("--suffix",	   type="string",       default="_backup",    help="suffix for xform name in backup")
	parser.add_option("--restore",     action="store_true", default=False,   help="restore parameters")
	parser.add_option("--delete",      action="store_true", default=False,   help="delete parameters")
	parser.add_option("--consecutive", action="store_true", default=False,   help="set selected parameter to consecutive integers starting from 0")

	(options,args) = parser.parse_args( arglist[1:] )

	if len(args) != 1 :
		print usage
		sys.exit(-1)

	if options.params == None:
		print "Error: no parameters given"
		exit(-1)

	if global_def.CACHE_DISABLE:
		from utilities import disable_bdb_cache
		disable_bdb_cache()
        from applications import header
	header(args[0], options.params, options.zero, options.one, options.set, options.randomize, options.rand_alpha, options.fimport, options.fexport, \
	options.fprint, options.backup, options.suffix, options.restore, options.delete, options.consecutive)
Exemple #22
0
def main():
	progname = os.path.basename(sys.argv[0])
	usage = progname + " stack <maskfile> --search_rng=10 --maxit=max_iteration --CTF --snr=SNR --Fourvar=Fourier_variance --oneDx --MPI"
	parser = OptionParser(usage,version=SPARXVERSION)
	parser.add_option("--search_rng",       type="int",           default=-1,      help="Search range for x-shift")
	parser.add_option("--search_ang",       type="int",           default=-1,      help="Search range for inplane rotation angle")
	parser.add_option("--search_rng_y",     type="int",           default=-1,      help="Search range for x-shift. Not used for 1D search (oneDx flag set).")
	parser.add_option("--maxit",            type="int",           default=100,     help="Maximum number of iterations program will perform")
	parser.add_option("--CTF",              action="store_true",  default=False,   help="Use CTF correction")
	parser.add_option("--snr",              type="float",         default=1.0,     help="signal-to-noise ratio of the data (default is 1.0)")
	parser.add_option("--Fourvar",          action="store_true",  default=False,   help="compute Fourier variance")
	parser.add_option("--oneDx",            action="store_true",  default=False,   help="1D search along x-axis")
	parser.add_option("--MPI",              action="store_true",  default=False,   help="use MPI")
	parser.add_option("--curvature",        action="store_true",  default=False,   help="for curved filament alignment")
	(options, args) = parser.parse_args()
	
	if not(options.MPI):
		print "Only MPI version is currently implemented."
		print "Please run '" + progname + " -h' for detailed options"
		return
			
	if len(args) < 1 or len(args) > 2:
		print "usage: " + usage
		print "Please run '" + progname + " -h' for detailed options"
	else:
	
		if len(args) == 1: mask = None
		else:              mask = args[1]
			
		if global_def.CACHE_DISABLE:
			from utilities import disable_bdb_cache
			disable_bdb_cache()
		
		from mpi import mpi_init
		sys.argv = mpi_init(len(sys.argv),sys.argv)

		global_def.BATCH = True
		if options.oneDx:
			helicalshiftali_MPI(args[0], mask, options.maxit, options.CTF, options.snr, options.Fourvar, options.search_rng)		
		else:
			shiftali_MPI(args[0], mask, options.maxit, options.CTF, options.snr, options.Fourvar,options.search_rng,options.oneDx,options.search_rng_y)
		global_def.BATCH = False
		
		from mpi import mpi_finalize
		mpi_finalize()
Exemple #23
0
def main():
	progname = os.path.basename(sys.argv[0])
	usage = progname + " stack_in  stack_out"
	parser = OptionParser(usage,version=SPARXVERSION)
	parser.add_option("--shift",		action="store_true",	 default=False,	      help="Apply only translation, disregard rotation, useful for centering of data (default False)")
	parser.add_option("--ignore_mirror",action="store_true",	 default=False,	      help="If centering data with CTF and astigmatism, use option ignore mirror (default False)")
	parser.add_option("--method",		type="string"      ,	 default="quadratic", help="Interpolation method (default linear)")
	(options, args) = parser.parse_args()
	if len(args) != 2:
    		print "usage: " + usage
    		print "Please run '" + progname + " -h' for detailed options"
	else:
		if global_def.CACHE_DISABLE:
			from utilities import disable_bdb_cache
			disable_bdb_cache()
		global_def.BATCH = True
		transform2d(args[0], args[1], options.shift, options.ignore_mirror, options.method)
		global_def.BATCH = False
def main():
	progname = os.path.basename(sys.argv[0])
	usage = progname + " input_stack output_stack average --avg --CTF"
	parser = OptionParser(usage,version=SPARXVERSION)
	parser.add_option("--avg", action="store_true", default=True, help="  Subtract averages computed within corners of individual images, default False")
	parser.add_option("--CTF", action="store_true", default=False, help="  Consider CTF correction during the alignment, dafault False")
	(options, args) = parser.parse_args()    	
	if len(args) != 3:
		print "usage: " + usage
		print "Please run '" + progname + " -h' for detailed options"
	else:
		if global_def.CACHE_DISABLE:
			from utilities import disable_bdb_cache
			disable_bdb_cache()
		from applications  import  prepare_2d_forPCA
		global_def.BATCH = True
		prepare_2d_forPCA(args[0], args[1], args[2], options.avg, options.CTF)
		global_def.BATCH = False
Exemple #25
0
def main():
	progname = os.path.basename(sys.argv[0])
	usage = progname + " volume ref_volume --discrepancy=ccc --ang_scale=angular range  --shift_scale=shift range  --mag_scale=magnification range --r=radius of a mask"
	parser = OptionParser(usage,version=SPARXVERSION)
	parser.add_option("--discrepancy", type="string", default="ccc", help="  Discrepancy measure used: ccc - crosscorrelation coefficient (default), SqEuclidean - Euclidean squared) ")
	parser.add_option("--ang_scale",    type='float', default=None, help="  Correct angles will be within +/- ang_scale of initial values")
	parser.add_option("--shift_scale",  type='float', default=None, help="  Correct shifts will be within +/- shift_scale of initial values")
	parser.add_option("--mag_scale",    type='float', default=None, help="  Correct magnification will be within +/- mag_scale of initial value")
	parser.add_option("--r",            type='float', default=None, help="  Radius of a spherical mask (nx/2-2)")
	(options, args) = parser.parse_args()    	

	if global_def.CACHE_DISABLE:
		from utilities import disable_bdb_cache
		disable_bdb_cache()

	if len(args) != 2:
		print "usage: " + usage
        	print "Please run '" + progname + " -h' for detailed options"
		exit(1)
	elif(options.ang_scale != None and options.shift_scale != None and options.mag_scale != None):
		from applications  import ali_vol_scale
		global_def.BATCH = True
		ali_vol_scale(args[0], args[1], options.ang_scale, options.shift_scale, options.mag_scale, options.r, options.discrepancy)
		global_def.BATCH = False
	elif(options.ang_scale is None and options.shift_scale is None and options.mag_scale != None):
		from applications  import ali_vol_only_scale
		global_def.BATCH = True
		ali_vol_only_scale(args[0], args[1], options.mag_scale, options.r, options.discrepancy)
		global_def.BATCH = False
	elif(options.ang_scale is None and options.shift_scale != None and options.mag_scale is None):
		from applications  import ali_vol_shift
		global_def.BATCH = True
		ali_vol_shift(args[0], args[1], options.shift_scale, options.r, options.discrepancy)
		global_def.BATCH = False
	elif(options.ang_scale != None and options.shift_scale != None and options.mag_scale is None):
		from applications  import ali_vol
		global_def.BATCH = True
		ali_vol(args[0], args[1], options.ang_scale, options.shift_scale, options.r, options.discrepancy)
		global_def.BATCH = False
	elif(options.ang_scale != None and options.shift_scale is None and options.mag_scale is None):
		from applications  import ali_vol_rotate
		global_def.BATCH = True
		ali_vol_rotate(args[0], args[1], options.ang_scale, options.r, options.discrepancy)
		global_def.BATCH = False
Exemple #26
0
def main():
	
	progname = os.path.basename(sys.argv[0])
	usage    = progname + " stack dendoname averages_name --K=number_of_groups"
	parser   = OptionParser(usage,version=SPARXVERSION)
	parser.add_option("--K", type="int", default=2, help="Number of classes (default 2)")
	
	(options, args) = parser.parse_args()
    	if len(args) != 3:
		print "usage: " + usage
		print "Please run '" + progname + " -h' for detailed options"
	else:
		if global_def.CACHE_DISABLE:
			from utilities import disable_bdb_cache
			disable_bdb_cache()
		from  applications  import  HAC_averages
		global_def.BATCH = True
		HAC_averages(args[0], args[1], args[2], options.K)
		global_def.BATCH = False
Exemple #27
0
def main():
	arglist = []
	for arg in sys.argv:
		arglist.append( arg )
	progname = os.path.basename(arglist[0])
	usage = progname + " stack ref_vol outdir --dp=rise --dphi=rotation --apix=pixel_size --phistep=phi_step --zstep=z_step --fract=helicising_fraction --rmax=maximum_radius --rmin=min_radius --CTF --sym=c1 --function=user_function --maxit=max_iter --MPI"
	parser = OptionParser(usage,version=SPARXVERSION)
	parser.add_option("--dp",       type="float",        default= 1.0,                help="delta z - translation in Angstroms")   
	parser.add_option("--dphi",     type="float",        default= 1.0,                help="delta phi - rotation in degrees")  
	parser.add_option("--apix",     type="float",        default= 1.84,               help="pixel size in Angstroms")
	parser.add_option("--rmin",     type="int",          default= 0,                  help="minimal radial extent of structure")   
	parser.add_option("--rmax",     type="int",          default= 70,                 help="maximal radial extent of structure")
	parser.add_option("--fract",    type="float",        default= 0.66,               help="fraction of the volume used for helical search")
	parser.add_option("--sym",      type="string",       default="c1",                help="symmetry of the structure")
	parser.add_option("--function", type="string",       default="helical",  	      help="name of the reference preparation function")
	parser.add_option("--zstep",    type="int",          default= 1,                  help="Step size for translational search along z")   
	parser.add_option("--CTF",      action="store_true", default=False,               help="CTF correction")
	parser.add_option("--maxit",    type="int",          default=5,                   help="maximum number of iterations performed")
	parser.add_option("--MPI",      action="store_true", default=False,               help="use MPI version")
	(options, args) = parser.parse_args(arglist[1:])
	if len(args) != 3:
		print "usage: " + usage
		print "Please run '" + progname + " -h' for detailed options"
	else:
		if options.MPI:
			from mpi import mpi_init, mpi_finalize
			sys.argv = mpi_init(len(sys.argv), sys.argv)
		else:
			print "There is only MPI version of sxfilrecons3d.py. See SPARX wiki page for downloading MyMPI details."
			sys.exit()
			
		if global_def.CACHE_DISABLE:
			from utilities import disable_bdb_cache
			disable_bdb_cache()

		from development import filrecons3D_MPI
		global_def.BATCH = True
		filrecons3D_MPI(args[0], args[1], args[2], options.dp, options.dphi, options.apix, options.function, options.zstep, options.fract, options.rmax, options.rmin,
		                options.CTF, options.maxit, options.sym)
		
		global_def.BATCH = False

		if options.MPI:  mpi_finalize()
Exemple #28
0
def main():

	progname = os.path.basename(sys.argv[0])
	usage = progname + " stackfile outdir  <maskfile> --K1=Min_number_of_Cluster --K2=Max_number_of_Clusters --opt_method=K-means_method --trials=Number_of_trials_of_K-means --CTF --rand_seed=1000 --maxit=Maximum_number_of_iterations --F=simulated_annealing --T0=simulated_annealing --MPI --CUDA --debug"
	parser = OptionParser(usage,version=SPARXVERSION)
	parser.add_option("--K1",          type="int",          default=2,          help="Mimimum number of clusters")
	parser.add_option("--K2",          type="int",          default=3,          help="Maximum number of clusters")
	parser.add_option("--trials",      type="int",          default=1,          help="Number of trials in K-means (default 1)")
	parser.add_option("--CTF",         action="store_true", default=False,      help="Perform clustering using CTF information")
	parser.add_option("--rand_seed",   type="int",          default=-1,         help="Random seed of initial (default random)" )
	parser.add_option("--maxit",       type="int",          default=100,        help="Mimimum number of iterations within K-means")
	#parser.add_option("--F",           type="float",        default=0.0,        help="Factor to decrease temperature in simulated annealing, ex.: 0.9")
	#parser.add_option("--T0",          type="float",        default=0.0,        help="Initial temperature in simulated annealing, ex: 100")
	parser.add_option("--MPI",         action="store_true", default=False,      help="Use MPI version")
	parser.add_option("--debug",       action="store_true", default=False,      help="Debug output")

	(options, args) = parser.parse_args()
	if len(args) < 2 or len(args) > 3:
				print "usage: " + usage
				print "Please run '" + progname + " -h' for detailed options"
	elif options.trials < 1:
			sys.stderr.write("ERROR: Number of trials should be at least 1.\n\n")
			sys.exit()
	
	else: 
		if len(args)==2: mask = None
		else:            mask = args[2]

		if options.K1 < 2:
			sys.stderr.write('ERROR: K1 must be > 1 group\n\n')
			sys.exit()

		if global_def.CACHE_DISABLE:
			from utilities import disable_bdb_cache
			disable_bdb_cache()
		from applications import k_means_groups
		global_def.BATCH = True
		k_means_groups(args[0], args[1], mask, "SSE", options.K1, options.K2, options.rand_seed, options.maxit, options.trials, options.CTF, 0.0, 0.0, options.MPI, False, options.debug)
		global_def.BATCH = False
		
		if options.MPI:
			from mpi import mpi_finalize
			mpi_finalize()
Exemple #29
0
def main():
	progname = os.path.basename(sys.argv[0])
	usage = progname + "  input_stack output_stack --subavg=average_image --rad=mask_radius --nvec=number_of_eigenvectors --incore --mask=maskfile --shuffle --usebuf --MPI"
	parser = OptionParser(usage, version=SPARXVERSION)
	parser.add_option("--subavg",  type="string",       default="",    help="subtract average")
	parser.add_option("--rad",     type="int",          default=-1,    help="radius of mask")
	parser.add_option("--nvec",    type="int",          default=1,     help="number of eigenvectors")
	parser.add_option("--mask",    type="string",       default="",    help="mask file" )
	parser.add_option("--genbuf",  action="store_true", default=False, help="use existing buffer")
	parser.add_option("--shuffle", action="store_true", default=False, help="use shuffle")
	parser.add_option("--incore",  action="store_true", default=False, help="no buffer on a disk" )
	parser.add_option("--MPI",     action="store_true", default=False, help="run mpi version" )

	(options, args) = parser.parse_args()

	input_stacks = args[0:-1]
	output_stack = args[-1]

	if options.nvec is None:
		print "Error: number of components is not given"
		sys.exit(-2) 

	isRoot = True
	if options.MPI:
		from mpi import mpi_init, mpi_comm_rank, MPI_COMM_WORLD
		sys.argv = mpi_init( len(sys.argv), sys.argv )
		isRoot = (mpi_comm_rank(MPI_COMM_WORLD) == 0)
		
	if global_def.CACHE_DISABLE:
		from utilities import disable_bdb_cache
		disable_bdb_cache()
	from applications import pca
	global_def.BATCH = True
	vecs = []
	vecs = pca(input_stacks, options.subavg, options.rad, options.nvec, options.incore, options.shuffle, not(options.genbuf), options.mask, options.MPI)
	if isRoot:
		for i in xrange(len(vecs)):
			vecs[i].write_image(output_stack, i)
	
	global_def.BATCH = False
        if options.MPI:
		from mpi import mpi_finalize
		mpi_finalize()
Exemple #30
0
def main():
	progname = os.path.basename(sys.argv[0])
	usage = progname + " tifdir <micdir> --inx=tif --foc=f --ext=spi --cst=1 pixel_size=2 --sca_a=1 --sca_b=1 --step=63.5 --mag=40 --MPI"
	parser = OptionParser(usage,version=SPARXVERSION)
	parser.add_option("--inx",        type = "string", default="tif", help =" input extension ")
	parser.add_option("--foc",        type = "string", default="f",   help =" film or CCD frames ")
	parser.add_option("--ext",        type = "string", default="spi", help =" extenstion of output file")
	parser.add_option("--cst",        type = "float",  default=1,     help =" contrast invert or not, -1=invert ")
	parser.add_option("--pixel_size", type = "float",  default=1,     help =" the dimension adjusted output image pixel size")
	parser.add_option("--sca_a",      type = "float",  default=1,     help =" scanner OD converting parameter a, check manual of the scanner ")
	parser.add_option("--sca_b",      type = "float",  default=1,     help =" scanner OD converting parameter b, check manual of the scanner ")
	parser.add_option("--step",       type = "float",  default=63.5,  help =" scan step size of scanner or CCD camera ")
 	parser.add_option("--mag",        type = "float",  default=40,    help =" magnification at which the images are taken ")		
	parser.add_option("--MPI", action="store_true", default=False,     help="  whether using MPI version ")
	(options, args) = parser.parse_args()    	
    	if len(args) < 1:
        	print "usage: "      + usage
        	print "Please run '" + progname + " -h' for detailed options"
	else:
	
		if len(args) == 1: 
			outdir = None
		else:
			outdir = args[1]

		from applications import copyfromtif

		if global_def.CACHE_DISABLE:
			from utilities import disable_bdb_cache
			disable_bdb_cache()

		if options.MPI:
			from mpi import mpi_init
			sys.argv = mpi_init(len(sys.argv),sys.argv)		

		global_def.BATCH = True

		copyfromtif(args[0], outdir, options.inx, options.foc, options.ext, options.cst, options.pixel_size, options.sca_a, options.sca_b, options.step, options.mag, options.MPI)
		global_def.BATCH = False
		
		if options.MPI:
			from mpi import mpi_finalize
			mpi_finalize()
Exemple #31
0
def main():
	progname = os.path.basename(sys.argv[0])
	usage = progname + " configure_file.cfg"

	parser = OptionParser(usage,version=SPARXVERSION)
	(options, args) = parser.parse_args()

	if len(args) != 1:
    		print "usage: " + usage
    		print "Please run '" + progname + " -h' for detailed options"
		sys.exit()

	if global_def.CACHE_DISABLE:
		from utilities import disable_bdb_cache
		disable_bdb_cache()

	from development import ali2d_mref
	global_def.BATCH = True
	ali2d_mref(args[0])
	global_def.BATCH = False