diff --git a/src/idpconfgen/cli_complex.py b/src/idpconfgen/cli_complex.py index be1d0cc6..4f25881e 100644 --- a/src/idpconfgen/cli_complex.py +++ b/src/idpconfgen/cli_complex.py @@ -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, @@ -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): @@ -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( diff --git a/src/idpconfgen/libs/libcomplex.py b/src/idpconfgen/libs/libcomplex.py index c5cdd80d..7168d091 100644 --- a/src/idpconfgen/libs/libcomplex.py +++ b/src/idpconfgen/libs/libcomplex.py @@ -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"] @@ -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