def run(args, command_name="distl.image_viewer"): help_str = """Same as distl.signal_strength (type that command for help) except that the image_viewer starts up an interactive GUI to visualize spotfinder spots. """ if (len(args) == 0 or args[0] in ["H", "h", "-H", "-h", "help", "--help", "-help"]): print "usage: %s image_filename [parameter=value ...]" % command_name print "example: %s lysozyme_001.img distl.res.outer=2.0 distl.res.inner=6.0 distl.minimum_spot_area=8" % command_name master_params.show(attributes_level=1, expert_level=1) print help_str return print "%s: characterization of candidate Bragg spots" % command_name phil_objects = [] argument_interpreter = master_params.command_line_argument_interpreter( home_scope="distl") image_file_name = None moving_pdb_file_name = None for arg in args: if (os.path.isfile(arg)): if (image_file_name is None): image_file_name = arg else: raise Sorry("Too many file names.") else: try: command_line_params = argument_interpreter.process(arg=arg) except KeyboardInterrupt: raise except Exception: raise Sorry("Unknown file or keyword: %s" % arg) else: phil_objects.append(command_line_params) working_params = master_params.fetch(sources=phil_objects) params = working_params.extract() def raise_missing(what): raise Sorry("""\ Missing file name for %(what)s structure: Please add %(what)s=file_name to the command line to specify the %(what)s structure.""" % vars()) if (image_file_name is None): if (params.distl.image is None): raise_missing("file name") else: params.distl.image = image_file_name working_params = master_params.format(python_object=params) #working_params.show(expert_level=1) #Now actually run the program logic from spotfinder.applications import image_viewer as app_image_viewer modeler = app_image_viewer.run_signal_strength_class( params=working_params.extract()) modeler.view()
def run(args, command_name="distl.image_viewer"): help_str="""Same as distl.signal_strength (type that command for help) except that the image_viewer starts up an interactive GUI to visualize spotfinder spots. """ if (len(args) == 0 or args[0] in ["H","h","-H","-h","help","--help","-help"]): print "usage: %s image_filename [parameter=value ...]" % command_name print "example: %s lysozyme_001.img distl.res.outer=2.0 distl.res.inner=6.0 distl.minimum_spot_area=8"%command_name master_params.show(attributes_level=1,expert_level=1) print help_str return print "%s: characterization of candidate Bragg spots"%command_name phil_objects = [] argument_interpreter = master_params.command_line_argument_interpreter( home_scope="distl") image_file_name = None moving_pdb_file_name = None for arg in args: if (os.path.isfile(arg)): if (image_file_name is None): image_file_name = arg else: raise Sorry("Too many file names.") else: try: command_line_params = argument_interpreter.process(arg=arg) except KeyboardInterrupt: raise except Exception: raise Sorry("Unknown file or keyword: %s" % arg) else: phil_objects.append(command_line_params) working_params = master_params.fetch(sources=phil_objects) params = working_params.extract() def raise_missing(what): raise Sorry("""\ Missing file name for %(what)s structure: Please add %(what)s=file_name to the command line to specify the %(what)s structure.""" % vars()) if (image_file_name is None): if (params.distl.image is None): raise_missing("file name") else: params.distl.image = image_file_name working_params = master_params.format(python_object=params) #working_params.show(expert_level=1) #Now actually run the program logic from spotfinder.applications import image_viewer as app_image_viewer modeler = app_image_viewer.run_signal_strength_class(params=working_params.extract()) modeler.view()
def run(args, command_name="distl.mp_spotfinder_server_read_file"): help_str = """Multiprocessing server to find Bragg spots & quantify signal strength. Full documentation: http://cci.lbl.gov/publications/download/ccn_jul2010_page18.pdf Allowed parameters: """ if (len(args) >= 1 and args[0] in ["H", "h", "-H", "-h", "help", "--help", "-help"]): print("usage: %s [parameter=value ...]" % command_name) print("example: %s distl.port=8125 distl.processors=8" % command_name) print(help_str) return else: print(help_str) phil_objects = [] argument_interpreter = master_params.command_line_argument_interpreter( home_scope="distl") for arg in args: try: command_line_params = argument_interpreter.process(arg=arg) except KeyboardInterrupt: raise except Exception: raise Sorry("Unknown file or keyword: %s" % arg) else: phil_objects.append(command_line_params) working_params = master_params.fetch(sources=phil_objects) params = working_params.extract() working_params = master_params.format(python_object=params) #working_params.show() screen = 100 for D in working_params.all_definitions(): fp = D.object.full_path() if fp in ["distl.image", "distl.verbose", "distl.pdf_output"]: continue name = " %s=%s" % (D.object.full_path(), D.object.extract()) help = D.object.help if D.object.expert_level > 1: continue if len(name) + len(help) < screen and len(name) < 36: print("%-36s" % name, "[%s]" % help) else: print("%-36s" % name, end=' ') tokens = ("[%s]" % help).split() reserve = min(screen - 36, screen - len(name)) while len(tokens) > 0: reserve -= len(tokens[0]) if len(tokens[0]) > (screen - 36): break while reserve < 0: print() print(" " * 36, end=' ') reserve = screen - 36 print(tokens.pop(0), end=' ') print() #Now actually run the program logic from spotfinder.servers import mp_spotfinder_server_read_file as srv NUMBER_OF_PROCESSES = params.distl.processors srv.generate_common_parameters(working_params) server_address = ('', params.distl.port) srv.image_request_handler.protocol_version = "HTTP/1.0" print("Serving %d-process HTTP on" % NUMBER_OF_PROCESSES, server_address[0], "port", server_address[1], "...") print("To exit press Ctrl-C") srv.runpool(server_address, NUMBER_OF_PROCESSES, srv.image_request_handler)
def run(args, command_name="distl.mp_spotfinder_server_read_file"): help_str="""Multiprocessing server to find Bragg spots & quantify signal strength. Full documentation: http://cci.lbl.gov/publications/download/ccn_jul2010_page18.pdf Allowed parameters: """ if (len(args)>=1 and args[0] in ["H","h","-H","-h","help","--help","-help"]): print "usage: %s [parameter=value ...]" % command_name print "example: %s distl.port=8125 distl.processors=8"%command_name print help_str return else: print help_str phil_objects = [] argument_interpreter = master_params.command_line_argument_interpreter( home_scope="distl") for arg in args: try: command_line_params = argument_interpreter.process(arg=arg) except KeyboardInterrupt: raise except Exception: raise Sorry("Unknown file or keyword: %s" % arg) else: phil_objects.append(command_line_params) working_params = master_params.fetch(sources=phil_objects) params = working_params.extract() working_params = master_params.format(python_object=params) #working_params.show() screen = 100 for D in working_params.all_definitions(): fp = D.object.full_path() if fp in ["distl.image", "distl.verbose", "distl.pdf_output"]: continue name = " %s=%s"%(D.object.full_path(),D.object.extract()) help = D.object.help if D.object.expert_level > 1: continue if len(name) + len(help) < screen and len(name) < 36: print "%-36s"%name,"[%s]"%help else: print "%-36s"%name, tokens = ("[%s]"%help).split() reserve = min(screen-36,screen-len(name)) while len(tokens)>0: reserve -= len(tokens[0]) if len(tokens[0])>(screen-36):break while reserve<0: print print " "*36, reserve = screen-36 print tokens.pop(0), print #Now actually run the program logic from spotfinder.servers import mp_spotfinder_server_read_file as srv NUMBER_OF_PROCESSES = params.distl.processors srv.generate_common_parameters(working_params) server_address = ('', params.distl.port) srv.image_request_handler.protocol_version = "HTTP/1.0" print "Serving %d-process HTTP on"%NUMBER_OF_PROCESSES, server_address[0], "port", server_address[1], "..." print "To exit press Ctrl-C" srv.runpool(server_address,NUMBER_OF_PROCESSES,srv.image_request_handler)