OpenStructure
hhblits.py
Go to the documentation of this file.
1 from ost import settings
2 from ost import bindings
3 import subprocess
4 import re
5 
7  version_string = None
8 
9  # raises if hhblits binary is not in path
10  try:
11  hhblits_bin = settings.Locate('hhblits')
12  except:
13  raise RuntimeError('Tried to determine HHblits version string which '\
14  'requires the hhblits binary to be in your path. '\
15  'Couldnt find it...')
16 
17  # run hhblits to determine version
18  proc = subprocess.run([hhblits_bin, '-h'], stdout=subprocess.PIPE)
19 
20  # regular expression in the form
21  # HHblits, whatever except newline, x.y.z
22  # where x.y.z are the version numerals
23  version_line = re.search(r'HHblits[^\n]+\d+\.\d+\.\d+', proc.stdout.decode())
24  if version_line is not None:
25  version = re.search(r'\d+\.\d+\.\d+', version_line.group())
26  if version is not None:
27  version_string = version.group()
28 
29  return version_string
30 
31 hhblits_version_string = GetHHblitsVersionString()
32 
33 if hhblits_version_string is None:
34  raise RuntimeError('Could not determine HHblits version. Please '\
35  'import the hhblits2 or hhblits3 binding explicitely.')
36 
37 hhblits_version = int(hhblits_version_string.split('.')[0])
38 
39 if hhblits_version == 2:
40  from ost.bindings.hhblits2 import *
41 elif hhblits_version == 3:
42  from ost.bindings.hhblits3 import *
43 else:
44  raise RuntimeError('Determined HHblits version to be %i. OpenStructure '\
45  'only supports 2 or 3. If you think the detected '\
46  'version is wrong and you have version 2 or 3, '\
47  'import the hhblits2 or hhblits3 binding explicitely.'\
48  %(hhblits_version))
49 
def GetHHblitsVersionString()
Definition: hhblits.py:6