Ejemplo n.º 1
0
def create_asu(ncs_filename,asu_filename,crystal_symmetry=None):
  ''' (str,str) -> crystal_symmetry object
  Create ASU from NCS and save the new pdb file
  with CRYST1 and SCALE records in local directory

  Argument:
  ---------
  ncs_filename : NCS to be used to create the ASU
  asu_filename : ASU file name
  crystal_symmetry : Allow forcing other crystal_symmetry

  Returns:
  --------
  crystal_symmetry
  '''
  m = multimer(ncs_filename,'cau',error_handle=True,eps=1e-2)
  if m.number_of_transforms == 0:
    print 'Number of transforms is zero'
  m.write(asu_filename)
  pdb_inp = pdb.input(file_name = asu_filename)
  xrs = pdb_inp.xray_structure_simple()
  if not crystal_symmetry:
    crystal_symmetry = xrs.crystal_symmetry()
  pdb_inp.write_pdb_file(file_name = asu_filename, crystal_symmetry = crystal_symmetry)
  return crystal_symmetry
Ejemplo n.º 2
0
  def create_asu(self,ncs_filename,asu_filename,crystal_symmetry=None):
    """ (str,str) -> crystal_symmetry object
    Create P1 crystal_symmetry that fit the ASU.
    Create ASU from NCS and save the new pdb file
    with CRYST1 and SCALE records in local directory

    Argument:
    ---------
    ncs_filename : NCS to be used to create the ASU
    asu_filename : ASU file name
    crystal_symmetry : Allow forcing other crystal_symmetry

    Returns:
    --------
    crystal_symmetry
    """
    m = multimer(
      file_name=ncs_filename,
      reconstruction_type='cau',error_handle=True,eps=1e-2)
    msg = 'Number of transforms is {0} instead of {1}'\
      .format(m.number_of_transforms,2)
    assert m.number_of_transforms == 2, msg
    m.write(asu_filename)
    pdb_inp = pdb.input(file_name = asu_filename)
    xrs = pdb_inp.xray_structure_simple()
    xrs_unit_cell = xrs.orthorhombic_unit_cell_around_centered_scatterers(
    buffer_size=2)
    if not crystal_symmetry:
      crystal_symmetry = xrs_unit_cell.crystal_symmetry()
    pdb_inp.write_pdb_file(file_name = asu_filename, crystal_symmetry = crystal_symmetry)
    return crystal_symmetry
Ejemplo n.º 3
0
  def test_BIOMT(self):
    '''Test MTRIX record processing'''
    # print sys._getframe().f_code.co_name
    ba_expected_results  = [
    [1.0, 1.0, 1.0], [1.0, -1.0, 1.0], [1.0, 1.0, -1.0], [-1.0, 1.0, 1.0], [1.0, 1.0, -1.0],
    [-1.0, 1.0, -1.0], [-0.366025, 1.366025, 1.0], [-1.366025, 0.366025, 1.0], [1.0, 1.5, 1.0],
    [-1.366025, 0.366025, 0.0], [94.618, -5.253, 91.582], [94.618, -91.582, -5.253],
    [91.582, -5.253, -94.618], [5.253, 94.618, 91.582], [91.582, -5.253, -94.618],
    [5.253, 91.582, -94.618], [51.858229, 79.315053, 91.582], [-42.759771, 84.568053, 91.582],
    [94.618, -4.753, 91.582], [-42.759771, 84.568053, 90.582], [62.395, 51.344, 80.786],
    [62.395, -80.786, 51.344], [80.786, 51.344, -62.395], [-51.344, 62.395, 80.786],
    [80.786, 51.344, -62.395], [-51.344, 80.786, -62.395], [-13.267688, 79.70763, 80.786],
    [-75.662688, 28.36363, 80.786], [62.395, 51.844, 80.786], [-75.662688, 28.36363, 79.786],
    [39.954, 51.526, 72.372], [39.954, -72.372, 51.526], [72.372, 51.526, -39.954],
    [-51.526, 39.954, 72.372], [72.372, 51.526, -39.954], [-51.526, 72.372, -39.954],
    [-24.645804, 60.364163, 72.372], [-64.599804, 8.838163, 72.372], [39.954, 52.026, 72.372],
    [-64.599804, 8.838163, 71.372]]

    # use BIOMT data
    ba_multimer_data = multimer(
      file_name='multimer_test_data.pdb',
      reconstruction_type='ba')
    ba_multimer_xyz = list(ba_multimer_data.sites_cart())
    assert ba_multimer_data.new_annotation is None

    # The multimer processing is my chain, so we need to sort lists before we compare them
    ba_multimer_xyz.sort()
    ba_expected_results.sort()

    assert approx_equal(ba_expected_results,ba_multimer_xyz,eps=0.001)
    self.assertEqual(ba_multimer_data.number_of_transforms,9)
Ejemplo n.º 4
0
  def test_MTRIX(self):
    '''Test MTRIX record processing'''
    # print sys._getframe().f_code.co_name
    cau_expected_results  = [
    [1.0, 1.0, 1.0], [1.0, -1.0, 1.0], [-0.366025, 1.366025, 1.0], [-1.366025, 0.366025, 1.0],
    [1.0, 1.5, 1.0], [94.618, -5.253, 91.582],
    [94.618, -91.582, -5.253], [51.858229, 79.315053, 91.582], [-42.759771, 84.568053, 91.582],
    [94.618, -4.753, 91.582], [62.395, 51.344, 80.786],
    [62.395, -80.786, 51.344], [-13.267688, 79.70763, 80.786], [-75.662688, 28.36363, 80.786],
    [62.395, 51.844, 80.786], [39.954, 51.526, 72.372],
    [39.954, -72.372, 51.526], [-24.645804, 60.364163, 72.372], [-64.599804, 8.838163, 72.372],
    [39.954, 52.026, 72.372]]

    # use MTRIX data
    multimer_data = multimer(
      file_name='multimer_test_data.pdb',
      reconstruction_type='cau')
    cau_multimer_xyz = list(multimer_data.sites_cart())

    cau_multimer_xyz.sort()
    cau_expected_results.sort()
    assert approx_equal(cau_expected_results,cau_multimer_xyz,eps=0.001)

    # Test that the number of MTRIX record to process is correct
    self.assertEqual(multimer_data.number_of_transforms,4)

    # Test getting non-rounded ASU
    source_xyz = multimer_data.get_ncs_hierarchy().atoms().extract_xyz()
    xyz = apply_transforms(
      ncs_coordinates = source_xyz,
      ncs_restraints_group_list = multimer_data.get_ncs_restraints_group_list(),
      total_asu_length = multimer_data.total_asu_length(),
      extended_ncs_selection = flex.size_t_range(source_xyz.size()),
      round_coordinates=False)
    cau_multimer_xyz = list(xyz)
    cau_multimer_xyz.sort()
    assert approx_equal(cau_expected_results,cau_multimer_xyz,eps=0.00001)

    # Test multimer without rounding
    multimer_data = multimer(
      file_name='multimer_test_data.pdb',
      round_coordinates=False,
      reconstruction_type='cau')
    cau_multimer_xyz = list(multimer_data.sites_cart())
    cau_multimer_xyz.sort()
    cau_expected_results.sort()
    assert approx_equal(cau_expected_results,cau_multimer_xyz,eps=0.00001)
Ejemplo n.º 5
0
def run():
  # 1 NCS copy: starting template to generate whole asu; place into P1 box
  pdb_inp = iotbx.pdb.input(source_info=None, lines=ncs_1_copy)
  mtrix_object = pdb_inp.process_mtrix_records()
  ph = pdb_inp.construct_hierarchy()
  xrs = pdb_inp.xray_structure_simple()
  xrs_one_ncs = xrs.orthorhombic_unit_cell_around_centered_scatterers(
    buffer_size=8)
  ph.adopt_xray_structure(xrs_one_ncs)
  of = open("one_ncs_in_asu.pdb", "w")
  print >> of, mtrix_object.format_MTRIX_pdb_string()
  print >> of, ph.as_pdb_string(crystal_symmetry=xrs_one_ncs.crystal_symmetry())
  of.close()
  # 1 NCS copy -> full asu (expand NCS). This is the answer-strucure
  m = multimer("one_ncs_in_asu.pdb",'cau',error_handle=True,eps=1e-2)
  assert m.number_of_transforms == 2, m.number_of_transforms
  xrs_asu = m.assembled_multimer.extract_xray_structure(
    crystal_symmetry = xrs_one_ncs.crystal_symmetry())
  m.write("full_asu.pdb")
  assert xrs_asu.crystal_symmetry().is_similar_symmetry(
    xrs_one_ncs.crystal_symmetry())
  # Generate Fobs from answer structure
  f_obs = abs(xrs_asu.structure_factors(d_min=2, algorithm="direct").f_calc())
  r_free_flags = f_obs.generate_r_free_flags()
  mtz_dataset = f_obs.as_mtz_dataset(column_root_label="F-obs")
  mtz_dataset.add_miller_array(
    miller_array=r_free_flags,
    column_root_label="R-free-flags")
  mtz_object = mtz_dataset.mtz_object()
  mtz_object.write(file_name = "data.mtz")
  # Shake structure - subject to refinement input
  xrs_shaken = xrs_one_ncs.deep_copy_scatterers()
  xrs_shaken.shake_sites_in_place(mean_distance=0.3)
  ph.adopt_xray_structure(xrs_shaken)
  of = open("one_ncs_in_asu_shaken.pdb", "w")
  print >> of, mtrix_object.format_MTRIX_pdb_string()
  print >> of, ph.as_pdb_string(crystal_symmetry=xrs.crystal_symmetry())
  of.close()
  ### Refinement
  params = mmtbx.f_model.sf_and_grads_accuracy_master_params.extract()
  params.algorithm = "direct"
  fmodel = mmtbx.f_model.manager(
    f_obs                        = f_obs,
    r_free_flags                 = r_free_flags,
    xray_structure               = xrs_one_ncs,
    sf_and_grads_accuracy_params = params,
    target_name                  = "ls_wunit_k1")
  print "start r_factor: %6.4f" % fmodel.r_work()
  for macro_cycle in xrange(60):
    # refine coordinates
    if(1):
      minimized = minimizer(fmodel = fmodel, sites = True)
      print "  macro_cycle %3d (sites) r_factor: %6.4f"%(macro_cycle,
        fmodel.r_work())
    # refine ADPs
    if(0):
      minimized = minimizer(fmodel = fmodel, u_iso = True)
      print "  macro_cycle %3d (adp)   r_factor: %6.4f"%(macro_cycle,
        fmodel.r_work())
Ejemplo n.º 6
0
 def build_asu(self,file_name_ncs,file_name_asu):
   """Build ASU from NCS and save the new pdb file in local directory"""
   m = multimer(
     pdb_input_file_name=file_name_ncs,
     reconstruction_type='cau',
     error_handle=True,
     eps=0.01)
   m.write(pdb_output_file_name=file_name_asu)
   return m
Ejemplo n.º 7
0
def run():
  pdb_dir = os.environ["PDB_MIRROR_PDB"]
  pdb_files = open(os.path.join(pdb_dir, "INDEX"), "r").readlines()
  pdb_code_list = [
      '3p0s', '2wws', '2xpj', '2bfu', '3n7x', '2iz9', '1dwn', '1ei7','2wzr',
      '2vf1', '1m1c', '1llc', '1dzl', '2vf9', '3ntt', '4ar2','4gmp', '3vdd',
      '3bcc', '3s4g', '3lob', '3qpr', '1tdi', '1ohg', '3e8k', '2qzv', '2e0z',
      '1wcd', '4bcu', '1vcr', '1ng0', '3dar', '4f5x', '4g93', '1bcc', '2izw',
      '1f2n', '1ny7', '3oah', '1vb4', '2gtl', '2g33', '2zzq', '2ws9', '1c8n',
      '2w4z', '1x9t', '3r0r', '4gb3', '1vsz', '2g34', '2c4y', '1z7s', '1ddl',
      '2bq5', '2c4z', '3fbm', '2gh8', '1qjx', '1f8v', '2iz8', '2bs1', '4aqq',
      '1qju', '1x36', '1w39', '1x35', '1pgw', '2wff', '2vq0', '2fz2', '2fz1',
      '1x9p', '3vbu', '3hag', '4gh4', '3chx', '1pgl', '1a37', '1lp3', '3zfe',
      '4fts', '4fsj', '3raa', '2c4q', '1qjy', '4hl8', '3tn9', '3es5', '1js9',
      '4gbt', '4fte', '2x5i', '2izn', '1zba', '1r2j', '1k5m', '2w4y', '2qqp',
      '4jgy', '4ftb', '4ang', '3zfg', '3zff', '3cji', '2c51', '1vak', '1uf2',
      '1ohf', '3ux1', '4g0r', '3s6p', '3ra4', '2bu1', '1laj', '1a34', '7msf',
      '4iv1', '3ra9', '3ra8', '2xbo', '1h8t', '5msf', '4jgz', '3vbo', '2ztn',
      '1b35', '6msf', '4aed', '3vbs', '3vbr', '3vbf', '3ra2', '3kz4', '1za7',
      '1vb2', '1rhq', '4iv3', '3vbh', '3nou', '3not', '3nop', '2xgk', '2wbh',
      '2qij', '2c50', '2buk', '1wce', '1tnv']

  pdb_code_list = [
    '3dar', '1vcr', '1r2j', '1a37', '1llc', '1tnv', '1tdi', '1w39', '1ny7',
    '1ddl', '1c8n', '2bfu', '4gmp', '3vbr', '3vbu', '3vbo', '4jgy', '3es5',
    '3nop', '3not', '3nou', '3bcc', '1bcc', '1z7s', '6msf', '2iz8', '7msf',
    '2izn', '2c50', '2c51', '2iz9', '2c4y', '2c4z', '5msf', '2c4q', '2bu1',
    '3raa', '3oah', '3ra2', '3ra9', '3ra8', '3ra4', '3qpr', '1ei7', '1a34',
    '3chx', '2wbh', '2fz1', '2fz2', '2gh8', '1wcd', '3fbm', '4gb3', '1laj',
    '3vbh', '1dzl', '3hag', '4iv3', '1js9', '3n7x', '4gh4', '4jgz', '3tn9',
    '4iv1', '1vb2', '1vb4', '1vak', '3s4g', '2buk', '1x36', '4bcu', '1b35',
    '2wzr', '1k5m', '2bq5', '1zba', '1pgw', '3vbs', '1x35', '3vbf', '1pgl',
    '4fsj', '4fte', '4fts', '2e0z', '4ftb', '2w4y', '2w4z', '2qzv', '3vdd',
    '3p0s', '1qjx', '1qjy', '1qju', '3r0r', '2bs1', '2ztn', '1x9t', '2zzq',
    '1x9p', '4aqq', '1za7', '4ar2', '2wws', '2xpj', '4hl8', '3ntt', '2vf1',
    '3ux1', '2xgk', '2izw', '3cji', '4gbt', '2vq0', '4g93', '2g34', '2qij',
    '2g33', '1f2n', '4g0r', '1ng0', '2ws9', '2xbo', '2wff', '1wce', '1dwn',
    '2vf9', '3zfe', '3zff', '3zfg', '2x5i', '1h8t', '3lob', '4ang', '2gtl',
    '2qqp', '1f8v', '1m1c', '1lp3', '4aed', '3e8k', '1uf2', '1ohg', '1ohf',
    '3s6p', '3kz4', '4f5x', '1vsz']



  pdb_length = []
  for fn in pdb_code_list:
    file_path = [x.strip() for x in pdb_files if x[-12:-8]==fn][0]
    print file_path
    full_path = os.path.join(pdb_dir,file_path)
    m = multimer(
      file_name=full_path,
      reconstruction_type='cau',
      error_handle=True,eps=1e-2)
    pdb_length.append([len(m.sites_cart()),fn])
  pdb_length.sort()
  print '='*60
  print pdb_length[:5]
  print '='*60
Ejemplo n.º 8
0
  def get_pdb_file_info(self,pdb_id):
    """
    Collect pdb file NCS and header info if there are NCS  relations
    and reslution >= 3

    Args:
      pdb_id (str): collect info for a single pdb file

    Return:
      new_rec (File_records object): object containing the collected info
    """
    new_rec = File_records()
    new_rec.pdb_id = pdb_id
    fetched_file = pdb_id + '.pdb'
    if not os.path.isfile(fetched_file):
      fetched_file = fetch.get_pdb (
        id=pdb_id, data_type='pdb',
        mirror='rcsb',quiet=True,log=null_out())
    else:
      print 'file exist in local folder, did not fetch it..'
    fn = os.path.realpath(fetched_file)
    pdb_inp = iotbx.pdb.input(file_name=fn)
    mtrix_info = pdb_inp.process_mtrix_records(eps=0.01)
    t = (mtrix_info.as_pdb_string() == '')
    t |= (not ncs_only(mtrix_info))
    new_rec.only_master_in_pdb = not t
    if len(mtrix_info.r) > 0 and new_rec.only_master_in_pdb:
      m = multimer(file_name=fn,reconstruction_type='cau')
      m.write(
        pdb_output_file_name=fn,
        crystal_symmetry=pdb_inp.crystal_symmetry())
    # note that now the fn is a complete ASU
    ncs_obj = iotbx.ncs.input(file_name=fn)
    if (ncs_obj.number_of_ncs_groups == 0):
      os.remove(fn)
      return None
    new_rec.n_ncs_groups = ncs_obj.number_of_ncs_groups
    new_rec.n_ncs_copies = len(ncs_obj.ncs_transform)
    pio = pdb_inp.get_r_rfree_sigma()
    new_rec.resolution = pio.resolution
    if new_rec.resolution and (new_rec.resolution < 3):
      os.remove(fn)
      return None
    new_rec.year = pdb_inp.extract_header_year()
    new_rec.experiment_type = pdb_inp.get_experiment_type()
    new_rec.r_work_header = pio.r_work
    new_rec.r_free_header = pio.r_free
    try:
      shutil.move(fn,self.asu_dir)
    except:
      # avoid error if file already exist
      pass
    return new_rec
Ejemplo n.º 9
0
 def test_ignoring_mtrix_rec(self):
   """
   Test ignoring MTRIX record when copies already present in file
   """
   pdb_inp = pdb.input(source_info=None, lines=test_pdb_9)
   m = multimer(
       pdb_str=test_pdb_9,
       round_coordinates=False,
       reconstruction_type='cau',
       error_handle=True,eps=1e-2)
   n1 = m.assembled_multimer.atoms().size()
   n2 = pdb_inp.atoms().size()
   self.assertEqual(n1,n2)
Ejemplo n.º 10
0
 def test_proper_biomat_application(self):
   """ Test that when building bio-molecule and then finding NCS relatin
   from it, we get the same rotation and translation"""
   pdb_strings = [pdb_test_data7,pdb_test_data8]
   methods = ['ba','cau']
   for method,pdb_string in zip(methods,pdb_strings):
     print "method:", method
     pdb_inp = pdb.input(source_info=None, lines=pdb_string)
     crystal_symmetry = pdb_inp.crystal_symmetry()
     m = multimer(
       pdb_str=pdb_string,
       round_coordinates=False,
       reconstruction_type=method,
       error_handle=True,eps=1e-2)
     # The exact transforms from pdb_string
     r1_expected = matrix.sqr(
       [0.309017, -0.951057, 0.0,0.951057, 0.309017,-0.0,0.0,0.0,1.0])
     r2_expected = matrix.sqr(
       [-0.809017,-0.587785,0.0,0.587785,-0.809017,-0.0,0.0,0.0,1.0])
     t1_expected = matrix.col([0,0,7])
     t2_expected = matrix.col([0,0,0])
     # Look at biomt records retrieved from PDB file
     if method == 'ba':
       rec = pdb_inp.process_BIOMT_records()
     else:
       rec = pdb_inp.process_mtrix_records()
     r1 = rec.r[1]
     r2 = rec.r[2]
     t1 = rec.t[1]
     t2 = rec.t[2]
     (the_same, transpose) = is_same_transform(r1,t1,r1_expected,t1_expected)
     self.assertTrue(the_same)
     (the_same, transpose)= is_same_transform(r2,t2,r2_expected,t2_expected)
     self.assertTrue(the_same)
     # Look at the rotation and translation found by the NCS search
     s = m.assembled_multimer.as_pdb_string(crystal_symmetry=crystal_symmetry)
     print "new h:", s
     ncs_obj = ncs.input(pdb_string=s)
     print "ncs_obj.number_of_ncs_groups", ncs_obj.number_of_ncs_groups
     r1 = ncs_obj.ncs_transform['002'].r
     t1 = ncs_obj.ncs_transform['002'].t
     r2 = ncs_obj.ncs_transform['003'].r
     t2 = ncs_obj.ncs_transform['003'].t
     (the_same, transpose) = is_same_transform(r1,t1,r1_expected,t1_expected)
     self.assertTrue(the_same)
     (the_same, transpose)= is_same_transform(r2,t2,r2_expected,t2_expected)
     self.assertTrue(the_same)
     if method == 'ba':
       self.assertEqual(ncs_obj.number_of_ncs_groups,1)
     elif method == 'cau':
       self.assertEqual(ncs_obj.number_of_ncs_groups,2)
Ejemplo n.º 11
0
  def test_spec_file_format(self):
    """ Verify that spec object are produced properly """
    # print sys._getframe().f_code.co_name

    multimer_data = multimer(
      pdb_str=pdb_test_data2,
      reconstruction_type='cau')
    pdb_inp = pdb.input(source_info=None, lines=pdb_test_data2)
    t_i = pdb_inp.process_mtrix_records()
    pdb_h = pdb_inp.construct_hierarchy()
    trans_obj = ncs.input(
        hierarchy=pdb_h,
        transform_info=t_i)
    pdb_hierarchy_asu = multimer_data.assembled_multimer
    # print "pdb_hierarchy_asu", pdb_hierarchy_asu.as_pdb_string()
    spec_output = trans_obj.get_ncs_info_as_spec(
      pdb_hierarchy_asu=pdb_hierarchy_asu)

    trans_obj2 = ncs.input(spec_ncs_groups=spec_output)

    # print "t1", trans_obj.ncs_transform
    # print "t2", trans_obj2.ncs_transform
    t1 = trans_obj.ncs_transform['0000000002'].r
    t2 = trans_obj2.ncs_transform['0000000002'].r
    self.assertEqual(t1,t2)
    self.assertEqual(len(trans_obj.ncs_transform),len(trans_obj2.ncs_transform))

    t1 = trans_obj.ncs_to_asu_selection
    t1_expected = {'chain A or chain B':
                     ['chain C or chain D', 'chain E or chain F']}
    self.assertEqual(t1,t1_expected)
    t2 = trans_obj2.ncs_to_asu_selection
    t2_expected = {
      'chain A and (resseq 1:3 or resseq 6:7)':
        ['chain C and (resseq 1:3 or resseq 6:7)',
         'chain E and (resseq 1:3 or resseq 6:7)'],
      'chain B and (resseq 4:5)':
        ['chain D and (resseq 4:5)', 'chain F and (resseq 4:5)']}
    self.assertEqual(t2,t2_expected)

    # print "trans_obj.tr_id_to_selection", trans_obj.tr_id_to_selection
    t1 = trans_obj.tr_id_to_selection['chain A_0000000003']
    t1_expected = ('chain A',
                   'chain E')
    self.assertEqual(t1,t1_expected)

    t2 = trans_obj2.tr_id_to_selection['chain A_0000000003']
    t2_expected = ('chain A and (resseq 1:3 or resseq 6:7)',
                   'chain E and (resseq 1:3 or resseq 6:7)')
    self.assertEqual(t2,t2_expected)
Ejemplo n.º 12
0
def biomt_reconstruction(args, command_name="phenix.pdb.biomt_reconstruction"):
    ''' (string) -> file

  Reconstruction of the biological assembly multimer by applying
  BIOMT transformation, from the REMARK 350 in the pdb file, to all
  chains in file.

  Produce a new pdb file containg the biological assembly multimer information

  Arguments:
  args: a string containing the pdb file name, 'file_name.pdb' and an
        optional output file name. If no file name is given, the output
        file will have the name 'biological_assembly_file_name.pdb'

  >>> phenix.pdb.biomt_reconstruction input_file_name.pdb
  bio-assembly reconstructed pdb file was added to your current directory
  /path/biological_assembly_input_file_name.pdb

   >>> phenix.pdb.biomt_reconstruction input_file_name.pdb output_file_name.pdb
  bio-assembly reconstructed pdb file was added to your current directory
  /path/output_file_name.pdb

  @author: Youval Dar (LBL 2013)
  '''
    if (len(args) == 0):
        raise Sorry('No input filename is given. Please provide a pdb file name. \n' + \
                    '>>> phenix.pdb.biomt_reconstruction input_file_name.pdb')
    elif ('--help' in args) or ('-h' in args):
        print help(biomt_reconstruction)
    elif (len(args) > 2):
        raise Sorry('To many input parameters are given')
    elif not os.path.isfile(args[0]):
        print 'There is no file {} in the current directory \n {}'.format(
            args[0], os.getcwd())
        raise Sorry('File name error')
    else:
        m = multimer(file_name=args[0], reconstruction_type='ba')
        if m.number_of_transforms > 0:
            # write the bio-assembly reconstructed file in current directory
            if len(args) == 2:
                # output file name given
                m.write(args[1])
                print '$s file was added to your current directory' % args[1]
            else:
                # output file name not given
                m.write()
                print 'bio-assembly reconstructed pdb file was added to your current directory'
                print os.getcwd() + '/' + m.pdb_output_file_name
        else:
            print 'No BIOMT information in {}'.format(args[0])
  def test_pdb_writing(self):
    # print sys._getframe().f_code.co_name
    """
    Verify that there are no errors processing the write command
    No inception of the output is done.
    To view the output change the write=False to ,write=True
    """
    pdb_inp = pdb.input(source_info=None, lines=pdb_test_data2)
    pdb_obj = pdb.hierarchy.input(pdb_string=pdb_test_data2)
    transform_info = pdb_inp.process_mtrix_records()
    transforms_obj = iotbx.ncs.input(
      transform_info=transform_info,
      hierarchy=pdb_inp.construct_hierarchy(),
      exclude_selection=None)

    multimer_data = multimer(
      pdb_str=pdb_test_data2,
      reconstruction_type='cau')

    pdb_hierarchy_asu = multimer_data.assembled_multimer

    # print '--- using ASU hierarchy ---'
    pdbstr = transforms_obj.get_transform_records(
      ncs_only=True,
      pdb_hierarchy=pdb_hierarchy_asu,
      write=False)
    # print pdbstr
    # print '='*50

    pdbstr = transforms_obj.get_transform_records(
      ncs_only=False,
      pdb_hierarchy=pdb_hierarchy_asu,
      write=False)
    # print pdbstr

    # print '--- using the hierarchy of only the master NCS ---'
    pdbstr = transforms_obj.get_transform_records(
      # pdb_hierarchy=pdb_obj.hierarchy,
      pdb_hierarchy=pdb_hierarchy_asu,
      biomt=True,
      write=False)
    # print pdbstr

    # print '--- from xray structure ---'
    xrs = pdb_hierarchy_asu.extract_xray_structure()
    pdbstr = transforms_obj.get_transform_records(
      # xrs=pdb_obj.xray_structure_simple(),
      xrs=xrs,
      biomt=True,
      write=False)
Ejemplo n.º 14
0
def biomt_reconstruction(args, command_name="phenix.pdb.biomt_reconstruction"):
  ''' (string) -> file

  Reconstruction of the biological assembly multimer by applying
  BIOMT transformation, from the REMARK 350 in the pdb file, to all
  chains in file.

  Produce a new pdb file containg the biological assembly multimer information

  Arguments:
  args: a string containing the pdb file name, 'file_name.pdb' and an
        optional output file name. If no file name is given, the output
        file will have the name 'biological_assembly_file_name.pdb'

  >>> phenix.pdb.biomt_reconstruction input_file_name.pdb
  bio-assembly reconstructed pdb file was added to your current directory
  /path/biological_assembly_input_file_name.pdb

   >>> phenix.pdb.biomt_reconstruction input_file_name.pdb output_file_name.pdb
  bio-assembly reconstructed pdb file was added to your current directory
  /path/output_file_name.pdb

  @author: Youval Dar (LBL 2013)
  '''
  if (len(args) == 0):
    raise Sorry('No input filename is given. Please provide a pdb file name. \n' + \
                '>>> phenix.pdb.biomt_reconstruction input_file_name.pdb')
  elif ('--help' in args) or ('-h' in args):
    print help(biomt_reconstruction)
  elif (len(args) > 2):
    raise Sorry('To many input parameters are given')
  elif not os.path.isfile(args[0]):
    print 'There is no file {} in the current directory \n {}'.format(args[0],os.getcwd())
    raise Sorry('File name error')
  else:
    m = multimer(file_name=args[0],reconstruction_type='ba')
    if m.number_of_transforms > 0:
      # write the bio-assembly reconstructed file in current directory
      if len(args) == 2:
        # output file name given
        m.write(args[1])
        print '$s file was added to your current directory'%args[1]
      else:
        # output file name not given
        m.write()
        print 'bio-assembly reconstructed pdb file was added to your current directory'
        print os.getcwd() + '/' + m.pdb_output_file_name
    else:
      print 'No BIOMT information in {}'.format(args[0])
Ejemplo n.º 15
0
def test_ignoring_mtrix_rec():
  """
  Test raising Sorry for MTRIX record when copies already present in file
  """
  pdb_inp = pdb.input(source_info=None, lines=test_pdb_9)
  try:
    m = multimer(
        pdb_str=test_pdb_9,
        round_coordinates=False,
        reconstruction_type='cau',
        error_handle=True,eps=1e-2)
  except Exception as e:
    assert e.message == "Copies are already present in the file"
  else:
    # There must be sorry.
    assert 0
Ejemplo n.º 16
0
def mtrix_reconstruction(args, command_name="phenix.pdb.mtrix_reconstruction"):
    ''' (string) -> file

  Reconstruction of the crystallographic asymmetric unit by applying
  MTRIX transformation, from the MTRIX records in the pdb file, to all chains in file.

  Produce a new pdb file containg the rystallographic asymmetric unit information

  Arguments:
  args: a string containing the pdb file name, 'file_name.pdb' and an optional output file name
        if no file name is given, the output file will have the name 'cryst_asym_unit_file_name.pdb'

  >>> phenix.pdb.mtrix_reconstruction input_file_name.pdb
  mtrix-assembly reconstructed pdb file was added to your current directory
  /path/cryst_asym_unit_input_file_name.pdb

   >>> phenix.pdb.mtrix_reconstruction input_file_name.pdb 'output_file_name.pdb
  mtrix-assembly reconstructed pdb file was added to your current directory
  /path/output_file_name.pdb

  @author: Youval Dar (LBL 2013)
  '''
    if (len(args) == 0):
        raise Sorry('No input filename is given. Please provide a pdb file name. \n' + \
                    '>>> phenix.pdb.mtrix_reconstruction input_file_name.pdb')
    elif ('--help' in args) or ('-h' in args):
        print help(mtrix_reconstruction)
    elif (len(args) > 2):
        raise Sorry('To many input parameters are given')
    elif not os.path.isfile(args[0]):
        print 'There is no file {} in the current directory \n {}'.format(
            args[0], os.getcwd())
        raise Sorry('File name error')
    else:
        m = multimer(file_name=args[0], reconstruction_type='cau')
        if m.number_of_transforms > 0:
            # write the mtrix-assembly reconstructed file in current directory
            if len(args) == 2:
                # output file name given
                m.write(args[1])
                print '%s was added to your current directory' % args[1]
            else:
                # output file name not given
                m.write()
                print '%s was added to your current directory' % m.pdb_output_file_name
        else:
            print 'No MTRIX information in {}'.format(args[0])
Ejemplo n.º 17
0
def mtrix_reconstruction(args, command_name="phenix.pdb.mtrix_reconstruction"):
  ''' (string) -> file

  Reconstruction of the crystallographic asymmetric unit by applying
  MTRIX transformation, from the MTRIX records in the pdb file, to all chains in file.

  Produce a new pdb file containg the rystallographic asymmetric unit information

  Arguments:
  args: a string containing the pdb file name, 'file_name.pdb' and an optional output file name
        if no file name is given, the output file will have the name 'cryst_asym_unit_file_name.pdb'

  >>> phenix.pdb.mtrix_reconstruction input_file_name.pdb
  mtrix-assembly reconstructed pdb file was added to your current directory
  /path/cryst_asym_unit_input_file_name.pdb

   >>> phenix.pdb.mtrix_reconstruction input_file_name.pdb 'output_file_name.pdb
  mtrix-assembly reconstructed pdb file was added to your current directory
  /path/output_file_name.pdb

  @author: Youval Dar (LBL 2013)
  '''
  if (len(args) == 0):
    raise Sorry('No input filename is given. Please provide a pdb file name. \n' + \
                '>>> phenix.pdb.mtrix_reconstruction input_file_name.pdb')
  elif ('--help' in args) or ('-h' in args):
    print help(mtrix_reconstruction)
  elif (len(args) > 2):
    raise Sorry('To many input parameters are given')
  elif not os.path.isfile(args[0]):
    print 'There is no file {} in the current directory \n {}'.format(args[0],os.getcwd())
    raise Sorry('File name error')
  else:
    m = multimer(file_name=args[0],reconstruction_type='cau')
    if m.number_of_transforms > 0:
      # write the mtrix-assembly reconstructed file in current directory
      if len(args) == 2:
        # output file name given
        m.write(args[1])
        print '%s was added to your current directory'%args[1]
      else:
        # output file name not given
        m.write()
        print '%s was added to your current directory'%m.pdb_output_file_name
    else:
      print 'No MTRIX information in {}'.format(args[0])
Ejemplo n.º 18
0
  def test_spec_file_format(self):
    """ Verify that spec object are produced properly """
    # print sys._getframe().f_code.co_name

    multimer_data = multimer(
      pdb_str=pdb_test_data2,
      reconstruction_type='cau')

    trans_obj = ncs.input(pdb_string=pdb_test_data2)

    pdb_hierarchy_asu = multimer_data.assembled_multimer
    spec_output = trans_obj.get_ncs_info_as_spec(
      pdb_hierarchy_asu=pdb_hierarchy_asu,write=False)

    trans_obj2 = ncs.input(spec_ncs_groups=spec_output)

    t1 = trans_obj.ncs_transform['002'].r
    t2 = trans_obj2.ncs_transform['002'].r
    self.assertEqual(t1,t2)
    self.assertEqual(len(trans_obj.ncs_transform),len(trans_obj2.ncs_transform))

    t1 = trans_obj.ncs_to_asu_selection
    t1_expected = {'chain A or chain B':
                     ['chain E or chain F', 'chain C or chain D']}
    self.assertEqual(t1,t1_expected)
    t2 = trans_obj2.ncs_to_asu_selection
    t2_expected = {
      'chain A and (resseq 1:3 or resseq 6:7)':
        ['chain C and (resseq 1:3 or resseq 6:7)',
         'chain E and (resseq 1:3 or resseq 6:7)'],
      'chain B and (resseq 4:5)':
        ['chain D and (resseq 4:5)', 'chain F and (resseq 4:5)']}
    self.assertEqual(t2,t2_expected)

    t1 = trans_obj.tr_id_to_selection['chain A_003']
    t1_expected = ('chain A',
                   'chain E')
    self.assertEqual(t1,t1_expected)

    t2 = trans_obj2.tr_id_to_selection['chain A_003']
    t2_expected = ('chain A and (resseq 1:3 or resseq 6:7)',
                   'chain E and (resseq 1:3 or resseq 6:7)')
    self.assertEqual(t2,t2_expected)
Ejemplo n.º 19
0
  def test_writing_spec_file(self):
    # print sys._getframe().f_code.co_name
    """
    Verify that there are no errors processing the write command
    No inception of the output is done. Just making sure it does not break
    To view the output change the write=False to ,write=True
    """
    transforms_obj = ncs_group_object()
    pdb_inp = pdb.input(source_info=None, lines=pdb_test_data2)
    pdb_obj = pdb.hierarchy.input(pdb_string=pdb_test_data2)
    transform_info = pdb_inp.process_mtrix_records()
    transforms_obj.preprocess_ncs_obj(
      # transform_info=transform_info,
      # pdb_hierarchy_inp=pdb_obj,
      pdb_inp=pdb_inp)

    asu = multimer(
      pdb_str=pdb_test_data2,
      reconstruction_type='cau')
    transforms_obj.get_ncs_info_as_spec(
      pdb_hierarchy_asu=asu.assembled_multimer,write=False)
Ejemplo n.º 20
0
def run(
        n_macro_cycle=10,
        sites=True,
        u_iso=False,
        run_finite_grad_differences_test = False):
  """
  Arguments:
  __________
  n_macro_cycle : Number of refinement macro cycles
  """
  # 1 NCS copy: starting template to generate whole asu; place into P1 box
  pdb_inp = iotbx.pdb.input(source_info=None, lines=ncs_1_copy)
  mtrix_object = pdb_inp.process_mtrix_records()
  ph = pdb_inp.construct_hierarchy()
  xrs = pdb_inp.xray_structure_simple()
  xrs_one_ncs = xrs.orthorhombic_unit_cell_around_centered_scatterers(
    buffer_size=8)
  ph.adopt_xray_structure(xrs_one_ncs)
  of = open("one_ncs_in_asu.pdb", "w")
  print >> of, mtrix_object.format_MTRIX_pdb_string()
  print >> of, ph.as_pdb_string(crystal_symmetry=xrs_one_ncs.crystal_symmetry())
  of.close()
  # 1 NCS copy -> full asu (expand NCS). This is the answer-strucure
  m = multimer("one_ncs_in_asu.pdb",'cau',error_handle=True,eps=1e-2)
  assert m.number_of_transforms == 2, m.number_of_transforms
  xrs_asu = m.assembled_multimer.extract_xray_structure(
    crystal_symmetry = xrs_one_ncs.crystal_symmetry())
  m.write("full_asu.pdb")
  assert xrs_asu.crystal_symmetry().is_similar_symmetry(
    xrs_one_ncs.crystal_symmetry())
  # Generate Fobs from answer structure
  f_obs = abs(xrs_asu.structure_factors(d_min=2, algorithm="direct").f_calc())
  r_free_flags = f_obs.generate_r_free_flags()
  mtz_dataset = f_obs.as_mtz_dataset(column_root_label="F-obs")
  mtz_dataset.add_miller_array(
    miller_array=r_free_flags,
    column_root_label="R-free-flags")
  mtz_object = mtz_dataset.mtz_object()
  mtz_object.write(file_name = "data.mtz")
  # Shake structure - subject to refinement input
  xrs_shaken = xrs_one_ncs.deep_copy_scatterers()
  if sites:
    xrs_shaken.shake_sites_in_place(mean_distance=0.3)
  if u_iso:
    xrs_shaken.shake_adp()
  ph.adopt_xray_structure(xrs_shaken)
  of = open("one_ncs_in_asu_shaken.pdb", "w")
  print >> of, mtrix_object.format_MTRIX_pdb_string()
  print >> of, ph.as_pdb_string(crystal_symmetry=xrs.crystal_symmetry())
  of.close()
  ### Refinement
  params = mmtbx.f_model.sf_and_grads_accuracy_master_params.extract()
  params.algorithm = "direct"
  # Get the xray_structure of the shaken ASU
  m_shaken = multimer(
    pdb_input_file_name="one_ncs_in_asu_shaken.pdb",
    reconstruction_type='cau',error_handle=True,eps=1e-2)
  xrs_shaken_asu = m_shaken.assembled_multimer.as_pdb_input().\
    xray_structure_simple(crystal_symmetry=xrs_one_ncs.crystal_symmetry())
  # Save the shaken ASU for inspection
  m_shaken.write(pdb_output_file_name='asu_shaken.pdb')
  # Create a boolean selection string for selecting chains in NCS
  selection_str = 'chain A'
  ncs_selection = m_shaken.assembled_multimer.\
    atom_selection_cache().selection(selection_str)
  fmodel = mmtbx.f_model.manager(
    f_obs                        = f_obs,
    r_free_flags                 = r_free_flags,
    xray_structure               = xrs_shaken_asu,
    sf_and_grads_accuracy_params = params,
    target_name                  = "ls_wunit_k1")
  print "start r_factor: %6.4f" % fmodel.r_work()
  refine_method = 'sites'
  for macro_cycle in xrange(n_macro_cycle):
    # refine coordinates
    if(sites):
      minimized = minimizer(
        fmodel = fmodel,
        ncs_transformations_object=m,
        ncs_atom_selection = ncs_selection,
        run_finite_grad_differences_test = run_finite_grad_differences_test,
        sites = True)
      print "  macro_cycle %3d (sites) r_factor: %6.4f"%(macro_cycle,
        fmodel.r_work())
    # refine ADPs
    if(u_iso):
      minimized = minimizer(
        fmodel = fmodel,
        ncs_transformations_object=m,
        ncs_atom_selection = ncs_selection,
        run_finite_grad_differences_test = run_finite_grad_differences_test,
        u_iso = True)
      print "  macro_cycle %3d (adp)   r_factor: %6.4f"%(macro_cycle,
        fmodel.r_work())
    if (0): save_pdb_file(
      macro_cycle=macro_cycle,
      fmodel=fmodel,
      m_shaken=m_shaken,
      u_iso=u_iso,
      sites=sites)
  if (1): save_pdb_file(
    macro_cycle=macro_cycle,
    fmodel=fmodel,
    m_shaken=m_shaken,
    u_iso=u_iso,
    sites=sites)
 def run_test(self):
   # Refinement
   params = mmtbx.f_model.sf_and_grads_accuracy_master_params.extract()
   params.algorithm = "direct"
   # Get the xray_structure of the shaken ASU
   m_shaken = multimer(
     file_name="one_ncs_in_asu_shaken.pdb",
     round_coordinates=False,
     reconstruction_type='cau',error_handle=True,eps=1e-2)
   xrs_shaken_asu = m_shaken.assembled_multimer.extract_xray_structure(
     crystal_symmetry=self.xrs_one_ncs.crystal_symmetry())
   # force non-rounded coordinates into xray structure
   xrs_shaken_asu.set_sites_cart(m_shaken.sites_cart())
   # Save the shaken ASU for inspection
   m_shaken.write(
     pdb_output_file_name='asu_shaken.pdb',
     crystal_symmetry=self.xrs_one_ncs.crystal_symmetry())
   tr_obj = m_shaken.transforms_obj
   self.ncs_restraints_group_list = tr_obj.get_ncs_restraints_group_list()
   # refine both ncs related and not related atoms
   self.refine_selection = flex.size_t(range(tr_obj.total_asu_length))
   self.extended_ncs_selection = nu.get_extended_ncs_selection(
     ncs_restraints_group_list=tr_obj.get_ncs_restraints_group_list(),
     refine_selection=self.refine_selection)
   assert self.refine_selection.size() == 21
   self.fmodel = mmtbx.f_model.manager(
     f_obs                        = self.f_obs,
     r_free_flags                 = self.r_free_flags,
     xray_structure               = xrs_shaken_asu,
     sf_and_grads_accuracy_params = params,
     target_name                  = "ls_wunit_k1")
   r_start = self.fmodel.r_work()
   assert r_start > 0.1, r_start
   print "start r_factor: %6.4f" % r_start
   for macro_cycle in xrange(self.n_macro_cycle):
     if self.transformations and \
             not self.ncs_restraints_group_list: continue
     data_weight = None
     if(self.use_geometry_restraints):
       data_weight = nu.get_weight(minimized_obj=self)
     target_and_grads_object = mmtbx.refinement.minimization_ncs_constraints.\
       target_function_and_grads_reciprocal_space(
         fmodel                 = self.fmodel,
         ncs_restraints_group_list = self.ncs_restraints_group_list,
         refine_selection     = self.refine_selection,
         restraints_manager     = self.grm,
         data_weight            = data_weight,
         refine_sites           = self.sites,
         refine_u_iso           = self.u_iso,
         refine_transformations = self.transformations,
         iso_restraints         = self.iso_restraints)
     minimized = mmtbx.refinement.minimization_ncs_constraints.lbfgs(
       target_and_grads_object      = target_and_grads_object,
       xray_structure               = self.fmodel.xray_structure,
       ncs_restraints_group_list    = self.ncs_restraints_group_list,
       refine_selection             = self.refine_selection,
       finite_grad_differences_test = self.finite_grad_differences_test,
       max_iterations               = 100,
       refine_sites                 = self.sites,
       refine_u_iso                 = self.u_iso,
       refine_transformations       = self.transformations)
     refine_type = 'adp'*self.u_iso + 'sites'*self.sites \
                   + 'transformation'*self.transformations
     outstr = "  macro_cycle {0:3} ({1})   r_factor: {2:6.4f}   " + \
           self.finite_grad_differences_test * \
           "finite_grad_difference_val: {3:.4f}"
     print outstr.format(
       macro_cycle, refine_type,self.fmodel.r_work(),
       minimized.finite_grad_difference_val)
     assert (minimized.finite_grad_difference_val < 1.0e-3)
     assert approx_equal(self.fmodel.r_work(), target_and_grads_object.fmodel.r_work())
     # break test if r_work is very small
     if target_and_grads_object.fmodel.r_work() < 1.0e-6: break
   # check results
   if(self.u_iso):
     assert approx_equal(self.fmodel.r_work(), 0, 1.e-5)
   elif(self.sites):
     if(self.use_geometry_restraints):
       assert approx_equal(self.fmodel.r_work(), 0, 0.00015)
     else:
       assert approx_equal(self.fmodel.r_work(), 0, 1.e-5)
   elif self.transformations:
       assert approx_equal(self.fmodel.r_work(), 0, 0.0001)
   else: assert 0
   # output refined model
   xrs_refined = self.fmodel.xray_structure
   m_shaken.assembled_multimer.adopt_xray_structure(self.fmodel.xray_structure)
   output_file_name = "refined_u_iso%s_sites%s.pdb"%(str(self.u_iso),
     str(self.sites))
   m_shaken.write(output_file_name)
   self.test_files_names.append(output_file_name)
   # check final model
   if(not self.use_geometry_restraints):
     # XXX fix later for case self.use_geometry_restraints=True
     pdb_inp_answer = iotbx.pdb.input(source_info=None, lines=ncs_1_copy)
     pdb_inp_refined = iotbx.pdb.input(file_name=output_file_name)
     xrs1 = pdb_inp_answer.xray_structure_simple()
     xrs2 = pdb_inp_refined.xray_structure_simple().select(
       minimized.extended_ncs_selection)
     mmtbx.utils.assert_xray_structures_equal(
       x1 = xrs1,
       x2 = xrs2,
       sites = False)
     delta = flex.vec3_double([xrs1.center_of_mass()]*xrs2.scatterers().size())-\
             flex.vec3_double([xrs2.center_of_mass()]*xrs2.scatterers().size())
     xrs2.set_sites_cart(sites_cart = xrs2.sites_cart()+delta)
     mmtbx.utils.assert_xray_structures_equal(
       x1 = xrs1,
       x2 = xrs2)
Ejemplo n.º 22
0
def exercise_ss_multiplication():
  pdb_str = """\
REMARK 350   BIOMT1   1  1.000000 -0.000000  0.000000        0.00000
REMARK 350   BIOMT2   1 -0.000000  1.000000 -0.000000        0.00000
REMARK 350   BIOMT3   1  0.000000 -0.000000  1.000000        0.00000
REMARK 350   BIOMT1   2 -0.809017 -0.500000  0.309017        0.00000
REMARK 350   BIOMT2   2 -0.500000  0.309017 -0.809017        0.00000
REMARK 350   BIOMT3   2  0.309017 -0.809017 -0.500000        0.00000
REMARK 350   BIOMT1   3 -0.000000  1.000000  0.000000        0.00000
REMARK 350   BIOMT2   3 -0.000000 -0.000000 -1.000000        0.00000
REMARK 350   BIOMT3   3 -1.000000  0.000000 -0.000000        0.00000
REMARK 350   BIOMT1   4  0.809017 -0.500000 -0.309017        0.00000
REMARK 350   BIOMT2   4 -0.500000 -0.309017 -0.809017        0.00000
REMARK 350   BIOMT3   4  0.309017  0.809017 -0.500000       -0.00000
REMARK 350   BIOMT1   5  0.500000  0.309017 -0.809017        0.00000
REMARK 350   BIOMT2   5 -0.309017 -0.809017 -0.500000        0.00000
REMARK 350   BIOMT3   5 -0.809017  0.500000 -0.309017        0.00000
REMARK 350   BIOMT1   6 -0.309017 -0.809017 -0.500000        0.00000
REMARK 350   BIOMT2   6 -0.809017  0.500000 -0.309017        0.00000
REMARK 350   BIOMT3   6  0.500000  0.309017 -0.809017       -0.00000
REMARK 350   BIOMT1   7 -0.809017  0.500000 -0.309017        0.00000
REMARK 350   BIOMT2   7  0.500000  0.309017 -0.809017        0.00000
REMARK 350   BIOMT3   7 -0.309017 -0.809017 -0.500000        0.00000
REMARK 350   BIOMT1   8 -0.809017 -0.500000 -0.309017        0.00000
REMARK 350   BIOMT2   8  0.500000 -0.309017 -0.809017        0.00000
REMARK 350   BIOMT3   8  0.309017 -0.809017  0.500000        0.00000
REMARK 350   BIOMT1   9 -0.309017  0.809017 -0.500000        0.00000
REMARK 350   BIOMT2   9 -0.809017 -0.500000 -0.309017        0.00000
REMARK 350   BIOMT3   9 -0.500000  0.309017  0.809017        0.00000
HELIX    1   1 PRO A   28  LEU A   33  1                                   6
HELIX    7   7 ASP B   74  ALA B   79  1                                   6
HELIX   12  12 LYS C  151  TYR C  159  1                                   9
CRYST1    0.000    0.000    0.000  90.00  90.00  90.00 P 1           1
ATOM     62  N   PRO A  28      33.884  22.417 110.984 14.01 14.01           N
ATOM     63  CA  PRO A  28      34.083  23.080 112.268 12.01 12.01           C
ATOM     64  C   PRO A  28      32.908  24.004 112.604 12.01 12.01           C
ATOM     65  O   PRO A  28      32.254  24.556 111.723 16.00 16.00           O
ATOM     66  CB  PRO A  28      35.381  23.873 112.096 12.01 12.01           C
ATOM     67  CG  PRO A  28      35.369  24.249 110.611 12.01 12.01           C
ATOM     68  CD  PRO A  28      34.692  23.045 109.949 12.01 12.01           C
ATOM     69  N   ASN A  29      32.694  24.235 113.899 14.01 14.01           N
ATOM     70  CA  ASN A  29      31.700  25.147 114.485 12.01 12.01           C
ATOM     71  C   ASN A  29      30.215  24.812 114.276 12.01 12.01           C
ATOM     72  O   ASN A  29      29.406  25.211 115.111 16.00 16.00           O
ATOM     73  CB  ASN A  29      32.013  26.616 114.122 12.01 12.01           C
ATOM     74  CG  ASN A  29      33.381  27.082 114.575 12.01 12.01           C
ATOM     75  OD1 ASN A  29      34.061  26.468 115.379 16.00 16.00           O
ATOM     76  ND2 ASN A  29      33.841  28.204 114.073 14.01 14.01           N
ATOM     77  N   GLU A  30      30.550  21.845 114.346 14.01 14.01           N
ATOM     78  CA  GLU A  30      29.386  21.544 115.199 12.01 12.01           C
ATOM     79  C   GLU A  30      29.802  20.720 116.428 12.01 12.01           C
ATOM     80  O   GLU A  30      29.237  19.675 116.751 16.00 16.00           O
ATOM     81  CB  GLU A  30      28.306  20.825 114.365 12.01 12.01           C
ATOM     82  CG  GLU A  30      27.795  21.680 113.200 12.01 12.01           C
ATOM     83  CD  GLU A  30      26.582  21.020 112.532 12.01 12.01           C
ATOM     84  OE1 GLU A  30      26.801  20.115 111.689 16.00 16.00           O
ATOM     85  OE2 GLU A  30      25.450  21.412 112.878 16.00 16.00           O
ATOM     86  N   LEU A  31      29.828  23.005 116.792 14.01 14.01           N
ATOM     87  CA  LEU A  31      29.299  22.073 115.816 12.01 12.01           C
ATOM     88  C   LEU A  31      28.149  21.279 116.426 12.01 12.01           C
ATOM     89  O   LEU A  31      28.305  20.133 116.853 16.00 16.00           O
ATOM     90  CB  LEU A  31      30.413  21.167 115.268 12.01 12.01           C
ATOM     91  CG  LEU A  31      31.519  21.894 114.483 12.01 12.01           C
ATOM     92  CD1 LEU A  31      32.517  20.866 113.958 12.01 12.01           C
ATOM     93  CD2 LEU A  31      30.995  22.696 113.286 12.01 12.01           C
ATOM     94  N   GLY A  32      26.947  21.837 116.303 14.01 14.01           N
ATOM     95  CA  GLY A  32      25.679  21.115 116.378 12.01 12.01           C
ATOM     96  C   GLY A  32      25.506  20.004 115.323 12.01 12.01           C
ATOM     97  O   GLY A  32      24.382  19.638 114.991 16.00 16.00           O
ATOM     98  N   LEU A  33      26.624  19.470 114.815 14.01 14.01           N
ATOM     99  CA  LEU A  33      26.791  18.378 113.866 12.01 12.01           C
ATOM    100  C   LEU A  33      27.494  17.166 114.509 12.01 12.01           C
ATOM    101  O   LEU A  33      27.549  16.110 113.890 16.00 16.00           O
ATOM    102  CB  LEU A  33      27.595  18.877 112.644 12.01 12.01           C
ATOM    103  CG  LEU A  33      27.192  20.239 112.037 12.01 12.01           C
ATOM    104  CD1 LEU A  33      28.098  20.578 110.853 12.01 12.01           C
ATOM    105  CD2 LEU A  33      25.745  20.281 111.549 12.01 12.01           C
ATOM   2090  N   ASP B  74      21.209  34.482 113.075 14.01 14.01           N
ATOM   2091  CA  ASP B  74      20.506  33.939 114.233 12.01 12.01           C
ATOM   2092  C   ASP B  74      21.375  33.841 115.474 12.01 12.01           C
ATOM   2093  O   ASP B  74      22.182  32.923 115.611 16.00 16.00           O
ATOM   2094  CB  ASP B  74      19.906  32.571 113.907 12.01 12.01           C
ATOM   2095  CG  ASP B  74      18.979  32.068 114.997 12.01 12.01           C
ATOM   2096  OD1 ASP B  74      19.110  32.533 116.149 16.00 16.00           O
ATOM   2097  OD2 ASP B  74      18.121  31.208 114.708 16.00 16.00           O
ATOM   2098  N   MET B  75      21.194  34.811 116.364 14.01 14.01           N
ATOM   2099  CA  MET B  75      21.934  34.884 117.610 12.01 12.01           C
ATOM   2100  C   MET B  75      22.089  33.512 118.239 12.01 12.01           C
ATOM   2101  O   MET B  75      23.123  33.213 118.837 16.00 16.00           O
ATOM   2102  CB  MET B  75      21.234  35.824 118.583 12.01 12.01           C
ATOM   2103  CG  MET B  75      21.525  37.288 118.322 12.01 12.01           C
ATOM   2104  SD  MET B  75      23.242  37.703 118.659 32.07 32.07           S
ATOM   2105  CE  MET B  75      23.058  38.659 120.162 12.01 12.01           C
ATOM   2106  N   ILE B  76      21.067  32.672 118.091 14.01 14.01           N
ATOM   2107  CA  ILE B  76      21.116  31.324 118.645 12.01 12.01           C
ATOM   2108  C   ILE B  76      22.422  30.683 118.212 12.01 12.01           C
ATOM   2109  O   ILE B  76      22.994  29.858 118.922 16.00 16.00           O
ATOM   2110  CB  ILE B  76      19.929  30.457 118.191 12.01 12.01           C
ATOM   2111  CG1 ILE B  76      20.068  30.070 116.720 12.01 12.01           C
ATOM   2112  CG2 ILE B  76      18.618  31.182 118.436 12.01 12.01           C
ATOM   2113  CD1 ILE B  76      18.979  29.144 116.230 12.01 12.01           C
ATOM   2114  N   LYS B  77      22.902  31.098 117.044 14.01 14.01           N
ATOM   2115  CA  LYS B  77      24.160  30.591 116.525 12.01 12.01           C
ATOM   2116  C   LYS B  77      25.209  30.734 117.613 12.01 12.01           C
ATOM   2117  O   LYS B  77      26.219  30.038 117.612 16.00 16.00           O
ATOM   2118  CB  LYS B  77      24.577  31.362 115.281 12.01 12.01           C
ATOM   2119  CG  LYS B  77      23.624  31.194 114.112 12.01 12.01           C
ATOM   2120  CD  LYS B  77      24.208  30.282 113.048 12.01 12.01           C
ATOM   2121  CE  LYS B  77      25.656  30.627 112.741 12.01 12.01           C
ATOM   2122  NZ  LYS B  77      25.986  32.047 113.045 14.01 14.01           N
ATOM   2123  N   ILE B  78      24.954  31.644 118.547 14.01 14.01           N
ATOM   2124  CA  ILE B  78      25.852  31.863 119.664 12.01 12.01           C
ATOM   2125  C   ILE B  78      25.432  30.891 120.752 12.01 12.01           C
ATOM   2126  O   ILE B  78      26.264  30.367 121.489 16.00 16.00           O
ATOM   2127  CB  ILE B  78      25.788  33.314 120.171 12.01 12.01           C
ATOM   2128  CG1 ILE B  78      26.541  34.227 119.215 12.01 12.01           C
ATOM   2129  CG2 ILE B  78      26.405  33.447 121.552 12.01 12.01           C
ATOM   2130  CD1 ILE B  78      27.879  33.670 118.785 12.01 12.01           C
ATOM   2131  N   ALA B  79      24.131  30.644 120.844 14.01 14.01           N
ATOM   2132  CA  ALA B  79      23.615  29.721 121.839 12.01 12.01           C
ATOM   2133  C   ALA B  79      24.401  28.426 121.758 12.01 12.01           C
ATOM   2134  O   ALA B  79      25.260  28.159 122.591 16.00 16.00           O
ATOM   2135  CB  ALA B  79      22.140  29.461 121.605 12.01 12.01           C
ATOM   4569  N   LYS C 151      65.128  35.635 115.156 14.01 14.01           N
ATOM   4570  CA  LYS C 151      65.530  35.389 113.777 12.01 12.01           C
ATOM   4571  C   LYS C 151      64.991  36.467 112.836 12.01 12.01           C
ATOM   4572  O   LYS C 151      65.493  37.600 112.882 16.00 16.00           O
ATOM   4573  CB  LYS C 151      65.144  33.970 113.358 12.01 12.01           C
ATOM   4574  CG  LYS C 151      65.912  32.877 114.088 12.01 12.01           C
ATOM   4575  CD  LYS C 151      67.128  32.399 113.304 12.01 12.01           C
ATOM   4576  CE  LYS C 151      67.638  31.055 113.817 12.01 12.01           C
ATOM   4577  NZ  LYS C 151      68.536  30.367 112.845 14.01 14.01           N
ATOM   4578  N   PRO C 152      63.957  36.119 111.972 14.01 14.01           N
ATOM   4579  CA  PRO C 152      63.508  37.232 111.112 12.01 12.01           C
ATOM   4580  C   PRO C 152      63.109  38.448 111.934 12.01 12.01           C
ATOM   4581  O   PRO C 152      63.440  39.574 111.564 16.00 16.00           O
ATOM   4582  CB  PRO C 152      62.297  36.661 110.371 12.01 12.01           C
ATOM   4583  CG  PRO C 152      62.611  35.226 110.237 12.01 12.01           C
ATOM   4584  CD  PRO C 152      63.111  34.901 111.606 12.01 12.01           C
ATOM   4585  N   ALA C 153      62.412  38.211 113.040 14.01 14.01           N
ATOM   4586  CA  ALA C 153      61.963  39.291 113.912 12.01 12.01           C
ATOM   4587  C   ALA C 153      63.098  40.266 114.150 12.01 12.01           C
ATOM   4588  O   ALA C 153      63.069  41.394 113.658 16.00 16.00           O
ATOM   4589  CB  ALA C 153      61.447  38.743 115.234 12.01 12.01           C
ATOM   4590  N   TYR C 154      64.115  39.823 114.883 14.01 14.01           N
ATOM   4591  CA  TYR C 154      65.267  40.665 115.165 12.01 12.01           C
ATOM   4592  C   TYR C 154      65.756  41.261 113.864 12.01 12.01           C
ATOM   4593  O   TYR C 154      66.400  42.302 113.847 16.00 16.00           O
ATOM   4594  CB  TYR C 154      66.376  39.866 115.831 12.01 12.01           C
ATOM   4595  CG  TYR C 154      67.016  40.606 116.973 12.01 12.01           C
ATOM   4596  CD2 TYR C 154      67.159  40.015 118.220 12.01 12.01           C
ATOM   4597  CD1 TYR C 154      67.468  41.902 116.804 12.01 12.01           C
ATOM   4598  CE2 TYR C 154      67.743  40.697 119.266 12.01 12.01           C
ATOM   4599  CE1 TYR C 154      68.055  42.593 117.842 12.01 12.01           C
ATOM   4600  CZ  TYR C 154      68.190  41.987 119.072 12.01 12.01           C
ATOM   4601  OH  TYR C 154      68.775  42.675 120.111 16.00 16.00           O
ATOM   4602  N   GLY C 155      65.432  40.583 112.771 14.01 14.01           N
ATOM   4603  CA  GLY C 155      65.788  41.039 111.449 12.01 12.01           C
ATOM   4604  C   GLY C 155      65.033  42.277 111.006 12.01 12.01           C
ATOM   4605  O   GLY C 155      64.881  43.241 111.751 16.00 16.00           O
ATOM   4606  N   GLN C 156      64.550  42.233 109.773 14.01 14.01           N
ATOM   4607  CA  GLN C 156      63.853  43.353 109.162 12.01 12.01           C
ATOM   4608  C   GLN C 156      62.850  43.968 110.123 12.01 12.01           C
ATOM   4609  O   GLN C 156      62.506  45.141 110.012 16.00 16.00           O
ATOM   4610  CB  GLN C 156      63.138  42.899 107.894 12.01 12.01           C
ATOM   4611  CG  GLN C 156      64.021  42.114 106.945 12.01 12.01           C
ATOM   4612  CD  GLN C 156      63.662  40.645 106.916 12.01 12.01           C
ATOM   4613  OE1 GLN C 156      62.516  40.271 107.160 16.00 16.00           O
ATOM   4614  NE2 GLN C 156      64.642  39.802 106.616 14.01 14.01           N
ATOM   4615  N   ALA C 157      62.387  43.173 111.075 14.01 14.01           N
ATOM   4616  CA  ALA C 157      61.412  43.650 112.046 12.01 12.01           C
ATOM   4617  C   ALA C 157      61.892  44.877 112.817 12.01 12.01           C
ATOM   4618  O   ALA C 157      61.110  45.516 113.514 16.00 16.00           O
ATOM   4619  CB  ALA C 157      61.039  42.537 113.014 12.01 12.01           C
ATOM   4620  N   LYS C 158      63.168  45.211 112.703 14.01 14.01           N
ATOM   4621  CA  LYS C 158      63.684  46.365 113.420 12.01 12.01           C
ATOM   4622  C   LYS C 158      63.183  47.677 112.829 12.01 12.01           C
ATOM   4623  O   LYS C 158      62.833  48.598 113.561 16.00 16.00           O
ATOM   4624  CB  LYS C 158      65.215  46.350 113.441 12.01 12.01           C
ATOM   4625  CG  LYS C 158      65.885  46.986 112.230 12.01 12.01           C
ATOM   4626  CD  LYS C 158      67.364  47.232 112.484 12.01 12.01           C
ATOM   4627  CE  LYS C 158      67.585  48.021 113.764 12.01 12.01           C
ATOM   4628  NZ  LYS C 158      67.696  47.123 114.945 14.01 14.01           N
ATOM   4629  N   TYR C 159      63.215  47.748 111.504 14.01 14.01           N
ATOM   4630  CA  TYR C 159      62.848  48.954 110.776 12.01 12.01           C
ATOM   4631  C   TYR C 159      61.362  49.227 110.625 12.01 12.01           C
ATOM   4632  O   TYR C 159      60.808  50.102 111.288 16.00 16.00           O
ATOM   4633  CB  TYR C 159      63.486  48.914 109.383 12.01 12.01           C
ATOM   4634  CG  TYR C 159      64.927  48.468 109.382 12.01 12.01           C
ATOM   4635  CD2 TYR C 159      65.676  48.472 110.547 12.01 12.01           C
ATOM   4636  CD1 TYR C 159      65.540  48.048 108.213 12.01 12.01           C
ATOM   4637  CE2 TYR C 159      66.996  48.072 110.545 12.01 12.01           C
ATOM   4638  CE1 TYR C 159      66.858  47.646 108.202 12.01 12.01           C
ATOM   4639  CZ  TYR C 159      67.578  47.660 109.370 12.01 12.01           C
ATOM   4640  OH  TYR C 159      68.888  47.260 109.362 16.00 16.00           O
END
"""
  m = multimer(reconstruction_type = 'ba', pdb_str=pdb_str)
  assert m.new_annotation is not None
  assert m.new_annotation.get_n_helices() == 24, \
      "expecing 24 helices, got %d" % m.new_annotation.get_n_helices()
  assert m.new_annotation.get_n_sheets() == 0, \
      "expecing 0 sheets, got %d" % m.new_annotation.get_n_helices()
 def __init__(self,
              n_macro_cycle,
              sites,
              u_iso,
              transformations,
              finite_grad_differences_test,
              use_geometry_restraints,
              shake_site_mean_distance = 1.5,
              d_min = 2,
              shake_angles_sigma = 0.035,
              shake_translation_sigma = 0.5):
   """ create temp test files and data for tests """
   adopt_init_args(self, locals())
   self.test_files_names = [] # collect names of files for cleanup
   # 1 NCS copy: starting template to generate whole asu; place into P1 box
   pdb_inp = iotbx.pdb.input(source_info=None, lines=ncs_1_copy)
   pdb_obj = iotbx.pdb.hierarchy.input(pdb_string=ncs_1_copy)
   mtrix_object = pdb_inp.process_mtrix_records()
   ph = pdb_inp.construct_hierarchy()
   xrs = pdb_inp.xray_structure_simple()
   xrs_one_ncs = xrs.orthorhombic_unit_cell_around_centered_scatterers(
     buffer_size=8)
   ph.adopt_xray_structure(xrs_one_ncs)
   of = open("one_ncs_in_asu.pdb", "w")
   print >> of, mtrix_object.as_pdb_string()
   print >> of, ph.as_pdb_string(crystal_symmetry=xrs_one_ncs.crystal_symmetry())
   of.close()
   # 1 NCS copy -> full asu (expand NCS). This is the answer-structure
   m = multimer(file_name="one_ncs_in_asu.pdb",
                round_coordinates=False,
                reconstruction_type='cau',error_handle=True,eps=1e-2)
   assert m.number_of_transforms == 2, m.number_of_transforms
   xrs_asu = m.assembled_multimer.extract_xray_structure(
     crystal_symmetry = xrs_one_ncs.crystal_symmetry())
   m.write("full_asu.pdb")
   # force ASU none-rounded coordinates into xray structure
   xrs_asu.set_sites_cart(m.sites_cart())
   assert xrs_asu.crystal_symmetry().is_similar_symmetry(
     xrs_one_ncs.crystal_symmetry())
   # Generate Fobs from answer structure
   f_obs = abs(xrs_asu.structure_factors(d_min=d_min, algorithm="direct").f_calc())
   r_free_flags = f_obs.generate_r_free_flags()
   mtz_dataset = f_obs.as_mtz_dataset(column_root_label="F-obs")
   mtz_dataset.add_miller_array(
     miller_array=r_free_flags,
     column_root_label="R-free-flags")
   mtz_object = mtz_dataset.mtz_object()
   mtz_object.write(file_name = "data.mtz")
   # Shake structure - subject to refinement input
   xrs_shaken = xrs_one_ncs.deep_copy_scatterers()
   if sites: xrs_shaken.shake_sites_in_place(
     mean_distance=shake_site_mean_distance)
   if self.u_iso:
     u_random = flex.random_double(xrs_shaken.scatterers().size())
     xrs_shaken = xrs_shaken.set_u_iso(values=u_random)
   if self.transformations:
     transforms_obj = ncs.input(
     transform_info = mtrix_object,
     pdb_hierarchy_inp = pdb_obj)
     x = nu.concatenate_rot_tran(transforms_obj=transforms_obj)
     x = nu.shake_transformations(
       x = x,
       shake_angles_sigma=self.shake_angles_sigma,
       shake_translation_sigma=self.shake_translation_sigma)
     transforms_obj = nu.update_rot_tran(x=x,transforms_obj=transforms_obj)
     mtrix_object = transforms_obj.build_MTRIX_object()
   ph.adopt_xray_structure(xrs_shaken)
   of = open("one_ncs_in_asu_shaken.pdb", "w")
   print >> of, mtrix_object.as_pdb_string()
   print >> of, ph.as_pdb_string(crystal_symmetry=xrs.crystal_symmetry())
   of.close()
   self.f_obs = f_obs
   self.r_free_flags = r_free_flags
   self.xrs_one_ncs = xrs_one_ncs
   # Get restraints manager
   self.grm = None
   pdb_str = m.assembled_multimer.as_pdb_string(
     crystal_symmetry=xrs_one_ncs.crystal_symmetry())
   self.iso_restraints = None
   if(self.use_geometry_restraints):
     self.grm = nu.get_restraints_manager(pdb_string=pdb_str)
     if(self.u_iso):
       temp = mmtbx.refinement.adp_refinement.adp_restraints_master_params
       self.iso_restraints = temp.extract().iso
Ejemplo n.º 24
0
def run():
  # 1 NCS copy: starting template to generate whole asu; place into P1 box
  pdb_inp = iotbx.pdb.input(source_info=None, lines=ncs_1_copy)
  mtrix_object = pdb_inp.process_mtrix_records()
  ph = pdb_inp.construct_hierarchy()
  xrs = pdb_inp.xray_structure_simple()
  xrs_one_ncs = xrs.orthorhombic_unit_cell_around_centered_scatterers(
    buffer_size=8)
  ph.adopt_xray_structure(xrs_one_ncs)
  open("one_ncs_in_asu.pdb", "w").write(ncs_1_copy)
  #of = open("one_ncs_in_asu.pdb", "w")
  #print >> of, mtrix_object.format_MTRIX_pdb_string()
  #print >> of, ph.as_pdb_string(crystal_symmetry=xrs_one_ncs.crystal_symmetry())
  #of.close()
  # 1 NCS copy -> full asu (expand NCS). This is the answer-strucure
  m = multimer("one_ncs_in_asu.pdb",'cau',error_handle=True,eps=1e-2)
  m.write("full_asu_2.pdb")
  pdb_inp = iotbx.pdb.input(file_name="full_asu_2.pdb")
  xrs = pdb_inp.xray_structure_simple()
  xrs_one_asu = xrs.orthorhombic_unit_cell_around_centered_scatterers(
    buffer_size=2)
  #xrs_one_asu = xrs.cubic_unit_cell_around_centered_scatterers(
    #buffer_size=1)

  crystal_symmetry = xrs_one_asu.crystal_symmetry()
  #crystal_symmetry = xrs.crystal_symmetry()
  xrs_asu = m.assembled_multimer.extract_xray_structure(
    crystal_symmetry = crystal_symmetry)

  #ph = pdb_inp.construct_hierarchy()
  #ph.adopt_xray_structure(xrs_one_asu)

  pdb_inp_2 = iotbx.pdb.input(file_name="one_ncs_in_asu.pdb")
  pdb_inp_2.write_pdb_file(file_name = "one_ncs_in_asu.pdb",
                         crystal_symmetry = crystal_symmetry)



  #of = open("one_ncs_in_asu.pdb", "w")
  #print >> of, mtrix_object.format_MTRIX_pdb_string()
  #print >> of, ph.as_pdb_string(crystal_symmetry=xrs_one_asu.crystal_symmetry())
  #of.close()
  #m = multimer("one_ncs_in_asu.pdb",'cau',error_handle=True,eps=1e-2)
  m.write("full_asu_2.pdb")

  assert m.number_of_transforms == 2
  #xrs_asu = m.assembled_multimer.extract_xray_structure(
    #crystal_symmetry = xrs_one_ncs.crystal_symmetry())
  #m.write("full_asu.pdb")
  assert xrs_asu.crystal_symmetry().is_similar_symmetry(
    xrs_one_ncs.crystal_symmetry())
  # Generate Fobs from answer structure
  f_obs = abs(xrs_asu.structure_factors(d_min=2, algorithm="direct").f_calc())
  r_free_flags = f_obs.generate_r_free_flags()
  mtz_dataset = f_obs.as_mtz_dataset(column_root_label="F-obs")
  mtz_dataset.add_miller_array(
    miller_array=r_free_flags,
    column_root_label="R-free-flags")
  mtz_object = mtz_dataset.mtz_object()
  mtz_object.write(file_name = "data.mtz")
  # Shake structure - subject to refinement input
  xrs_shaken = xrs_one_ncs.deep_copy_scatterers()
  xrs_shaken.shake_sites_in_place(mean_distance=0.3)
  #ph.adopt_xray_structure(xrs_shaken)
  of = open("one_ncs_in_asu_shaken.pdb", "w")
  print >> of, mtrix_object.format_MTRIX_pdb_string()