def exercise():
  """
  Exercise refine "easy" with DNA/RNA.
  """
  pi_good = get_pdb_inputs(pdb_str=pdb_str_answer, restraints=False)
  map_data = get_map(xrs=pi_good.xrs)
  xrs_good = pi_good.xrs.deep_copy_scatterers()
  pi_good.ph.write_pdb_file(file_name="answer.pdb",
    crystal_symmetry=xrs_good.crystal_symmetry())
  #
  pi_poor = get_pdb_inputs(pdb_str=pdb_str_poor, restraints=True)
  pi_poor.ph.write_pdb_file(file_name="poor.pdb")
  xrs_poor = pi_poor.xrs.deep_copy_scatterers()
  #
  d = xrs_good.distances(other=xrs_poor)
  print d.min_max_mean().as_tuple()
  assert flex.max(d)>2
  assert flex.mean(d)>0.7
  #
  xrs_refined = xrs_poor
  for i in xrange(3):
    ero = individual_sites.easy(
      map_data                    = map_data,
      xray_structure              = xrs_refined,
      pdb_hierarchy               = pi_poor.ph,
      geometry_restraints_manager = pi_poor.grm)
    xrs_refined = ero.xray_structure
  # comapre
  d = xrs_good.distances(other=xrs_refined)
  print d.min_max_mean().as_tuple()
  assert flex.max(d)<0.15
  assert flex.mean(d)<0.03
  ero.pdb_hierarchy.write_pdb_file(file_name="refined.pdb",
    crystal_symmetry=xrs_good.crystal_symmetry())
Пример #2
0
def exercise():
    """
  Exercise refine "easy" with DNA/RNA.
  """
    pi_good = get_pdb_inputs(pdb_str=pdb_str_answer, restraints=False)
    map_data = get_map(xrs=pi_good.xrs)
    xrs_good = pi_good.xrs.deep_copy_scatterers()
    pi_good.ph.write_pdb_file(file_name="answer.pdb",
                              crystal_symmetry=xrs_good.crystal_symmetry())
    #
    pi_poor = get_pdb_inputs(pdb_str=pdb_str_poor, restraints=True)
    pi_poor.ph.write_pdb_file(file_name="poor.pdb")
    xrs_poor = pi_poor.xrs.deep_copy_scatterers()
    #
    d = xrs_good.distances(other=xrs_poor)
    print d.min_max_mean().as_tuple()
    assert flex.max(d) > 2
    assert flex.mean(d) > 0.7
    #
    xrs_refined = xrs_poor
    for i in xrange(3):
        ero = individual_sites.easy(map_data=map_data,
                                    xray_structure=xrs_refined,
                                    pdb_hierarchy=pi_poor.ph,
                                    geometry_restraints_manager=pi_poor.grm)
        xrs_refined = ero.xray_structure
    # comapre
    d = xrs_good.distances(other=xrs_refined)
    print d.min_max_mean().as_tuple()
    assert flex.max(d) < 0.15
    assert flex.mean(d) < 0.03
    ero.pdb_hierarchy.write_pdb_file(
        file_name="refined.pdb", crystal_symmetry=xrs_good.crystal_symmetry())
Пример #3
0
def flip_and_refine(pdb_hierarchy,
                    xray_structure,
                    target_map,
                    geometry_restraints_manager,
                    chain,
                    res_num,
                    alt_loc = None,
                    n_refine_cycles = 3,
                    log = sys.stdout):
  sites_cart = xray_structure.sites_cart()
  ero = False
  for ch in pdb_hierarchy.chains():
    if ch.id.strip() != chain : continue
    for rg in ch.residue_groups():
      if rg.resseq_as_int() != res_num : continue
      if rg.have_conformers() and not alt_loc :
        s = 'Specified residue has alternate conformations. Please specify '
        raise RuntimeError(s + 'alt_loc on the command line')
      for residue in rg.atom_groups():
        if alt_loc and alt_loc != residue.altloc.strip():
          continue
        flip_base(residue, angle=180)

        sites_cart.set_selected(residue.atoms().extract_i_seq(),
          residue.atoms().extract_xyz())
        xray_structure = xray_structure.replace_sites_cart(sites_cart)
        sele = residue.atoms().extract_i_seq()
        print >> log, 'real-space refinement BEGIN'.center(79,'*')
        for i in range(n_refine_cycles):
          print >> log, 'real-space refinement cycle %i...' % (i + 1)
          ero = individual_sites.easy(
            map_data                    = target_map,
            xray_structure              = xray_structure,
            pdb_hierarchy               = pdb_hierarchy,
            geometry_restraints_manager = geometry_restraints_manager,
            selection                   = sele)
        print >> log, 'real-space refinement FINISHED'.center(79,'*')
  if not ero : raise RuntimeError('Specified residue not found')
  return ero.pdb_hierarchy
Пример #4
0
def flip_and_refine(pdb_hierarchy,
                    xray_structure,
                    target_map,
                    geometry_restraints_manager,
                    chain,
                    res_num,
                    alt_loc = None,
                    n_refine_cycles = 3,
                    log = sys.stdout) :
  sites_cart = xray_structure.sites_cart()
  ero = False
  for ch in pdb_hierarchy.chains():
    if ch.id.strip() != chain : continue
    for rg in ch.residue_groups():
      if rg.resseq_as_int() != res_num : continue
      if rg.have_conformers() and not alt_loc :
        s = 'Specified residue has alternate conformations. Please specify '
        raise RuntimeError(s + 'alt_loc on the command line')
      for residue in rg.atom_groups():
        if alt_loc and alt_loc != residue.altloc.strip():
          continue
        flip_base(residue, angle=180)

        sites_cart.set_selected(residue.atoms().extract_i_seq(),
          residue.atoms().extract_xyz())
        xray_structure = xray_structure.replace_sites_cart(sites_cart)
        sele = residue.atoms().extract_i_seq()
        print >> log, 'real-space refinement BEGIN'.center(79,'*')
        for i in range(n_refine_cycles):
          print >> log, 'real-space refinement cycle %i...' % (i + 1)
          ero = individual_sites.easy(
            map_data                    = target_map,
            xray_structure              = xray_structure,
            pdb_hierarchy               = pdb_hierarchy,
            geometry_restraints_manager = geometry_restraints_manager,
            selection                   = sele)
        print >> log, 'real-space refinement FINISHED'.center(79,'*')
  if not ero : raise RuntimeError('Specified residue not found')
  return ero.pdb_hierarchy
Пример #5
0
 def refine_rsr(self, pdb_obj, pdb_hier, pdb_xrs, map_data, restraints):
     #restraints manager required, generated as part of structure data
     #res_sigma is target for coordinate restraints
     #refinement updates coordinates, so make a copy first
     input_xrs = copy.deepcopy(pdb_xrs)
     input_hier = copy.deepcopy(pdb_hier)
     try:
         #weight of 5.0 allows good movement into density
         #speeds up by skipping weight calculation
         ref_out = rsr.easy(map_data,
                            input_xrs,
                            input_hier,
                            restraints,
                            w=5.0,
                            max_iterations=100)
         ref_xrs = ref_out.xray_structure
         ref_hier = ref_out.pdb_hierarchy
     except:
         print "RSR of chainid,resid " + self.chainid + str(
             self.resid) + " FAILED!"
         #return unrefined structure (a bit dangerous)
         ref_xrs = input_xrs
         ref_hier = input_hier
     return ref_xrs, ref_hier
Пример #6
0
def exercise():
  """
  Exercise refine "easy" with DNA/RNA.
  """
  pi_good = get_pdb_inputs(pdb_str=pdb_str_answer, restraints=False)
  map_data = get_map(xrs=pi_good.xrs)
  xrs_good = pi_good.xrs.deep_copy_scatterers()
  pi_good.ph.write_pdb_file(file_name="answer.pdb",
    crystal_symmetry=xrs_good.crystal_symmetry())
  #
  pi_poor = get_pdb_inputs(pdb_str=pdb_str_poor, restraints=True)
  pi_poor.ph.write_pdb_file(file_name="poor.pdb")
  xrs_poor = pi_poor.xrs.deep_copy_scatterers()
  #
  d = xrs_good.distances(other=xrs_poor)
  print d.min_max_mean().as_tuple()
  assert flex.max(d)>3
  assert flex.mean(d)>1

  chain = 'B'
  res_num = 40
  alt_loc = None
  ero = False
  n_refine_cycles = 3
  target_map = get_map(xrs=pi_good.xrs)
  sites_cart = xrs_poor.sites_cart()
  for ch in pi_poor.ph.chains():
    if ch.id.strip() != chain : continue
    print 'chain'
    for rg in ch.residue_groups():
      if rg.resseq_as_int() != res_num : continue
      print "res#"
      if rg.have_conformers() and not alt_loc :
        s = 'Specified residue has alternate conformations. Please specify '
        raise RuntimeError(s + 'alt_loc on the command line')
      for residue in rg.atom_groups():
        if alt_loc and alt_loc != residue.altloc.strip():
          continue
        flipbase.flip_base(residue, angle=180)

        sites_cart.set_selected(residue.atoms().extract_i_seq(),
          residue.atoms().extract_xyz())
        xray_structure = xrs_poor.replace_sites_cart(sites_cart)
        sele = residue.atoms().extract_i_seq()
        print 'real-space refinement BEGIN'.center(79,'*')
        for i in range(n_refine_cycles):
          print 'real-space refinement cycle %i...' % (i + 1)
          ero = individual_sites.easy(
            map_data                    = target_map,
            xray_structure              = xray_structure,
            pdb_hierarchy               = pi_poor.ph,
            geometry_restraints_manager = pi_poor.grm,
            selection                   = sele)
        print 'real-space refinement FINISHED'.center(79,'*')
        xrs_refined = ero.xray_structure
  if not ero : raise RuntimeError('Specified residue not found')
  d = xrs_good.distances(other=xrs_refined)
  print d.min_max_mean().as_tuple()
  assert flex.max(d)<0.07
  assert flex.mean(d)<0.03
  ero.pdb_hierarchy.write_pdb_file(file_name="refined.pdb",
    crystal_symmetry=xrs_good.crystal_symmetry())
Пример #7
0
def exercise():
    """
  Exercise refine "easy" with DNA/RNA.
  """
    pi_good = get_pdb_inputs(pdb_str=pdb_str_answer, restraints=False)
    map_data = get_map(xrs=pi_good.xrs)
    xrs_good = pi_good.xrs.deep_copy_scatterers()
    pi_good.ph.write_pdb_file(file_name="answer.pdb", crystal_symmetry=xrs_good.crystal_symmetry())
    #
    pi_poor = get_pdb_inputs(pdb_str=pdb_str_poor, restraints=True)
    pi_poor.ph.write_pdb_file(file_name="poor.pdb")
    xrs_poor = pi_poor.xrs.deep_copy_scatterers()
    #
    d = xrs_good.distances(other=xrs_poor)
    print d.min_max_mean().as_tuple()
    assert flex.max(d) > 3
    assert flex.mean(d) > 1

    chain = "B"
    res_num = 40
    alt_loc = None
    ero = False
    n_refine_cycles = 3
    target_map = get_map(xrs=pi_good.xrs)
    sites_cart = xrs_poor.sites_cart()
    for ch in pi_poor.ph.chains():
        if ch.id.strip() != chain:
            continue
        print "chain"
        for rg in ch.residue_groups():
            if rg.resseq_as_int() != res_num:
                continue
            print "res#"
            if rg.have_conformers() and not alt_loc:
                s = "Specified residue has alternate conformations. Please specify "
                raise RuntimeError(s + "alt_loc on the command line")
            for residue in rg.atom_groups():
                if alt_loc and alt_loc != residue.altloc.strip():
                    continue
                flipbase.flip_base(residue, angle=180)

                sites_cart.set_selected(residue.atoms().extract_i_seq(), residue.atoms().extract_xyz())
                xray_structure = xrs_poor.replace_sites_cart(sites_cart)
                sele = residue.atoms().extract_i_seq()
                print "real-space refinement BEGIN".center(79, "*")
                for i in range(n_refine_cycles):
                    print "real-space refinement cycle %i..." % (i + 1)
                    ero = individual_sites.easy(
                        map_data=target_map,
                        xray_structure=xray_structure,
                        pdb_hierarchy=pi_poor.ph,
                        geometry_restraints_manager=pi_poor.grm,
                        selection=sele,
                    )
                print "real-space refinement FINISHED".center(79, "*")
                xrs_refined = ero.xray_structure
    if not ero:
        raise RuntimeError("Specified residue not found")
    d = xrs_good.distances(other=xrs_refined)
    print d.min_max_mean().as_tuple()
    assert flex.max(d) < 0.07
    assert flex.mean(d) < 0.03
    ero.pdb_hierarchy.write_pdb_file(file_name="refined.pdb", crystal_symmetry=xrs_good.crystal_symmetry())