def ligand_neighbor_selection(lig, radius, pose, include_ligand=False): rad = float(radius) not_ligand = NotResidueSelector() not_ligand.set_residue_selector(lig) lig_distant_neighbors = InterGroupInterfaceByVectorSelector() lig_distant_neighbors.group1_selector(lig) lig_distant_neighbors.group2_selector(not_ligand) lig_distant_neighbors.cb_dist_cut(2.0 * rad) lig_distant_neighbors.nearby_atom_cut(rad) lig_contacts = pr.rosetta.core.select.residue_selector.CloseContactResidueSelector( ) lig_contacts.central_residue_group_selector(lig) lig_contacts.threshold(rad) lig_neighbors = OrResidueSelector() lig_neighbors.add_residue_selector(lig_distant_neighbors) lig_neighbors.add_residue_selector(lig_contacts) if include_ligand: selection = AndResidueSelector() selection.add_residue_selector(not_ligand) else: selection = OrResidueSelector() selection.add_residue_selector(lig) selection.add_residue_selector(lig_neighbors) return get_residues_from_subset(selection.apply(pose))
#interface_sele.cb_dist_cut(100.0) # To be included based on distance, the rules are different for protein and DNA # residues. For protein, a sidechain atom needs to be within `nearby_atom_cut` # of any atom in the other group. For DNA, C1' (the sugar carbon supporting # the base, defined as the "neighbor" atom, see database/chemical/...) needs to # be within `nearby_atom_cut` of any atom in the other group. So DNA is a # little more restrictive, because it only counts distances from one atom, not # all atoms. protein_interface_sele = AndResidueSelector(interface_sele, protein_sele) print('interface_sele.vector_dist_cut =', interface_sele.vector_dist_cut()) print('interface_sele.vector_angle_cut =', interface_sele.vector_angle_cut()) print('interface_sele.nearby_atom_cut =', interface_sele.nearby_atom_cut()) print('interface_sele.cb_dist_cut =', interface_sele.cb_dist_cut()) pymol_from_sele('protein_sele', pose) pymol_from_sele('dna_sele', pose) pymol_from_sele('interface_sele', pose) pymol_from_sele('protein_interface_sele', pose) raise SystemExit #n_close = 0 #n_contact = 0 #n_total = 0 # # #for k, v in n.items(): # n_close += v.close()
def main(args): if args.ligand_type == 'ligand': init_args = ' '.join(['-extra_res_fa', args.ligand_name]) lig_name = args.ligand_name.split('/')[-1].strip('.params') else: init_args = '' pr.init(init_args) sf = pr.get_fa_scorefxn() sf.add_weights_from_file('ref2015') pose = pr.pose_from_pdb(args.input_pdb) sf(pose) print_notice("Scaffold protein Loaded Successfully!") print_notice("Scaffold protein has" + str(pose.total_residue()) + "residues.") if args.symmetric_file: sfsm = SetupForSymmetryMover(args.symmetric_file) sfsm.apply(pose) #Importing list of residues if the ligand is a protein if args.ligand_type == 'protein': ligres = ResidueIndexSelector(args.residue_set) #Targeting the ligand if the ligand isn't protein elif args.ligand_type == 'ligand': ligres = ResidueNameSelector() ligres.set_residue_name3(lig_name) print_notice("Ligand found at resnum: " + \ str(get_residues_from_subset(ligres.apply(pose))) ) #Setting the proteins not in the ligand not_ligand = NotResidueSelector() not_ligand.set_residue_selector(ligres) #Setting the protein considered part of the ligand ligand_distant_contacts = InterGroupInterfaceByVectorSelector() ligand_distant_contacts.group1_selector(ligres) ligand_distant_contacts.group2_selector(not_ligand) ligand_distant_contacts.cb_dist_cut(2.5 * float(args.radius)) ligand_distant_contacts.nearby_atom_cut(float(args.radius)) #Test set: ClosecontactResidueSelector close_contacts = pr.rosetta.core.select.residue_selector.CloseContactResidueSelector( ) close_contacts.central_residue_group_selector(ligres) close_contacts.threshold(float(args.radius)) all_contacts = OrResidueSelector() all_contacts.add_residue_selector(close_contacts) all_contacts.add_residue_selector(ligand_distant_contacts) non_lig_residues = AndResidueSelector() non_lig_residues.add_residue_selector(all_contacts) non_lig_residues.add_residue_selector(not_ligand) #Collecting the residues from the subset neighbor_residues = get_residues_from_subset(non_lig_residues.apply(pose)) pdb_residues = [] for residue in neighbor_residues: print(pose.pdb_info().pose2pdb(residue)) resid = pose.pdb_info().pose2pdb(residue).split() pdb_residues.append(''.join(resid)) print_notice("Ligand found, neighbor residues are: " + ', '.join([x for x in pdb_residues])) print_notice("Ligand found, total neighbor residues is " + str(len(pdb_residues))) #Removing residues in the REMARKS section remove_set = [] f = open(args.input_pdb, 'r') for line in f.readlines(): if 'REMARK' in line: items = [x for x in line.split(' ') if x != ''] residue_set = [int(items[6]), int(items[11])] for resi in residue_set: if resi not in remove_set: remove_set.append(resi) residue_final_set = [] for resi in pdb_residues: idx = int(resi[0:-1]) if idx not in remove_set: residue_final_set.append(resi) #Final list for the designable residues residue_final_set.append('0') print_notice("Neighbor residues cleaned \n \n Residues are: " +\ ', '.join([x for x in residue_final_set])) if args.out_file: out_name = args.out_file else: out_name = args.input_pdb.strip('.pdb') + '_lig.pos' f = open(out_name, "w") for x in residue_final_set: f.write(x + '\n') f.close print("emd182::Wrote ligand position residues of pdb file " + args.input_pdb + " to filename: " + out_name)