本文整理汇总了Python中hmm.HMM.load_hmm方法的典型用法代码示例。如果您正苦于以下问题:Python HMM.load_hmm方法的具体用法?Python HMM.load_hmm怎么用?Python HMM.load_hmm使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hmm.HMM
的用法示例。
在下文中一共展示了HMM.load_hmm方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from hmm import HMM [as 别名]
# 或者: from hmm.HMM import load_hmm [as 别名]
#.........这里部分代码省略.........
group.hmm = hmm_group_list[g].split(",")
# Verifying HMM application mode (one HMM or multiple HMM files)
if(len(group.hmm) == 1):
group.flag_multiple_hmms = False
group.hmm = group.hmm[0]
elif(len(group.hmm) == len(histone_file_name_list)): flag_multiple_hmms = True
else: error_handler.throw_error("FP_NB_HMMS")
else: # Argument was not passed
for group in group_list:
group.flag_multiple_hmms = False
if(group.dnase_only):
if(bias_correction): group.hmm = hmm_data.get_default_hmm_dnase_bc()
else: group.hmm = hmm_data.get_default_hmm_dnase()
elif(group.histone_only):
group.hmm = hmm_data.get_default_hmm_histone()
else:
if(bias_correction): group.hmm = hmm_data.get_default_hmm_dnase_histone_bc()
else: group.hmm = hmm_data.get_default_hmm_dnase_histone()
# Creating scikit HMM list
for group in group_list:
if(group.flag_multiple_hmms):
hmm_list = []
for hmm_file_name in group.hmm:
try:
hmm_scaffold = HMM()
hmm_scaffold.load_hmm(hmm_file_name)
if(int(hmm_ver.split(".")[0]) <= 0 and int(hmm_ver.split(".")[1]) <= 1):
scikit_hmm = GaussianHMM(n_components=hmm_scaffold.states, covariance_type="full",
transmat=array(hmm_scaffold.A), startprob=array(hmm_scaffold.pi))
scikit_hmm.means_ = array(hmm_scaffold.means)
scikit_hmm.covars_ = array(hmm_scaffold.covs)
else:
scikit_hmm = GaussianHMM(n_components=hmm_scaffold.states, covariance_type="full")
scikit_hmm.startprob_ = array(hmm_scaffold.pi)
scikit_hmm.transmat_ = array(hmm_scaffold.A)
scikit_hmm.means_ = array(hmm_scaffold.means)
scikit_hmm.covars_ = array(hmm_scaffold.covs)
except Exception: error_handler.throw_error("FP_HMM_FILES")
hmm_list.append(scikit_hmm)
group.hmm = hmm_list
else:
scikit_hmm = None
try:
hmm_scaffold = HMM()
hmm_scaffold.load_hmm(group.hmm)
if(int(hmm_ver.split(".")[0]) <= 0 and int(hmm_ver.split(".")[1]) <= 1):
scikit_hmm = GaussianHMM(n_components=hmm_scaffold.states, covariance_type="full",
transmat=array(hmm_scaffold.A), startprob=array(hmm_scaffold.pi))
scikit_hmm.means_ = array(hmm_scaffold.means)
scikit_hmm.covars_ = array(hmm_scaffold.covs)
else:
scikit_hmm = GaussianHMM(n_components=hmm_scaffold.states, covariance_type="full")
scikit_hmm.startprob_ = array(hmm_scaffold.pi)
scikit_hmm.transmat_ = array(hmm_scaffold.A)
示例2: main
# 需要导入模块: from hmm import HMM [as 别名]
# 或者: from hmm.HMM import load_hmm [as 别名]
#.........这里部分代码省略.........
# Handling errors
if(not dnase_file): error_handler.throw_error("FP_NO_DNASE")
if(len(histone_file_list) == 0): error_handler.throw_error("FP_NO_HISTONE")
elif(len(histone_file_list) > 3): error_handler.throw_warning("FP_MANY_HISTONE")
###################################################################################################
# Creating HMM list
###################################################################################################
# Fetching HMM input
flag_multiple_hmms = False
if(options.hmm_file): # Argument is passed
# Fetching list of HMM files
hmm_file_list = options.hmm_file.split(",")
# Verifying HMM application mode (one HMM or multiple HMM files)
if(len(hmm_file_list) == 1): flag_multiple_hmms = False # One HMM file only
elif(len(hmm_file_list) == len(histone_file_name_list)): flag_multiple_hmms = True # One HMM file for each histone
else: error_handler.throw_error("FP_NB_HMMS")
else: # Argument was not passed
flag_multiple_hmms = False
hmm_data = HmmData()
hmm_file_list = [hmm_data.get_default_hmm()]
# Creating scikit HMM list
hmm_list = []
for hmm_file_name in hmm_file_list:
try:
hmm_scaffold = HMM()
hmm_scaffold.load_hmm(hmm_file_name)
scikit_hmm = GaussianHMM(n_components=hmm_scaffold.states, covariance_type="full",
transmat=array(hmm_scaffold.A), startprob=array(hmm_scaffold.pi))
scikit_hmm.means_ = array(hmm_scaffold.means)
scikit_hmm.covars_ = array(hmm_scaffold.covs)
except Exception: error_handler.throw_error("FP_HMM_FILES")
hmm_list.append(scikit_hmm)
###################################################################################################
# Main Pipeline
###################################################################################################
# Initializing result set
footprints = GenomicRegionSet("footprints")
# Iterating over regions
for r in regions.sequences:
# Fetching DNase signal
try:
dnase_norm, dnase_slope = dnase_file.get_signal(r.chrom, r.initial, r.final,
dnase_frag_ext, dnase_initial_clip, dnase_norm_per, dnase_slope_per)
except Exception:
error_handler.throw_warning("FP_DNASE_PROC",add_msg="for region ("+",".join([r.chrom, str(r.initial), str(r.final)])+"). This iteration will be skipped.")
continue
# Iterating over histone modifications
for i in range(0,len(histone_file_list)):
# Fetching histone signal
try:
histone_file = histone_file_list[i]
histone_norm, histone_slope = histone_file.get_signal(r.chrom, r.initial, r.final,