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
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