def run(args):
  import iotbx.phil
  phil = iotbx.phil.process_command_line(args=args, master_string="""
target_unit_cell = 78,78,37,90,90,90
  .type = unit_cell
target_space_group = P43212
  .type = space_group
d_min = 2.1
  .type = float
plot = False
  .type = str
cut_short_at = None
  .type = int
""").show()
  print
  work_params = phil.work.extract()
  assert work_params.d_min is not None

  print work_params.target_unit_cell
  print work_params.target_space_group

  from cctbx import miller
  miller_set = symmetry(
      unit_cell=work_params.target_unit_cell,
      space_group_info=work_params.target_space_group
    ).build_miller_set(
      anomalous_flag=True,
      d_min=work_params.d_min
    )

  miller_set.show_summary()

  # reality check
  #recip_cell_volume = work_params.target_unit_cell.reciprocal().volume()
  #recip_sphere_volume = (4/3)*math.pi*math.pow(1./work_params.d_min,3)
  #resolution_cells = recip_sphere_volume/recip_cell_volume
  #print "Number of asu's in sphere=",resolution_cells/miller_set.size()

  results = get_observations(miller_set,phil.remaining_args,work_params)

  # Create (and initialise?) arrays for statistics on the set of the
  # observed reflections which are present in the reference data set.
  completeness = flex.int(miller_set.size())
  sum_I        = flex.double(miller_set.size())
  sum_I_SIGI   = flex.double(miller_set.size())
  #last = completeness.deep_copy()

  for result,filename in results:
    result.show_summary()
    show_observations(result)

    if work_params.plot==True:
      #private interface to get the very strong diffraction images
      import StringIO
      G = StringIO.StringIO()
      show_observations(result,out=G)
      for line in G.getvalue().split("\n"):
        tokens = line.split()
        if len(tokens)>6:
          try:
            if float(tokens[3]) < 2.6 and float(tokens[-1]) > 10:
              print "Strong signal",filename,line
          except ValueError: pass
    print

    # Match up the observed intensities against the reference data
    # set, i_model, instead of the pre-generated miller set,
    # miller_set.
    matches = miller.match_indices(
      miller_set.indices(),
      result.indices())

    #for ih,hkl in enumerate(result.indices()):
    #  print hkl, result.data()[ih]
    print

    # Update the count for each matched reflection.
    completeness +=  (~matches.single_selection(0)).as_int()
    for pair in matches.pairs():
      sum_I[pair[0]] += result.data()[pair[1]]
      sum_I_SIGI[pair[0]] += (result.data()[pair[1]]/result.sigmas()[pair[1]])
    #for ih,hkl in enumerate(miller_set.indices()):
    #  print "%15s"%str(hkl),"%4d"%last[ih],"%4d"%completeness[ih], sum_I[ih]

    #print matches
    #help(matches)
    #print matches.pair_selection(0)
    #for item in matches.pairs(): print item
    #print list(miller_set.indices().select(matches.pairs().column(1)))
    #print list(~matches.single_selection(0))
    #print list(~matches.single_selection(1))
    #last  = completeness.deep_copy()

  #plot_overall_completeness(completeness)

  show_overall_observations(miller_set,completeness,sum_I,sum_I_SIGI)
Exemplo n.º 2
0
def run(args):
    import iotbx.phil

    phil = iotbx.phil.process_command_line(
        args=args,
        master_string="""
target_unit_cell = 78,78,37,90,90,90
  .type = unit_cell
target_space_group = P43212
  .type = space_group
d_min = 2.1
  .type = float
plot = False
  .type = str
cut_short_at = None
  .type = int
""",
    ).show()
    print
    work_params = phil.work.extract()
    assert work_params.d_min is not None

    print work_params.target_unit_cell
    print work_params.target_space_group

    from cctbx import miller

    miller_set = symmetry(
        unit_cell=work_params.target_unit_cell, space_group_info=work_params.target_space_group
    ).build_miller_set(anomalous_flag=True, d_min=work_params.d_min)

    miller_set.show_summary()

    # reality check
    # recip_cell_volume = work_params.target_unit_cell.reciprocal().volume()
    # recip_sphere_volume = (4/3)*math.pi*math.pow(1./work_params.d_min,3)
    # resolution_cells = recip_sphere_volume/recip_cell_volume
    # print "Number of asu's in sphere=",resolution_cells/miller_set.size()

    results = get_observations(miller_set, phil.remaining_args, work_params)

    # Create (and initialise?) arrays for statistics on the set of the
    # observed reflections which are present in the reference data set.
    completeness = flex.int(miller_set.size())
    sum_I = flex.double(miller_set.size())
    sum_I_SIGI = flex.double(miller_set.size())
    # last = completeness.deep_copy()

    for result, filename in results:
        result.show_summary()
        show_observations(result)

        if work_params.plot == True:
            # private interface to get the very strong diffraction images
            import StringIO

            G = StringIO.StringIO()
            show_observations(result, out=G)
            for line in G.getvalue().split("\n"):
                tokens = line.split()
                if len(tokens) > 6:
                    try:
                        if float(tokens[3]) < 2.6 and float(tokens[-1]) > 10:
                            print "Strong signal", filename, line
                    except ValueError:
                        pass
        print

        # Match up the observed intensities against the reference data
        # set, i_model, instead of the pre-generated miller set,
        # miller_set.
        matches = miller.match_indices(miller_set.indices(), result.indices())

        # for ih,hkl in enumerate(result.indices()):
        #  print hkl, result.data()[ih]
        print

        # Update the count for each matched reflection.
        completeness += (~matches.single_selection(0)).as_int()
        for pair in matches.pairs():
            sum_I[pair[0]] += result.data()[pair[1]]
            sum_I_SIGI[pair[0]] += result.data()[pair[1]] / result.sigmas()[pair[1]]
        # for ih,hkl in enumerate(miller_set.indices()):
        #  print "%15s"%str(hkl),"%4d"%last[ih],"%4d"%completeness[ih], sum_I[ih]

        # print matches
        # help(matches)
        # print matches.pair_selection(0)
        # for item in matches.pairs(): print item
        # print list(miller_set.indices().select(matches.pairs().column(1)))
        # print list(~matches.single_selection(0))
        # print list(~matches.single_selection(1))
        # last  = completeness.deep_copy()

    # plot_overall_completeness(completeness)

    show_overall_observations(miller_set, completeness, sum_I, sum_I_SIGI)