Repository: haddocking/arctic3d

Issue:
return cif_f in get_maxint_pdb
`get_maxint_pdb` function should return the updated cif file, so that we can a) check its presence in the tests b) delete it in the tests

Comments:

Patch:
diff --git a/src/arctic3d/cli.py b/src/arctic3d/cli.py
index cc265bf..7e3dfe2 100644
--- a/src/arctic3d/cli.py
+++ b/src/arctic3d/cli.py
@@ -260,7 +260,7 @@ def main(
             else:
                 pdb_data_path = None
             # get best pdb
-            pdb_f, filtered_interfaces = get_best_pdb(
+            pdb_f, cif_f, filtered_interfaces = get_best_pdb(
                 uniprot_id=uniprot_id,
                 interface_residues=interface_residues,
                 pdb_to_use=pdb_to_use,
diff --git a/src/arctic3d/modules/pdb.py b/src/arctic3d/modules/pdb.py
index 83a0043..fad58c0 100644
--- a/src/arctic3d/modules/pdb.py
+++ b/src/arctic3d/modules/pdb.py
@@ -610,7 +610,7 @@ def get_maxint_pdb(
         if max_nint != 0:
             log.info(f"filtered_interfaces {filtered_interfaces}")
             log.info(f"pdb {pdb_f} retains the most interfaces ({max_nint})")
-    return pdb_f, hit, filtered_interfaces
+    return pdb_f, cif_f, hit, filtered_interfaces
 
 
 def filter_pdb_list(fetch_list, pdb_to_use=None, chain_to_use=None):
@@ -707,12 +707,12 @@ def get_best_pdb(
 
     validated_pdbs = validate_api_hit(pdb_list)
 
-    pdb_f, top_hit, filtered_interfaces = get_maxint_pdb(
+    pdb_f, cif_f, top_hit, filtered_interfaces = get_maxint_pdb(
         validated_pdbs, interface_residues, uniprot_id, numbering=numbering
     )
 
-    if pdb_f is None:
-        log.warning(f"Could not fetch PDB file for {uniprot_id}")
+    if pdb_f is None or cif_f is None:
+        log.warning(f"Could not fetch PDB/mmcif file for {uniprot_id}")
         return None, None
 
     pdb_id = top_hit["pdb_id"]
@@ -730,4 +730,4 @@ def get_best_pdb(
 
     processed_pdb = pdb_f.rename(f"{uniprot_id}-{pdb_id}-{chain_id}.pdb")
 
-    return processed_pdb, filtered_interfaces
+    return processed_pdb, cif_f, filtered_interfaces


Test patch:
diff --git a/tests/test_pdb.py b/tests/test_pdb.py
index 59c43a6..ce06ae3 100644
--- a/tests/test_pdb.py
+++ b/tests/test_pdb.py
@@ -178,21 +178,25 @@ def test_validate_api_hit_nmr(pdb_hit_no_resolution):
 
 def test_get_best_pdb(example_interfaces):
     """Test get_best_pdb."""
-    pdb, filtered_interfaces = get_best_pdb("P20023", example_interfaces)
+    pdb, cif, filtered_interfaces = get_best_pdb("P20023", example_interfaces)
     exp_pdb = Path("P20023-1ghq-B.pdb")
+    exp_cif = Path("1ghq_updated.cif")
     exp_interfaces = {"P01024": [103, 104, 105]}
     assert pdb == exp_pdb
+    assert cif == exp_cif
     assert filtered_interfaces == exp_interfaces
     exp_pdb.unlink()
+    exp_cif.unlink()
 
 
 def test_get_maxint_pdb_empty():
     """Test get_maxint_pdb with empty output."""
     empty_validated_pdbs = []
-    pdb_f, top_hit, filtered_interfaces = get_maxint_pdb(
+    pdb_f, cif_f, top_hit, filtered_interfaces = get_maxint_pdb(
         empty_validated_pdbs, {}, uniprot_id=None
     )
     assert pdb_f is None
+    assert cif_f is None
     assert top_hit is None
     assert filtered_interfaces is None
 
@@ -200,10 +204,11 @@ def test_get_maxint_pdb_empty():
 def test_get_maxint_pdb(good_hits, example_interfaces):
     """Test get_maxint_pdb with implicit pdb numbering."""
     validated_pdbs = validate_api_hit(good_hits)
-    pdb_f, top_hit, filtered_interfaces = get_maxint_pdb(
+    pdb_f, cif_f, top_hit, filtered_interfaces = get_maxint_pdb(
         validated_pdbs, example_interfaces, "P00760"
     )
     assert pdb_f.name == "4xoj-model1-atoms-A-occ-tidy_renum.pdb"
+    assert cif_f.name == "4xoj_updated.cif"
     assert top_hit["pdb_id"] == "4xoj"
     assert top_hit["chain_id"] == "A"
     assert filtered_interfaces == {"P01024": [103, 104, 105]}
@@ -212,11 +217,12 @@ def test_get_maxint_pdb(good_hits, example_interfaces):
 def test_get_maxint_pdb_resi(good_hits, example_interfaces):
     """Test get_maxint_pdb with resi numbering."""
     validated_pdbs = validate_api_hit(good_hits)
-    pdb_f, top_hit, filtered_interfaces = get_maxint_pdb(
+    pdb_f, cif_f, top_hit, filtered_interfaces = get_maxint_pdb(
         validated_pdbs, example_interfaces, "P00760", numbering="resi"
     )
     # here the pdb is not renumbered
     assert pdb_f.name == "4xoj-model1-atoms-A-occ-tidy.pdb"
+    assert cif_f.name == "4xoj_updated.cif"
     assert top_hit["pdb_id"] == "4xoj"
     assert top_hit["chain_id"] == "A"
     # here the interfaces are renumbered, so the residues change
@@ -242,12 +248,13 @@ def test_filter_pdb_list(good_hits):
 def test_pdb_data(inp_pdb_data):
     """Test pdb_data input json file."""
     orig_interfaces = {"P00441": [85, 137, 138]}
-    pdb, filtered_interfaces = get_best_pdb(
+    pdb, cif, filtered_interfaces = get_best_pdb(
         "P40202", orig_interfaces, pdb_data=inp_pdb_data
     )
 
     assert filtered_interfaces == orig_interfaces
     pdb.unlink()
+    cif.unlink()
 
 
 def test_get_numbering_dict(inp_cif_3psg):
@@ -280,7 +287,7 @@ def test_renumber_pdb_from_cif(inp_pdb_3psg):
     cif_fname.unlink()
 
 
-def test_renumber_interfaces_from_cif(inp_pdb_3psg):
+def test_renumber_interfaces_from_cif():
     """Test renumber_interfaces_from_cif."""
     interfaces = {"P00441": [85, 137, 138]}
     renum_interfaces, cif_fname = renumber_interfaces_from_cif(