Ejemplo n.º 1
0
    def __init__(self, cif_block, pdb_hierarchy):
        self.tls_params = []
        self.tls_present = False
        self.error_string = None
        tls_ids = cif_block.get('_pdbx_refine_tls.id')

        T_ijs = [
            cif_block.get('_pdbx_refine_tls.T[%s][%s]' % (i, j))
            for i, j in ('11', '22', '33', '12', '13', '23')
        ]
        L_ijs = [
            cif_block.get('_pdbx_refine_tls.L[%s][%s]' % (i, j))
            for i, j in ('11', '22', '33', '12', '13', '23')
        ]
        S_ijs = [
            cif_block.get('_pdbx_refine_tls.S[%s][%s]' % (i, j))
            for i, j in ('11', '12', '13', '21', '22', '23', '31', '32', '33')
        ]
        origin_xyzs = [
            cif_block.get('_pdbx_refine_tls.origin_%s' % x) for x in 'xyz'
        ]

        if isinstance(tls_ids, string_types):
            # in case the TLS items are not in a loop
            tls_ids = [tls_ids]
            T_ijs = [[T_ij] for T_ij in T_ijs]
            L_ijs = [[L_ij] for L_ij in L_ijs]
            S_ijs = [[S_ij] for S_ij in S_ijs]
            origin_xyzs = [[origin_xyz] for origin_xyz in origin_xyzs]

        assert T_ijs.count(None) in (0, 6)
        assert L_ijs.count(None) in (0, 6)
        assert S_ijs.count(None) in (0, 9)
        assert origin_xyzs.count(None) in (0, 3)

        if T_ijs.count(None) == 6:
            return

        tls_group_ids = cif_block.get('_pdbx_refine_tls_group.id')
        refine_tls_ids = cif_block.get('_pdbx_refine_tls_group.refine_tls_id')
        beg_chain_ids = cif_block.get(
            '_pdbx_refine_tls_group.beg_auth_asym_id')
        beg_seq_ids = cif_block.get('_pdbx_refine_tls_group.beg_auth_seq_id')
        end_chain_ids = cif_block.get(
            '_pdbx_refine_tls_group.end_auth_asym_id')
        end_seq_ids = cif_block.get('_pdbx_refine_tls_group.end_auth_seq_id')
        selection_details = cif_block.get(
            '_pdbx_refine_tls_group.selection_details')

        assert tls_group_ids is not None

        if isinstance(tls_group_ids, string_types):
            # in case the TLS group items are not in a loop
            refine_tls_ids = flex.std_string([refine_tls_ids])
            beg_chain_ids = [beg_chain_ids]
            beg_seq_ids = [beg_seq_ids]
            end_chain_ids = [end_chain_ids]
            end_seq_ids = [end_seq_ids]
            if selection_details is not None:
                selection_details = flex.std_string([selection_details])

        selection_cache = pdb_hierarchy.atom_selection_cache()

        for i, tls_id in enumerate(tls_ids):
            T = [float(T_ij[i]) for T_ij in T_ijs]
            L = [float(L_ij[i]) for L_ij in L_ijs]
            S = [float(S_ij[i]) for S_ij in S_ijs]
            origin = [float(origin_x[i]) for origin_x in origin_xyzs]
            i_groups = (refine_tls_ids == tls_id).iselection()
            sel_strings = []
            for i_group in i_groups:
                if selection_details is not None and not selection_details.all_eq(
                        '?'):
                    # phenix selection
                    sel_strings.append(selection_details[i_group].strip())
                    # check it is a valid selection string
                    selection_cache.selection(sel_strings[-1])
                else:
                    sel_strings.append(
                        refmac_range_to_phenix_string_selection(
                            pdb_hierarchy=pdb_hierarchy,
                            chain_start=beg_chain_ids[i_group],
                            resseq_start=beg_seq_ids[i_group],
                            chain_end=end_chain_ids[i_group],
                            resseq_end=end_seq_ids[i_group]))
            sel_str = " or ".join(sel_strings)
            self.tls_params.append(
                tls(t=T, l=L, s=S, origin=origin, selection_string=sel_str))
        self.tls_present = True
Ejemplo n.º 2
0
  def __init__(self, cif_block, pdb_hierarchy):
    self.tls_params = []
    self.tls_present = False
    self.error_string = None
    tls_ids = cif_block.get('_pdbx_refine_tls.id')

    T_ijs = [cif_block.get('_pdbx_refine_tls.T[%s][%s]' %(i, j))
             for i, j in ('11', '22', '33', '12', '13', '23')]
    L_ijs = [cif_block.get('_pdbx_refine_tls.L[%s][%s]' %(i, j))
             for i, j in ('11', '22', '33', '12', '13', '23')]
    S_ijs = [cif_block.get('_pdbx_refine_tls.S[%s][%s]' %(i, j))
             for i, j in ('11', '12', '13', '21', '22', '23', '31', '32', '33')]
    origin_xyzs = [cif_block.get('_pdbx_refine_tls.origin_%s' %x) for x in 'xyz']

    if isinstance(tls_ids, basestring):
      # in case the TLS items are not in a loop
      tls_ids = [tls_ids]
      T_ijs = [[T_ij] for T_ij in T_ijs]
      L_ijs = [[L_ij] for L_ij in L_ijs]
      S_ijs = [[S_ij] for S_ij in S_ijs]
      origin_xyzs = [[origin_xyz] for origin_xyz in origin_xyzs]

    assert T_ijs.count(None) in (0, 6)
    assert L_ijs.count(None) in (0, 6)
    assert S_ijs.count(None) in (0, 9)
    assert origin_xyzs.count(None) in (0, 3)

    if T_ijs.count(None) == 6:
      return

    tls_group_ids = cif_block.get('_pdbx_refine_tls_group.id')
    refine_tls_ids = cif_block.get('_pdbx_refine_tls_group.refine_tls_id')
    beg_chain_ids = cif_block.get('_pdbx_refine_tls_group.beg_auth_asym_id')
    beg_seq_ids = cif_block.get('_pdbx_refine_tls_group.beg_auth_seq_id')
    end_chain_ids = cif_block.get('_pdbx_refine_tls_group.end_auth_asym_id')
    end_seq_ids = cif_block.get('_pdbx_refine_tls_group.end_auth_seq_id')
    selection_details = cif_block.get('_pdbx_refine_tls_group.selection_details')

    assert tls_group_ids is not None

    if isinstance(tls_group_ids, basestring):
      # in case the TLS group items are not in a loop
      refine_tls_ids = flex.std_string([refine_tls_ids])
      beg_chain_ids = [beg_chain_ids]
      beg_seq_ids = [beg_seq_ids]
      end_chain_ids = [end_chain_ids]
      end_seq_ids = [end_seq_ids]
      if selection_details is not None:
        selection_details = flex.std_string([selection_details])

    selection_cache = pdb_hierarchy.atom_selection_cache()

    for i, tls_id in enumerate(tls_ids):
      T = [float(T_ij[i]) for T_ij in T_ijs]
      L = [float(L_ij[i]) for L_ij in L_ijs]
      S = [float(S_ij[i]) for S_ij in S_ijs]
      origin = [float(origin_x[i]) for origin_x in origin_xyzs]
      i_groups = (refine_tls_ids == tls_id).iselection()
      sel_strings = []
      for i_group in i_groups:
        if selection_details is not None and not selection_details.all_eq('?'):
          # phenix selection
          sel_strings.append(selection_details[i_group].strip())
          # check it is a valid selection string
          selection_cache.selection(sel_strings[-1])
        else:
          sel_strings.append(refmac_range_to_phenix_string_selection(
            pdb_hierarchy=pdb_hierarchy,
            chain_start=beg_chain_ids[i_group],
            resseq_start=beg_seq_ids[i_group],
            chain_end=end_chain_ids[i_group],
            resseq_end=end_seq_ids[i_group]))
      sel_str = " or ".join(sel_strings)
      self.tls_params.append(tls(
        t=T, l=L, s=S, origin=origin, selection_string=sel_str))
    self.tls_present = True