def remove_anomalous_suffix_if_necessary(miller_array=None,
                                         column_root_label=None):
    # if the miller array is anomalous and the suffix is "(+)", remove it
    if column_root_label and column_root_label.endswith("(+)") and \
         miller_array.anomalous_flag():
        column_root_label = column_root_label[:-3]
    return column_root_label
def remove_anomalous_suffix_if_necessary(
   miller_array=None,
   column_root_label=None):
  # if the miller array is anomalous and the suffix is "(+)", remove it
  if column_root_label and column_root_label.endswith("(+)") and \
       miller_array.anomalous_flag():
    column_root_label=column_root_label[:-3]
  return column_root_label
Exemple #3
0
def exercise_reflection_file_as_miller_array():
    refl_1 = """\
 NREFlection=         3
 ANOMalous=FALSe { equiv. to HERMitian=TRUE}
 DECLare NAME=FOBS         DOMAin=RECIprocal   TYPE=COMP END
 DECLare NAME=PHASE        DOMAin=RECIprocal   TYPE=REAL END
 DECLare NAME=SIGMA        DOMAin=RECIprocal   TYPE=REAL END
 DECLare NAME=TEST         DOMAin=RECIprocal   TYPE=INTE END
 DECLare NAME=FOM          DOMAin=RECIprocal   TYPE=REAL END
 INDE     1    1    2 FOBS=   713.650 PHASE=     0.000 SIGMA=     3.280
                   TEST=  0 FOM=    -1.000
 INDE    -2    0    3 FOBS=   539.520 PHASE=     0.000 SIGMA=     4.140
                   TEST=  1 FOM=    -1.000
 INDE     0    2    1 FOBS=   268.140 PHASE=     0.000 SIGMA=     1.690
                   TEST=  0 FOM=    -1.000
"""
    refl_2 = """\
 { sg=C2 a=97.37 b=46.64 c=65.47 alpha=90 beta=115.4 gamma=90 }
 NREFlection=         3
 ANOMalous=FALSe { equiv. to HERMitian=TRUE}
 DECLare NAME=FOBS         DOMAin=RECIprocal   TYPE=COMP END
 DECLare NAME=SIGMA        DOMAin=RECIprocal   TYPE=REAL END
 DECLare NAME=TEST         DOMAin=RECIprocal   TYPE=INTE END
 DECLare NAME=FOM          DOMAin=RECIprocal   TYPE=REAL END
 DECLare NAME=PA           DOMAin=RECIprocal   TYPE=REAL END
 DECLare NAME=PB           DOMAin=RECIprocal   TYPE=REAL END
 DECLare NAME=PC           DOMAin=RECIprocal   TYPE=REAL END
 DECLare NAME=PD           DOMAin=RECIprocal   TYPE=REAL END
 GROUp TYPE=HL
     OBJEct=PA
     OBJEct=PB
     OBJEct=PC
     OBJEct=PD
 END
 INDE     1    1    2 FOBS=   713.650    44.854 SIGMA=     3.280 TEST=         0
                   FOM=     0.044 PA=     0.066 PB=     0.065 PC=    -0.001
                   PD=    -0.099
 INDE    -2    0    3 FOBS=   539.520     0.000 SIGMA=     4.140 TEST=         1
                   FOM=     0.994 PA=     2.893 PB=     0.000 PC=     0.000
                   PD=     0.000
 INDE     0    2    1 FOBS=   268.140   184.247 SIGMA=     1.690 TEST=         0
                   FOM=     0.890 PA=   -46.660 PB=    -3.465 PC=   -12.988
                   PD=    -1.940
"""
    crystal_symmetry = crystal.symmetry(unit_cell=(97.37, 46.64, 65.47, 90,
                                                   115.4, 90),
                                        space_group_symbol="C 1 2 1")
    all_arrays = [
        iotbx.cns.reflection_reader.cns_reflection_file(
            file_handle=StringIO(refl)).as_miller_arrays(crystal_symmetry=cs)
        for refl, cs in [(refl_1, crystal_symmetry), (refl_2, None)]
    ]
    for miller_arrays in all_arrays:
        for miller_array in miller_arrays:
            assert miller_array.crystal_symmetry().is_similar_symmetry(
                other=crystal_symmetry,
                relative_length_tolerance=1.e-10,
                absolute_angle_tolerance=1.e-10)
            assert not miller_array.anomalous_flag()
            assert list(miller_array.indices()) == [(1, 1, 2), (-2, 0, 3),
                                                    (0, 2, 1)]
            lbl = miller_array.info().label_string()
            if (lbl == "FOBS,SIGMA"):
                assert str(miller_array.observation_type()) == "xray.amplitude"
                assert approx_equal(miller_array.data(),
                                    [713.65, 539.52, 268.14])
                assert approx_equal(miller_array.sigmas(), [3.28, 4.14, 1.69])
            else:
                assert miller_array.observation_type() is None
                if (lbl == "TEST"):
                    assert list(miller_array.data()) == [0, 1, 0]
                elif (lbl == "PHASE"):
                    assert approx_equal(miller_array.data(), [0, 0, 0])
                elif (lbl == "FOM"):
                    if (miller_array.data()[0] < 0):
                        assert approx_equal(miller_array.data(), [-1, -1, -1])
                    else:
                        assert approx_equal(miller_array.data(),
                                            [0.044, 0.994, 0.890])
                elif (lbl == "PA,PB,PC,PD"):
                    assert approx_equal(miller_array.data(),
                                        [(0.066, 0.065, -0.001, -0.099),
                                         (2.893, 0.000, 0.000, 0.000),
                                         (-46.660, -3.465, -12.988, -1.940)])
                else:
                    raise RuntimeError
Exemple #4
0
def exercise_reflection_file_as_miller_array():
  refl_1 = """\
 NREFlection=         3
 ANOMalous=FALSe { equiv. to HERMitian=TRUE}
 DECLare NAME=FOBS         DOMAin=RECIprocal   TYPE=COMP END
 DECLare NAME=PHASE        DOMAin=RECIprocal   TYPE=REAL END
 DECLare NAME=SIGMA        DOMAin=RECIprocal   TYPE=REAL END
 DECLare NAME=TEST         DOMAin=RECIprocal   TYPE=INTE END
 DECLare NAME=FOM          DOMAin=RECIprocal   TYPE=REAL END
 INDE     1    1    2 FOBS=   713.650 PHASE=     0.000 SIGMA=     3.280
                   TEST=  0 FOM=    -1.000
 INDE    -2    0    3 FOBS=   539.520 PHASE=     0.000 SIGMA=     4.140
                   TEST=  1 FOM=    -1.000
 INDE     0    2    1 FOBS=   268.140 PHASE=     0.000 SIGMA=     1.690
                   TEST=  0 FOM=    -1.000
"""
  refl_2 = """\
 { sg=C2 a=97.37 b=46.64 c=65.47 alpha=90 beta=115.4 gamma=90 }
 NREFlection=         3
 ANOMalous=FALSe { equiv. to HERMitian=TRUE}
 DECLare NAME=FOBS         DOMAin=RECIprocal   TYPE=COMP END
 DECLare NAME=SIGMA        DOMAin=RECIprocal   TYPE=REAL END
 DECLare NAME=TEST         DOMAin=RECIprocal   TYPE=INTE END
 DECLare NAME=FOM          DOMAin=RECIprocal   TYPE=REAL END
 DECLare NAME=PA           DOMAin=RECIprocal   TYPE=REAL END
 DECLare NAME=PB           DOMAin=RECIprocal   TYPE=REAL END
 DECLare NAME=PC           DOMAin=RECIprocal   TYPE=REAL END
 DECLare NAME=PD           DOMAin=RECIprocal   TYPE=REAL END
 GROUp TYPE=HL
     OBJEct=PA
     OBJEct=PB
     OBJEct=PC
     OBJEct=PD
 END
 INDE     1    1    2 FOBS=   713.650    44.854 SIGMA=     3.280 TEST=         0
                   FOM=     0.044 PA=     0.066 PB=     0.065 PC=    -0.001
                   PD=    -0.099
 INDE    -2    0    3 FOBS=   539.520     0.000 SIGMA=     4.140 TEST=         1
                   FOM=     0.994 PA=     2.893 PB=     0.000 PC=     0.000
                   PD=     0.000
 INDE     0    2    1 FOBS=   268.140   184.247 SIGMA=     1.690 TEST=         0
                   FOM=     0.890 PA=   -46.660 PB=    -3.465 PC=   -12.988
                   PD=    -1.940
"""
  crystal_symmetry = crystal.symmetry(
    unit_cell=(97.37, 46.64, 65.47, 90, 115.4, 90),
    space_group_symbol="C 1 2 1")
  all_arrays = [iotbx.cns.reflection_reader.cns_reflection_file(
    file_handle=StringIO(refl)).as_miller_arrays(
      crystal_symmetry=cs)
        for refl,cs in [(refl_1,crystal_symmetry), (refl_2,None)]]
  for miller_arrays in all_arrays:
    for miller_array in miller_arrays:
      assert miller_array.crystal_symmetry().is_similar_symmetry(
        other=crystal_symmetry,
        relative_length_tolerance=1.e-10,
        absolute_angle_tolerance=1.e-10)
      assert not miller_array.anomalous_flag()
      assert list(miller_array.indices()) == [(1,1,2), (-2,0,3), (0,2,1)]
      lbl = miller_array.info().label_string()
      if (lbl == "FOBS,SIGMA"):
        assert str(miller_array.observation_type()) == "xray.amplitude"
        assert approx_equal(miller_array.data(), [713.65, 539.52, 268.14])
        assert approx_equal(miller_array.sigmas(), [3.28, 4.14, 1.69])
      else:
        assert miller_array.observation_type() is None
        if (lbl == "TEST"):
          assert list(miller_array.data()) == [0, 1, 0]
        elif (lbl == "PHASE"):
          assert approx_equal(miller_array.data(), [0, 0, 0])
        elif (lbl == "FOM"):
          if (miller_array.data()[0] < 0):
            assert approx_equal(miller_array.data(), [-1, -1, -1])
          else:
            assert approx_equal(miller_array.data(), [0.044, 0.994, 0.890])
        elif (lbl == "PA,PB,PC,PD"):
          assert approx_equal(miller_array.data(), [
            (0.066, 0.065, -0.001, -0.099),
            (2.893, 0.000, 0.000, 0.000),
            (-46.660, -3.465, -12.988, -1.940)])
        else:
          raise RuntimeError