diff --git a/.github/workflows/ci_tools.yml b/.github/workflows/ci_tools.yml index aa4d064..d0b83ee 100644 --- a/.github/workflows/ci_tools.yml +++ b/.github/workflows/ci_tools.yml @@ -1,7 +1,7 @@ name: Uni-Dock Tools CI/CD on: push: - branches: [ main ] + branches: [ fix_unidock_ut ] pull_request: branches: [ main ] diff --git a/.github/workflows/ci_unidock.yml b/.github/workflows/ci_unidock.yml index 0c7e262..4531df4 100644 --- a/.github/workflows/ci_unidock.yml +++ b/.github/workflows/ci_unidock.yml @@ -1,7 +1,7 @@ name: Uni-Dock CI/CD on: push: - branches: [ main ] + branches: [ fix_unidock_ut ] pull_request: branches: [ main ] diff --git a/unidock/test/ut/test_unidock.py b/unidock/test/ut/test_unidock.py index 7e39d04..d28a25f 100644 --- a/unidock/test/ut/test_unidock.py +++ b/unidock/test/ut/test_unidock.py @@ -17,16 +17,17 @@ def setUp(self): def tearDown(self): shutil.rmtree(self.workdir, ignore_errors=True) - def test_unidock(self): + def test_unidock_vina(self): cmd = f"unidock --receptor {self.receptor} --gpu_batch {self.ligand} --dir {self.workdir} \ --center_x {self.pocket[0]} --center_y {self.pocket[1]} --center_z {self.pocket[2]} \ --size_x {self.pocket[3]} --size_y {self.pocket[4]} --size_z {self.pocket[5]} \ --scoring vina --search_mode fast --num_modes 1 --seed 181129" resp = subprocess.run(cmd, shell=True, - stdout=subprocess.PIPE, stderr=subprocess.PIPE, - encoding="utf-8") + capture_output=True, + encoding="utf-8", + cwd=self.workdir) print(resp.stdout) - if resp.stderr: + if resp.returncode != 0: print(resp.stderr) result_ligand = os.path.join(self.workdir, "1iep_ligand_out.pdbqt") self.assertTrue(os.path.exists(result_ligand)) @@ -38,8 +39,31 @@ def test_unidock(self): break self.assertNotEqual(score_line, "") score = float([e for e in score_line[len("REMARK VINA RESULT:"):].split(" ") if e!=""][0]) - self.assertEqual(score, -10.33) + self.assertTrue(-12 <= score <= -5) + def test_unidock_vinardo(self): + cmd = f"unidock --receptor {self.receptor} --gpu_batch {self.ligand} --dir {self.workdir} \ + --center_x {self.pocket[0]} --center_y {self.pocket[1]} --center_z {self.pocket[2]} \ + --size_x {self.pocket[3]} --size_y {self.pocket[4]} --size_z {self.pocket[5]} \ + --scoring vinardo --search_mode fast --num_modes 1 --seed 181129" + resp = subprocess.run(cmd, shell=True, + capture_output=True, + encoding="utf-8", + cwd=self.workdir) + print(resp.stdout) + if resp.returncode != 0: + print(resp.stderr) + result_ligand = os.path.join(self.workdir, "1iep_ligand_out.pdbqt") + self.assertTrue(os.path.exists(result_ligand)) + score_line = "" + with open(result_ligand, "r") as f: + for line in f.readlines(): + if line.startswith("REMARK VINA RESULT:"): + score_line = line.strip("\n") + break + self.assertNotEqual(score_line, "") + score = float([e for e in score_line[len("REMARK VINA RESULT:"):].split(" ") if e!=""][0]) + self.assertTrue(-12 <= score <= -5) if __name__ == "__main__": ut.main() \ No newline at end of file diff --git a/unidock/test/ut/test_unidock_sdf.py b/unidock/test/ut/test_unidock_sdf.py index 6594beb..eee6519 100644 --- a/unidock/test/ut/test_unidock_sdf.py +++ b/unidock/test/ut/test_unidock_sdf.py @@ -17,16 +17,17 @@ def setUp(self): def tearDown(self): shutil.rmtree(self.workdir, ignore_errors=True) - def test_unidock_sdf(self): + def test_unidock_sdf_vina(self): cmd = f"unidock --receptor {self.receptor} --gpu_batch {self.ligand} --dir {self.workdir} \ --center_x {self.pocket[0]} --center_y {self.pocket[1]} --center_z {self.pocket[2]} \ --size_x {self.pocket[3]} --size_y {self.pocket[4]} --size_z {self.pocket[5]} \ --scoring vina --search_mode fast --num_modes 1 --seed 181129" resp = subprocess.run(cmd, shell=True, - stdout=subprocess.PIPE, stderr=subprocess.PIPE, - encoding="utf-8", cwd=self.workdir) + capture_output=True, + encoding="utf-8", + cwd=self.workdir) print(resp.stdout) - if resp.stderr: + if resp.returncode != 0: print(resp.stderr) result_ligand = os.path.join(self.workdir, "1a30_ligand_out.sdf") self.assertTrue(os.path.exists(result_ligand)) @@ -41,8 +42,34 @@ def test_unidock_sdf(self): break self.assertNotEqual(score_line, "") score = float([e for e in score_line[len("ENERGY="):].split(" ") if e!=""][0]) - self.assertEqual(score, -6.432) + self.assertTrue(-15 <= score <= -8) + def test_unidock_sdf_vinardo(self): + cmd = f"unidock --receptor {self.receptor} --gpu_batch {self.ligand} --dir {self.workdir} \ + --center_x {self.pocket[0]} --center_y {self.pocket[1]} --center_z {self.pocket[2]} \ + --size_x {self.pocket[3]} --size_y {self.pocket[4]} --size_z {self.pocket[5]} \ + --scoring vinardo --search_mode fast --num_modes 1 --seed 181129" + resp = subprocess.run(cmd, shell=True, + capture_output=True, + encoding="utf-8", + cwd=self.workdir) + print(resp.stdout) + if resp.returncode != 0: + print(resp.stderr) + result_ligand = os.path.join(self.workdir, "1a30_ligand_out.sdf") + self.assertTrue(os.path.exists(result_ligand)) + score_line = "" + with open(result_ligand, "r") as f: + while True: + line = f.readline() + if line.startswith("> "): + score_line = f.readline().strip("\n") + break + if not line: + break + self.assertNotEqual(score_line, "") + score = float([e for e in score_line[len("ENERGY="):].split(" ") if e!=""][0]) + self.assertTrue(-15 <= score <= -8) if __name__ == "__main__": ut.main() \ No newline at end of file