Skip to content

Commit

Permalink
fix ut
Browse files Browse the repository at this point in the history
  • Loading branch information
dp-yuanyn committed Jan 29, 2024
1 parent ebec02e commit a309df3
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci_tools.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Uni-Dock Tools CI/CD
on:
push:
branches: [ main ]
branches: [ fix_unidock_ut ]
pull_request:
branches: [ main ]

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci_unidock.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Uni-Dock CI/CD
on:
push:
branches: [ main ]
branches: [ fix_unidock_ut ]
pull_request:
branches: [ main ]

Expand Down
34 changes: 29 additions & 5 deletions unidock/test/ut/test_unidock.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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()
37 changes: 32 additions & 5 deletions unidock/test/ut/test_unidock_sdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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("> <Uni-Dock RESULT>"):
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()

0 comments on commit a309df3

Please sign in to comment.