def main(): parser = argparse.ArgumentParser( formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument("-i", "--input", type=str, help="Particle star file") parser.add_argument("-o", "--output", type=str, help="Output directory", default=None) parser.add_argument("-cols", "--columns", type=str, help="Columns to copy", nargs='*', default=None) args = parser.parse_args() # Prepare args dict args_dict = { 'input': args.input, 'output': args.output, 'columns': args.columns } # Check if the input file exists if args_dict['input'] is None or not os.path.isfile(args_dict['input']): parser.print_help() sys.exit('Input file does not exist!') # Get the new column parameters if args_dict['columns'] is not None: new_column_parameters = util.parse_star_parameters( args_dict['columns']) else: new_column_parameters = None # Create an EM project object new_project = em.Project(name='EMRenameColumns') new_project.set_output_directory(args_dict['output'], project_root='.') # Write parameters to args filename args_filename = new_project.output_directory + '/args.yaml' util.write_config_file(args_filename, args_dict) # Read particles new_project.read_particles(args_dict['input']) print('Read particle star file {}'.format(args_dict['input'])) # Prepare input and output files new_project.prepare_io_files_star() # Add new columns new_project.rename_columns(new_column_parameters) # Write output files new_project.write_output_files(write_ref_class_star=False)
def main(): parser = argparse.ArgumentParser( formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument("-i", "--input", type=str, help="Particle star file") parser.add_argument("-n", "--numptcls", type=int, help="Number of ptcls in the subset", default=100000) parser.add_argument("-r", "--randseed", type=int, help="Random seed", default=1) parser.add_argument("-o", "--output", type=str, help="Output directory", default=None) args = parser.parse_args() # Prepare args dict args_dict = { 'input': args.input, 'numptcls': args.numptcls, 'randseed': args.randseed, 'output': args.output } # Check if the input file exists if args_dict['input'] is None or not os.path.isfile(args_dict['input']): parser.print_help() sys.exit('Input file does not exist!') # Create an EM project object new_project = em.Project(name='EMSubset') new_project.set_output_directory(args_dict['output'], project_root='.') # Write parameters to args filename args_filename = new_project.output_directory + '/args.yaml' util.write_config_file(args_filename, args_dict) # Read particles new_project.read_particles(args_dict['input']) print('Read particle star file {}'.format(args_dict['input'])) # Prepare input and output files new_project.prepare_io_files_star() # Add new columns new_project.pick_random_set(args_dict['numptcls'], args_dict['randseed']) # Write output files new_project.write_output_files()
def main(): parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument("-i", "--input", type=str, help="Particle star file") parser.add_argument("-o", "--output", type=str, help="Output directory", default=None) parser.add_argument("-ref", "--reference", type=str, help="Reference class star file") parser.add_argument("-cols", "--columns", type=str, help="Columns to copy", nargs='+') parser.add_argument("-comp", "--compare", type=str, help="Criteria to compare", choices=['img','mic'], default='img') args = parser.parse_args() # Prepare args dict args_dict = {'input': args.input, 'output': args.output, 'reference': args.reference, 'columns': args.columns, 'compare': args.compare } # Check if the input file exists if args_dict['input'] is None or not os.path.isfile(args_dict['input']): parser.print_help() sys.exit('Input file does not exist!') # Check if the reference file exists if args_dict['reference'] is None and not os.path.isfile(args_dict['reference']): parser.print_help() sys.exit('Reference file file does not exist!') # Create an EM project object new_project = em.Project(name='EMCopy') new_project.set_output_directory(args_dict['output'], project_root='.') # Write parameters to args filename args_filename = new_project.output_directory+'/args.yaml' util.write_config_file(args_filename, args_dict) # Read particles new_project.read_particles(args_dict['input']) print('Read particle star file {}'.format(args_dict['input'])) new_project.read_class_refs(args_dict['reference']) print('Read class reference file {}'.format(args_dict['reference'])) # Prepare input and output files new_project.prepare_io_files_star() # Add new columns new_project.copy_from_ref(args_dict['columns'], args_dict['compare']) # Write output files new_project.write_output_files(write_ref_class_star=False)
def main(): parser = argparse.ArgumentParser( formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument("-i", "--input", type=str, help="Particle star file") parser.add_argument("-o", "--output", type=str, help="Output directory", default=None) parser.add_argument("-offsetrot", "--offsetrot", type=float, help="Rotation offset", default=0) args = parser.parse_args() # Prepare args dict args_dict = { 'input': args.input, 'output': args.output, 'offsetrot': args.offsetrot } # Check if the input file exists if args_dict['input'] is None or not os.path.isfile(args_dict['input']): parser.print_help() sys.exit('Input file does not exist!') # Create an EM project object new_project = em.Project(name='EMApplyBarcode') new_project.set_output_directory(args_dict['output'], project_root='.') # Write parameters to args filename args_filename = new_project.output_directory + '/args.yaml' util.write_config_file(args_filename, args_dict) # Read particles new_project.read_particles(args_dict['input']) print('Read particle star file {}'.format(args_dict['input'])) # Prepare input and output files new_project.prepare_io_files_star() # Add new columns new_project.apply_barcode(args_dict['offsetrot']) # Write output files new_project.write_output_files(write_ref_class_star=False)
def main(): parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument("-i", "--input", type=str, nargs='+', help="Star file(s)") parser.add_argument("-o", "--output", type=str, help="Output directory", default=None) args = parser.parse_args() # Prepare args dict args_dict = {'input': args.input, 'output': args.output } # Check if the input file exists if args_dict['input'] is None: parser.print_help() sys.exit('Input file does not exist!') # Create an EM project object new_project = em.Project(name='EMMergeStar') new_project.set_output_directory(args_dict['output'], project_root='.') # Write parameters to args filename args_filename = new_project.output_directory+'/args.yaml' util.write_config_file(args_filename, args_dict) # Read particles new_project.read_particle_stars(args_dict['input']) print('Read particle star files {}'.format(','.join(args_dict['input']))) # Prepare input and output files new_project.prepare_io_files_star() # Write output files new_project.write_output_files()
def main(): parser = argparse.ArgumentParser( formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument("-i", "--input", type=str, help="Particle cs file") parser.add_argument("-ref", "--reference", type=str, help="Template cs file", default=None) parser.add_argument("-pass", "--passthrough", type=str, help="Passthrough cs file from cryosparc", default=None) parser.add_argument("-o", "--output", type=str, help="Output directory", default=None) parser.add_argument("-orig", "--original", type=str, help="Original star file", default=None) parser.add_argument("-micpath", "--micpath", type=str, help="Micrographs path", default="Micrographs") parser.add_argument("-projpath", "--projpath", type=str, help="Cryosparc project path", default="") parser.add_argument("-delclass", "--delclass", type=int, nargs='+', help="Classes to delete", default=[]) parser.add_argument("-delstr", "--delstr", type=str, help="String to delete from Micrograph name", default='') parser.add_argument("-restore-offsets", "--restoreoffsets", action='store_true', help="Restore offsets from original star file") parser.add_argument("-merge-orig", "--mergeoriginal", action='store_true', help="Merge with original star file") args = parser.parse_args() # Prepare args dict args_dict = { 'input': args.input, 'reference': args.reference, 'passthrough': args.passthrough, 'output': args.output, 'original': args.original, 'micpath': args.micpath, 'projpath': args.projpath, 'delclass': args.delclass, 'delstr': args.delstr, 'restoreoffsets': args.restoreoffsets, 'mergeoriginal': args.mergeoriginal } # Check if the input file exists if args_dict['input'] is None or not os.path.isfile(args_dict['input']): parser.print_help() sys.exit('Input file does not exist!') # Create an EM project object new_project = em.Project(name='EMcsparc2star') new_project.set_output_directory(args_dict['output'], project_root='.') # Write parameters to args filename args_filename = new_project.output_directory + '/args.yaml' util.write_config_file(args_filename, args_dict) # Set cs files new_project.set_cs_files(blob_cs_file=args_dict['input'], passthrough_cs_file=args_dict['passthrough'], original_star_file=args_dict['original'], ref_class_cs_file=args_dict['reference']) # Read cs files new_project.read_cs_files() # Prepare input and output files new_project.prepare_io_files_cs() # Conert cs to star new_project.convert_cs2star(args_dict['micpath'], args_dict['projpath'], args_dict['delclass'], args_dict['delstr'], args_dict['restoreoffsets'], args_dict['mergeoriginal']) # Write output files new_project.write_output_files()
def main(): parser = argparse.ArgumentParser( formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument("-i", "--input", type=str, help="Particle star file") parser.add_argument("-o", "--output", type=str, help="Output directory", default=None) parser.add_argument("-selbarcode", "--selbarcode", type=str, help="Barcode to select", nargs='*', default={}) parser.add_argument("-delbarcode", "--delbarcode", type=str, help="Barcode to delete", nargs='*', default={}) args = parser.parse_args() # Prepare args dict args_dict = { 'input': args.input, 'output': args.output, 'selbarcode': args.selbarcode, 'delbarcode': args.delbarcode } # Check if the input file exists if args_dict['input'] is None or not os.path.isfile(args_dict['input']): parser.print_help() sys.exit('Input file does not exist!') # Create an EM project object new_project = em.Project(name='EMSelectBarcode') new_project.set_output_directory(args_dict['output'], project_root='.') # Write parameters to args filename args_filename = new_project.output_directory + '/args.yaml' util.write_config_file(args_filename, args_dict) # Read particles new_project.read_particles(args_dict['input']) print('Read particle star file {}'.format(args_dict['input'])) # Prepare input and output files new_project.prepare_io_files_star() # Select barcode new_project.select_by_barcode(args_dict['selbarcode']) # Delete barcode new_project.delete_by_barcode(args_dict['delbarcode']) # Write output files new_project.write_output_files(write_ref_class_star=False)
def main(): parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument("-i", "--input", type=str, help="Particle star file") parser.add_argument("-o", "--output", type=str, help="Output directory", default=None) parser.add_argument("-copytopriors", "--copypriors", action='store_true', help="Copy offset and/or angle parameters to priors", default=True) parser.add_argument("-copytooffsets", "--copyoffsets", action='store_true', help="Copy priors to angle and distance offset parameters") parser.add_argument("-fliponly", "--fliponly", action='store_true', help="Set only flip ratio to 0") parser.add_argument("-fliprot", "--fliprot", action='store_true', help="Set flip ratio to 0 and delete rlnAngleRotPrior") args = parser.parse_args() # Prepare args dict args_dict = {'input': args.input, 'output': args.output, 'copypriors': args.copypriors, 'copyoffsets': args.copyoffsets, 'fliponly': args.fliponly, 'fliprot': args.fliprot } # Check if the input file exists if args_dict['input'] is None or not os.path.isfile(args_dict['input']): parser.print_help() sys.exit('Input file does not exist!') # Copy offsets to priors overwrites if args_dict['copypriors']: add_column_parameters = {'rlnAngleTilt':90, 'rlnAngleTiltPrior':90, 'rlnAnglePsiFlipRatio':0} del_column_parameters = {'rlnAngleRotPrior':None} copy_column_parameters = {'rlnOriginX': 'rlnOriginXPrior', 'rlnOriginY': 'rlnOriginYPrior', 'rlnAnglePsi': 'rlnAnglePsiPrior', 'rlnAngleTilt':'rlnAngleTiltPrior'} if args_dict['copyoffsets']: add_column_parameters = {} del_column_parameters = {} copy_column_parameters = {'rlnOriginXPrior': 'rlnOriginX', 'rlnOriginYPrior': 'rlnOriginY', 'rlnAnglePsiPrior': 'rlnAnglePsi', 'rlnAngleTiltPrior':'rlnAngleTilt'} if args_dict['fliponly']: add_column_parameters = {'rlnAnglePsiFlipRatio':0} del_column_parameters = {} copy_column_parameters = {} if args_dict['fliprot']: add_column_parameters = {'rlnAnglePsiFlipRatio':0} del_column_parameters = {'rlnAngleRotPrior':None} copy_column_parameters = {} # Create an EM project object new_project = em.Project(name='EMHelixReady') new_project.set_output_directory(args_dict['output'], project_root='.') # Write parameters to args filename args_filename = new_project.output_directory+'/args.yaml' util.write_config_file(args_filename, args_dict) # Read particles new_project.read_particles(args_dict['input']) print('Read particle star file {}'.format(args_dict['input'])) # Prepare input and output files new_project.prepare_io_files_star() # Delete columns new_project.delete_columns(del_column_parameters) # Add new columns new_project.add_columns(add_column_parameters) # Add new columns new_project.copy_columns(copy_column_parameters) # Write output files new_project.write_output_files(write_ref_class_star=False)
def main(): parser = argparse.ArgumentParser( formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument("-i", "--input", type=str, help="Particle star file") parser.add_argument("-o", "--output", type=str, help="Output directory", default=None) parser.add_argument("-Zflip", "--Zflip", action='store_true', help="Z-Flip particles in star file") parser.add_argument("-tilt90", "--tilt90", action='store_true', help="Set tilt of particles to 90-degree side") parser.add_argument("-aligntopriors", "--aligntopriors", type=str, nargs='*', default=None) args = parser.parse_args() # Prepare args dict args_dict = { 'input': args.input, 'Zflip': args.Zflip, 'tilt90': args.tilt90, 'output': args.output, 'aligntopriors': args.aligntopriors } # Check if the input file exists if args_dict['input'] is None or not os.path.isfile(args_dict['input']): parser.print_help() sys.exit('Input file does not exist!') # Create an EM project object new_project = em.Project(name='EMRotate') new_project.set_output_directory(args_dict['output'], project_root='.') # Write parameters to args filename args_filename = new_project.output_directory + '/args.yaml' util.write_config_file(args_filename, args_dict) # Read particles new_project.read_particles(args_dict['input']) print('Read particle star file {}'.format(args_dict['input'])) # Prepare input and output files new_project.prepare_io_files_star() # Make tilt angle around 90 degree if args_dict['tilt90']: new_project.tilt90_particles() # Z-flip particles if args_dict['Zflip']: new_project.Zflip_particles() # Align to priors if args_dict['aligntopriors'] is not None: new_project.align_to_priors(args_dict['aligntopriors']) # Write output files new_project.write_output_files()
def main(): parser = argparse.ArgumentParser( formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument("-i", "--input", type=str, help="Particle star file") parser.add_argument("-o", "--output", type=str, help="Output directory", default=None) parser.add_argument("-cols", "--columns", type=str, help="Columns to copy", nargs='*', default=None) parser.add_argument("-copytopriors", "--copypriors", type=str, help="Copy offset and/or angle parameters to priors", default=None, choices=['angle', 'all', 'helix']) parser.add_argument( "-copytooffsets", "--copyoffsets", type=str, help="Copy priors to angle and distance offset parameters", default=None, choices=['angle', 'all', 'helix']) parser.add_argument("-reset-priors", "--resetpriors", action='store_true', help="Delete prior offset and angle columngs") parser.add_argument("-reset-offsets", "--resetoffsets", action='store_true', help="Assign angle and origin offsets to 0") parser.add_argument("-invert-psi", "--invertpsi", action='store_true', help="Invert psi angle") parser.add_argument("-invert-origin", "--invertorigin", action='store_true', help="Invert originX and originY") args = parser.parse_args() # Prepare args dict args_dict = { 'input': args.input, 'output': args.output, 'columns': args.columns, 'copypriors': args.copypriors, 'copyoffsets': args.copyoffsets, 'resetpriors': args.resetpriors, 'resetoffsets': args.resetoffsets, 'invertpsi': args.invertpsi, 'invertorigin': args.invertorigin } # Check if the input file exists if args_dict['input'] is None or not os.path.isfile(args_dict['input']): parser.print_help() sys.exit('Input file does not exist!') # Get the new column parameters if args_dict['columns'] is not None: new_column_parameters = util.parse_star_parameters( args_dict['columns']) else: new_column_parameters = None # Copy offsets to priors overwrites if args_dict['copypriors'] == 'all': new_column_parameters = { 'rlnOriginX': 'rlnOriginXPrior', 'rlnOriginY': 'rlnOriginYPrior', 'rlnAnglePsi': 'rlnAnglePsiPrior', 'rlnAngleRot': 'rlnAngleRotPrior', 'rlnAngleTilt': 'rlnAngleTiltPrior' } elif args_dict['copypriors'] == 'angle': new_column_parameters = { 'rlnAnglePsi': 'rlnAnglePsiPrior', 'rlnAngleRot': 'rlnAngleRotPrior', 'rlnAngleTilt': 'rlnAngleTiltPrior' } elif args_dict['copypriors'] == 'helix': new_column_parameters = { 'rlnOriginX': 'rlnOriginXPrior', 'rlnOriginY': 'rlnOriginYPrior', 'rlnAnglePsi': 'rlnAnglePsiPrior', 'rlnAngleTilt': 'rlnAngleTiltPrior' } # Copy priors to offsets overwrites if args_dict['copyoffsets'] == 'all': new_column_parameters = { 'rlnOriginXPrior': 'rlnOriginX', 'rlnOriginYPrior': 'rlnOriginY', 'rlnAnglePsiPrior': 'rlnAnglePsi', 'rlnAngleRotPrior': 'rlnAngleRot', 'rlnAngleTiltPrior': 'rlnAngleTilt' } elif args_dict['copyoffsets'] == 'angle': new_column_parameters = { 'rlnAnglePsiPrior': 'rlnAnglePsi', 'rlnAngleRotPrior': 'rlnAngleRot', 'rlnAngleTiltPrior': 'rlnAngleTilt' } elif args_dict['copyoffsets'] == 'helix': new_column_parameters = { 'rlnOriginXPrior': 'rlnOriginX', 'rlnOriginYPrior': 'rlnOriginY', 'rlnAnglePsiPrior': 'rlnAnglePsi', 'rlnAngleTiltPrior': 'rlnAngleTilt' } # Create an EM project object new_project = em.Project(name='EMCopyColumns') new_project.set_output_directory(args_dict['output'], project_root='.') # Write parameters to args filename args_filename = new_project.output_directory + '/args.yaml' util.write_config_file(args_filename, args_dict) # Read particles new_project.read_particles(args_dict['input']) print('Read particle star file {}'.format(args_dict['input'])) # Prepare input and output files new_project.prepare_io_files_star() # If reset priors option is ON if args_dict['resetpriors']: new_project.reset_priors() # If reset offset option is on if args_dict['resetoffsets']: new_project.reset_offsets() # If invert-psi option is on if args_dict['invertpsi']: new_project.invert_psi() # If invert-origin if args_dict['invertorigin']: new_project.invert_origin() # Add new columns new_project.copy_columns(new_column_parameters) # Write output files new_project.write_output_files(write_ref_class_star=False)
def main(): parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument("-i", "--input", type=str, help="Particle star file") parser.add_argument("-o", "--output", type=str, help="Output directory", default=None) parser.add_argument("-ref", "--reference", type=str, help="Reference class star file", default=None) parser.add_argument("-newclassid", "--newclassid", action='store_true', help="Create new class ids for the reference file") parser.add_argument("-addcols", "--addcolumns", type=str, help="Add new columns with same value for all particles", nargs='*', default=None) parser.add_argument("-recenter", "--recenter", action='store_true', help="Recenter particles") parser.add_argument("-offset", "--offset", nargs=2, type=float, default=[0, 0], help="Final offset") parser.add_argument("-offsetcom", "--offsetcom", action='store_true', help="Set final offset from center-of-mass") parser.add_argument("-apix", "--apix", type=float, help="Micrograph pixel size", default=1.82) parser.add_argument("-rotatepsi", "--rotatepsi", type=float, help="Rotate psi by angle", default=0) parser.add_argument("-flipX", "--flipX", action='store_true', help='Modify star file for flip around X axis') args = parser.parse_args() # Prepare args dict args_dict = {'input': args.input, 'output': args.output, 'reference': args.reference, 'addcolumns': args.addcolumns, 'recenter': args.recenter, 'newclassid': args.newclassid, 'apix': args.apix, 'offset': args.offset, 'offsetcom': args.offsetcom, 'rotatepsi': args.rotatepsi, 'flipX': args.flipX } # Check if the input file exists if args_dict['input'] is None or not os.path.isfile(args_dict['input']): parser.print_help() sys.exit('Input file does not exist!') # Get the new column parameters if not args_dict['addcolumns'] is None: new_column_parameters = util.parse_star_parameters(args_dict['addcolumns']) else: new_column_parameters = None # Create an EM project object new_project = em.Project(name='EMTransform') new_project.set_output_directory(args_dict['output'], project_root='.') # Set microgragraph pixel size new_project.set_mic_apix(args_dict['apix']) # Write parameters to args filename args_filename = new_project.output_directory+'/args.yaml' util.write_config_file(args_filename, args_dict) # Read particles new_project.read_particles(args_dict['input']) print('Read particle star file {}'.format(args_dict['input'])) # Check if the input file exists if args_dict['reference'] is not None and os.path.isfile(args_dict['reference']): new_project.read_class_refs(args_dict['reference'], new_classids=args_dict['newclassid']) print('Read class reference file {}'.format(args_dict['reference'])) # Prepare input and output files new_project.prepare_io_files_star() # Perform reference based particle star transformation new_project.transform_particles(final_offset=args_dict['offset'], com_offset=args_dict['offsetcom'], rotate_psi=args_dict['rotatepsi']) # Add new columns new_project.add_columns(new_column_parameters) # Recenter if args_dict['recenter']: new_project.read_particle_apix() new_project.recenter_particles() if args_dict['flipX']: new_project.flipX_particles() # Write output files new_project.write_output_files()
def main(): parser = argparse.ArgumentParser( formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument("-i", "--input", type=str, help="Particle star file") parser.add_argument("-o", "--output", type=str, help="Output directory", default=None) parser.add_argument("-mic", "--micrograph", type=str, help="Micrograph star file") args = parser.parse_args() # Prepare args dict args_dict = { 'input': args.input, 'output': args.output, 'micrograph': args.micrograph } # Check if the input file exists if args_dict['input'] is None or not os.path.isfile(args_dict['input']): parser.print_help() sys.exit('Input file does not exist!') # Check if the reference file exists if args_dict['micrograph'] is None and not os.path.isfile( args_dict['micrograph']): parser.print_help() sys.exit('Micrographs file does not exist!') # Create an EM project object new_project = em.Project(name='EMClean') new_project.set_output_directory(args_dict['output'], project_root='.') # Write parameters to args filename args_filename = new_project.output_directory + '/args.yaml' util.write_config_file(args_filename, args_dict) # Read particles new_project.read_particles(args_dict['input']) print('Read particle star file {}'.format(args_dict['input'])) # Read particle pixel size information new_project.read_particle_apix() new_project.read_micrographs(args_dict['micrograph']) print('Read micrographs star file {}'.format(args_dict['micrograph'])) # Read micrograph pixel size information new_project.read_mic_apix() # Read micrograph header new_project.read_mic_header() # Prepare input and output files new_project.prepare_io_files_star() # Check particle positions new_project.check_particle_pos() # Delete outside particles new_project.delete_outside_ptcls() # Write output files new_project.write_output_files()
def main(): parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument("-i", "--input", type=str, help="Particle star file") parser.add_argument("-o", "--output", type=str, help="Output directory", default=None) parser.add_argument("-maxprob", "--maxprob", type=float, help="Maximum probability", default=None) parser.add_argument("-maxclass", "--maxclass", type=int, help="Maximum number of classes assigned for a particle", default=None) parser.add_argument("-tilt", "--tilt", type=float, nargs=2, help="Accepted range of tilt angles. [ min ,max]", default=[0, 360]) parser.add_argument("-dtilt", "--dtilt", type=float, nargs=2, help="Accepted range of diff-tilt angles. [ min ,max]", default=[0, 360]) parser.add_argument("-dpsi", "--dpsi", type=float, nargs=2, help="Accepted range of diff-psi angles. [ min ,max]", default=[0, 360]) parser.add_argument("-drot", "--drot", type=float, nargs=2, help="Accepted range of diff-rot angles. [ min ,max]", default=[0, 360]) parser.add_argument("-dalign", "--dalign", type=float, nargs=2, help="Accepted range of diff-align angles. [ min ,max]", default=[-1, 1]) args = parser.parse_args() # Prepare args dict args_dict = {'input': args.input, 'output': args.output, 'maxprob': args.maxprob, 'maxclass': args.maxclass, 'tilt': args.tilt, 'dtilt': args.dtilt, 'dpsi': args.dpsi, 'drot': args.drot, 'dalign': args.dalign} # Check if the input file exists if args_dict['input'] is None or not os.path.isfile(args_dict['input']): parser.print_help() sys.exit('Input file does not exist!') # Create an EM project object new_project = em.Project(name='EMFilter') new_project.set_output_directory(args_dict['output'], project_root='.') # Write parameters to args filename args_filename = new_project.output_directory+'/args.yaml' util.write_config_file(args_filename, args_dict) # Read particles new_project.read_particles(args_dict['input']) print('Read particle star file {}'.format(args_dict['input'])) # Prepare input and output files new_project.prepare_io_files_star() # Determine pixel size from particle star file new_project.read_particle_apix() # Subtract class mrc from particle mrc new_project.filter_ptcls(maxprob=args_dict['maxprob'], maxclass=args_dict['maxclass'], tilt_range=args_dict['tilt'], dpsi_range=args_dict['dpsi'], dtilt_range=args_dict['dtilt'], drot_range=args_dict['drot'], dalign_range=args_dict['dalign']) # Write output files new_project.write_output_files()