本文整理汇总了Python中pymodule.PassingData.list_type_id2index方法的典型用法代码示例。如果您正苦于以下问题:Python PassingData.list_type_id2index方法的具体用法?Python PassingData.list_type_id2index怎么用?Python PassingData.list_type_id2index使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pymodule.PassingData
的用法示例。
在下文中一共展示了PassingData.list_type_id2index方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getListTypeInfo
# 需要导入模块: from pymodule import PassingData [as 别名]
# 或者: from pymodule.PassingData import list_type_id2index [as 别名]
def getListTypeInfo(cls, affiliated_table_name=None, extra_condition=None, extra_tables=None):
"""
2009-3-9
handle the case in which there is no the where_condition at all.
2008-10-30
affiliated_table_name becomes optional
2008-10-19
add option extra_tables
2008-10-16
sort gene list type by biology_category_id and return other info as well
add -1 as a separator into list_type_id_ls
"""
if affiliated_table_name:
table_str = "%s s, %s p" % (affiliated_table_name, model.Stock_250kDB.GeneListType.table.name)
where_condition = ["p.id=s.list_type_id"]
else:
table_str = "%s p" % (model.Stock_250kDB.GeneListType.table.name)
where_condition = []
if extra_tables:
table_str += ", %s" % extra_tables
if extra_condition:
where_condition.append(extra_condition)
if where_condition: # 2009-3-9
where_condition = "where " + " and ".join(where_condition)
else:
where_condition = ""
rows = model.db.metadata.bind.execute(
"select distinct p.id, p.biology_category_id, p.short_name from %s \
%s order by p.biology_category_id, p.id"
% (table_str, where_condition)
)
list_type_id_ls = []
list_type_id2index = {}
list_type_label_ls = []
prev_biology_category_id = -1
no_of_separators = 0
for row in rows:
if prev_biology_category_id == -1:
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
no_of_separators += 1
list_type_id2index[-no_of_separators] = len(list_type_id_ls)
list_type_id_ls.append(-no_of_separators)
list_type_label_ls.append("====\n====")
list_type_id2index[row.id] = len(list_type_id_ls)
list_type_id_ls.append(row.id)
list_type_label_ls.append("%s %s" % (row.id, row.short_name))
list_info = PassingData()
list_info.list_type_id2index = list_type_id2index
list_info.list_type_id_ls = list_type_id_ls
list_info.list_type_label_ls = list_type_label_ls
return list_info
示例2: getAssociationOverlappingTypeInfo
# 需要导入模块: from pymodule import PassingData [as 别名]
# 或者: from pymodule.PassingData import list_type_id2index [as 别名]
def getAssociationOverlappingTypeInfo(cls, affiliated_table_name=None, extra_condition=None, extra_tables=None):
"""
2009-11-30
"""
if affiliated_table_name:
table_str = "%s s, %s p" % (affiliated_table_name, model.Stock_250kDB.AssociationOverlappingType.table.name)
where_condition = ["p.id=s.overlapping_type_id"]
else:
table_str = "%s p" % (model.Stock_250kDB.AssociationOverlappingType.table.name)
where_condition = []
if extra_tables:
table_str += ", %s" % extra_tables
if extra_condition:
where_condition.append(extra_condition)
if where_condition: # 2009-3-9
where_condition = "where " + " and ".join(where_condition)
else:
where_condition = ""
rows = model.db.metadata.bind.execute(
"select distinct p.id, p.short_name, p.description from %s \
%s order by p.no_of_methods, p.short_name"
% (table_str, where_condition)
)
list_type_id_ls = []
list_type_id2index = {}
list_type_label_ls = []
no_of_separators = 0
for row in rows:
list_type_id2index[row.id] = len(list_type_id_ls)
list_type_id_ls.append(row.id)
list_type_label_ls.append("%s %s" % (row.short_name, row.description))
list_info = PassingData()
list_info.list_type_id2index = list_type_id2index
list_info.list_type_id_ls = list_type_id_ls
list_info.list_type_label_ls = list_type_label_ls
return list_info