-
Notifications
You must be signed in to change notification settings - Fork 4
/
SeedSequence_HMMBuildEmit.py
executable file
·53 lines (46 loc) · 1.98 KB
/
SeedSequence_HMMBuildEmit.py
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
50
51
52
53
#! /usr/bin/env python3
'''
Niema Moshiri 2016
"SeedSequence" module, where the user specifies a multiple sequence alignment,
and hmmbuild is used to create a profile HMM from the MSA. Then, hmmemit is
used to sample seed sequences from the resulting profile HMM.
'''
from SeedSequence import SeedSequence
from SeedSequence_HMMEmit import SeedSequence_HMMEmit
import FAVITES_GlobalContext as GC
from subprocess import check_output
from random import choice
from os.path import abspath,expanduser
from os import makedirs
HMMBuildEmit_path = "HMMBuildEmit_files"
HMM_filename = "seedseq.hmm"
class SeedSequence_HMMBuildEmit(SeedSequence):
'''
Implement the ``SeedSequence'' using hmmbuild to build a profile HMM from
an input MSA, and then use hmmemit to generate seed sequences from the
resulting profile HMM
'''
def cite():
return GC.CITATION_HMMER
def init():
GC.hmmbuild_msafile = abspath(expanduser(GC.hmmbuild_msafile.strip()))
GC.hmmbuild_path = expanduser(GC.hmmbuild_path.strip())
GC.hmmemit_path = expanduser(GC.hmmemit_path.strip())
GC.hmmbuild_options = [i.strip() for i in GC.hmmbuild_options.strip().split()]
GC.hmmemit_options = [i.strip() for i in GC.hmmemit_options.strip().split()]
GC.HMMBuildEmit_build = False
def generate():
if not GC.HMMBuildEmit_build:
makedirs(HMMBuildEmit_path, exist_ok=True)
command = [GC.hmmbuild_path] + GC.hmmbuild_options + ["%s/%s" % (HMMBuildEmit_path,HMM_filename), GC.hmmbuild_msafile]
try:
check_output(command)
except FileNotFoundError:
from os import chdir
chdir(GC.START_DIR)
assert False, "hmmbuild executable was not found: %s" % GC.hmmbuild_path
GC.hmmemit_hmmfile = "%s/%s" % (HMMBuildEmit_path,HMM_filename)
GC.HMMBuildEmit_build = True
return SeedSequence_HMMEmit.generate()
def merge_trees():
return [],[]