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


Python PassingData.plate_set2index方法代碼示例

本文整理匯總了Python中pymodule.PassingData.plate_set2index方法的典型用法代碼示例。如果您正苦於以下問題:Python PassingData.plate_set2index方法的具體用法?Python PassingData.plate_set2index怎麽用?Python PassingData.plate_set2index使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pymodule.PassingData的用法示例。


在下文中一共展示了PassingData.plate_set2index方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: alignStrainsAccordingToSeqPlate

# 需要導入模塊: from pymodule import PassingData [as 別名]
# 或者: from pymodule.PassingData import plate_set2index [as 別名]
	def alignStrainsAccordingToSeqPlate(self, db):
		"""
		2008-09-12
			group strains by sequenom plate set(usually 4 plates comprise 1 set)
		"""
		sys.stderr.write("Aligning strainid according to sequenom plate ...")
		#rows = db.metadata.bind.execute("select id, group_concat(seqinfoid order by seqinfoid) as plate_set from (select distinct s.id, c.seqinfoid from calls_byseq c, strain s where s.ecotypeid=c.ecotypeid and (s.plateid=c.plateid or s.plateid is NULL ) and (s.wellid=c.wellid  or s.wellid is null) order by s.id, c.seqinfoid, c.snpid ) as newt group by id order by plate_set")
		rows = StockDB.Strain.query.all()
		plate_set2strain_id_ls = {}
		plate_set2index = {}
		plate_id2plate_set = {}
		unprocessed_plate_set2strain_id_ls = {}
		seqinfoid_name_ls = ['seqinfoid1', 'seqinfoid2', 'seqinfoid3', 'seqinfoid4']
		for row in rows:
			plate_id_ls = []
			four_plate_complete = True
			for i in range(len(seqinfoid_name_ls)):
				seqinfoid = getattr(row, seqinfoid_name_ls[i], None)
				if seqinfoid is not None:
					plate_id_ls.append(seqinfoid)
				else:
					plate_id_ls.append(0)
					four_plate_complete = False
			strain_id = row.id
			plate_set = tuple(plate_id_ls)
			if four_plate_complete:
				if plate_set not in plate_set2index:
					plate_set2index[plate_set] = len(plate_set2index)
					for plate_id in plate_id_ls:
						plate_id2plate_set[plate_id] = plate_set
					plate_set2strain_id_ls[plate_set] = []
				plate_set2strain_id_ls[plate_set].append(strain_id)
			else:	#incomplete plate set, defer them to handle later
				pdata = self.testAllPlateIDinPlateSet(plate_id_ls, plate_id2plate_set)
				if pdata.all_plate_id_in_plate_set:
					plate_set2strain_id_ls[pdata.plate_set].append(strain_id)
				else:	#new plate_set, there might be complet 4-plate set to cover it later, so defer this.
					if plate_set not in unprocessed_plate_set2strain_id_ls:
						unprocessed_plate_set2strain_id_ls[plate_set] = []
					unprocessed_plate_set2strain_id_ls[plate_set].append(strain_id)
		
		for unprocessed_plate_set, strain_id_ls in unprocessed_plate_set2strain_id_ls.iteritems():
			plate_id_ls = unprocessed_plate_set
			pdata = self.testAllPlateIDinPlateSet(plate_id_ls, plate_id2plate_set)
			if pdata.all_plate_id_in_plate_set:
				for strain_id in strain_id_ls:
					plate_set2strain_id_ls[pdata.plate_set].append(strain_id)
			else:	#new plate set
				plate_set2index[unprocessed_plate_set] = len(plate_set2index)
				for plate_id in plate_id_ls:
					plate_id2plate_set[plate_id] = unprocessed_plate_set
				plate_set2strain_id_ls[unprocessed_plate_set] = []
				for strain_id in strain_id_ls:
					plate_set2strain_id_ls[unprocessed_plate_set].append(strain_id)
		
		strain_id2plate_set = {}
		for plate_set, strain_id_ls in plate_set2strain_id_ls.iteritems():
			for strain_id in strain_id_ls:
				strain_id2plate_set[strain_id] = plate_set
		
		plate_info = PassingData()
		plate_info.plate_set2strain_id_ls = plate_set2strain_id_ls
		plate_info.plate_set2index = plate_set2index
		plate_info.plate_id2plate_set = plate_id2plate_set
		plate_info.strain_id2plate_set = strain_id2plate_set
		sys.stderr.write("Done.\n")
		return plate_info
開發者ID:,項目名稱:,代碼行數:69,代碼來源:


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