From f902a8133833f15beee917932c08a466914320b9 Mon Sep 17 00:00:00 2001 From: clami66 Date: Mon, 25 Mar 2024 16:52:58 +0100 Subject: [PATCH] simplify --- README.md | 19 +++++++++--------- src/DockQ/DockQ.py | 48 ++++++++++++++++++---------------------------- 2 files changed, 28 insertions(+), 39 deletions(-) diff --git a/README.md b/README.md index 3f1dbad..ab5b6cd 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ After installing DockQ with `pip`, the `DockQ` binary will be in your path. Just **Example** -When running DockQ on model/native complexes with one or more interfaces, you will get a result for each interface. Results are computed to maximise the average DockQ across all interface: +When running DockQ on model/native complexes with one or more interfaces, you will get a result for each interface. Results are computed to maximise the average DockQ across all interfaces: ``` @@ -144,30 +144,29 @@ Run DockQ with `-h/--help` to see a list of the available flags: ``` bash$ DockQ -h -usage: DockQ [-h] [--capri_peptide] [--short] [--verbose] [--use_CA] [--no_align] [--optDockQF1] [--allowed_mismatches ALLOWED_MISMATCHES] [--mapping MODELCHAINS:NATIVECHAINS] +usage: DockQ [-h] [--capri_peptide] [--short] [--verbose] [--no_align] [--n_cpu n_cpu] [--optDockQF1] [--allowed_mismatches ALLOWED_MISMATCHES] [--mapping MODELCHAINS:NATIVECHAINS] DockQ - Quality measure for protein-protein docking models positional arguments: - path to model file - path to native file + Path to model file + Path to native file optional arguments: -h, --help show this help message and exit --capri_peptide use version for capri_peptide (DockQ cannot not be trusted for this setting) - --short short output - --verbose, -v talk a lot! - --use_CA, -ca use CA instead of backbone + --short Short output + --verbose, -v Verbose output --no_align Do not align native and model using sequence alignments, but use the numbering of residues instead - --optDockQF1 optimize on DockQ_F1 instead of DockQ + --n_cpu n_cpu Number of cores to use + --optDockQF1 Optimize on DockQ_F1 instead of DockQ --allowed_mismatches ALLOWED_MISMATCHES - number of allowed mismatches when mapping model sequence to native sequence. + Number of allowed mismatches when mapping model sequence to native sequence. --mapping MODELCHAINS:NATIVECHAINS Specify a chain mapping between model and native structure. If the native contains two chains "H" and "L" while the model contains two chains "A" and "B", and chain A is a model of native chain H and chain B is a model of native chain L, the flag can be set as: '--mapping AB:HL'. This can also help limit the search to specific native interfaces. For example, if the native is a tetramer (ABCD) but the user is only interested in the interface between chains B and C, the flag can be set as: '--mapping :BC' or the equivalent '--mapping *:BC'. - ``` diff --git a/src/DockQ/DockQ.py b/src/DockQ/DockQ.py index ef1e729..f3b7af4 100755 --- a/src/DockQ/DockQ.py +++ b/src/DockQ/DockQ.py @@ -7,6 +7,7 @@ import warnings import traceback import itertools +from collections import Counter from argparse import ArgumentParser from functools import lru_cache, wraps, partial @@ -669,13 +670,8 @@ def product_without_dupl(*args, repeat=1): def count_chain_combinations(chain_clusters): - counts = {} - for chain in chain_clusters: - chains = tuple(chain_clusters[chain]) - if chains not in counts: - counts[chains] = 0 - counts[chains] += 1 - number_of_combinations = np.prod([math.factorial(a) for a in counts.values()]) + tuples = [tuple(l) for l in chain_clusters.values()] + number_of_combinations = np.prod([math.factorial(a) for a in Counter(tuples).values()]) return number_of_combinations @@ -743,7 +739,6 @@ def main(): native_chains_to_combo, args.allowed_mismatches, ) - num_chain_combinations = count_chain_combinations(chain_clusters) chain_maps = get_all_chain_maps( chain_clusters, @@ -793,29 +788,24 @@ def main(): best_dockq = total_dockq best_result = result_this_mapping best_mapping = chain_map - - else: # skip multi-threading for single jobs (skip the bar basically) - for chain_map in chain_maps: - result_this_mapping = run_chain_map(chain_map) - total_dockq = sum( - [ - result["DockQ_F1" if args.optDockQF1 else "DockQ"] - for result in result_this_mapping.values() - ] + if low_memory: # retrieve the full output by rerunning the best chain mapping + best_result = run_on_all_native_interfaces( + model_structure, + native_structure, + best_mapping, + args.no_align, + args.capri_peptide, + low_memory=False, ) - if total_dockq > best_dockq: - best_dockq = total_dockq - best_result = result_this_mapping - best_mapping = chain_map - if low_memory: # retrieve the full output by reruning the best chain mapping - best_result = run_on_all_native_interfaces( - model_structure, - native_structure, - best_mapping, - args.no_align, - args.capri_peptide, - low_memory=False, + else: # skip multi-threading for single jobs (skip the bar basically) + best_mapping = next(chain_maps) + best_result = run_chain_map(best_mapping) + best_dockq = sum( + [ + result["DockQ_F1" if args.optDockQF1 else "DockQ"] + for result in best_result.values() + ] ) info["model"] = args.model