File: hhblits.py

package info (click to toggle)
openstructure 2.11.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 206,240 kB
  • sloc: cpp: 188,571; python: 36,686; ansic: 34,298; fortran: 3,275; sh: 312; xml: 146; makefile: 29
file content (49 lines) | stat: -rw-r--r-- 1,772 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
from ost import settings
from ost import bindings
import subprocess
import re

def GetHHblitsVersionString():
    version_string = None

    # raises if hhblits binary is not in path
    try:
        hhblits_bin = settings.Locate('hhblits')
    except:
        raise RuntimeError('Tried to determine HHblits version string which '\
                           'requires the hhblits binary to be in your path. '\
                           'Couldnt find it...')

    # run hhblits to determine version
    proc = subprocess.run([hhblits_bin, '-h'], stdout=subprocess.PIPE)

    # regular expression in the form
    # HHblits, whatever except newline, x.y.z
    # where x.y.z are the version numerals
    version_line = re.search(r'HHblits[^\n]+\d+\.\d+\.\d+', proc.stdout.decode())
    if version_line is not None:
        version = re.search(r'\d+\.\d+\.\d+', version_line.group())
        if version is not None:
            version_string = version.group()

    return version_string

hhblits_version_string = GetHHblitsVersionString()

if hhblits_version_string is None:
    raise RuntimeError('Could not determine HHblits version. Please '\
                       'import the hhblits2 or hhblits3 binding explicitely.')

hhblits_version = int(hhblits_version_string.split('.')[0])

if hhblits_version == 2:
    from ost.bindings.hhblits2 import *
elif hhblits_version == 3:
    from ost.bindings.hhblits3 import *
else:
    raise RuntimeError('Determined HHblits version to be %i. OpenStructure '\
                       'only supports 2 or 3. If you think the detected '\
                       'version is wrong and you have version 2 or 3, '\
                       'import the hhblits2 or hhblits3 binding explicitely.'\
                       %(hhblits_version))