Пример #1
0
def run(args, verbose=False):
    from libtbx.utils import Sorry
    import os
    from spotfinder.command_line.signal_strength import master_params
    from spotfinder.servers import LoggingFramework

    # For the Apache server version, do not allow site, user, or dataset preferences
    # all parameters are to be passed in through the http: query line

    logfile = LoggingFramework()

    phil_objects = []
    argument_interpreter = master_params.command_line_argument_interpreter(home_scope="distl")

    for key in args.keys():
        arg = "%s=%s" % (key, args.get(key, ""))
        try:
            command_line_params = argument_interpreter.process(arg=arg)
        except Exception:
            return str(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.show()

    if not os.path.isfile(params.distl.image):
        return str(Sorry("%s is not a readable file" % params.distl.image))

    print "Image: %s" % params.distl.image

    from spotfinder.applications import signal_strength

    try:
        signal_strength.run_signal_strength(params)
    except Exception:
        import traceback

        logger = StringIO.StringIO()
        logger.write("Sorry, can't process %s.  Please contact authors.\n" % params.distl.image)
        traceback.print_exc(file=logger)
        return str(Sorry(logger.getvalue()))

    return logfile.getvalue()
Пример #2
0
def run(args, verbose=False):
    from libtbx.utils import Sorry
    import os
    from spotfinder.command_line.signal_strength import master_params
    from spotfinder.servers import LoggingFramework

    #For the Apache server version, do not allow site, user, or dataset preferences
    #all parameters are to be passed in through the http: query line

    logfile = LoggingFramework()

    phil_objects = []
    argument_interpreter = master_params.command_line_argument_interpreter(
        home_scope="distl")

    for key in args.keys():
        arg = "%s=%s" % (key, args.get(key, ""))
        try:
            command_line_params = argument_interpreter.process(arg=arg)
        except Exception:
            return str(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.show()

    if not os.path.isfile(params.distl.image):
        return str(Sorry("%s is not a readable file" % params.distl.image))

    print "Image: %s" % params.distl.image

    from spotfinder.applications import signal_strength
    try:
        signal_strength.run_signal_strength(params)
    except Exception:
        import traceback
        logger = StringIO()
        logger.write("Sorry, can't process %s.  Please contact authors.\n" %
                     params.distl.image)
        traceback.print_exc(file=logger)
        return str(Sorry(logger.getvalue()))

    return logfile.getvalue()
Пример #3
0
    def do_GET_run(self,
                   qs):  #similar to the run() function in apache.py module
        from libtbx.utils import Sorry
        import os
        from spotfinder.servers import LoggingFramework

        base_params = copy.deepcopy(common_parameters_singleton)
        argument_interpreter = base_params.command_line_argument_interpreter()
        phil_objects = []

        for key in qs.keys():
            arg = "%s=%s" % (key, qs.get(key, "")[0])
            try:
                command_line_params = argument_interpreter.process(arg=arg)
            except Exception:
                return str(Sorry("Unknown file or keyword: %s" % arg))
            else:
                phil_objects.append(command_line_params)

        working_params = base_params.fetch(sources=phil_objects)
        params = working_params.extract()
        #working_params.show()
        if not os.path.isfile(params.distl.image):
            return str(Sorry("%s is not a readable file" % params.distl.image))

        print "Image: %s" % params.distl.image

        logfile = LoggingFramework()
        from spotfinder.applications import signal_strength
        try:
            signal_strength.run_signal_strength(params)
        except Exception:
            import traceback
            logger = StringIO()
            logger.write(
                "Sorry, can't process %s.  Please contact authors.\n" %
                params.distl.image)
            traceback.print_exc(file=logger)
            return str(Sorry(logger.getvalue()))

        return logfile.getvalue()
  def do_GET_run(self,qs): #similar to the run() function in apache.py module
    from libtbx.utils import Sorry
    import os
    from spotfinder.servers import LoggingFramework

    base_params = copy.deepcopy(common_parameters_singleton)
    argument_interpreter = base_params.command_line_argument_interpreter()
    phil_objects = []

    for key in qs.keys():
      arg = "%s=%s"%(key,qs.get(key,"")[0])
      try: command_line_params = argument_interpreter.process(arg=arg)
      except Exception: return str(Sorry("Unknown file or keyword: %s" % arg))
      else: phil_objects.append(command_line_params)

    working_params = base_params.fetch(sources=phil_objects)
    params = working_params.extract()
    #working_params.show()
    if not os.path.isfile(params.distl.image):
      return  str(Sorry("%s is not a readable file" % params.distl.image))

    print "Image: %s"%params.distl.image

    logfile = LoggingFramework()
    from spotfinder.applications import signal_strength
    try:
      signal_strength.run_signal_strength(params)
    except Exception:
      import traceback
      logger = StringIO.StringIO()
      logger.write(
      "Sorry, can't process %s.  Please contact authors.\n"% params.distl.image)
      traceback.print_exc(file=logger)
      return str(Sorry( logger.getvalue() ))

    return logfile.getvalue()
Пример #5
0
def run(args, verbose=False):
    from libtbx.utils import Sorry
    try:
        from dials.array_family import flex
    except ImportError:
        return str(Sorry("DIALS is not configured"))

    from iotbx.phil import parse
    import os
    from spotfinder.servers import LoggingFramework
    from dials.array_family import flex
    from dxtbx.model.experiment_list import ExperimentListFactory
    phil_scope = parse("""
  file_name = None
    .type = str
  frame_number = None
    .type = int
  stats = True
    .type = bool
  include scope dials.algorithms.spot_finding.factory.phil_scope
  """,
                       process_includes=True)

    #For the Apache server version, do not allow site, user, or dataset preferences
    #all parameters are to be passed in through the http: query line

    logfile = LoggingFramework()

    phil_objects = []

    for key in args.keys():
        arg = "%s=%s" % (key, args.get(key, ""))
        try:
            phil_objects.append(parse(arg))
        except Exception:
            return str(Sorry("Unknown file or keyword: %s" % arg))

    working_params = phil_scope.fetch(sources=phil_objects)
    params = working_params.extract()
    #working_params.show()

    if not os.path.isfile(params.file_name):
        return str(Sorry("%s is not a readable file" % params.file_name))

    print "Image: %s\n" % params.file_name

    try:
        experiments = ExperimentListFactory.from_filenames([params.file_name])
        assert len(experiments) == 1
        if len(experiments[0].imageset
               ) > 0 and params.frame_number is not None:
            print "Frame number", params.frame_number
            experiments[0].imageset = experiments[0].imageset[
                params.frame_number:params.frame_number + 1]
            experiments[0].scan = experiments[0].imageset.get_scan()
        reflections = flex.reflection_table.from_observations(
            experiments, params)

        if params.stats:
            from dials.algorithms.spot_finding.per_image_analysis import stats_single_image
            print stats_single_image(experiments[0].imageset,
                                     reflections,
                                     i=None,
                                     resolution_analysis=True,
                                     plot=False)

    except Exception:
        import traceback
        logger = StringIO()
        logger.write("Sorry, can't process %s.  Please contact authors.\n" %
                     params.file_name)
        traceback.print_exc(file=logger)
        return str(Sorry(logger.getvalue())) + logfile.getvalue()

    print "Found %d strong reflections" % len(reflections)

    return logfile.getvalue()