本文整理汇总了Python中pymodule.PassingData.phenotype_method_id2index方法的典型用法代码示例。如果您正苦于以下问题:Python PassingData.phenotype_method_id2index方法的具体用法?Python PassingData.phenotype_method_id2index怎么用?Python PassingData.phenotype_method_id2index使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pymodule.PassingData
的用法示例。
在下文中一共展示了PassingData.phenotype_method_id2index方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getPhenotypeInfo
# 需要导入模块: from pymodule import PassingData [as 别名]
# 或者: from pymodule.PassingData import phenotype_method_id2index [as 别名]
def getPhenotypeInfo(self, db, where_condition):
"""
2008-08-29
add -1 as a separator into phenotype_method_id_ls and others
"""
sys.stderr.write("Getting phenotype method info ...")
rows = db.metadata.bind.execute("select distinct r.phenotype_method_id, p.biology_category_id from %s p, %s and p.id=r.phenotype_method_id order by p.biology_category_id, r.phenotype_method_id"\
%(PhenotypeMethod.table.name, where_condition))
phenotype_method_id_ls = []
phenotype_method_id2index = {}
phenotype_method_label_ls = []
prev_biology_category_id = None
no_of_separators = 0
for row in rows:
if prev_biology_category_id == None:
prev_biology_category_id = row.biology_category_id
elif row.biology_category_id!=prev_biology_category_id:
prev_biology_category_id = row.biology_category_id
#add a blank phenotype id as separator
no_of_separators += 1
phenotype_method_id2index[-no_of_separators] = len(phenotype_method_id_ls)
phenotype_method_id_ls.append(-no_of_separators)
phenotype_method_label_ls.append('')
phenotype_method_id2index[row.phenotype_method_id] = len(phenotype_method_id_ls)
phenotype_method_id_ls.append(row.phenotype_method_id)
pm = PhenotypeMethod.get(row.phenotype_method_id)
phenotype_method_label_ls.append('%s_%s'%(pm.id, pm.short_name))
phenotype_info = PassingData()
phenotype_info.phenotype_method_id2index = phenotype_method_id2index
phenotype_info.phenotype_method_id_ls = phenotype_method_id_ls
phenotype_info.phenotype_method_label_ls = phenotype_method_label_ls
sys.stderr.write("Done.\n")
return phenotype_info