Skip to content

Commit

Permalink
keep cache but be careful with use_numbering flag
Browse files Browse the repository at this point in the history
  • Loading branch information
clami66 committed Mar 25, 2024
1 parent 34a4029 commit fd4555d
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions src/DockQ/DockQ.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ def get_residue_distances(chain1, chain2, what, all_atom=True):
return model_res_distances


# @profile
def calc_DockQ(
sample_chains,
ref_chains,
Expand Down Expand Up @@ -306,7 +305,7 @@ def dockq_formula(fnat, irms, Lrms):
) / 3


#@lru_cache
@lru_cache
def align_chains(model_chain, native_chain, use_numbering=False):
"""
Function to align two PDB structures. This can be done by sequence (default) or by
Expand All @@ -326,7 +325,7 @@ def align_chains(model_chain, native_chain, use_numbering=False):
for residue in native_chain.get_residues():
resn = int(residue.id[1])
native_numbering.append(resn)
# if the samllest resn is negative, it will be used to shift all numbers so they start from 0
# if the smallest resn is negative, it will be used to shift all numbers so they start from 0
# the minimum offset is 45 to avoid including the "-" character that is reserved for gaps
min_resn = max(45, -min(model_numbering + native_numbering))

Expand Down Expand Up @@ -483,7 +482,6 @@ def get_interface_atoms(


@lru_cache
# @profile
def run_on_chains(
model_chains,
native_chains,
Expand Down Expand Up @@ -553,7 +551,6 @@ def run_on_all_native_interfaces(
return results_dic


# @profile
def load_PDB(path, chains=[], n_model=0):
try:
pdb_parser = PDBParser(QUIET=True)
Expand All @@ -572,7 +569,6 @@ def load_PDB(path, chains=[], n_model=0):
)
model = structure[n_model]

# remove_h(model)
return model


Expand All @@ -591,7 +587,7 @@ def group_chains(
chain_clusters = {chain: [] for chain in ref_chains}

for query_chain, ref_chain in alignment_targets:
aln = align_chains(query_structure[query_chain], ref_structure[ref_chain], use_numbering=False)
aln = align_chains(query_structure[query_chain], ref_structure[ref_chain], use_numbering=None)
alignment = format_alignment(aln)
n_mismatches = alignment["matches"].count(".")

Expand Down Expand Up @@ -712,7 +708,6 @@ def get_all_chain_maps(
yield (chain_map)


# @profile
def main():
args = parse_args()
initial_mapping, model_chains, native_chains = format_mapping(args.mapping)
Expand Down Expand Up @@ -766,7 +761,7 @@ def main():
no_align=args.no_align,
capri_peptide=args.capri_peptide,
low_memory=low_memory,
) ##args: chain_map
)

if num_chain_combinations > 1:
chunk_size = 512
Expand Down Expand Up @@ -839,7 +834,6 @@ def print_results(info, short=False, verbose=False, capri_peptide=False):
print(
f"Total DockQ over {len(info['best_result'])} native interfaces: {info['GlobalDockQ']:.3f} with {info['best_mapping_str']} model:native mapping"
)
# print(info["best_result"])
for chains, results in info["best_result"].items():
print(
f"DockQ{capri_peptide_str} {results['DockQ']:.3f} DockQ_F1 {results['DockQ_F1']:.3f} Fnat {results['fnat']:.3f} iRMS {results['irms']:.3f} LRMS {results['Lrms']:.3f} Fnonnat {results['fnonnat']:.3f} clashes {results['clashes']} mapping {results['chain1']}{results['chain2']}:{chains[0]}{chains[1]} {info['model']} {results['chain1']} {results['chain2']} -> {info['native']} {chains[0]} {chains[1]}"
Expand Down

0 comments on commit fd4555d

Please sign in to comment.