Exemple #1
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
Exemple #2
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
Exemple #3
0
 def as_geometry_restraints_motif(self):
   result = geometry_restraints.motif()
   result.id = if_none(self.chem_comp.id, "")
   result.description = if_none(self.chem_comp.name, "").strip()
   if (self.source_info is not None):
     result.info.append(self.source_info)
   result.set_atoms([
     geometry_restraints.motif_atom(
       name=if_none(atom.atom_id, ""),
       scattering_type=if_none(atom.type_symbol, ""),
       nonbonded_type=if_none(atom.type_energy, ""),
       partial_charge=if_none(atom.partial_charge, 0))
         for atom in self.atom_list])
   result.set_bonds([
     geometry_restraints.motif_bond(
       atom_names=[
         if_none(bond.atom_id_1, ""),
         if_none(bond.atom_id_2, "")],
       type=if_none(bond.type, ""),
       distance_ideal=if_none(bond.value_dist, 0),
       weight=esd_as_weight(bond.value_dist_esd))
         for bond in self.bond_list])
   result.set_angles([
     geometry_restraints.motif_angle(
       atom_names=[
         if_none(angle.atom_id_1, ""),
         if_none(angle.atom_id_2, ""),
         if_none(angle.atom_id_3, "")],
       angle_ideal=if_none(angle.value_angle, 0),
       weight=esd_as_weight(angle.value_angle_esd))
         for angle in self.angle_list])
   result.set_dihedrals([
     geometry_restraints.motif_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, "")],
       angle_ideal=if_none(tor.value_angle, 0),
       weight=esd_as_weight(tor.value_angle_esd),
       periodicity=if_none(tor.period, 0),
       id=tor.id)
         for tor in self.tor_list])
   result.set_chiralities([
     geometry_restraints.motif_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, "")],
       volume_sign=chir.volume_sign,
       id=chir.id)
         for chir in self.chir_list])
   planarities = []
   for plane in self.get_planes():
     atom_names = flex.std_string([if_none(plane_atom.atom_id, "")
       for plane_atom in plane.plane_atoms])
     weights = flex.double([esd_as_weight(plane_atom.dist_esd)
       for plane_atom in plane.plane_atoms])
     planarities.append(
       geometry_restraints.motif_planarity(
         atom_names=atom_names,
         weights=weights,
         id=plane.plane_id))
   result.set_planarities(planarities)
   return result
Exemple #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
Exemple #5
0
 def as_geometry_restraints_motif(self):
     result = geometry_restraints.motif()
     result.id = if_none(self.chem_comp.id, "")
     result.description = if_none(self.chem_comp.name, "").strip()
     if (self.source_info is not None):
         result.info.append(self.source_info)
     result.set_atoms([
         geometry_restraints.motif_atom(
             name=if_none(atom.atom_id, ""),
             scattering_type=if_none(atom.type_symbol, ""),
             nonbonded_type=if_none(atom.type_energy, ""),
             partial_charge=if_none(atom.partial_charge, 0))
         for atom in self.atom_list
     ])
     result.set_bonds([
         geometry_restraints.motif_bond(
             atom_names=[
                 if_none(bond.atom_id_1, ""),
                 if_none(bond.atom_id_2, "")
             ],
             type=if_none(bond.type, ""),
             distance_ideal=if_none(bond.value_dist, 0),
             weight=esd_as_weight(bond.value_dist_esd))
         for bond in self.bond_list
     ])
     result.set_angles([
         geometry_restraints.motif_angle(
             atom_names=[
                 if_none(angle.atom_id_1, ""),
                 if_none(angle.atom_id_2, ""),
                 if_none(angle.atom_id_3, "")
             ],
             angle_ideal=if_none(angle.value_angle, 0),
             weight=esd_as_weight(angle.value_angle_esd))
         for angle in self.angle_list
     ])
     result.set_dihedrals([
         geometry_restraints.motif_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, "")
             ],
             angle_ideal=if_none(tor.value_angle, 0),
             weight=esd_as_weight(tor.value_angle_esd),
             periodicity=if_none(tor.period, 0),
             id=tor.id) for tor in self.tor_list
     ])
     result.set_chiralities([
         geometry_restraints.motif_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, "")
         ],
                                             volume_sign=chir.volume_sign,
                                             id=chir.id)
         for chir in self.chir_list
     ])
     planarities = []
     for plane in self.get_planes():
         atom_names = flex.std_string([
             if_none(plane_atom.atom_id, "")
             for plane_atom in plane.plane_atoms
         ])
         weights = flex.double([
             esd_as_weight(plane_atom.dist_esd)
             for plane_atom in plane.plane_atoms
         ])
         planarities.append(
             geometry_restraints.motif_planarity(atom_names=atom_names,
                                                 weights=weights,
                                                 id=plane.plane_id))
     result.set_planarities(planarities)
     return result
Exemple #6
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