Exemplo n.º 1
0
def apply_glyco_link_using_proxies_and_atoms(atom_group1,
                                             atom_group2,
                                             bond_params_table,
                                             bond_asu_table,
                                             geometry_proxy_registries,
                                             rt_mx_ji,
                                             link_carbon_dist=2.0,
                                             ):
  def _add_bond(i_seqs,
                bond_params_table,
                bond_asu_table,
                value,
                esd,
                rt_mx_ji,
                ):
    proxy = geometry_restraints.bond_simple_proxy(
      i_seqs=i_seqs,
      distance_ideal=value,
      weight=1/esd**2)
    bond_params_table.update(i_seq=i_seqs[0],
                             j_seq=i_seqs[1],
                             params=proxy)
    bond_asu_table.add_pair(
      i_seq=i_seqs[0],
      j_seq=i_seqs[1],
      rt_mx_ji=rt_mx_ji,
      )
  #
  def _add_angle(i_seqs, geometry_proxy_registries, value, esd):
    proxy = geometry_restraints.angle_proxy(
      i_seqs=i_seqs,
      angle_ideal=value,
      weight=1/esd**2)
    geometry_proxy_registries.angle.add_if_not_duplicated(proxy=proxy)
  #
  def _add_chiral(i_seqs, geometry_proxy_registries, value, esd, both_signs=False):
    proxy = geometry_restraints.chirality_proxy(
      i_seqs=i_seqs,
      volume_ideal=value,
      both_signs=both_signs,
      weight=1/esd**2,
      )
    geometry_proxy_registries.chirality.add_if_not_duplicated(proxy=proxy)

  def atom_group_output(atom_group):
    outl = ""
    for atom in atom_group.atoms():
      outl += "%s%s\n" % (' '*10, atom.quote())
    return outl

  ########
  from mmtbx.monomer_library import glyco_utils
#  anomeric_carbon, link_oxygen, ring_oxygen, ring_carbon, link_carbon, anomeric_hydrogen = \
#      glyco_utils.get_glyco_link_atoms(atom_group1, atom_group2)
  gla = glyco_utils.get_glyco_link_atoms(atom_group1,
                                         atom_group2,
                                         link_carbon_dist=link_carbon_dist,
    )
  # checks
  if gla and not gla.is_correct():
    gla = glyco_utils.get_glyco_link_atoms(atom_group2,
                                           atom_group1,
                                           link_carbon_dist=link_carbon_dist,
      )
  if gla and not gla.is_correct():
    raise Sorry("""Failed to get all the atoms needed for glycosidic bond
between

      group 1
%s
      group 2
%s
    """ % (atom_group_output(atom_group1), atom_group_output(atom_group2)
    )
    )
  if gla is None:
    raise Sorry("""Unspecified problem with carbohydrate groups. Could be that
the linking oxygen is on the linking residue instead of the docking residue.

    group 1
%s
    group 2
%s
    """ % (atom_group_output(atom_group1), atom_group_output(atom_group2)
           )
           )
  if not gla.anomeric_carbon_linking:
    raise Sorry("""The linking carbohydrate unit has the oxygen attached to the
anomeric carbon.

  Consider replacing oxygen %s
  with an oxygen linked to  %s in the same residue
    %s""" % (gla.link_oxygen.quote(),
             gla.link_carbon.quote(),
             gla)
             )
  i_seqs = [gla.anomeric_carbon.i_seq, gla.link_oxygen.i_seq]
  bond_i_seqs = i_seqs
  # bonds
  _add_bond(i_seqs, bond_params_table, bond_asu_table, 1.439, 0.02, rt_mx_ji)
  # angles
  for i_atoms, value, esd in [
      [[gla.link_carbon, gla.link_oxygen,     gla.anomeric_carbon],   108.7,  3.],
      [[gla.link_oxygen, gla.anomeric_carbon, gla.ring_oxygen],       112.3,  3.],
      [[gla.link_oxygen, gla.anomeric_carbon, gla.ring_carbon],       109.47, 3.],
      [[gla.link_oxygen, gla.anomeric_carbon, gla.anomeric_hydrogen], 109.47, 3.],
    ]:
    if None in i_atoms: continue
    i_seqs = [atom.i_seq for atom in i_atoms]
    _add_angle(i_seqs, geometry_proxy_registries, value, esd)
  # chiral
  i_seqs = gla.get_chiral_i_seqs()
  if i_seqs is None:
    raise Sorry("""Unable to determine the linking chiral atoms for atom groups
    group 1
%s
    group 2
%s
    """ % (atom_group_output(atom_group1), atom_group_output(atom_group2)
    )
    )
  value = get_chiral_sign(gla.anomeric_carbon.parent().resname)
  if value:
    esd = 0.02
    _add_chiral(i_seqs, geometry_proxy_registries, value, esd)

  return gla.get_isomer(), gla.as_cif(), bond_i_seqs
Exemplo n.º 2
0
def apply_glyco_link_using_proxies_and_atoms(
    atom_group1,
    atom_group2,
    bond_params_table,
    bond_asu_table,
    geometry_proxy_registries,
    rt_mx_ji,
    link_carbon_dist=2.0,
):
    def _add_bond(
        i_seqs,
        bond_params_table,
        bond_asu_table,
        value,
        esd,
        rt_mx_ji,
    ):
        proxy = geometry_restraints.bond_simple_proxy(i_seqs=i_seqs,
                                                      distance_ideal=value,
                                                      weight=1 / esd**2)
        bond_params_table.update(i_seq=i_seqs[0],
                                 j_seq=i_seqs[1],
                                 params=proxy)
        bond_asu_table.add_pair(
            i_seq=i_seqs[0],
            j_seq=i_seqs[1],
            rt_mx_ji=rt_mx_ji,
        )

    #
    def _add_angle(i_seqs, geometry_proxy_registries, value, esd):
        proxy = geometry_restraints.angle_proxy(i_seqs=i_seqs,
                                                angle_ideal=value,
                                                weight=1 / esd**2)
        geometry_proxy_registries.angle.add_if_not_duplicated(proxy=proxy)

    #
    def _add_chiral(i_seqs,
                    geometry_proxy_registries,
                    value,
                    esd,
                    both_signs=False):
        proxy = geometry_restraints.chirality_proxy(
            i_seqs=i_seqs,
            volume_ideal=value,
            both_signs=both_signs,
            weight=1 / esd**2,
        )
        geometry_proxy_registries.chirality.add_if_not_duplicated(proxy=proxy)

    def atom_group_output(atom_group):
        outl = ""
        for atom in atom_group.atoms():
            outl += "%s%s\n" % (' ' * 10, atom.quote())
        return outl

    ########
    from mmtbx.monomer_library import glyco_utils
    #  anomeric_carbon, link_oxygen, ring_oxygen, ring_carbon, link_carbon, anomeric_hydrogen = \
    #      glyco_utils.get_glyco_link_atoms(atom_group1, atom_group2)
    gla = glyco_utils.get_glyco_link_atoms(
        atom_group1,
        atom_group2,
        link_carbon_dist=link_carbon_dist,
    )
    # checks
    if gla and not gla.is_correct():
        gla = glyco_utils.get_glyco_link_atoms(
            atom_group2,
            atom_group1,
            link_carbon_dist=link_carbon_dist,
        )
    if gla and not gla.is_correct():
        raise Sorry("""Failed to get all the atoms needed for glycosidic bond
between

      group 1
%s
      group 2
%s
    """ % (atom_group_output(atom_group1), atom_group_output(atom_group2)))
    if gla is None:
        raise Sorry(
            """Unspecified problem with carbohydrate groups. Could be that
the linking oxygen is on the linking residue instead of the docking residue.

    group 1
%s
    group 2
%s
    """ % (atom_group_output(atom_group1), atom_group_output(atom_group2)))
    if not gla.anomeric_carbon_linking:
        raise Sorry(
            """The linking carbohydrate unit has the oxygen attached to the
anomeric carbon.

  Consider replacing oxygen %s
  with an oxygen linked to  %s in the same residue
    %s""" % (gla.link_oxygen.quote(), gla.link_carbon.quote(), gla))
    i_seqs = [gla.anomeric_carbon.i_seq, gla.link_oxygen.i_seq]
    bond_i_seqs = i_seqs
    # bonds
    _add_bond(i_seqs, bond_params_table, bond_asu_table, 1.439, 0.02, rt_mx_ji)
    # angles
    for i_atoms, value, esd in [
        [[gla.link_carbon, gla.link_oxygen, gla.anomeric_carbon], 108.7, 3.],
        [[gla.link_oxygen, gla.anomeric_carbon, gla.ring_oxygen], 112.3, 3.],
        [[gla.link_oxygen, gla.anomeric_carbon, gla.ring_carbon], 109.47, 3.],
        [[gla.link_oxygen, gla.anomeric_carbon, gla.anomeric_hydrogen], 109.47,
         3.],
    ]:
        if None in i_atoms: continue
        i_seqs = [atom.i_seq for atom in i_atoms]
        _add_angle(i_seqs, geometry_proxy_registries, value, esd)
    # chiral
    i_seqs = gla.get_chiral_i_seqs()
    if i_seqs is None:
        raise Sorry(
            """Unable to determine the linking chiral atoms for atom groups
    group 1
%s
    group 2
%s
    """ % (atom_group_output(atom_group1), atom_group_output(atom_group2)))
    value = get_chiral_sign(gla.anomeric_carbon.parent().resname)
    if value:
        esd = 0.02
        _add_chiral(i_seqs, geometry_proxy_registries, value, esd)

    return gla.get_isomer(), gla.as_cif(), bond_i_seqs