Skip to content

Commit

Permalink
coordinates retriever for fragment mover
Browse files Browse the repository at this point in the history
  • Loading branch information
menoliu committed May 16, 2024
1 parent bf4974c commit 05f1307
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/idpconfgen/cli_complex.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
electropotential_matrix,
extract_interpairs_from_db,
extract_intrapairs_from_db,
find_ca_coords_fld,
get_contact_distances,
process_custom_contacts,
select_contacts,
Expand Down Expand Up @@ -949,13 +950,7 @@ def main(
selected_contacts["Y"][contact_type[0]][case].append(y_coords) # noqa: E501
contacts_counter -= len(x_coords)
log.info(S('done'))

# TODO extracting distance distributions from database
# For custom-contacts we would need to rescan the database for
# residue pairs
# - Make a d_mtx for every custom contact and align it with
# `cus_inter_res` and `cus_intra_res`


# NOTE work with generalizable inter- for IDP-Folded and IDP-IDP before
# algorithm for intramolecular contacts
for conf in range(nconfs):
Expand Down Expand Up @@ -1079,6 +1074,17 @@ def main(
imap = pool.imap(execute, range(1))
for _ in imap:
pass
log.info(S("done"))

# Move IDP fragments to the desired distance and location
fld_contact_coords = []
fld_struc = Structure(Path(folded_structure))
fld_struc.build()
fld_data = fld_struc.data_array
for res in res_combos:
# First element in res contains our residues of interest
coords = find_ca_coords_fld(fld_data, res[0])
fld_contact_coords.append(coords)


def populate_globals(
Expand Down
31 changes: 31 additions & 0 deletions src/idpconfgen/libs/libcomplex.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
get_substring_characters,
has_consecutive_match,
)
from idpconfgen.libs.libstructure import col_name, col_resSeq, cols_coords


contact_type = ["intra", "inter"]
Expand Down Expand Up @@ -830,3 +831,33 @@ def get_contact_distances(
residues = (sub_seq1, sub_seq2)

return distances, residues


def find_ca_coords_fld(fld_struc, residues):
"""
Locates CA coordinates in a structure based on residues.
Parameters
----------
fld_struc : np.ndarray
data_array property of libstructure.Structure.
residues : list or tuple
Series of residue numbers for the CA residues of interest.
Returns
-------
coords : list of array
[x, y, z] coordinates for each residue's CA.
"""
fld_res = fld_struc[:, col_resSeq].astype(int)
fld_coords = fld_struc[:, cols_coords]
fld_atom_names = fld_struc[:, col_name]
coords = []
for r in residues:
for i, fr in enumerate(fld_res):
atom = fld_atom_names[i]
if r == fr and atom == "CA":
coords.append(fld_coords[i])

return coords

0 comments on commit 05f1307

Please sign in to comment.