Skip to content
Snippets Groups Projects
Commit 104b8d8e authored by Studer Gabriel's avatar Studer Gabriel
Browse files

port hbplus binding to Python 3

parent a4dbfec1
Branches
Tags
No related merge requests found
...@@ -8,6 +8,7 @@ from ost import settings ...@@ -8,6 +8,7 @@ from ost import settings
import subprocess import subprocess
import re import re
import os import os
import shutil
from ost import io from ost import io
from ost import mol from ost import mol
...@@ -62,20 +63,23 @@ def HBondList(ent, hbplus_bin=None): ...@@ -62,20 +63,23 @@ def HBondList(ent, hbplus_bin=None):
""" """
full_bin=_LocateHBPlus(hbplus_bin) full_bin=_LocateHBPlus(hbplus_bin)
temp_d=tempfile.mkdtemp(prefix='hbplus_') temp_d=tempfile.mkdtemp(prefix='hbplus_')
hb_proc=subprocess.Popen(full_bin, shell=True, stdout=subprocess.PIPE,
stdin=subprocess.PIPE)
file_name=os.path.join(temp_d, 'ent.pdb') file_name=os.path.join(temp_d, 'ent.pdb')
io.SaveEntity(ent, file_name) io.SaveEntity(ent, file_name)
hb_proc.stdin.write('%s\n' % temp_d) hb_proc=subprocess.Popen(full_bin, shell=True, stdout=subprocess.PIPE,
hb_proc.stdin.write('%s\n\n' % file_name) stdin=subprocess.PIPE)
for line in hb_proc.stdout: hb_proc.stdin.write(('%s\n' % temp_d).encode())
hb_proc.stdin.write(('%s\n\n' % file_name).encode())
stdout,_ = hb_proc.communicate()
for line in stdout.decode().splitlines():
match=re.match(r'Configured for (\d+) atoms and\s+(\d+) residues\.', line) match=re.match(r'Configured for (\d+) atoms and\s+(\d+) residues\.', line)
if match: if match:
assert ent.atom_count<int(match.group(1)) assert ent.atom_count<int(match.group(1))
assert ent.residue_count<int(match.group(2)) assert ent.residue_count<int(match.group(2))
hb_out=open(os.path.join(temp_d, 'ent.hb2'), 'r') hb_out=open(os.path.join(temp_d, 'ent.hb2'), 'r')
hbonds=_ParseOutput(ent, hb_out) hbonds=_ParseOutput(ent, hb_out)
os.system('rm -rf "%s"' % temp_d) hb_out.close()
shutil.rmtree(temp_d)
return hbonds return hbonds
def HBondScore(ent1, ent2, hbplus_bin=None): def HBondScore(ent1, ent2, hbplus_bin=None):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment