From 2bb0db29da3d0b5e220e159aabbe71da5302c0f1 Mon Sep 17 00:00:00 2001 From: bjornwallner Date: Sat, 23 Mar 2024 11:00:57 +0100 Subject: [PATCH 01/17] Update main.yml --- .github/workflows/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c8eb96b..9983776 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -28,6 +28,7 @@ jobs: bash run_test.sh - name: Coverage run: | + coverage report test $(coverage report | grep TOTAL | awk '{ print $4 }' | tr -d "%") -ge $MIN_COVERAGE_REQUIRED #test_oldbio: From a5222d0089d43989f8fc8c20fd925bce1953495f Mon Sep 17 00:00:00 2001 From: bjornwallner Date: Sat, 23 Mar 2024 11:19:40 +0100 Subject: [PATCH 02/17] Update main.yml, changed min coverage to 35, to avoid failing the coverage test --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9983776..289c406 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -3,7 +3,7 @@ name: CI on: [push, pull_request, workflow_dispatch] env: - MIN_COVERAGE_REQUIRED: 50 + MIN_COVERAGE_REQUIRED: 35 jobs: From aacdc6080b0c7db1a69591671d9341ff048e2cc8 Mon Sep 17 00:00:00 2001 From: clami66 Date: Mon, 25 Mar 2024 08:59:00 +0100 Subject: [PATCH 03/17] small fixes --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 842416e..d89bfee 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ ![CI status](https://github.com/bjornwallner/DockQ/actions/workflows/main.yml/badge.svg) -# DockQ: A Quality Measure for Protein-Protein Docking Models +# DockQ +## A Quality Measure for Protein-Protein Docking Models ## Installation @@ -12,7 +13,7 @@ cd DockQ pip install . ``` -## Quick start: +## Quick start After installing DockQ with `pip`, the `DockQ` binary will be in your path. Just run DockQ with: From 0148f55a1c8901c3fec700bcfab51f889f15b142 Mon Sep 17 00:00:00 2001 From: clami66 Date: Mon, 25 Mar 2024 09:41:24 +0100 Subject: [PATCH 04/17] debug coverage issue --- run_test.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/run_test.sh b/run_test.sh index e421fad..90041b1 100644 --- a/run_test.sh +++ b/run_test.sh @@ -17,3 +17,5 @@ coverage run -a -m DockQ.DockQ examples/1EXB_r_l_b.model.pdb examples/1EXB_r_l_b # Test that cif parsing behaves same as pdb parsing coverage run -a -m DockQ.DockQ examples/1EXB_r_l_b.model.pdb examples/1EXB_r_l_b.pdb --mapping DH:AE coverage run -a -m DockQ.DockQ examples/1EXB_r_l_b.model.pdb examples/1EXB.cif.gz --mapping DH:AE + +coverage report From 0728794183f2b99e728b0109ff7dfa21531a49d9 Mon Sep 17 00:00:00 2001 From: clami66 Date: Mon, 25 Mar 2024 09:50:26 +0100 Subject: [PATCH 05/17] coverage version output --- run_test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run_test.sh b/run_test.sh index 90041b1..e5bf086 100644 --- a/run_test.sh +++ b/run_test.sh @@ -1,6 +1,6 @@ #!/bin/bash set -euo pipefail - +coverage --version # Test that cython version behaves the same as nocython coverage run -a -m DockQ.DockQ examples/1A2K_r_l_b.model.pdb examples/1A2K_r_l_b.pdb coverage run -a src/DockQ/DockQ.py examples/1A2K_r_l_b.model.pdb examples/1A2K_r_l_b.pdb From 2d1933f3e6071914c753bae8fd33021a5594588d Mon Sep 17 00:00:00 2001 From: clami66 Date: Mon, 25 Mar 2024 09:54:28 +0100 Subject: [PATCH 06/17] more debugging --- run_test.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/run_test.sh b/run_test.sh index e5bf086..4445709 100644 --- a/run_test.sh +++ b/run_test.sh @@ -1,8 +1,8 @@ #!/bin/bash set -euo pipefail -coverage --version + # Test that cython version behaves the same as nocython -coverage run -a -m DockQ.DockQ examples/1A2K_r_l_b.model.pdb examples/1A2K_r_l_b.pdb +coverage run -a -m --debug=trace DockQ.DockQ examples/1A2K_r_l_b.model.pdb examples/1A2K_r_l_b.pdb coverage run -a src/DockQ/DockQ.py examples/1A2K_r_l_b.model.pdb examples/1A2K_r_l_b.pdb coverage run -a -m DockQ.DockQ examples/1A2K_r_l_b.model.pdb examples/1A2K_r_l_b.pdb --no_align coverage run -a src/DockQ/DockQ.py examples/1A2K_r_l_b.model.pdb examples/1A2K_r_l_b.pdb --no_align From fa1e7d661d147fc178efb14d14880564d28a0aa3 Mon Sep 17 00:00:00 2001 From: clami66 Date: Mon, 25 Mar 2024 10:05:04 +0100 Subject: [PATCH 07/17] move coverage install --- .github/workflows/main.yml | 1 - setup.cfg | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 289c406..7ad4286 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -20,7 +20,6 @@ jobs: - name: Test outputs run: | python -m pip install . - python -m pip install coverage bash run_test.sh - name: Test with old biopython run: | diff --git a/setup.cfg b/setup.cfg index b95a414..75e37af 100644 --- a/setup.cfg +++ b/setup.cfg @@ -11,6 +11,7 @@ install_requires = cython tqdm parallelbar + coverage numpy~=1.21 biopython>=1.79 From 3d404e795c56c214fcd87c6b3f4b08a4816109ba Mon Sep 17 00:00:00 2001 From: clami66 Date: Mon, 25 Mar 2024 10:10:15 +0100 Subject: [PATCH 08/17] add source in covtest --- run_test.sh | 22 +++---- setup.cfg | 1 - src/DockQ/DockQ.py | 148 ++++++++++++++++++++++++++++----------------- 3 files changed, 105 insertions(+), 66 deletions(-) diff --git a/run_test.sh b/run_test.sh index 4445709..e25b0ee 100644 --- a/run_test.sh +++ b/run_test.sh @@ -2,20 +2,20 @@ set -euo pipefail # Test that cython version behaves the same as nocython -coverage run -a -m --debug=trace DockQ.DockQ examples/1A2K_r_l_b.model.pdb examples/1A2K_r_l_b.pdb -coverage run -a src/DockQ/DockQ.py examples/1A2K_r_l_b.model.pdb examples/1A2K_r_l_b.pdb -coverage run -a -m DockQ.DockQ examples/1A2K_r_l_b.model.pdb examples/1A2K_r_l_b.pdb --no_align -coverage run -a src/DockQ/DockQ.py examples/1A2K_r_l_b.model.pdb examples/1A2K_r_l_b.pdb --no_align +coverage run -a -m --source=src/ DockQ.DockQ examples/1A2K_r_l_b.model.pdb examples/1A2K_r_l_b.pdb +coverage run -a --source=src/ src/DockQ/DockQ.py examples/1A2K_r_l_b.model.pdb examples/1A2K_r_l_b.pdb +coverage run -a -m --source=src/ DockQ.DockQ examples/1A2K_r_l_b.model.pdb examples/1A2K_r_l_b.pdb --no_align +coverage run -a --source=src/ src/DockQ/DockQ.py examples/1A2K_r_l_b.model.pdb examples/1A2K_r_l_b.pdb --no_align # Multiple interfaces -coverage run -a -m DockQ.DockQ examples/dimer_dimer.model.pdb examples/dimer_dimer.pdb --short +coverage run -a -m --source=src/ DockQ.DockQ examples/dimer_dimer.model.pdb examples/dimer_dimer.pdb --short # Test on structures with slightly different sequences -coverage run -a -m DockQ.DockQ examples/model.pdb examples/native.pdb --allowed_mismatches 1 +coverage run -a -m --source=src/ DockQ.DockQ examples/model.pdb examples/native.pdb --allowed_mismatches 1 # Test various mapping strategies -coverage run -a -m DockQ.DockQ examples/1EXB_r_l_b.model.pdb examples/1EXB_r_l_b.pdb --short --mapping AB*:BA* -coverage run -a -m DockQ.DockQ examples/1EXB_r_l_b.model.pdb examples/1EXB_r_l_b.pdb --short --mapping :ABC -coverage run -a -m DockQ.DockQ examples/1EXB_r_l_b.model.pdb examples/1EXB_r_l_b.pdb --short --mapping ABCDEFGH:BADCFEHG +coverage run -a -m --source=src/ DockQ.DockQ examples/1EXB_r_l_b.model.pdb examples/1EXB_r_l_b.pdb --short --mapping AB*:BA* +coverage run -a -m --source=src/ DockQ.DockQ examples/1EXB_r_l_b.model.pdb examples/1EXB_r_l_b.pdb --short --mapping :ABC +coverage run -a -m --source=src/ DockQ.DockQ examples/1EXB_r_l_b.model.pdb examples/1EXB_r_l_b.pdb --short --mapping ABCDEFGH:BADCFEHG # Test that cif parsing behaves same as pdb parsing -coverage run -a -m DockQ.DockQ examples/1EXB_r_l_b.model.pdb examples/1EXB_r_l_b.pdb --mapping DH:AE -coverage run -a -m DockQ.DockQ examples/1EXB_r_l_b.model.pdb examples/1EXB.cif.gz --mapping DH:AE +coverage run -a -m --source=src/ DockQ.DockQ examples/1EXB_r_l_b.model.pdb examples/1EXB_r_l_b.pdb --mapping DH:AE +coverage run -a -m --source=src/ DockQ.DockQ examples/1EXB_r_l_b.model.pdb examples/1EXB.cif.gz --mapping DH:AE coverage report diff --git a/setup.cfg b/setup.cfg index 75e37af..b95a414 100644 --- a/setup.cfg +++ b/setup.cfg @@ -11,7 +11,6 @@ install_requires = cython tqdm parallelbar - coverage numpy~=1.21 biopython>=1.79 diff --git a/src/DockQ/DockQ.py b/src/DockQ/DockQ.py index 9278f78..de73b9c 100755 --- a/src/DockQ/DockQ.py +++ b/src/DockQ/DockQ.py @@ -68,7 +68,7 @@ def parse_args(): ) parser.add_argument( "--n_cpu", - default=32, + default=8, type=int, metavar="n_cpu", help="Number of cores to use", @@ -448,7 +448,7 @@ def calc_DockQ( ) # using the private _rms function which does not superimpose info = {} - + info["DockQ_F1"] = dockq_formula( f1(nat_correct, nonnat_count, nat_total), irms, Lrms ) @@ -771,7 +771,7 @@ def run_on_all_native_interfaces( return results_dic -#@profile +# @profile def load_PDB(path, chains=[], n_model=0): try: pdb_parser = PDBParser(QUIET=True) @@ -784,12 +784,13 @@ def load_PDB(path, chains=[], n_model=0): except Exception: pdb_parser = MMCIFParser(QUIET=True) structure = pdb_parser.get_structure( - "-", (gzip.open if path.endswith(".gz") else open)(path, "rt"), + "-", + (gzip.open if path.endswith(".gz") else open)(path, "rt"), chains=None, ) model = structure[n_model] - #remove_h(model) + # remove_h(model) return model @@ -828,7 +829,7 @@ def group_chains( f"For these chains {chains_without_match} no match was found between model and native, try increasing the --allowed_mismatches from {allowed_mismatches}" ) print(f"Current number of alignments with 1-10 mismatches: {mismatch_dict}") - + return chain_clusters, reverse_map @@ -864,9 +865,9 @@ def format_mapping(mapping_str): def format_mapping_string(chain_mapping): chain1 = "" chain2 = "" - - #mapping = sorted([(b, a) for a, b in chain_mapping.items()]) - #Sorting might change LRMSD since the definition of receptor/ligand for equal length depends on order + + # mapping = sorted([(b, a) for a, b in chain_mapping.items()]) + # Sorting might change LRMSD since the definition of receptor/ligand for equal length depends on order mapping = [(b, a) for a, b in chain_mapping.items()] for ( model_chain, @@ -877,32 +878,46 @@ def format_mapping_string(chain_mapping): return f"{chain1}:{chain2}" + def product_without_dupl(*args, repeat=1): pools = [tuple(pool) for pool in args] * repeat result = [[]] for pool in pools: - result = [x+[y] for x in result for y in pool if y not in x] # here we added condition - #result = set(list(map(lambda x: tuple(sorted(x)), result))) # to remove symmetric duplicates + result = [ + x + [y] for x in result for y in pool if y not in x + ] # here we added condition + # result = set(list(map(lambda x: tuple(sorted(x)), result))) # to remove symmetric duplicates for prod in result: yield tuple(prod) + + def count_chain_combinations(chain_clusters): - counts={} + counts = {} for chain in chain_clusters: - chains=tuple(chain_clusters[chain]) + 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()]) - #combos=itertools.product(*[itertools.permutations(chains) for chains in set([tuple(ch) for ch in chain_clusters.values()])]) - return(number_of_combinations,counts) - #set(chain_clusters.values()) + counts[chains] = 0 + counts[chains] += 1 + number_of_combinations = np.prod([math.factorial(a) for a in counts.values()]) + # combos=itertools.product(*[itertools.permutations(chains) for chains in set([tuple(ch) for ch in chain_clusters.values()])]) + return (number_of_combinations, counts) + # set(chain_clusters.values()) def get_all_mappings( - model_structure, native_structure, model_chains, native_chains,initial_mapping,allowed_mismatches=0 -): - model_chains_to_combo = [mc for mc in model_chains if mc not in initial_mapping.values()] - native_chains_to_combo = [nc for nc in native_chains if nc not in initial_mapping.keys()] + model_structure, + native_structure, + model_chains, + native_chains, + initial_mapping, + allowed_mismatches=0, +): + model_chains_to_combo = [ + mc for mc in model_chains if mc not in initial_mapping.values() + ] + native_chains_to_combo = [ + nc for nc in native_chains if nc not in initial_mapping.keys() + ] chain_clusters, reverse_map = group_chains( model_structure, @@ -915,32 +930,39 @@ def get_all_mappings( all_mappings = product_without_dupl( *[cluster for cluster in chain_clusters.values() if cluster] ) - chain_maps=[] - for mapping in all_mappings: - chain_map = {key:value for key, value in initial_mapping.items()} + chain_maps = [] + for mapping in all_mappings: + chain_map = {key: value for key, value in initial_mapping.items()} if reverse_map: - chain_map.update({ - mapping[i]: model_chain for i, model_chain in enumerate(model_chains_to_combo) - }) + chain_map.update( + { + mapping[i]: model_chain + for i, model_chain in enumerate(model_chains_to_combo) + } + ) else: - chain_map.update({ - native_chain: mapping[i] for i, native_chain in enumerate(native_chains_to_combo) - }) + chain_map.update( + { + native_chain: mapping[i] + for i, native_chain in enumerate(native_chains_to_combo) + } + ) chain_maps.append(chain_map) return chain_maps + def run_on_all_native_interfaces_multi(args): return run_on_all_native_interfaces(*args) -#@profile +# @profile def main(): args = parse_args() initial_mapping, model_chains, native_chains = format_mapping(args.mapping) model_structure = load_PDB(args.model, chains=model_chains) native_structure = load_PDB(args.native, chains=native_chains) - #check user-given chains are in the structures + # check user-given chains are in the structures model_chains = [c.id for c in model_structure] if not model_chains else model_chains native_chains = ( [c.id for c in native_structure] if not native_chains else native_chains @@ -955,11 +977,7 @@ def main(): best_result = None best_mapping = None - - - - - chain_maps=get_all_mappings( + chain_maps = get_all_mappings( model_structure, native_structure, model_chains, @@ -968,32 +986,54 @@ def main(): args.allowed_mismatches, ) - - low_memory=len(chain_maps) > 100 - chain_map_args=[(model_structure,native_structure,chain_map,args.no_align,args.use_CA,args.capri_peptide,low_memory) for chain_map in chain_maps] - if len(chain_maps)>1: - chunk_size=max(1,len(chain_maps) // args.n_cpu) - result_this_mappings=progress_map(run_on_all_native_interfaces_multi,chain_map_args, n_cpu=args.n_cpu, chunk_size=chunk_size) - else: #skip multi-threading for single jobs (skip the bar basically) - result_this_mappings=[run_on_all_native_interfaces(*chain_map_arg) for chain_map_arg in chain_map_args] - for chain_map,result_this_mapping in zip(chain_maps,result_this_mappings): + low_memory = len(chain_maps) > 100 + chain_map_args = [ + ( + model_structure, + native_structure, + chain_map, + args.no_align, + args.use_CA, + args.capri_peptide, + low_memory, + ) + for chain_map in chain_maps + ] + if len(chain_maps) > 1: + chunk_size = max(1, len(chain_maps) // args.n_cpu) + result_this_mappings = progress_map( + run_on_all_native_interfaces_multi, + chain_map_args, + n_cpu=args.n_cpu, + chunk_size=chunk_size, + ) + else: # skip multi-threading for single jobs (skip the bar basically) + result_this_mappings = [ + run_on_all_native_interfaces(*chain_map_arg) + for chain_map_arg in chain_map_args + ] + for chain_map, result_this_mapping in zip(chain_maps, result_this_mappings): total_dockq = sum( - [result["DockQ_F1" if args.optDockQF1 else "DockQ"] for result in result_this_mapping.values()] + [ + result["DockQ_F1" if args.optDockQF1 else "DockQ"] + for result in result_this_mapping.values() + ] ) 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( + 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.use_CA, args.capri_peptide, - low_memory=False) - + low_memory=False, + ) + info["model"] = args.model info["native"] = args.native info["best_dockq"] = best_dockq @@ -1010,7 +1050,7 @@ 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"]) + # 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]}" From cb01c01e01564ab6149baa009f1ce7a58a90aadf Mon Sep 17 00:00:00 2001 From: clami66 Date: Mon, 25 Mar 2024 10:11:25 +0100 Subject: [PATCH 09/17] fix pip command --- .github/workflows/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7ad4286..289c406 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -20,6 +20,7 @@ jobs: - name: Test outputs run: | python -m pip install . + python -m pip install coverage bash run_test.sh - name: Test with old biopython run: | From 71b089600f3b9cc93a01effb30e235e20090a21b Mon Sep 17 00:00:00 2001 From: clami66 Date: Mon, 25 Mar 2024 10:18:25 +0100 Subject: [PATCH 10/17] add source to coverage --- run_test.sh | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/run_test.sh b/run_test.sh index e25b0ee..33faaf6 100644 --- a/run_test.sh +++ b/run_test.sh @@ -2,20 +2,20 @@ set -euo pipefail # Test that cython version behaves the same as nocython -coverage run -a -m --source=src/ DockQ.DockQ examples/1A2K_r_l_b.model.pdb examples/1A2K_r_l_b.pdb -coverage run -a --source=src/ src/DockQ/DockQ.py examples/1A2K_r_l_b.model.pdb examples/1A2K_r_l_b.pdb -coverage run -a -m --source=src/ DockQ.DockQ examples/1A2K_r_l_b.model.pdb examples/1A2K_r_l_b.pdb --no_align +coverage run -a --source='DockQ.DockQ' -m DockQ.DockQ examples/1A2K_r_l_b.model.pdb examples/1A2K_r_l_b.pdb +coverage run -a --source=src/ src/DockQ/DockQ.py examples/1A2K_r_l_b.model.pdb examples/1A2K_r_l_b.pdb +coverage run -a --source='DockQ.DockQ' -m DockQ.DockQ examples/1A2K_r_l_b.model.pdb examples/1A2K_r_l_b.pdb --no_align coverage run -a --source=src/ src/DockQ/DockQ.py examples/1A2K_r_l_b.model.pdb examples/1A2K_r_l_b.pdb --no_align # Multiple interfaces -coverage run -a -m --source=src/ DockQ.DockQ examples/dimer_dimer.model.pdb examples/dimer_dimer.pdb --short +coverage run -a --source='DockQ.DockQ' -m DockQ.DockQ examples/dimer_dimer.model.pdb examples/dimer_dimer.pdb --short # Test on structures with slightly different sequences -coverage run -a -m --source=src/ DockQ.DockQ examples/model.pdb examples/native.pdb --allowed_mismatches 1 +coverage run -a --source='DockQ.DockQ' -m DockQ.DockQ examples/model.pdb examples/native.pdb --allowed_mismatches 1 # Test various mapping strategies -coverage run -a -m --source=src/ DockQ.DockQ examples/1EXB_r_l_b.model.pdb examples/1EXB_r_l_b.pdb --short --mapping AB*:BA* -coverage run -a -m --source=src/ DockQ.DockQ examples/1EXB_r_l_b.model.pdb examples/1EXB_r_l_b.pdb --short --mapping :ABC -coverage run -a -m --source=src/ DockQ.DockQ examples/1EXB_r_l_b.model.pdb examples/1EXB_r_l_b.pdb --short --mapping ABCDEFGH:BADCFEHG +coverage run -a --source='DockQ.DockQ' -m DockQ.DockQ examples/1EXB_r_l_b.model.pdb examples/1EXB_r_l_b.pdb --short --mapping AB*:BA* +coverage run -a --source='DockQ.DockQ' -m DockQ.DockQ examples/1EXB_r_l_b.model.pdb examples/1EXB_r_l_b.pdb --short --mapping :ABC +coverage run -a --source='DockQ.DockQ' -m DockQ.DockQ examples/1EXB_r_l_b.model.pdb examples/1EXB_r_l_b.pdb --short --mapping ABCDEFGH:BADCFEHG # Test that cif parsing behaves same as pdb parsing -coverage run -a -m --source=src/ DockQ.DockQ examples/1EXB_r_l_b.model.pdb examples/1EXB_r_l_b.pdb --mapping DH:AE -coverage run -a -m --source=src/ DockQ.DockQ examples/1EXB_r_l_b.model.pdb examples/1EXB.cif.gz --mapping DH:AE +coverage run -a --source='DockQ.DockQ' -m DockQ.DockQ examples/1EXB_r_l_b.model.pdb examples/1EXB_r_l_b.pdb --mapping DH:AE +coverage run -a --source='DockQ.DockQ' -m DockQ.DockQ examples/1EXB_r_l_b.model.pdb examples/1EXB.cif.gz --mapping DH:AE coverage report From 4c2a379d97a73a1d61962ceb5d10fd4ce2b93062 Mon Sep 17 00:00:00 2001 From: clami66 Date: Mon, 25 Mar 2024 10:33:47 +0100 Subject: [PATCH 11/17] fix src --- run_test.sh | 4 ++-- src/DockQ/DockQ.py | 18 ------------------ 2 files changed, 2 insertions(+), 20 deletions(-) diff --git a/run_test.sh b/run_test.sh index 33faaf6..a30f6ea 100644 --- a/run_test.sh +++ b/run_test.sh @@ -3,9 +3,9 @@ set -euo pipefail # Test that cython version behaves the same as nocython coverage run -a --source='DockQ.DockQ' -m DockQ.DockQ examples/1A2K_r_l_b.model.pdb examples/1A2K_r_l_b.pdb -coverage run -a --source=src/ src/DockQ/DockQ.py examples/1A2K_r_l_b.model.pdb examples/1A2K_r_l_b.pdb +coverage run -a src/DockQ/DockQ.py examples/1A2K_r_l_b.model.pdb examples/1A2K_r_l_b.pdb coverage run -a --source='DockQ.DockQ' -m DockQ.DockQ examples/1A2K_r_l_b.model.pdb examples/1A2K_r_l_b.pdb --no_align -coverage run -a --source=src/ src/DockQ/DockQ.py examples/1A2K_r_l_b.model.pdb examples/1A2K_r_l_b.pdb --no_align +coverage run -a src/DockQ/DockQ.py examples/1A2K_r_l_b.model.pdb examples/1A2K_r_l_b.pdb --no_align # Multiple interfaces coverage run -a --source='DockQ.DockQ' -m DockQ.DockQ examples/dimer_dimer.model.pdb examples/dimer_dimer.pdb --short # Test on structures with slightly different sequences diff --git a/src/DockQ/DockQ.py b/src/DockQ/DockQ.py index de73b9c..a180061 100755 --- a/src/DockQ/DockQ.py +++ b/src/DockQ/DockQ.py @@ -52,7 +52,6 @@ def parse_args(): parser.add_argument( "--verbose", "-v", default=False, action="store_true", help="talk a lot!" ) - parser.add_argument( "--use_CA", "-ca", @@ -73,14 +72,6 @@ def parse_args(): metavar="n_cpu", help="Number of cores to use", ) - parser.add_argument( - "--chunk_size", - default=64, - type=int, - metavar="chunk_size", - help="Size of chunks given to the cores", - ) - parser.add_argument( "--optDockQF1", default=False, @@ -112,15 +103,6 @@ def parse_args(): return parser.parse_args() -def open_file(filename): - if filename.endswith(".gz"): - with gzip.open(filename) as f: - yield f - else: - with open(filename) as f: - yield f - - @lru_cache def get_aligned_residues(chainA, chainB, alignment): aligned_resA = [] From 540a70f9ed9dda0f2f5472ea67adfabe17e41630 Mon Sep 17 00:00:00 2001 From: clami66 Date: Mon, 25 Mar 2024 11:03:22 +0100 Subject: [PATCH 12/17] actual tests --- run_test.sh | 39 +++++++++++++++++++-------- src/DockQ/DockQ.py | 3 ++- testdata/1A2K.dockq | 37 +++++++++++++++++++++++++ testdata/1EXB_.ABC.dockq | 3 +++ testdata/1EXB_AB.BA.dockq | 17 ++++++++++++ testdata/1EXB_ABCDEFGH.BADCFEHG.dockq | 17 ++++++++++++ testdata/1EXB_DH.AE.dockq | 23 ++++++++++++++++ testdata/1EXB_DH.AE_cif.dockq | 23 ++++++++++++++++ testdata/dimer_dimer.dockq | 5 ++++ testdata/model.dockq | 23 ++++++++++++++++ 10 files changed, 178 insertions(+), 12 deletions(-) create mode 100644 testdata/1A2K.dockq create mode 100644 testdata/1EXB_.ABC.dockq create mode 100644 testdata/1EXB_AB.BA.dockq create mode 100644 testdata/1EXB_ABCDEFGH.BADCFEHG.dockq create mode 100644 testdata/1EXB_DH.AE.dockq create mode 100644 testdata/1EXB_DH.AE_cif.dockq create mode 100644 testdata/dimer_dimer.dockq create mode 100644 testdata/model.dockq diff --git a/run_test.sh b/run_test.sh index a30f6ea..768240f 100644 --- a/run_test.sh +++ b/run_test.sh @@ -1,21 +1,38 @@ #!/bin/bash set -euo pipefail +which DockQ + # Test that cython version behaves the same as nocython -coverage run -a --source='DockQ.DockQ' -m DockQ.DockQ examples/1A2K_r_l_b.model.pdb examples/1A2K_r_l_b.pdb -coverage run -a src/DockQ/DockQ.py examples/1A2K_r_l_b.model.pdb examples/1A2K_r_l_b.pdb -coverage run -a --source='DockQ.DockQ' -m DockQ.DockQ examples/1A2K_r_l_b.model.pdb examples/1A2K_r_l_b.pdb --no_align -coverage run -a src/DockQ/DockQ.py examples/1A2K_r_l_b.model.pdb examples/1A2K_r_l_b.pdb --no_align +coverage run -a --source='DockQ.DockQ' -m DockQ.DockQ examples/1A2K_r_l_b.model.pdb examples/1A2K_r_l_b.pdb > test +diff test testdata/1A2K.dockq +coverage run -a --source='DockQ.DockQ' src/DockQ/DockQ.py examples/1A2K_r_l_b.model.pdb examples/1A2K_r_l_b.pdb > test +diff test testdata/1A2K.dockq +coverage run -a --source='DockQ.DockQ' -m DockQ.DockQ examples/1A2K_r_l_b.model.pdb examples/1A2K_r_l_b.pdb --no_align > test +diff test testdata/1A2K.dockq +coverage run -a --source='DockQ.DockQ' src/DockQ/DockQ.py examples/1A2K_r_l_b.model.pdb examples/1A2K_r_l_b.pdb --no_align > test +diff test testdata/1A2K.dockq + # Multiple interfaces -coverage run -a --source='DockQ.DockQ' -m DockQ.DockQ examples/dimer_dimer.model.pdb examples/dimer_dimer.pdb --short +coverage run -a --source='DockQ.DockQ' -m DockQ.DockQ examples/dimer_dimer.model.pdb examples/dimer_dimer.pdb --short > test +diff test testdata/dimer_dimer.dockq + # Test on structures with slightly different sequences -coverage run -a --source='DockQ.DockQ' -m DockQ.DockQ examples/model.pdb examples/native.pdb --allowed_mismatches 1 +coverage run -a --source='DockQ.DockQ' -m DockQ.DockQ examples/model.pdb examples/native.pdb --allowed_mismatches 1 > test +diff test testdata/model.dockq + # Test various mapping strategies -coverage run -a --source='DockQ.DockQ' -m DockQ.DockQ examples/1EXB_r_l_b.model.pdb examples/1EXB_r_l_b.pdb --short --mapping AB*:BA* -coverage run -a --source='DockQ.DockQ' -m DockQ.DockQ examples/1EXB_r_l_b.model.pdb examples/1EXB_r_l_b.pdb --short --mapping :ABC -coverage run -a --source='DockQ.DockQ' -m DockQ.DockQ examples/1EXB_r_l_b.model.pdb examples/1EXB_r_l_b.pdb --short --mapping ABCDEFGH:BADCFEHG +coverage run -a --source='DockQ.DockQ' -m DockQ.DockQ examples/1EXB_r_l_b.model.pdb examples/1EXB_r_l_b.pdb --short --mapping AB*:BA* > test +diff test testdata/1EXB_AB.BA.dockq +coverage run -a --source='DockQ.DockQ' -m DockQ.DockQ examples/1EXB_r_l_b.model.pdb examples/1EXB_r_l_b.pdb --short --mapping :ABC > test +diff test testdata/1EXB_.ABC.dockq +coverage run -a --source='DockQ.DockQ' -m DockQ.DockQ examples/1EXB_r_l_b.model.pdb examples/1EXB_r_l_b.pdb --short --mapping ABCDEFGH:BADCFEHG > test +diff test testdata/1EXB_ABCDEFGH.BADCFEHG.dockq + # Test that cif parsing behaves same as pdb parsing -coverage run -a --source='DockQ.DockQ' -m DockQ.DockQ examples/1EXB_r_l_b.model.pdb examples/1EXB_r_l_b.pdb --mapping DH:AE -coverage run -a --source='DockQ.DockQ' -m DockQ.DockQ examples/1EXB_r_l_b.model.pdb examples/1EXB.cif.gz --mapping DH:AE +coverage run -a --source='DockQ.DockQ' -m DockQ.DockQ examples/1EXB_r_l_b.model.pdb examples/1EXB_r_l_b.pdb --mapping DH:AE > test +diff test testdata/1EXB_DH.AE.dockq +coverage run -a --source='DockQ.DockQ' -m DockQ.DockQ examples/1EXB_r_l_b.model.pdb examples/1EXB.cif.gz --mapping DH:AE > test +diff test testdata/1EXB_DH.AE_cif.dockq coverage report diff --git a/src/DockQ/DockQ.py b/src/DockQ/DockQ.py index a180061..a11e91b 100755 --- a/src/DockQ/DockQ.py +++ b/src/DockQ/DockQ.py @@ -3,6 +3,7 @@ import sys import gzip import hashlib +import warnings import traceback import itertools import math @@ -22,7 +23,7 @@ from .operations import residue_distances, get_fnat_stats from .parsers import PDBParser, MMCIFParser except ImportError: - print( + warnings.warn( """WARNING: It looks like cython is not working, falling back on native python. This will make DockQ slower""" ) diff --git a/testdata/1A2K.dockq b/testdata/1A2K.dockq new file mode 100644 index 0000000..0ac14cc --- /dev/null +++ b/testdata/1A2K.dockq @@ -0,0 +1,37 @@ +**************************************************************** +* DockQ * +* Scoring function for protein-protein docking models * +* Statistics on CAPRI data: * +* 0.00 <= DockQ < 0.23 - Incorrect * +* 0.23 <= DockQ < 0.49 - Acceptable quality * +* 0.49 <= DockQ < 0.80 - Medium quality * +* DockQ >= 0.80 - High quality * +* Ref: S. Basu and B. Wallner, DockQ: A quality measure for * +* protein-protein docking models * +* doi:10.1371/journal.pone.0161879 * +* For comments, please email: bjorn.wallner@.liu.se * +**************************************************************** +Model : examples/1A2K_r_l_b.model.pdb +Native : examples/1A2K_r_l_b.pdb +Total DockQ over 3 native interfaces: 1.959 +Native chains: A, B + Model chains: B, A + DockQ_F1: 0.996 + DockQ: 0.994 + irms: 0.000 + Lrms: 0.000 + fnat: 0.983 +Native chains: A, C + Model chains: B, C + DockQ_F1: 0.567 + DockQ: 0.511 + irms: 1.237 + Lrms: 6.864 + fnat: 0.333 +Native chains: B, C + Model chains: A, C + DockQ_F1: 0.500 + DockQ: 0.453 + irms: 2.104 + Lrms: 8.131 + fnat: 0.500 diff --git a/testdata/1EXB_.ABC.dockq b/testdata/1EXB_.ABC.dockq new file mode 100644 index 0000000..f63b8b2 --- /dev/null +++ b/testdata/1EXB_.ABC.dockq @@ -0,0 +1,3 @@ +Total DockQ over 2 native interfaces: 0.998 with ABC:ABC model:native mapping +DockQ 0.995 DockQ_F1 0.998 Fnat 0.985 iRMS 0.000 LRMS 0.000 Fnonnat 0.000 clashes 0 mapping AC:AC examples/1EXB_r_l_b.model.pdb A C -> examples/1EXB_r_l_b.pdb A C +DockQ 1.000 DockQ_F1 1.000 Fnat 1.000 iRMS 0.000 LRMS 0.000 Fnonnat 0.000 clashes 0 mapping BC:BC examples/1EXB_r_l_b.model.pdb B C -> examples/1EXB_r_l_b.pdb B C diff --git a/testdata/1EXB_AB.BA.dockq b/testdata/1EXB_AB.BA.dockq new file mode 100644 index 0000000..b864372 --- /dev/null +++ b/testdata/1EXB_AB.BA.dockq @@ -0,0 +1,17 @@ +Total DockQ over 16 native interfaces: 0.852 with ABCDFHEG:BADCEGFH model:native mapping +DockQ 0.995 DockQ_F1 0.998 Fnat 0.985 iRMS 0.000 LRMS 0.000 Fnonnat 0.000 clashes 0 mapping AC:BD examples/1EXB_r_l_b.model.pdb A C -> examples/1EXB_r_l_b.pdb B D +DockQ 0.995 DockQ_F1 0.998 Fnat 0.985 iRMS 0.000 LRMS 0.000 Fnonnat 0.000 clashes 0 mapping AD:BC examples/1EXB_r_l_b.model.pdb A D -> examples/1EXB_r_l_b.pdb B C +DockQ 0.742 DockQ_F1 0.772 Fnat 0.609 iRMS 0.850 LRMS 3.426 Fnonnat 0.176 clashes 0 mapping AE:BF examples/1EXB_r_l_b.model.pdb A E -> examples/1EXB_r_l_b.pdb B F +DockQ 0.824 DockQ_F1 0.853 Fnat 0.800 iRMS 0.625 LRMS 3.994 Fnonnat 0.000 clashes 0 mapping AG:BH examples/1EXB_r_l_b.model.pdb A G -> examples/1EXB_r_l_b.pdb B H +DockQ 1.000 DockQ_F1 1.000 Fnat 1.000 iRMS 0.000 LRMS 0.000 Fnonnat 0.000 clashes 0 mapping BC:AD examples/1EXB_r_l_b.model.pdb B C -> examples/1EXB_r_l_b.pdb A D +DockQ 0.995 DockQ_F1 0.998 Fnat 0.985 iRMS 0.000 LRMS 0.000 Fnonnat 0.000 clashes 0 mapping BD:AC examples/1EXB_r_l_b.model.pdb B D -> examples/1EXB_r_l_b.pdb A C +DockQ 0.552 DockQ_F1 0.606 Fnat 0.304 iRMS 1.458 LRMS 3.757 Fnonnat 0.000 clashes 0 mapping BF:AE examples/1EXB_r_l_b.model.pdb B F -> examples/1EXB_r_l_b.pdb A E +DockQ 0.694 DockQ_F1 0.751 Fnat 0.400 iRMS 0.793 LRMS 2.831 Fnonnat 0.000 clashes 0 mapping BH:AG examples/1EXB_r_l_b.model.pdb B H -> examples/1EXB_r_l_b.pdb A G +DockQ 0.687 DockQ_F1 0.737 Fnat 0.600 iRMS 1.161 LRMS 3.757 Fnonnat 0.000 clashes 0 mapping CF:DE examples/1EXB_r_l_b.model.pdb C F -> examples/1EXB_r_l_b.pdb D E +DockQ 0.477 DockQ_F1 0.502 Fnat 0.087 iRMS 1.425 LRMS 3.994 Fnonnat 0.000 clashes 0 mapping CG:DH examples/1EXB_r_l_b.model.pdb C G -> examples/1EXB_r_l_b.pdb D H +DockQ 0.775 DockQ_F1 0.812 Fnat 0.609 iRMS 0.711 LRMS 2.831 Fnonnat 0.125 clashes 0 mapping DH:CG examples/1EXB_r_l_b.model.pdb D H -> examples/1EXB_r_l_b.pdb C G +DockQ 0.914 DockQ_F1 0.914 Fnat 1.000 iRMS 0.547 LRMS 3.426 Fnonnat 0.000 clashes 0 mapping DE:CF examples/1EXB_r_l_b.model.pdb D E -> examples/1EXB_r_l_b.pdb C F +DockQ 0.992 DockQ_F1 0.996 Fnat 0.976 iRMS 0.001 LRMS 0.000 Fnonnat 0.000 clashes 0 mapping FH:EG examples/1EXB_r_l_b.model.pdb F H -> examples/1EXB_r_l_b.pdb E G +DockQ 0.992 DockQ_F1 0.996 Fnat 0.976 iRMS 0.001 LRMS 0.000 Fnonnat 0.000 clashes 0 mapping FG:EH examples/1EXB_r_l_b.model.pdb F G -> examples/1EXB_r_l_b.pdb E H +DockQ 0.992 DockQ_F1 0.996 Fnat 0.976 iRMS 0.001 LRMS 0.001 Fnonnat 0.000 clashes 0 mapping HE:GF examples/1EXB_r_l_b.model.pdb H E -> examples/1EXB_r_l_b.pdb G F +DockQ 1.000 DockQ_F1 0.996 Fnat 1.000 iRMS 0.001 LRMS 0.001 Fnonnat 0.024 clashes 0 mapping EG:FH examples/1EXB_r_l_b.model.pdb E G -> examples/1EXB_r_l_b.pdb F H diff --git a/testdata/1EXB_ABCDEFGH.BADCFEHG.dockq b/testdata/1EXB_ABCDEFGH.BADCFEHG.dockq new file mode 100644 index 0000000..1c263d6 --- /dev/null +++ b/testdata/1EXB_ABCDEFGH.BADCFEHG.dockq @@ -0,0 +1,17 @@ +Total DockQ over 16 native interfaces: 0.852 with ABCDEFGH:BADCFEHG model:native mapping +DockQ 0.995 DockQ_F1 0.998 Fnat 0.985 iRMS 0.000 LRMS 0.000 Fnonnat 0.000 clashes 0 mapping AC:BD examples/1EXB_r_l_b.model.pdb A C -> examples/1EXB_r_l_b.pdb B D +DockQ 0.995 DockQ_F1 0.998 Fnat 0.985 iRMS 0.000 LRMS 0.000 Fnonnat 0.000 clashes 0 mapping AD:BC examples/1EXB_r_l_b.model.pdb A D -> examples/1EXB_r_l_b.pdb B C +DockQ 0.742 DockQ_F1 0.772 Fnat 0.609 iRMS 0.850 LRMS 3.426 Fnonnat 0.176 clashes 0 mapping AE:BF examples/1EXB_r_l_b.model.pdb A E -> examples/1EXB_r_l_b.pdb B F +DockQ 0.824 DockQ_F1 0.853 Fnat 0.800 iRMS 0.625 LRMS 3.994 Fnonnat 0.000 clashes 0 mapping AG:BH examples/1EXB_r_l_b.model.pdb A G -> examples/1EXB_r_l_b.pdb B H +DockQ 1.000 DockQ_F1 1.000 Fnat 1.000 iRMS 0.000 LRMS 0.000 Fnonnat 0.000 clashes 0 mapping BC:AD examples/1EXB_r_l_b.model.pdb B C -> examples/1EXB_r_l_b.pdb A D +DockQ 0.995 DockQ_F1 0.998 Fnat 0.985 iRMS 0.000 LRMS 0.000 Fnonnat 0.000 clashes 0 mapping BD:AC examples/1EXB_r_l_b.model.pdb B D -> examples/1EXB_r_l_b.pdb A C +DockQ 0.552 DockQ_F1 0.606 Fnat 0.304 iRMS 1.458 LRMS 3.757 Fnonnat 0.000 clashes 0 mapping BF:AE examples/1EXB_r_l_b.model.pdb B F -> examples/1EXB_r_l_b.pdb A E +DockQ 0.694 DockQ_F1 0.751 Fnat 0.400 iRMS 0.793 LRMS 2.831 Fnonnat 0.000 clashes 0 mapping BH:AG examples/1EXB_r_l_b.model.pdb B H -> examples/1EXB_r_l_b.pdb A G +DockQ 0.687 DockQ_F1 0.737 Fnat 0.600 iRMS 1.161 LRMS 3.757 Fnonnat 0.000 clashes 0 mapping CF:DE examples/1EXB_r_l_b.model.pdb C F -> examples/1EXB_r_l_b.pdb D E +DockQ 0.477 DockQ_F1 0.502 Fnat 0.087 iRMS 1.425 LRMS 3.994 Fnonnat 0.000 clashes 0 mapping CG:DH examples/1EXB_r_l_b.model.pdb C G -> examples/1EXB_r_l_b.pdb D H +DockQ 0.914 DockQ_F1 0.914 Fnat 1.000 iRMS 0.547 LRMS 3.426 Fnonnat 0.000 clashes 0 mapping DE:CF examples/1EXB_r_l_b.model.pdb D E -> examples/1EXB_r_l_b.pdb C F +DockQ 0.775 DockQ_F1 0.812 Fnat 0.609 iRMS 0.711 LRMS 2.831 Fnonnat 0.125 clashes 0 mapping DH:CG examples/1EXB_r_l_b.model.pdb D H -> examples/1EXB_r_l_b.pdb C G +DockQ 1.000 DockQ_F1 0.996 Fnat 1.000 iRMS 0.001 LRMS 0.001 Fnonnat 0.024 clashes 0 mapping EG:FH examples/1EXB_r_l_b.model.pdb E G -> examples/1EXB_r_l_b.pdb F H +DockQ 0.992 DockQ_F1 0.996 Fnat 0.976 iRMS 0.001 LRMS 0.001 Fnonnat 0.000 clashes 0 mapping EH:FG examples/1EXB_r_l_b.model.pdb E H -> examples/1EXB_r_l_b.pdb F G +DockQ 0.992 DockQ_F1 0.996 Fnat 0.976 iRMS 0.001 LRMS 0.000 Fnonnat 0.000 clashes 0 mapping FG:EH examples/1EXB_r_l_b.model.pdb F G -> examples/1EXB_r_l_b.pdb E H +DockQ 0.992 DockQ_F1 0.996 Fnat 0.976 iRMS 0.001 LRMS 0.000 Fnonnat 0.000 clashes 0 mapping FH:EG examples/1EXB_r_l_b.model.pdb F H -> examples/1EXB_r_l_b.pdb E G diff --git a/testdata/1EXB_DH.AE.dockq b/testdata/1EXB_DH.AE.dockq new file mode 100644 index 0000000..3b5e296 --- /dev/null +++ b/testdata/1EXB_DH.AE.dockq @@ -0,0 +1,23 @@ +**************************************************************** +* DockQ * +* Scoring function for protein-protein docking models * +* Statistics on CAPRI data: * +* 0.00 <= DockQ < 0.23 - Incorrect * +* 0.23 <= DockQ < 0.49 - Acceptable quality * +* 0.49 <= DockQ < 0.80 - Medium quality * +* DockQ >= 0.80 - High quality * +* Ref: S. Basu and B. Wallner, DockQ: A quality measure for * +* protein-protein docking models * +* doi:10.1371/journal.pone.0161879 * +* For comments, please email: bjorn.wallner@.liu.se * +**************************************************************** +Model : examples/1EXB_r_l_b.model.pdb +Native : examples/1EXB_r_l_b.pdb +Total DockQ over 1 native interfaces: 0.775 +Native chains: A, E + Model chains: D, H + DockQ_F1: 0.812 + DockQ: 0.775 + irms: 0.711 + Lrms: 2.831 + fnat: 0.609 diff --git a/testdata/1EXB_DH.AE_cif.dockq b/testdata/1EXB_DH.AE_cif.dockq new file mode 100644 index 0000000..52d2056 --- /dev/null +++ b/testdata/1EXB_DH.AE_cif.dockq @@ -0,0 +1,23 @@ +**************************************************************** +* DockQ * +* Scoring function for protein-protein docking models * +* Statistics on CAPRI data: * +* 0.00 <= DockQ < 0.23 - Incorrect * +* 0.23 <= DockQ < 0.49 - Acceptable quality * +* 0.49 <= DockQ < 0.80 - Medium quality * +* DockQ >= 0.80 - High quality * +* Ref: S. Basu and B. Wallner, DockQ: A quality measure for * +* protein-protein docking models * +* doi:10.1371/journal.pone.0161879 * +* For comments, please email: bjorn.wallner@.liu.se * +**************************************************************** +Model : examples/1EXB_r_l_b.model.pdb +Native : examples/1EXB.cif.gz +Total DockQ over 1 native interfaces: 0.775 +Native chains: A, E + Model chains: D, H + DockQ_F1: 0.812 + DockQ: 0.775 + irms: 0.711 + Lrms: 2.831 + fnat: 0.609 diff --git a/testdata/dimer_dimer.dockq b/testdata/dimer_dimer.dockq new file mode 100644 index 0000000..1f4c077 --- /dev/null +++ b/testdata/dimer_dimer.dockq @@ -0,0 +1,5 @@ +Total DockQ over 4 native interfaces: 1.000 with ABLH:ABLH model:native mapping +DockQ 1.000 DockQ_F1 1.000 Fnat 1.000 iRMS 0.000 LRMS 0.000 Fnonnat 0.000 clashes 0 mapping AB:AB examples/dimer_dimer.model.pdb A B -> examples/dimer_dimer.pdb A B +DockQ 1.000 DockQ_F1 1.000 Fnat 1.000 iRMS 0.000 LRMS 0.000 Fnonnat 0.000 clashes 0 mapping AL:AL examples/dimer_dimer.model.pdb A L -> examples/dimer_dimer.pdb A L +DockQ 1.000 DockQ_F1 1.000 Fnat 1.000 iRMS 0.000 LRMS 0.000 Fnonnat 0.000 clashes 0 mapping AH:AH examples/dimer_dimer.model.pdb A H -> examples/dimer_dimer.pdb A H +DockQ 1.000 DockQ_F1 1.000 Fnat 1.000 iRMS 0.000 LRMS 0.000 Fnonnat 0.000 clashes 0 mapping LH:LH examples/dimer_dimer.model.pdb L H -> examples/dimer_dimer.pdb L H diff --git a/testdata/model.dockq b/testdata/model.dockq new file mode 100644 index 0000000..767269a --- /dev/null +++ b/testdata/model.dockq @@ -0,0 +1,23 @@ +**************************************************************** +* DockQ * +* Scoring function for protein-protein docking models * +* Statistics on CAPRI data: * +* 0.00 <= DockQ < 0.23 - Incorrect * +* 0.23 <= DockQ < 0.49 - Acceptable quality * +* 0.49 <= DockQ < 0.80 - Medium quality * +* DockQ >= 0.80 - High quality * +* Ref: S. Basu and B. Wallner, DockQ: A quality measure for * +* protein-protein docking models * +* doi:10.1371/journal.pone.0161879 * +* For comments, please email: bjorn.wallner@.liu.se * +**************************************************************** +Model : examples/model.pdb +Native : examples/native.pdb +Total DockQ over 1 native interfaces: 0.700 +Native chains: A, B + Model chains: A, B + DockQ_F1: 0.731 + DockQ: 0.700 + irms: 1.232 + Lrms: 1.516 + fnat: 0.533 From 8ae5f6ae5f5157514708c8147194c7207d572330 Mon Sep 17 00:00:00 2001 From: clami66 Date: Mon, 25 Mar 2024 11:19:56 +0100 Subject: [PATCH 13/17] testing on src --- run_test.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/run_test.sh b/run_test.sh index 768240f..d3ccac1 100644 --- a/run_test.sh +++ b/run_test.sh @@ -1,16 +1,17 @@ #!/bin/bash set -euo pipefail -which DockQ +src=$(find $(dirname $(which DockQ))/../ -name "DockQ.py" -exec dirname {} \;) +echo $src # Test that cython version behaves the same as nocython coverage run -a --source='DockQ.DockQ' -m DockQ.DockQ examples/1A2K_r_l_b.model.pdb examples/1A2K_r_l_b.pdb > test diff test testdata/1A2K.dockq -coverage run -a --source='DockQ.DockQ' src/DockQ/DockQ.py examples/1A2K_r_l_b.model.pdb examples/1A2K_r_l_b.pdb > test +coverage run -a --source=$src $src/DockQ.py examples/1A2K_r_l_b.model.pdb examples/1A2K_r_l_b.pdb > test diff test testdata/1A2K.dockq coverage run -a --source='DockQ.DockQ' -m DockQ.DockQ examples/1A2K_r_l_b.model.pdb examples/1A2K_r_l_b.pdb --no_align > test diff test testdata/1A2K.dockq -coverage run -a --source='DockQ.DockQ' src/DockQ/DockQ.py examples/1A2K_r_l_b.model.pdb examples/1A2K_r_l_b.pdb --no_align > test +coverage run -a --source=$src $src/DockQ.py examples/1A2K_r_l_b.model.pdb examples/1A2K_r_l_b.pdb --no_align > test diff test testdata/1A2K.dockq # Multiple interfaces From f7def987c309cef310556a1caa8adac2aeec37ef Mon Sep 17 00:00:00 2001 From: clami66 Date: Mon, 25 Mar 2024 11:53:31 +0100 Subject: [PATCH 14/17] move includes to setup.cfg --- .github/workflows/main.yml | 18 ------------------ run_test.sh | 26 ++++++++++++-------------- setup.cfg | 4 ++++ 3 files changed, 16 insertions(+), 32 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 289c406..e49e179 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -28,22 +28,4 @@ jobs: bash run_test.sh - name: Coverage run: | - coverage report test $(coverage report | grep TOTAL | awk '{ print $4 }' | tr -d "%") -ge $MIN_COVERAGE_REQUIRED - - #test_oldbio: - # if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name - # runs-on: ubuntu-latest - # timeout-minutes: 10 - # defaults: - # run: - # shell: bash -l {0} -# -# steps: -# - uses: actions/checkout@v3 -# - name: Test pipeline output -# run: | -# python -m pip install biopython==1.79 -# python -m pip install coverage -# python -m pip install . -# bash ./run_test.sh diff --git a/run_test.sh b/run_test.sh index d3ccac1..d5cd7f0 100644 --- a/run_test.sh +++ b/run_test.sh @@ -1,39 +1,37 @@ #!/bin/bash set -euo pipefail - -src=$(find $(dirname $(which DockQ))/../ -name "DockQ.py" -exec dirname {} \;) -echo $src +rm -f .coverage # Test that cython version behaves the same as nocython -coverage run -a --source='DockQ.DockQ' -m DockQ.DockQ examples/1A2K_r_l_b.model.pdb examples/1A2K_r_l_b.pdb > test +coverage run -m DockQ.DockQ examples/1A2K_r_l_b.model.pdb examples/1A2K_r_l_b.pdb > test diff test testdata/1A2K.dockq -coverage run -a --source=$src $src/DockQ.py examples/1A2K_r_l_b.model.pdb examples/1A2K_r_l_b.pdb > test +python src/DockQ/DockQ.py examples/1A2K_r_l_b.model.pdb examples/1A2K_r_l_b.pdb > test diff test testdata/1A2K.dockq -coverage run -a --source='DockQ.DockQ' -m DockQ.DockQ examples/1A2K_r_l_b.model.pdb examples/1A2K_r_l_b.pdb --no_align > test +coverage run -a -m DockQ.DockQ examples/1A2K_r_l_b.model.pdb examples/1A2K_r_l_b.pdb --no_align > test diff test testdata/1A2K.dockq -coverage run -a --source=$src $src/DockQ.py examples/1A2K_r_l_b.model.pdb examples/1A2K_r_l_b.pdb --no_align > test +python src/DockQ/DockQ.py examples/1A2K_r_l_b.model.pdb examples/1A2K_r_l_b.pdb --no_align > test diff test testdata/1A2K.dockq # Multiple interfaces -coverage run -a --source='DockQ.DockQ' -m DockQ.DockQ examples/dimer_dimer.model.pdb examples/dimer_dimer.pdb --short > test +coverage run -a -m DockQ.DockQ examples/dimer_dimer.model.pdb examples/dimer_dimer.pdb --short > test diff test testdata/dimer_dimer.dockq # Test on structures with slightly different sequences -coverage run -a --source='DockQ.DockQ' -m DockQ.DockQ examples/model.pdb examples/native.pdb --allowed_mismatches 1 > test +coverage run -a -m DockQ.DockQ examples/model.pdb examples/native.pdb --allowed_mismatches 1 > test diff test testdata/model.dockq # Test various mapping strategies -coverage run -a --source='DockQ.DockQ' -m DockQ.DockQ examples/1EXB_r_l_b.model.pdb examples/1EXB_r_l_b.pdb --short --mapping AB*:BA* > test +coverage run -a -m DockQ.DockQ examples/1EXB_r_l_b.model.pdb examples/1EXB_r_l_b.pdb --short --mapping AB*:BA* > test diff test testdata/1EXB_AB.BA.dockq -coverage run -a --source='DockQ.DockQ' -m DockQ.DockQ examples/1EXB_r_l_b.model.pdb examples/1EXB_r_l_b.pdb --short --mapping :ABC > test +coverage run -a -m DockQ.DockQ examples/1EXB_r_l_b.model.pdb examples/1EXB_r_l_b.pdb --short --mapping :ABC > test diff test testdata/1EXB_.ABC.dockq -coverage run -a --source='DockQ.DockQ' -m DockQ.DockQ examples/1EXB_r_l_b.model.pdb examples/1EXB_r_l_b.pdb --short --mapping ABCDEFGH:BADCFEHG > test +coverage run -a -m DockQ.DockQ examples/1EXB_r_l_b.model.pdb examples/1EXB_r_l_b.pdb --short --mapping ABCDEFGH:BADCFEHG > test diff test testdata/1EXB_ABCDEFGH.BADCFEHG.dockq # Test that cif parsing behaves same as pdb parsing -coverage run -a --source='DockQ.DockQ' -m DockQ.DockQ examples/1EXB_r_l_b.model.pdb examples/1EXB_r_l_b.pdb --mapping DH:AE > test +coverage run -a -m DockQ.DockQ examples/1EXB_r_l_b.model.pdb examples/1EXB_r_l_b.pdb --mapping DH:AE > test diff test testdata/1EXB_DH.AE.dockq -coverage run -a --source='DockQ.DockQ' -m DockQ.DockQ examples/1EXB_r_l_b.model.pdb examples/1EXB.cif.gz --mapping DH:AE > test +coverage run -a -m DockQ.DockQ examples/1EXB_r_l_b.model.pdb examples/1EXB.cif.gz --mapping DH:AE > test diff test testdata/1EXB_DH.AE_cif.dockq coverage report diff --git a/setup.cfg b/setup.cfg index b95a414..a206c6c 100644 --- a/setup.cfg +++ b/setup.cfg @@ -21,3 +21,7 @@ where=src console_scripts = DockQ = DockQ.__main__:main +[coverage:run] +include = + */DockQ/* + From c0a9a169101238a41c6e7f2fdf79e485de96fbbb Mon Sep 17 00:00:00 2001 From: clami66 Date: Mon, 25 Mar 2024 12:01:01 +0100 Subject: [PATCH 15/17] coverage not mandatory --- run_test.sh | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/run_test.sh b/run_test.sh index d5cd7f0..a84aba5 100644 --- a/run_test.sh +++ b/run_test.sh @@ -1,37 +1,42 @@ #!/bin/bash set -euo pipefail -rm -f .coverage +rm -f test .coverage + +if command -v coverage &> /dev/null; then + binary="coverage run -a -m DockQ.DockQ" +else + binary="DockQ" +fi + # Test that cython version behaves the same as nocython -coverage run -m DockQ.DockQ examples/1A2K_r_l_b.model.pdb examples/1A2K_r_l_b.pdb > test +$binary examples/1A2K_r_l_b.model.pdb examples/1A2K_r_l_b.pdb > test diff test testdata/1A2K.dockq python src/DockQ/DockQ.py examples/1A2K_r_l_b.model.pdb examples/1A2K_r_l_b.pdb > test diff test testdata/1A2K.dockq -coverage run -a -m DockQ.DockQ examples/1A2K_r_l_b.model.pdb examples/1A2K_r_l_b.pdb --no_align > test +$binary examples/1A2K_r_l_b.model.pdb examples/1A2K_r_l_b.pdb --no_align > test diff test testdata/1A2K.dockq python src/DockQ/DockQ.py examples/1A2K_r_l_b.model.pdb examples/1A2K_r_l_b.pdb --no_align > test diff test testdata/1A2K.dockq # Multiple interfaces -coverage run -a -m DockQ.DockQ examples/dimer_dimer.model.pdb examples/dimer_dimer.pdb --short > test +$binary examples/dimer_dimer.model.pdb examples/dimer_dimer.pdb --short > test diff test testdata/dimer_dimer.dockq # Test on structures with slightly different sequences -coverage run -a -m DockQ.DockQ examples/model.pdb examples/native.pdb --allowed_mismatches 1 > test +$binary examples/model.pdb examples/native.pdb --allowed_mismatches 1 > test diff test testdata/model.dockq # Test various mapping strategies -coverage run -a -m DockQ.DockQ examples/1EXB_r_l_b.model.pdb examples/1EXB_r_l_b.pdb --short --mapping AB*:BA* > test +$binary examples/1EXB_r_l_b.model.pdb examples/1EXB_r_l_b.pdb --short --mapping AB*:BA* > test diff test testdata/1EXB_AB.BA.dockq -coverage run -a -m DockQ.DockQ examples/1EXB_r_l_b.model.pdb examples/1EXB_r_l_b.pdb --short --mapping :ABC > test +$binary examples/1EXB_r_l_b.model.pdb examples/1EXB_r_l_b.pdb --short --mapping :ABC > test diff test testdata/1EXB_.ABC.dockq -coverage run -a -m DockQ.DockQ examples/1EXB_r_l_b.model.pdb examples/1EXB_r_l_b.pdb --short --mapping ABCDEFGH:BADCFEHG > test +$binary examples/1EXB_r_l_b.model.pdb examples/1EXB_r_l_b.pdb --short --mapping ABCDEFGH:BADCFEHG > test diff test testdata/1EXB_ABCDEFGH.BADCFEHG.dockq # Test that cif parsing behaves same as pdb parsing -coverage run -a -m DockQ.DockQ examples/1EXB_r_l_b.model.pdb examples/1EXB_r_l_b.pdb --mapping DH:AE > test +$binary examples/1EXB_r_l_b.model.pdb examples/1EXB_r_l_b.pdb --mapping DH:AE > test diff test testdata/1EXB_DH.AE.dockq -coverage run -a -m DockQ.DockQ examples/1EXB_r_l_b.model.pdb examples/1EXB.cif.gz --mapping DH:AE > test +$binary examples/1EXB_r_l_b.model.pdb examples/1EXB.cif.gz --mapping DH:AE > test diff test testdata/1EXB_DH.AE_cif.dockq - -coverage report From 5dedab7e45296b449007919dca2a7695256132b6 Mon Sep 17 00:00:00 2001 From: clami66 Date: Mon, 25 Mar 2024 12:03:55 +0100 Subject: [PATCH 16/17] coverage report --- .github/workflows/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e49e179..ed4cfc5 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -28,4 +28,5 @@ jobs: bash run_test.sh - name: Coverage run: | + coverage report test $(coverage report | grep TOTAL | awk '{ print $4 }' | tr -d "%") -ge $MIN_COVERAGE_REQUIRED From b28d6a906b1580cad3fefc24213e531f3914893d Mon Sep 17 00:00:00 2001 From: clami66 Date: Mon, 25 Mar 2024 12:07:24 +0100 Subject: [PATCH 17/17] remove useCA --- src/DockQ/DockQ.py | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/src/DockQ/DockQ.py b/src/DockQ/DockQ.py index a11e91b..be3b4c8 100755 --- a/src/DockQ/DockQ.py +++ b/src/DockQ/DockQ.py @@ -53,13 +53,6 @@ def parse_args(): parser.add_argument( "--verbose", "-v", default=False, action="store_true", help="talk a lot!" ) - parser.add_argument( - "--use_CA", - "-ca", - default=False, - action="store_true", - help="use CA instead of backbone", - ) parser.add_argument( "--no_align", default=False, @@ -328,11 +321,10 @@ def calc_DockQ( sample_chains, ref_chains, alignments, - use_CA_only=False, capri_peptide=False, low_memory=False, ): - atom_for_sup = ("CA", "C", "N", "O", "P") if not use_CA_only else ("CA", "P") + atom_for_sup = ("CA", "C", "N", "O", "P") fnat_threshold = 4.0 if capri_peptide else 5.0 interface_threshold = 8.0 if capri_peptide else 10.0 clash_threshold = 2.0 @@ -685,7 +677,6 @@ def run_on_chains( model_chains, native_chains, no_align=False, - use_CA_only=False, capri_peptide=False, low_memory=False, ): @@ -704,7 +695,6 @@ def run_on_chains( model_chains, native_chains, alignments=tuple(alignments), - use_CA_only=use_CA_only, capri_peptide=capri_peptide, low_memory=False, ) @@ -716,7 +706,6 @@ def run_on_all_native_interfaces( native_structure, chain_map={"A": "A", "B": "B"}, no_align=False, - use_CA_only=False, capri_peptide=False, low_memory=False, ): @@ -740,7 +729,6 @@ def run_on_all_native_interfaces( model_chains, native_chains, no_align=no_align, - use_CA_only=use_CA_only, capri_peptide=capri_peptide, low_memory=False, ) @@ -976,7 +964,6 @@ def main(): native_structure, chain_map, args.no_align, - args.use_CA, args.capri_peptide, low_memory, ) @@ -1012,7 +999,6 @@ def main(): native_structure, best_mapping, args.no_align, - args.use_CA, args.capri_peptide, low_memory=False, )