Samad14 commited on
Commit
87bb202
·
verified ·
1 Parent(s): 95fdc9f

Upload folder using huggingface_hub (part 2)

Browse files
tests/test_docking_pose_interaction_parser.py CHANGED
@@ -4,7 +4,7 @@ These tests exercise the PDBQT record/model parser independently of chemistry.
4
  They deliberately mock the chemistry routine: they validate parser behavior,
5
  not the scientific validity of interaction classifications.
6
  """
7
- from app.routers import docking as module
8
 
9
 
10
  def _atom(record="ATOM", serial=1, atom="C1"):
@@ -90,3 +90,39 @@ def test_stored_job_pose_extractor_preserves_model_ids_affinities_and_atom_recor
90
  assert [m["model"] for m in models] == [1, 2]
91
  assert [m["affinity_kcal_mol"] for m in models] == [-5.132, -4.981]
92
  assert all(len(m["records"]) == 1 for m in models)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  They deliberately mock the chemistry routine: they validate parser behavior,
5
  not the scientific validity of interaction classifications.
6
  """
7
+ import asyncio\n\nfrom app.routers import docking as module
8
 
9
 
10
  def _atom(record="ATOM", serial=1, atom="C1"):
 
90
  assert [m["model"] for m in models] == [1, 2]
91
  assert [m["affinity_kcal_mol"] for m in models] == [-5.132, -4.981]
92
  assert all(len(m["records"]) == 1 for m in models)
93
+
94
+
95
+
96
+ def test_exact_job_reproduction_returns_all_poses_without_mutating_artifact(monkeypatch):
97
+ original = {
98
+ "pdb_id": "4HHB",
99
+ "smiles": "CCO",
100
+ "vina_version": "1.2.7",
101
+ "vina_exhaustiveness": 32,
102
+ "vina_num_modes": 2,
103
+ "vina_seed": 42,
104
+ "box_center": [0.0, 0.0, 0.0],
105
+ "box_size": [20.0, 20.0, 20.0],
106
+ "receptor_pdb": "ATOM\n",
107
+ "result_pdbqt": (
108
+ "MODEL 1\nREMARK VINA RESULT: -5.132 0.0 0.0\n" + _atom("ATOM", 1) + "\nENDMDL\n"
109
+ "MODEL 2\nREMARK VINA RESULT: -4.981 0.0 0.0\n" + _atom("ATOM", 2) + "\nENDMDL\n"
110
+ ),
111
+ "interaction_analysis": {"status": "UNAVAILABLE", "reason": "ValueError"},
112
+ }
113
+ monkeypatch.setattr(module, "_load_docking_result", lambda job_id, user_id: original)
114
+ monkeypatch.setattr(
115
+ module, "_compute_interactions",
116
+ lambda protein, ligand, smiles: {
117
+ "status": "COMPUTED", "engine": "RDKit", "engine_version": "test",
118
+ "counts": {"hbonds": 1, "hydrophobic": 0, "pi_stacking": 0, "salt_bridges": 0},
119
+ "hbonds": [{"type": "hbond"}], "hydrophobic": [], "pi_stacking": [], "salt_bridges": [],
120
+ "protein_parse": {"residues_skipped": []}, "limitations": [],
121
+ },
122
+ )
123
+ result = asyncio.run(module.recalculate_stored_docking_interactions("job-1", "user-1"))
124
+ assert result["status"] == "COMPUTED"
125
+ assert result["pose_count"] == 2
126
+ assert [p["affinity_kcal_mol"] for p in result["pose_results"]] == [-5.132, -4.981]
127
+ assert result["reproduction"]["original_artifact_mutated"] is False
128
+ assert original["interaction_analysis"]["status"] == "UNAVAILABLE"