def main(): progname = os.path.basename(sys.argv[0]) usage = progname + """ [options] <movie.mrcs> Run p3ctf.py on cluster. Needs: 'ctffind' command (v4.0.16, Rohou & Grigorieff, 2015) """ args_def = {'apix':1.25, 'voltage':200, 'cs':2, 'ac':0.1, 'dpsize':5} parser = argparse.ArgumentParser() parser.add_argument("image", nargs='*', help="specify images to be processed") parser.add_argument("-a", "--apix", type=float, help="specify apix, by default {}".format(args_def['apix'])) parser.add_argument("-v", "--voltage", type=int, help="specify the voltage (kV), by default {}".format(args_def['voltage'])) parser.add_argument("-c", "--cs", type=float, help="specify spherical abberration, by default {}".format(args_def['cs'])) parser.add_argument("-ac", "--ac", type=float, help="specify amplitude contrast, by default {}".format(args_def['ac'])) parser.add_argument("-d", "--dpsize", type=float, help="specify detector pixel size (um), by default {}".format(args_def['dpsize'])) args = parser.parse_args() if len(sys.argv) == 1: print "usage: " + usage print "Please run '" + progname + " -h' for detailed options." sys.exit(1) # get default values for i in args_def: if args.__dict__[i] == None: args.__dict__[i] = args_def[i] # loop over all the input images walltime, cpu, ptile = 1, 1, 1 option = '-a {} -v {} -c {} -ac {} -d {}'.format(args.apix, args.voltage, args.cs, args.ac, args.dpsize) for image in args.image: basename = os.path.basename(os.path.splitext(image)[0]) cmd = "p3ctf.py {} {}".format(image, option) p3c.ada(cmd, basename, walltime, cpu, ptile)
def main(): progname = os.path.basename(sys.argv[0]) usage = progname + """ [options] <_data.star> Reconstruct from randomly selected particles from _data.star. Needs: relion (v1.4, Scheres, 2012) """ args_def = {'repeat':1000, 'apix':1.25, 'maxres':6, 'walltime':1} parser = argparse.ArgumentParser() parser.add_argument("star", nargs='*', help="specify _data.star") parser.add_argument("-r", "--repeat", type=int, help="specify how many times you want to repeat the experiment (reconstruct from random particles), by default {}".format(args_def['repeat'])) parser.add_argument("-a", "--apix", type=float, help="specify the apix, by default {}".format(args_def['apix'])) parser.add_argument("-m", "--maxres", type=float, help="specify maximum resolution (in Angstrom) to consider in Fourier space, by default {}".format(args_def['maxres'])) parser.add_argument("-w", "--walltime", type=int, help="specify the walltime (in hour), by default {}".format(args_def['walltime'])) args = parser.parse_args() if len(sys.argv) == 1: print "usage: " + usage print "Please run '" + progname + " -h' for detailed options." sys.exit(1) # get default values for i in args_def: if args.__dict__[i] == None: args.__dict__[i] = args_def[i] # repeat star = args.star[0] star_dict = p3s.star_parse(star, 'data_images') header = star_dict['data_'] + star_dict['loop_'] for i in xrange(args.repeat): # root name for output out = star[:-10] + '_repeat{:05}'.format(i) # check if output exists if os.path.isfile(out+'.mrc'): continue # write a new random data.star with open(star) as s_read: lines = s_read.readlines()[len(header):-1] l_len = len(lines) new_star = star[:-10] + '_repeat{:05}_data.star'.format(i) with open(new_star, 'w') as s_write: s_write.write(''.join(header)) # randomly select for l_len times for j in xrange(l_len): k = random.randint(0,l_len-1) s_write.write(lines[k]) s_write.write('\n') # write and submit the job cmd = "`which relion_reconstruct` --i {} --o {} --angpix {} --maxres {} --ctf true".format(new_star, out+'.mrc', args.apix, args.maxres) walltime, cpu, ptile = args.walltime, 1, 1 p3c.ada(cmd, out, walltime, cpu, ptile)
def main(): progname = os.path.basename(sys.argv[0]) usage = progname + """ [options] <*.pdb> Run rosetta. """ args_def = {'repeat':100, 'resolution':4, 'rosetta3':'/scratch/user/kailuyang/compile/rosetta_bin_linux_2015.39.58186_bundle/main'} parser = argparse.ArgumentParser() parser.add_argument("pdb", nargs='*', help="specify pdb to be processed") parser.add_argument("-r", "--repeat", type=int, help="specify repeat, by default {}".format(args_def['repeat'])) parser.add_argument("-re", "--resolution", type=float, help="specify reslution, by default {}".format(args_def['resolution'])) parser.add_argument("-r3", "--rosetta3", type=str, help="specify rosetta3, by default {}".format(args_def['rosetta3'])) args = parser.parse_args() if len(sys.argv) == 1: print "usage: " + usage print "Please run '" + progname + " -h' for detailed options." sys.exit(1) # get default values for i in args_def: if args.__dict__[i] == None: args.__dict__[i] = args_def[i] # loop over input pdbs for i in args.pdb: basename = os.path.basename(os.path.splitext(i)[0]) for j in xrange(args.repeat): out = '{}_repeat{:04}'.format(basename, j) with open('{}.sh'.format(out), 'w') as write_sh: write_sh.write('ROSETTA3={}\n'.format(args.rosetta3)) write_sh.write('$ROSETTA3/source/bin/rosetta_scripts.linuxgccrelease \\\n') write_sh.write(' -database $ROSETTA3/database/ \\\n') write_sh.write(' -in::file::s {} \\\n'.format(i)) write_sh.write(' -parser::protocol refine.xml \\\n') write_sh.write(' -parser::script_vars denswt=25 rms=1.5 reso={} map={}.mrc testmap={}.mrc \\\n'.format(args.resolution, basename, basename)) write_sh.write(' -ignore_unrecognized_res \\\n') write_sh.write(' -edensity::mapreso {} \\\n'.format(args.resolution)) write_sh.write(' -default_max_cycles 200 \\\n') write_sh.write(' -edensity::cryoem_scatterers \\\n') write_sh.write(' -out::suffix _{} \\\n'.format(out)) write_sh.write(' -crystal_refine\n') # submit to cluster cmd = 'sh {}.sh'.format(out) walltime, cpu, ptile = 1, 1, 1 p3c.ada(cmd, out, walltime, cpu, ptile)
def main(): progname = os.path.basename(sys.argv[0]) usage = progname + """ [options] <f.txt> Run p3movie.py to process movies listed in f.txt, and the movies will be deleted to save space. """ args_def = {'apix':1.25, 'voltage':200, 'time':200, 'rate':8, 'save':'0 0 0', 'xsuper':7420, 'scale':1, 'delete':1} parser = argparse.ArgumentParser() parser.add_argument("f", nargs='*', help="specify the txt file used for p3download.py") parser.add_argument("-a", "--apix", type=float, help="specify counting apix before scaling, by default {}".format(args_def['apix'])) parser.add_argument("-v", "--voltage", type=int, help="specify the voltage (kV), by default {}".format(args_def['voltage'])) parser.add_argument("-t", "--time", type=float, help="specify exposure time per frame in ms, by default {}".format(args_def['time'])) parser.add_argument("-r", "--rate", type=float, help="specify dose rate in e/pix/s (counting pixel, not superresolution), by default {}. if specified as 0, no filtered sum will be output".format(args_def['rate'])) parser.add_argument("-s", "--save", type=str, help="save a specified number of aligned frames, by default '{}', which means do not save. e.g., '0 19 4' means the saved movie starts from frame #0, ends at #19, in total (19-0+1)/4 = 5 frames. if 19 >= the real number of frames of the movie, skip".format(args_def['save'])) parser.add_argument("-x", "--xsuper", type=int, help="specify the x dimension of superresolution images, by default {}".format(args_def['xsuper'])) parser.add_argument("-sc", "--scale", type=float, help="specify the down scaling factor, by default {}. e.g., 1.2 means counting images will be downscaled by 1.2 times, superresolution 2.4".format(args_def['scale'])) parser.add_argument("-d", "--delete", type=int, help="delete (!!!) the raw movie (specify as 1), by default {}, which means do not delete".format(args_def['delete'])) args = parser.parse_args() if len(sys.argv) == 1: print "usage: " + usage print "Please run '" + progname + " -h' for detailed options." sys.exit(1) # get default values for i in args_def: if args.__dict__[i] == None: args.__dict__[i] = args_def[i] # import import pat3dem.cluster as p3c # get the local file list based on f.txt f = args.f[0] f2 = f + '.p3movie' with open(f) as f_r: lines = f_r.readlines() with open(f2, 'w') as f2_w: for i in lines: j = './' + i.replace('\\','/').split('/')[-1] f2_w.write(j) with open(f2) as f2_r: lines = f2_r.readlines() # run line #i if line #(i+1) exists, the last line will be ignored walltime, cpu, ptile = 1, 1, 1 option = "-a {} -v {} -t {} -r {} -s '{}' -x {} -sc {} -d {}".format(args.apix, args.voltage, args.time, args.rate, args.save, args.xsuper, args.scale, args.delete) for i, l in enumerate(lines[:-1]): l = l.strip() l2 = lines[i+1].strip() while not os.path.isfile(l2): time.sleep(60) # submit the job, the option '-d 1' means delete the raw movie!!! cmd = "p3movie.py {} {}".format(l, option) basename = os.path.basename(os.path.splitext(l)[0]) p3c.ada(cmd, basename, walltime, cpu, ptile) # process the last one last = lines[-1].strip() size = os.path.getsize(last) time.sleep(30) size_new = os.path.getsize(last) while size_new > size: size = size_new time.sleep(30) size_new = os.path.getsize(last) cmd = "p3movie.py {} {}".format(last, option) basename = os.path.basename(os.path.splitext(last)[0]) p3c.ada(cmd, basename, walltime, cpu, ptile)