def build_den_proxies(self, pdb_hierarchy): from mmtbx.geometry_restraints.torsion_restraints import utils self.atoms_per_chain = \ self.count_atoms_per_chain(pdb_hierarchy=pdb_hierarchy) self.atoms_per_chain_ref = \ self.count_atoms_per_chain(pdb_hierarchy=self.pdb_hierarchy_ref) self.resid_hash_ref = \ utils.build_resid_hash(pdb_hierarchy=self.pdb_hierarchy_ref) self.i_seq_hash = \ utils.build_i_seq_hash(pdb_hierarchy=pdb_hierarchy) self.i_seq_hash_ref = \ utils.build_i_seq_hash(pdb_hierarchy=self.pdb_hierarchy_ref) self.name_hash = \ utils.build_name_hash(pdb_hierarchy=pdb_hierarchy) self.name_hash_ref = \ utils.build_name_hash(pdb_hierarchy=self.pdb_hierarchy_ref) self.ref_atom_pairs, self.ref_distance_hash = \ self.find_atom_pairs(pdb_hierarchy=self.pdb_hierarchy_ref, resid_hash=self.resid_hash_ref) self.remove_non_matching_pairs() if self.den_network_file is not None: self.den_atom_pairs = self.load_den_network() else: self.random_ref_atom_pairs = \ self.select_random_den_restraints() self.den_atom_pairs = self.get_den_atom_pairs() self.check_den_pair_consistency() if self.export_den_pairs: self.dump_den_network()
def build_dihedral_hash(self, dihedral_proxies=None, sites_cart=None, pdb_hierarchy=None, include_hydrogens=False, include_main_chain=True, include_side_chain=True): if not include_hydrogens: i_seq_element_hash = \ utils.build_element_hash(pdb_hierarchy=pdb_hierarchy) i_seq_name_hash = \ utils.build_name_hash(pdb_hierarchy=pdb_hierarchy) dihedral_hash = dict() for dp in dihedral_proxies: try: #check for H atoms if required if not include_hydrogens: for i_seq in dp.i_seqs: if i_seq_element_hash[i_seq] == " H": raise StopIteration() #ignore backbone dihedrals if not include_main_chain: sc_atoms = False for i_seq in dp.i_seqs: if i_seq_name_hash[i_seq][0:4] not in [ ' CA ', ' N ', ' C ', ' O ' ]: sc_atoms = True break if not sc_atoms: raise StopIteration() if not include_side_chain: sc_atoms = False for i_seq in dp.i_seqs: if i_seq_name_hash[i_seq][0:4] \ not in [' CA ', ' N ', ' C ', ' O ']: sc_atoms = True break if sc_atoms: raise StopIteration() key = "" for i_seq in dp.i_seqs: key = key + i_seq_name_hash[i_seq] di = \ cctbx.geometry_restraints.dihedral( sites_cart=sites_cart, proxy=dp) dihedral_hash[key] = di.angle_model except StopIteration: pass return dihedral_hash
def build_dihedral_hash(self, dihedral_proxies=None, sites_cart=None, pdb_hierarchy=None, include_hydrogens=False, include_main_chain=True, include_side_chain=True): if not include_hydrogens: i_seq_element_hash = \ utils.build_element_hash(pdb_hierarchy=pdb_hierarchy) i_seq_name_hash = \ utils.build_name_hash(pdb_hierarchy=pdb_hierarchy) dihedral_hash = dict() for dp in dihedral_proxies: try: #check for H atoms if required if not include_hydrogens: for i_seq in dp.i_seqs: if i_seq_element_hash[i_seq] == " H": raise StopIteration() #ignore backbone dihedrals if not include_main_chain: sc_atoms = False for i_seq in dp.i_seqs: if i_seq_name_hash[i_seq][0:4] not in [' CA ',' N ',' C ',' O ']: sc_atoms = True break if not sc_atoms: raise StopIteration() if not include_side_chain: sc_atoms = False for i_seq in dp.i_seqs: if i_seq_name_hash[i_seq][0:4] \ not in [' CA ', ' N ', ' C ', ' O ']: sc_atoms = True break if sc_atoms: raise StopIteration() key = "" for i_seq in dp.i_seqs: key = key+i_seq_name_hash[i_seq] di = \ cctbx.geometry_restraints.dihedral( sites_cart=sites_cart, proxy=dp) dihedral_hash[key] = di.angle_model except StopIteration: pass return dihedral_hash
def __init__(self, processed_pdb_file, reference_hierarchy_list=None, reference_file_list=None, mon_lib_srv=None, ener_lib=None, has_hd=False, params=None, selection=None, log=None): assert [reference_hierarchy_list, reference_file_list].count(None) == 1 if (log is None): log = sys.stdout self.params = params self.selection = selection self.mon_lib_srv = mon_lib_srv self.ener_lib = ener_lib self.pdb_hierarchy = processed_pdb_file.all_chain_proxies.pdb_hierarchy self.pdb_hierarchy.reset_i_seq_if_necessary() sites_cart = self.pdb_hierarchy.atoms().extract_xyz() if self.selection is None: self.selection = flex.bool(len(sites_cart), True) if reference_hierarchy_list is None: reference_hierarchy_list = \ utils.process_reference_files( reference_file_list=reference_file_list, log=log) if reference_file_list is None: reference_file_list = \ ["ref%d" % x for x in range(len(reference_hierarchy_list))] # # this takes 20% of constructor time. self.dihedral_proxies_ref = utils.get_reference_dihedral_proxies( reference_hierarchy_list=reference_hierarchy_list, reference_file_list=reference_file_list, mon_lib_srv=self.mon_lib_srv, ener_lib=self.ener_lib, log=log) self.i_seq_name_hash = utils.build_name_hash( pdb_hierarchy=self.pdb_hierarchy) #reference model components self.sites_cart_ref = {} self.pdb_hierarchy_ref = {} self.i_seq_name_hash_ref = {} self.reference_dihedral_hash = {} self.reference_file_list = reference_file_list #triage reference model files for file, hierarchy in zip(reference_file_list, reference_hierarchy_list): self.sites_cart_ref[file] = hierarchy.atoms().extract_xyz() self.pdb_hierarchy_ref[file] = hierarchy self.i_seq_name_hash_ref[file] = \ utils.build_name_hash( pdb_hierarchy=hierarchy) self.reference_dihedral_hash[file] = \ self.build_dihedral_hash( dihedral_proxies=self.dihedral_proxies_ref[file], sites_cart=self.sites_cart_ref[file], pdb_hierarchy=hierarchy, include_hydrogens=self.params.hydrogens, include_main_chain=self.params.main_chain, include_side_chain=self.params.side_chain) self.match_map = None self.proxy_map = None self.build_reference_dihedral_proxy_hash() # # This takes 80% of constructor time!!! self.residue_match_hash = {} # {key_model: ('file_name', key_ref)} self.match_map = {} # {'file_name':{i_seq_model:i_seq_ref}} if params.use_starting_model_as_reference: self.get_matching_from_self() else: self.get_matching_from_ncs(log=log) if self.match_map == {}: # making empty container new_ref_dih_proxies = self.reference_dihedral_proxies = \ cctbx.geometry_restraints.shared_dihedral_proxy() else: new_ref_dih_proxies = self.get_reference_dihedral_proxies( processed_pdb_file=processed_pdb_file)
def __init__(self, processed_pdb_file, reference_hierarchy_list=None, reference_file_list=None, mon_lib_srv=None, ener_lib=None, has_hd=False, params=None, selection=None, log=None): assert [reference_hierarchy_list, reference_file_list].count(None) == 1 if(log is None): log = sys.stdout self.params = params self.selection = selection self.mon_lib_srv = mon_lib_srv self.ener_lib = ener_lib self.pdb_hierarchy = processed_pdb_file.all_chain_proxies.pdb_hierarchy self.pdb_hierarchy.reset_i_seq_if_necessary() sites_cart = self.pdb_hierarchy.atoms().extract_xyz() if self.selection is None: self.selection = flex.bool(len(sites_cart), True) if reference_hierarchy_list is None: reference_hierarchy_list = \ utils.process_reference_files( reference_file_list=reference_file_list, log=log) if reference_file_list is None: reference_file_list = \ ["ref%d" % x for x in range(len(reference_hierarchy_list))] # # this takes 20% of constructor time. self.dihedral_proxies_ref = utils.get_reference_dihedral_proxies( reference_hierarchy_list=reference_hierarchy_list, reference_file_list=reference_file_list, mon_lib_srv=self.mon_lib_srv, ener_lib=self.ener_lib, log=log) self.i_seq_name_hash = utils.build_name_hash( pdb_hierarchy=self.pdb_hierarchy) #reference model components self.sites_cart_ref = {} self.pdb_hierarchy_ref = {} self.i_seq_name_hash_ref = {} self.reference_dihedral_hash = {} self.reference_file_list = reference_file_list #triage reference model files for file, hierarchy in zip(reference_file_list, reference_hierarchy_list): self.sites_cart_ref[file] = hierarchy.atoms().extract_xyz() self.pdb_hierarchy_ref[file] = hierarchy self.i_seq_name_hash_ref[file] = \ utils.build_name_hash( pdb_hierarchy=hierarchy) self.reference_dihedral_hash[file] = \ self.build_dihedral_hash( dihedral_proxies=self.dihedral_proxies_ref[file], sites_cart=self.sites_cart_ref[file], pdb_hierarchy=hierarchy, include_hydrogens=self.params.hydrogens, include_main_chain=self.params.main_chain, include_side_chain=self.params.side_chain) self.match_map = None self.proxy_map = None self.build_reference_dihedral_proxy_hash() # # This takes 80% of constructor time!!! self.residue_match_hash = {} # {key_model: ('file_name', key_ref)} self.match_map = {} # {'file_name':{i_seq_model:i_seq_ref}} if params.use_starting_model_as_reference: self.get_matching_from_self() else: self.get_matching_from_ncs(log=log) if self.match_map == {}: # making empty container new_ref_dih_proxies = self.reference_dihedral_proxies = \ cctbx.geometry_restraints.shared_dihedral_proxy() else: new_ref_dih_proxies = self.get_reference_dihedral_proxies( processed_pdb_file=processed_pdb_file)