當前位置: 首頁>>代碼示例>>Python>>正文


Python PassingData.list_type_id2index方法代碼示例

本文整理匯總了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
開發者ID:,項目名稱:,代碼行數:58,代碼來源:

示例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
開發者ID:,項目名稱:,代碼行數:41,代碼來源:


注:本文中的pymodule.PassingData.list_type_id2index方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。