Example #1
0
def exercise_manipulation():
  m = geometry_restraints.motif_manipulation()
  assert m.id == ""
  assert m.description == ""
  assert m.info.size() == 0
  assert len(m.alterations_as_list()) == 0
  m.id = "a"
  assert m.id == "a"
  m.description = "b"
  assert m.description == "b"
  m.info.append("c")
  m.info.append("d")
  assert list(m.info) == ["c", "d"]
  alts = []
  a = geometry_restraints.motif_alteration()
  a.action = "add"
  a.operand = "bond"
  alts.append(a)
  a = geometry_restraints.motif_alteration()
  a.action = "delete"
  a.operand = "angle"
  alts.append(a)
  m.set_alterations(alts)
  l = m.alterations_as_list()
  assert len(l) == 2
  assert l[0].action == "add"
  assert l[0].operand == "bond"
  assert l[1].action == "delete"
  assert l[1].operand == "angle"
  #
  m = geometry_restraints.motif_manipulation()
  m.id = "a"
  m.description = "b"
  m.info.append("c")
  #
  alterations = []
  a = geometry_restraints.motif_alteration(action="add", operand="atom")
  a.motif_ids.append("1")
  a.atom.name = "x"
  a.atom.scattering_type = "y"
  a.atom.nonbonded_type = "z"
  a.atom.partial_charge = -0.2
  alterations.append(a)
  for change_partial_charge in [False, True]:
    a = geometry_restraints.motif_alteration(action="change", operand="atom")
    a.motif_ids.append("0")
    a.motif_atom_name = "p"
    a.atom.name = "q"
    a.atom.scattering_type = "r"
    a.atom.nonbonded_type = "s"
    a.atom.partial_charge = 0.3
    a.set_change_partial_charge(state=change_partial_charge)
    alterations.append(a)
  a = geometry_restraints.motif_alteration(action="delete", operand="atom")
  a.motif_ids.append("3")
  a.motif_atom_name = "d"
  alterations.append(a)
  #
  a = geometry_restraints.motif_alteration(action="add", operand="bond")
  a.motif_ids.append("1")
  a.motif_ids.append("2")
  a.bond.atom_names = ["j", "k"]
  a.bond.distance_ideal = 1.2
  a.bond.weight = 3.1
  a.bond.id = "s"
  alterations.append(a)
  for change_distance_ideal in [False, True]:
    for change_weight in [False, True]:
      a = geometry_restraints.motif_alteration(action="change", operand="bond")
      a.motif_ids.append("3")
      a.motif_ids.append("4")
      a.bond.atom_names = ["l", "m"]
      a.bond.distance_ideal = 4.5
      a.bond.weight = 2.8
      a.bond.id = "g"
      a.set_change_distance_ideal(state=change_distance_ideal)
      a.set_change_weight(state=change_weight)
      alterations.append(a)
  a = geometry_restraints.motif_alteration(action="delete", operand="bond")
  a.motif_ids.append("5")
  a.motif_ids.append("6")
  a.bond.atom_names = ["t", "n"]
  alterations.append(a)
  #
  a = geometry_restraints.motif_alteration(action="add", operand="angle")
  a.motif_ids.append("1")
  a.motif_ids.append("2")
  a.motif_ids.append("3")
  a.angle.atom_names = ["j", "k", "l"]
  a.angle.angle_ideal = 1.2
  a.angle.weight = 3.1
  a.angle.id = "s"
  alterations.append(a)
  for change_angle_ideal in [False, True]:
    for change_weight in [False, True]:
      a = geometry_restraints.motif_alteration(
        action="change", operand="angle")
      a.motif_ids.append("3")
      a.motif_ids.append("4")
      a.motif_ids.append("5")
      a.angle.atom_names = ["l", "m", "g"]
      a.angle.angle_ideal = 4.5
      a.angle.weight = 2.8
      a.angle.id = "g"
      a.set_change_angle_ideal(state=change_angle_ideal)
      a.set_change_weight(state=change_weight)
      alterations.append(a)
  a = geometry_restraints.motif_alteration(action="delete", operand="angle")
  a.motif_ids.append("6")
  a.motif_ids.append("7")
  a.motif_ids.append("8")
  a.angle.atom_names = ["t", "n", "d"]
  alterations.append(a)
  #
  a = geometry_restraints.motif_alteration(action="add", operand="dihedral")
  a.motif_ids.append("1")
  a.motif_ids.append("2")
  a.motif_ids.append("3")
  a.motif_ids.append("4")
  a.dihedral.atom_names = ["j", "k", "l", "r"]
  a.dihedral.angle_ideal = 1.2
  a.dihedral.weight = 3.1
  a.dihedral.periodicity = 20
  a.dihedral.id = "s"
  alterations.append(a)
  for change_angle_ideal in [False, True]:
    for change_weight in [False, True]:
      for change_periodicity in [False, True]:
        a = geometry_restraints.motif_alteration(
          action="change", operand="dihedral")
        a.motif_ids.append("5")
        a.motif_ids.append("6")
        a.motif_ids.append("7")
        a.motif_ids.append("8")
        a.dihedral.atom_names = ["l", "m", "g", "e"]
        a.dihedral.angle_ideal = 4.5
        a.dihedral.weight = 2.8
        a.dihedral.periodicity = 13
        a.dihedral.id = "g"
        a.set_change_angle_ideal(state=change_angle_ideal)
        a.set_change_weight(state=change_weight)
        a.set_change_periodicity(state=change_periodicity)
        alterations.append(a)
  a = geometry_restraints.motif_alteration(action="delete", operand="dihedral")
  a.motif_ids.append("9")
  a.motif_ids.append("10")
  a.motif_ids.append("11")
  a.motif_ids.append("12")
  a.dihedral.atom_names = ["t", "n", "d", "y"]
  alterations.append(a)
  #
  a = geometry_restraints.motif_alteration(action="add", operand="chirality")
  a.motif_ids.append("1")
  a.motif_ids.append("2")
  a.motif_ids.append("3")
  a.motif_ids.append("4")
  a.chirality.atom_names = ["j", "k", "l", "r"]
  a.chirality.volume_sign = "x"
  a.chirality.volume_ideal = 1.2
  a.chirality.weight = 3.1
  a.chirality.id = "w"
  alterations.append(a)
  for change_volume_ideal in [False, True]:
    for change_weight in [False, True]:
      a = geometry_restraints.motif_alteration(
        action="change", operand="chirality")
      a.motif_ids.append("5")
      a.motif_ids.append("6")
      a.motif_ids.append("7")
      a.motif_ids.append("8")
      a.chirality.atom_names = ["l", "m", "g", "e"]
      a.chirality.volume_sign = "u"
      a.chirality.volume_ideal = 4.5
      a.chirality.weight = 2.8
      a.chirality.id = "g"
      a.set_change_volume_ideal(state=change_volume_ideal)
      a.set_change_weight(state=change_weight)
      alterations.append(a)
  a = geometry_restraints.motif_alteration(
    action="delete", operand="chirality")
  a.motif_ids.append("9")
  a.motif_ids.append("10")
  a.motif_ids.append("11")
  a.motif_ids.append("12")
  a.chirality.atom_names = ["t", "n", "d", "y"]
  alterations.append(a)
  #
  a = geometry_restraints.motif_alteration(action="add", operand="planarity")
  a.planarity_motif_id = "7"
  a.planarity.id = "e"
  a.motif_ids.append("1")
  a.motif_ids.append("2")
  a.motif_ids.append("3")
  a.planarity.atom_names.append("s")
  a.planarity.atom_names.append("d")
  a.planarity.atom_names.append("f")
  a.planarity.weights.append(1.2)
  a.planarity.weights.append(2.3)
  a.planarity.weights.append(3.4)
  alterations.append(a)
  a = geometry_restraints.motif_alteration(
    action="change", operand="planarity")
  a.planarity_motif_id = "8"
  a.planarity.id = "f"
  a.set_planarity_atom_actions(["add", "change", "delete"])
  a.motif_ids.append("1")
  a.motif_ids.append("2")
  a.motif_ids.append("3")
  a.planarity.atom_names.append("s")
  a.planarity.atom_names.append("d")
  a.planarity.atom_names.append("f")
  a.planarity.weights.append(1.2)
  a.planarity.weights.append(2.3)
  a.planarity.weights.append(0)
  alterations.append(a)
  a = geometry_restraints.motif_alteration(
    action="delete", operand="planarity")
  a.planarity_motif_id = "4"
  a.planarity.id = "n"
  alterations.append(a)
  #
  m.set_alterations(alterations)
  out = StringIO()
  m.show(out=out, prefix="^")
  assert not show_diff(out.getvalue(), """\
^geometry_restraints.motif_manipulation {
^  id = "a"
^  description = "b"
^  info = "c"
^  atom = add [motif_id name scattering_type nonbonded_type partial_charge]
^  atom = add "1" "x" "y" "z" -0.2
^  atom = change [motif_id motif_atom_name \\
^                 name scattering_type nonbonded_type partial_charge]
^  atom = change "0" "p" \\
^                "q" "r" "s" None
^  atom = change "0" "p" \\
^                "q" "r" "s" 0.3
^  atom = delete [motif_id motif_atom_name]
^  atom = delete "3" "d"
^  bond = add [(motif_id atom_name)*2 type distance_ideal weight id]
^  bond = add "1" "j" "2" "k" 1.2 3.1 "s"
^  bond = change [(motif_id atom_name)*2 type distance_ideal weight id]
^  bond = change "3" "l" "4" "m" None None "g"
^  bond = change "3" "l" "4" "m" None 2.8 "g"
^  bond = change "3" "l" "4" "m" 4.5 None "g"
^  bond = change "3" "l" "4" "m" 4.5 2.8 "g"
^  bond = delete [(motif_id atom_name)*2]
^  bond = delete "5" "t" "6" "n"
^  angle = add [(motif_id atom_name)*3 type angle_ideal weight id]
^  angle = add "1" "j" "2" "k" "3" "l" 1.2 3.1 "s"
^  angle = change [(motif_id atom_name)*3 type angle_ideal weight id]
^  angle = change "3" "l" "4" "m" "5" "g" None None "g"
^  angle = change "3" "l" "4" "m" "5" "g" None 2.8 "g"
^  angle = change "3" "l" "4" "m" "5" "g" 4.5 None "g"
^  angle = change "3" "l" "4" "m" "5" "g" 4.5 2.8 "g"
^  angle = delete [(motif_id atom_name)*3]
^  angle = delete "6" "t" "7" "n" "8" "d"
^  dihedral = add [(motif_id atom_name)*4 angle_ideal weight periodicity id]
^  dihedral = add "1" "j" "2" "k" "3" "l" "4" "r" 1.2 3.1 20 "s"
^  dihedral = change [(motif_id atom_name)*4 angle_ideal weight periodicity id]
^  dihedral = change "5" "l" "6" "m" "7" "g" "8" "e" None None None "g"
^  dihedral = change "5" "l" "6" "m" "7" "g" "8" "e" None None 13 "g"
^  dihedral = change "5" "l" "6" "m" "7" "g" "8" "e" None 2.8 None "g"
^  dihedral = change "5" "l" "6" "m" "7" "g" "8" "e" None 2.8 13 "g"
^  dihedral = change "5" "l" "6" "m" "7" "g" "8" "e" 4.5 None None "g"
^  dihedral = change "5" "l" "6" "m" "7" "g" "8" "e" 4.5 None 13 "g"
^  dihedral = change "5" "l" "6" "m" "7" "g" "8" "e" 4.5 2.8 None "g"
^  dihedral = change "5" "l" "6" "m" "7" "g" "8" "e" 4.5 2.8 13 "g"
^  dihedral = delete [(motif_id atom_name)*4]
^  dihedral = delete "9" "t" "10" "n" "11" "d" "12" "y"
^  chirality = add [(motif_id atom_name)*4 \\
^                   volume_sign volume_ideal weight id]
^  chirality = add "1" "j" "2" "k" "3" "l" "4" "r" \\
^                  "x" 1.2 3.1 "w"
^  chirality = change [(motif_id atom_name)*4 \\
^                      volume_sign volume_ideal weight id]
^  chirality = change "5" "l" "6" "m" "7" "g" "8" "e" \\
^                     "u" None None "g"
^  chirality = change "5" "l" "6" "m" "7" "g" "8" "e" \\
^                     "u" None 2.8 "g"
^  chirality = change "5" "l" "6" "m" "7" "g" "8" "e" \\
^                     "u" 4.5 None "g"
^  chirality = change "5" "l" "6" "m" "7" "g" "8" "e" \\
^                     "u" 4.5 2.8 "g"
^  chirality = delete [(motif_id atom_name)*4]
^  chirality = delete "9" "t" "10" "n" "11" "d" "12" "y"
^  planarity {
^    action = add
^    motif_id = "7"
^    id = "e"
^    atom = [motif_id name weight]
^    atom = "1" "s" 1.2
^    atom = "2" "d" 2.3
^    atom = "3" "f" 3.4
^  }
^  planarity {
^    action = change
^    motif_id = "8"
^    id = "f"
^    atom = add [motif_id name weight]
^    atom = add "1" "s" 1.2
^    atom = change [motif_id name weight]
^    atom = change "2" "d" 2.3
^    atom = delete [motif_id name]
^    atom = delete "3" "f"
^  }
^  planarity {
^    action = delete
^    motif_id = "4"
^    id = "n"
^  }
^}
""")
  out = StringIO()
  m.show(out=out)
  phil.parse(input_string=out.getvalue())
Example #2
0
 def as_geometry_restraints_motif_manipulation(self):
   result = geometry_restraints.motif_manipulation()
   result.id = if_none(self.chem_mod.id, "")
   result.description = if_none(self.chem_mod.name, "")
   if (self.source_info is not None):
     result.info.append(self.source_info)
   alts = []
   for atom in self.atom_list:
     a = geometry_restraints.motif_alteration(
       action=if_none(atom.function, ""), operand="atom")
     a.motif_ids.append("")
     if (a.action != "add"):
       a.motif_atom_name = if_none(atom.atom_id, "")
     a.atom.name = if_none(atom.new_atom_id, "")
     a.atom.scattering_type = if_none(atom.new_type_symbol, "")
     a.atom.nonbonded_type = if_none(atom.new_type_energy, "")
     a.atom.partial_charge = if_none(atom.new_partial_charge, 0)
     if (a.action == "change"):
       a.set_change_partial_charge(state=atom.new_partial_charge is not None)
     alts.append(a)
   for bond in self.bond_list:
     a = geometry_restraints.motif_alteration(
       action=if_none(bond.function, ""), operand="bond")
     a.motif_ids.append("")
     a.motif_ids.append("")
     a.bond.atom_names = [
       if_none(bond.atom_id_1, ""),
       if_none(bond.atom_id_2, "")]
     a.bond.type = if_none(bond.new_type, "")
     a.bond.distance_ideal = if_none(bond.new_value_dist, 0)
     a.bond.weight = esd_as_weight(bond.new_value_dist_esd)
     if (a.action == "change"):
       a.set_change_distance_ideal(state=bond.new_value_dist is not None)
       a.set_change_weight(state=bond.new_value_dist_esd is not None)
     alts.append(a)
   for angle in self.angle_list:
     a = geometry_restraints.motif_alteration(
       action=if_none(bond.function, ""), operand="angle")
     a.motif_ids.append("")
     a.motif_ids.append("")
     a.motif_ids.append("")
     a.angle.atom_names = [
       if_none(angle.atom_id_1, ""),
       if_none(angle.atom_id_2, ""),
       if_none(angle.atom_id_3, "")]
     a.angle.angle_ideal = if_none(angle.new_value_angle, 0)
     a.angle.weight = esd_as_weight(angle.new_value_angle_esd)
     if (a.action == "change"):
       a.set_change_angle_ideal(state=angle.new_value_angle is not None)
       a.set_change_weight(state=angle.new_value_angle_esd is not None)
     alts.append(a)
   for tor in self.tor_list:
     a = geometry_restraints.motif_alteration(
       action=if_none(tor.function, ""), operand="dihedral")
     a.motif_ids.append("")
     a.motif_ids.append("")
     a.motif_ids.append("")
     a.motif_ids.append("")
     a.dihedral.atom_names = [
       if_none(tor.atom_id_1, ""),
       if_none(tor.atom_id_2, ""),
       if_none(tor.atom_id_3, ""),
       if_none(tor.atom_id_4, "")]
     a.dihedral.angle_ideal = if_none(tor.new_value_angle, 0)
     a.dihedral.weight = esd_as_weight(tor.new_value_angle_esd)
     a.dihedral.periodicity = if_none(tor.new_period, 0)
     a.dihedral.id = if_none(tor.id, "")
     if (a.action == "change"):
       a.set_change_angle_ideal(state=tor.new_value_angle is not None)
       a.set_change_weight(state=tor.new_value_angle_esd is not None)
       a.set_change_periodicity(state=tor.new_period is not None)
     alts.append(a)
   for chir in self.chir_list:
     a = geometry_restraints.motif_alteration(
       action=if_none(chir.function, ""), operand="chirality")
     a.motif_ids.append("")
     a.motif_ids.append("")
     a.motif_ids.append("")
     a.motif_ids.append("")
     a.chirality.atom_names = [
       if_none(chir.atom_id_centre, ""),
       if_none(chir.atom_id_1, ""),
       if_none(chir.atom_id_2, ""),
       if_none(chir.atom_id_3, "")]
     a.chirality.volume_sign = if_none(chir.new_volume_sign, 0)
     a.chirality.id = if_none(chir.id, "")
     alts.append(a)
   for plane in self.get_planes():
     a = geometry_restraints.motif_alteration(
       action="change", operand="planarity")
     a.motif_ids.resize(len(plane.plane_atoms))
     a.set_planarity_atom_actions([if_none(plane_atom.function, "")
       for plane_atom in plane.plane_atoms])
     a.planarity.atom_names = flex.std_string([if_none(plane_atom.atom_id, "")
       for plane_atom in plane.plane_atoms])
     a.planarity.weights = flex.double([esd_as_weight(plane_atom.new_dist_esd)
       for plane_atom in plane.plane_atoms])
     a.planarity.id = plane.plane_id
     alts.append(a)
   result.set_alterations(alts)
   return result
Example #3
0
 def as_geometry_restraints_motif_manipulation(self):
     result = geometry_restraints.motif_manipulation()
     result.id = if_none(self.chem_link.id, "")
     result.description = if_none(self.chem_link.name, "")
     if (self.source_info is not None):
         result.info.append(self.source_info)
     alts = []
     for bond in self.bond_list:
         a = geometry_restraints.motif_alteration(action="add",
                                                  operand="bond")
         a.motif_ids.append(str(if_none(bond.atom_1_comp_id, "")))
         a.motif_ids.append(str(if_none(bond.atom_2_comp_id, "")))
         a.bond.atom_names = [
             if_none(bond.atom_id_1, ""),
             if_none(bond.atom_id_2, "")
         ]
         a.bond.type = if_none(bond.type, "")
         a.bond.distance_ideal = if_none(bond.value_dist, 0)
         a.bond.weight = esd_as_weight(bond.value_dist_esd)
         alts.append(a)
     for angle in self.angle_list:
         a = geometry_restraints.motif_alteration(action="add",
                                                  operand="angle")
         a.motif_ids.append(str(if_none(angle.atom_1_comp_id, "")))
         a.motif_ids.append(str(if_none(angle.atom_2_comp_id, "")))
         a.motif_ids.append(str(if_none(angle.atom_3_comp_id, "")))
         a.angle.atom_names = [
             if_none(angle.atom_id_1, ""),
             if_none(angle.atom_id_2, ""),
             if_none(angle.atom_id_3, "")
         ]
         a.angle.angle_ideal = if_none(angle.value_angle, 0)
         a.angle.weight = esd_as_weight(angle.value_angle_esd)
         alts.append(a)
     for tor in self.tor_list:
         a = geometry_restraints.motif_alteration(action="add",
                                                  operand="dihedral")
         a.motif_ids.append(str(if_none(tor.atom_1_comp_id, "")))
         a.motif_ids.append(str(if_none(tor.atom_2_comp_id, "")))
         a.motif_ids.append(str(if_none(tor.atom_3_comp_id, "")))
         a.motif_ids.append(str(if_none(tor.atom_4_comp_id, "")))
         a.dihedral.atom_names = [
             if_none(tor.atom_id_1, ""),
             if_none(tor.atom_id_2, ""),
             if_none(tor.atom_id_3, ""),
             if_none(tor.atom_id_4, "")
         ]
         a.dihedral.angle_ideal = if_none(tor.value_angle, 0)
         a.dihedral.weight = esd_as_weight(tor.value_angle_esd)
         a.dihedral.periodicity = if_none(tor.period, 0)
         a.dihedral.id = if_none(tor.id, "")
         alts.append(a)
     for chir in self.chir_list:
         a = geometry_restraints.motif_alteration(action="add",
                                                  operand="chirality")
         a.motif_ids.append(str(if_none(chir.atom_centre_comp_id, "")))
         a.motif_ids.append(str(if_none(chir.atom_1_comp_id, "")))
         a.motif_ids.append(str(if_none(chir.atom_2_comp_id, "")))
         a.motif_ids.append(str(if_none(chir.atom_3_comp_id, "")))
         a.chirality.atom_names = [
             if_none(chir.atom_id_centre, ""),
             if_none(chir.atom_id_1, ""),
             if_none(chir.atom_id_2, ""),
             if_none(chir.atom_id_3, "")
         ]
         a.chirality.volume_sign = if_none(chir.volume_sign, 0)
         a.chirality.id = if_none(chir.id, "")
         alts.append(a)
     for plane in self.get_planes():
         a = geometry_restraints.motif_alteration(action="add",
                                                  operand="planarity")
         for plane_atom in plane.plane_atoms:
             if (plane_atom.atom_comp_id is None):
                 a.motif_ids.append("")
             else:
                 a.motif_ids.append(str(plane_atom.atom_comp_id))
         a.planarity.atom_names = flex.std_string([
             if_none(plane_atom.atom_id, "")
             for plane_atom in plane.plane_atoms
         ])
         a.planarity.weights = flex.double([
             esd_as_weight(plane_atom.dist_esd)
             for plane_atom in plane.plane_atoms
         ])
         a.planarity.id = plane.plane_id
         alts.append(a)
     result.set_alterations(alts)
     return result
Example #4
0
 def as_geometry_restraints_motif_manipulation(self):
   result = geometry_restraints.motif_manipulation()
   result.id = if_none(self.chem_link.id, "")
   result.description = if_none(self.chem_link.name, "")
   if (self.source_info is not None):
     result.info.append(self.source_info)
   alts = []
   for bond in self.bond_list:
     a = geometry_restraints.motif_alteration(
       action="add", operand="bond")
     a.motif_ids.append(str(if_none(bond.atom_1_comp_id, "")))
     a.motif_ids.append(str(if_none(bond.atom_2_comp_id, "")))
     a.bond.atom_names = [
       if_none(bond.atom_id_1, ""),
       if_none(bond.atom_id_2, "")]
     a.bond.type = if_none(bond.type, "")
     a.bond.distance_ideal = if_none(bond.value_dist, 0)
     a.bond.weight = esd_as_weight(bond.value_dist_esd)
     alts.append(a)
   for angle in self.angle_list:
     a = geometry_restraints.motif_alteration(
       action="add", operand="angle")
     a.motif_ids.append(str(if_none(angle.atom_1_comp_id, "")))
     a.motif_ids.append(str(if_none(angle.atom_2_comp_id, "")))
     a.motif_ids.append(str(if_none(angle.atom_3_comp_id, "")))
     a.angle.atom_names = [
       if_none(angle.atom_id_1, ""),
       if_none(angle.atom_id_2, ""),
       if_none(angle.atom_id_3, "")]
     a.angle.angle_ideal = if_none(angle.value_angle, 0)
     a.angle.weight = esd_as_weight(angle.value_angle_esd)
     alts.append(a)
   for tor in self.tor_list:
     a = geometry_restraints.motif_alteration(
       action="add", operand="dihedral")
     a.motif_ids.append(str(if_none(tor.atom_1_comp_id, "")))
     a.motif_ids.append(str(if_none(tor.atom_2_comp_id, "")))
     a.motif_ids.append(str(if_none(tor.atom_3_comp_id, "")))
     a.motif_ids.append(str(if_none(tor.atom_4_comp_id, "")))
     a.dihedral.atom_names = [
       if_none(tor.atom_id_1, ""),
       if_none(tor.atom_id_2, ""),
       if_none(tor.atom_id_3, ""),
       if_none(tor.atom_id_4, "")]
     a.dihedral.angle_ideal = if_none(tor.value_angle, 0)
     a.dihedral.weight = esd_as_weight(tor.value_angle_esd)
     a.dihedral.periodicity = if_none(tor.period, 0)
     a.dihedral.id = if_none(tor.id, "")
     alts.append(a)
   for chir in self.chir_list:
     a = geometry_restraints.motif_alteration(
       action="add", operand="chirality")
     a.motif_ids.append(str(if_none(chir.atom_centre_comp_id, "")))
     a.motif_ids.append(str(if_none(chir.atom_1_comp_id, "")))
     a.motif_ids.append(str(if_none(chir.atom_2_comp_id, "")))
     a.motif_ids.append(str(if_none(chir.atom_3_comp_id, "")))
     a.chirality.atom_names = [
       if_none(chir.atom_id_centre, ""),
       if_none(chir.atom_id_1, ""),
       if_none(chir.atom_id_2, ""),
       if_none(chir.atom_id_3, "")]
     a.chirality.volume_sign = if_none(chir.volume_sign, 0)
     a.chirality.id = if_none(chir.id, "")
     alts.append(a)
   for plane in self.get_planes():
     a = geometry_restraints.motif_alteration(
       action="add", operand="planarity")
     for plane_atom in plane.plane_atoms:
       if (plane_atom.atom_comp_id is None):
         a.motif_ids.append("")
       else:
         a.motif_ids.append(str(plane_atom.atom_comp_id))
     a.planarity.atom_names = flex.std_string([if_none(plane_atom.atom_id, "")
       for plane_atom in plane.plane_atoms])
     a.planarity.weights = flex.double([esd_as_weight(plane_atom.dist_esd)
       for plane_atom in plane.plane_atoms])
     a.planarity.id = plane.plane_id
     alts.append(a)
   result.set_alterations(alts)
   return result
Example #5
0
 def as_geometry_restraints_motif_manipulation(self):
     result = geometry_restraints.motif_manipulation()
     result.id = if_none(self.chem_mod.id, "")
     result.description = if_none(self.chem_mod.name, "")
     if (self.source_info is not None):
         result.info.append(self.source_info)
     alts = []
     for atom in self.atom_list:
         a = geometry_restraints.motif_alteration(action=if_none(
             atom.function, ""),
                                                  operand="atom")
         a.motif_ids.append("")
         if (a.action != "add"):
             a.motif_atom_name = if_none(atom.atom_id, "")
         a.atom.name = if_none(atom.new_atom_id, "")
         a.atom.scattering_type = if_none(atom.new_type_symbol, "")
         a.atom.nonbonded_type = if_none(atom.new_type_energy, "")
         a.atom.partial_charge = if_none(atom.new_partial_charge, 0)
         if (a.action == "change"):
             a.set_change_partial_charge(
                 state=atom.new_partial_charge is not None)
         alts.append(a)
     for bond in self.bond_list:
         a = geometry_restraints.motif_alteration(action=if_none(
             bond.function, ""),
                                                  operand="bond")
         a.motif_ids.append("")
         a.motif_ids.append("")
         a.bond.atom_names = [
             if_none(bond.atom_id_1, ""),
             if_none(bond.atom_id_2, "")
         ]
         a.bond.type = if_none(bond.new_type, "")
         a.bond.distance_ideal = if_none(bond.new_value_dist, 0)
         a.bond.weight = esd_as_weight(bond.new_value_dist_esd)
         if (a.action == "change"):
             a.set_change_distance_ideal(
                 state=bond.new_value_dist is not None)
             a.set_change_weight(state=bond.new_value_dist_esd is not None)
         alts.append(a)
     for angle in self.angle_list:
         a = geometry_restraints.motif_alteration(action=if_none(
             bond.function, ""),
                                                  operand="angle")
         a.motif_ids.append("")
         a.motif_ids.append("")
         a.motif_ids.append("")
         a.angle.atom_names = [
             if_none(angle.atom_id_1, ""),
             if_none(angle.atom_id_2, ""),
             if_none(angle.atom_id_3, "")
         ]
         a.angle.angle_ideal = if_none(angle.new_value_angle, 0)
         a.angle.weight = esd_as_weight(angle.new_value_angle_esd)
         if (a.action == "change"):
             a.set_change_angle_ideal(
                 state=angle.new_value_angle is not None)
             a.set_change_weight(
                 state=angle.new_value_angle_esd is not None)
         alts.append(a)
     for tor in self.tor_list:
         a = geometry_restraints.motif_alteration(action=if_none(
             tor.function, ""),
                                                  operand="dihedral")
         a.motif_ids.append("")
         a.motif_ids.append("")
         a.motif_ids.append("")
         a.motif_ids.append("")
         a.dihedral.atom_names = [
             if_none(tor.atom_id_1, ""),
             if_none(tor.atom_id_2, ""),
             if_none(tor.atom_id_3, ""),
             if_none(tor.atom_id_4, "")
         ]
         a.dihedral.angle_ideal = if_none(tor.new_value_angle, 0)
         a.dihedral.weight = esd_as_weight(tor.new_value_angle_esd)
         a.dihedral.periodicity = if_none(tor.new_period, 0)
         a.dihedral.id = if_none(tor.id, "")
         if (a.action == "change"):
             a.set_change_angle_ideal(state=tor.new_value_angle is not None)
             a.set_change_weight(state=tor.new_value_angle_esd is not None)
             a.set_change_periodicity(state=tor.new_period is not None)
         alts.append(a)
     for chir in self.chir_list:
         a = geometry_restraints.motif_alteration(action=if_none(
             chir.function, ""),
                                                  operand="chirality")
         a.motif_ids.append("")
         a.motif_ids.append("")
         a.motif_ids.append("")
         a.motif_ids.append("")
         a.chirality.atom_names = [
             if_none(chir.atom_id_centre, ""),
             if_none(chir.atom_id_1, ""),
             if_none(chir.atom_id_2, ""),
             if_none(chir.atom_id_3, "")
         ]
         a.chirality.volume_sign = if_none(chir.new_volume_sign, 0)
         a.chirality.id = if_none(chir.id, "")
         alts.append(a)
     for plane in self.get_planes():
         a = geometry_restraints.motif_alteration(action="change",
                                                  operand="planarity")
         a.motif_ids.resize(len(plane.plane_atoms))
         a.set_planarity_atom_actions([
             if_none(plane_atom.function, "")
             for plane_atom in plane.plane_atoms
         ])
         a.planarity.atom_names = flex.std_string([
             if_none(plane_atom.atom_id, "")
             for plane_atom in plane.plane_atoms
         ])
         a.planarity.weights = flex.double([
             esd_as_weight(plane_atom.new_dist_esd)
             for plane_atom in plane.plane_atoms
         ])
         a.planarity.id = plane.plane_id
         alts.append(a)
     result.set_alterations(alts)
     return result