本文整理汇总了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