Skip to content

Commit 564aef3

Browse files
author
Alfie Brownless
committed
Added function to suggest reference positions
1 parent dd9edb4 commit 564aef3

4 files changed

Lines changed: 74 additions & 8 deletions

File tree

WatCon/find_conserved_networks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ def cluster_coordinates_only(coordinate_list, cluster='hdbscan', min_samples=10,
202202
return(cluster_labels, cluster_centers)
203203

204204

205-
def find_commonality(networks, centers, names, dist_cutoff=3, local_dens_radius=6):
205+
def find_commonality(networks, centers, names, dist_cutoff=1.5, local_dens_radius=6):
206206
"""
207207
Find the commonality of a list of networks relative to a summary network created from clustering.
208208

WatCon/generate_static_networks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1112,7 +1112,7 @@ def get_shortest_path(self, selection='all', source=None, target=None):
11121112

11131113

11141114
def extract_objects(pdb_file, network_type, custom_selection, active_region_reference, active_region_COM, active_region_radius,
1115-
water_name, msa_indexing, active_region_only=False, directed=False, angle_criteria=None, max_connection_distance=3.0
1115+
water_name, msa_indexing, active_region_only=False, directed=False, angle_criteria=None, max_connection_distance=3.0,
11161116
max_neighbors=10):
11171117
"""
11181118
Extract and compute a water network for each frame.

WatCon/print_structure_from_pymol.py

Whitespace-only changes.

WatCon/sequence_processing.py

Lines changed: 72 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ def generate_msa_alignment(alignment_file, combined_fasta, fasta_individual):
300300
301301
Returns
302302
-------
303-
list of int
303+
list[int]
304304
List of MSA indices corresponding to the sequence of interest.
305305
"""
306306
#Make alignment file with modeller if name does not exist
@@ -377,15 +377,81 @@ def convert_msa_to_individual(msa_indices, msa_indices_ref, resids, resid_sequen
377377
desired_resid=None
378378
print('Failed')
379379

380-
#individual_index = np.where(msa_indices == reference_msa)[0][0]
381-
#print(individual_index)
380+
return desired_resid
382381

383-
# Extract the desired residue ID
384-
#desired_resid = int(resids[individual_index[0]])
382+
def suggest_references(input_pdb, pymol_structure_file, num_options=1, min_res=50, max_res=40, dist_cutoff=20):
383+
"""
384+
Suggest reference points based on secondary structure and distance criteria.
385385
386-
return desired_resid
386+
Parameters
387+
----------
388+
input_pdb : str
389+
Path to MDAnalysis-readable topology file
390+
pymol_structure_file : str
391+
Path to PyMOL file outputted from WatCon.print_structure_from_pymol
392+
num_options : int, optional
393+
Desired number of reference options to return. Default is 1.
394+
min_res : int, optional
395+
First residue option. Default is 50.
396+
max_res : int, optional
397+
Last residue option (counted backwards from end of sequence). Default is 40.
398+
dist_cutoff : float, optional
399+
Minimum distance two residues need to be to be considered a potential pair. Default is 20A.
387400
401+
Returns
402+
-------
403+
list[tuple(int)]
404+
List of possible reference pairs
388405
406+
"""
407+
def read_structure(pymol_file):
408+
"""
409+
Read structural information from PyMOL-outputted text file
410+
"""
411+
#Check that PyMOL-outputted text file exists.
412+
try:
413+
with open(pymol_file, 'r') as FILE:
414+
lines = FILE.readlines()
415+
return lines
416+
except FileNotFoundError:
417+
print('Cannot find corresponding structural information file.\n \
418+
Please open a PyMOL session with the structure of interest and run WatCon.print_structure_from_pymol.\n \
419+
Make sure the path to the corresponding file is correct.')
420+
raise FileNotFoundError
421+
422+
def create_options(lines, min_res, max_res):
423+
"""
424+
Return list of residue options based on structure and given residue range
425+
"""
426+
options = []
427+
for line in lines[min_res:-max_res]:
428+
res, resnum, ss = line.split()
429+
if ss != 'L':
430+
options.append(resnum)
431+
return options
432+
433+
def pick_pair(u, options, num_options=1, dist_cutoff=20):
434+
"""
435+
Return pairs of residues which could work for two-angle references
436+
"""
437+
pairs = []
438+
cur_option = 0
439+
while cur_option < no_options:
440+
for option1 in options:
441+
coords1 = u.select_atoms(f"resid {option1} and name CA").positions
442+
for option2 in options[::-1]:
443+
coords2 = u.select_atoms(f"resid {option2} and name CA").positions
444+
distance = dist(*coords1[0], *coords2[0])
445+
if distance > dist_cutoff:
446+
pairs.append((option1, option2))
447+
cur_option += 1
448+
return(pairs)
449+
450+
u = mda.Universe(input_pdb)
451+
lines = read_structure(pymol_structure_file)
452+
options = create_options(lines, min_res, max_res)
453+
return pick_pair(u, options, num_options, dist_cutoff)
454+
389455

390456

391457
'''

0 commit comments

Comments
 (0)