当前位置: 首页>>代码示例>>Python>>正文


Python PassingData.strain_id2index方法代码示例

本文整理汇总了Python中pymodule.PassingData.strain_id2index方法的典型用法代码示例。如果您正苦于以下问题:Python PassingData.strain_id2index方法的具体用法?Python PassingData.strain_id2index怎么用?Python PassingData.strain_id2index使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pymodule.PassingData的用法示例。


在下文中一共展示了PassingData.strain_id2index方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: getStrainIDInfo

# 需要导入模块: from pymodule import PassingData [as 别名]
# 或者: from pymodule.PassingData import strain_id2index [as 别名]
	def getStrainIDInfo(self, db, strain_id_info_query, strain_id_set=None):
		"""
		2008-08-29
		"""
		sys.stderr.write("Getting strain id info ...")
		rows = db.metadata.bind.execute(strain_id_info_query)
		strain_id_ls = []
		strain_id2index = {}
		strain_label_ls = []
		prev_country_abbr = None
		no_of_separators = 0
		for row in rows:
			if strain_id_set and row.strainid not in strain_id_set:	#skip
				continue
			if prev_country_abbr == None:
				prev_country_abbr = row.abbr
			elif row.abbr!=prev_country_abbr:
				prev_country_abbr = row.abbr
				no_of_separators += 1
				strain_id2index[-no_of_separators] = len(strain_id_ls)
				strain_id_ls.append(-no_of_separators)
				strain_label_ls.append('')
			strain_id2index[row.strainid] = len(strain_id_ls)
			strain_id_ls.append(row.strainid)
			if len(row.sitename)>10:
				sitename = row.sitename[:10]
			else:
				sitename = row.sitename
			strain_label_ls.append('%s_%s_%s_%s'%(row.abbr, sitename, row.nativename, row.strainid))
		strain_id_info = PassingData()
		strain_id_info.strain_id_ls = strain_id_ls
		strain_id_info.strain_id2index = strain_id2index
		strain_id_info.strain_label_ls = strain_label_ls
		sys.stderr.write("Done.\n")
		return strain_id_info
开发者ID:,项目名称:,代码行数:37,代码来源:

示例2: getStrainInfoGivenPlateInfo

# 需要导入模块: from pymodule import PassingData [as 别名]
# 或者: from pymodule.PassingData import strain_id2index [as 别名]
	def getStrainInfoGivenPlateInfo(self, db, plate_info, strain_id_info_query, strain_id_set=None):
		"""
		2008-09-13
			order/group the strains according to plate_set, country, strain longitude
			fetch appropriate labels for each strain
		"""
		sys.stderr.write("Getting strain_info given plate_info ...")

		
		#fetch appropriate label, and put strain id in country_longitude order within each plate
		plate_set2strain_id_ls_in_GPS_order = {}
		strain_id2label = {}
		rows = db.metadata.bind.execute(strain_id_info_query)
		for row in rows:
			if strain_id_set and row.strainid not in strain_id_set:	#skip
				continue
			plate_set = plate_info.strain_id2plate_set[row.strainid]
			if plate_set not in plate_set2strain_id_ls_in_GPS_order:
				plate_set2strain_id_ls_in_GPS_order[plate_set] = []
			plate_set2strain_id_ls_in_GPS_order[plate_set].append(row.strainid)
			
			if len(row.sitename)>10:	#cut short on the site name
				sitename = row.sitename[:10]
			else:
				sitename = row.sitename
			strain_label = '%s_%s_%s_%s_%s'%(row.abbr, sitename, row.nativename, row.strainid, repr(plate_set)[1:-1])
			strain_id2label[row.strainid] = strain_label
		
		#put in plate_set order, assign row index
		plate_set_ls = plate_set2strain_id_ls_in_GPS_order.keys()
		plate_set_ls.sort()
		no_of_plates = len(plate_set_ls)
		strain_id_ls = []
		strain_id2index = {}
		strain_label_ls = []
		for i in range(no_of_plates):
			plate_set = plate_set_ls[i]
			plate_strain_id_ls = plate_set2strain_id_ls_in_GPS_order[plate_set]
			if i!=0:	#insert separator, but not before the first plate_set
				strain_id2index[-i] = len(strain_id2index)
				strain_id_ls.append(-i)
				strain_label_ls.append('')
			for strain_id in plate_strain_id_ls:
				strain_id2index[strain_id] = len(strain_id2index)
				strain_id_ls.append(strain_id)
				strain_label_ls.append(strain_id2label[strain_id])
		
		strain_id_info = PassingData()
		strain_id_info.strain_id_ls = strain_id_ls
		strain_id_info.strain_id2index = strain_id2index
		strain_id_info.strain_label_ls = strain_label_ls
		sys.stderr.write("Done.\n")
		return strain_id_info
开发者ID:,项目名称:,代码行数:55,代码来源:


注:本文中的pymodule.PassingData.strain_id2index方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。