示例#1
0
	def orderListTypeAnalysisMethodID(self, list_type_id_ls, analysis_method_id_ls):
		"""
		2008-08-29
			deal with separator (list_type_id=-1) in list_type_id_ls
		"""
		sys.stderr.write("Orderinig list type id and analysis_method id ... ")
		list_type_id_analysis_method_id_ls = []
		list_type_id_analysis_method_id2index = {}
		list_type_analysis_method_label_ls = []
		no_of_separators = 0
		for list_type_id in list_type_id_ls:
			if list_type_id==-1:	#separator
				no_of_separators += 1
				tup = (-no_of_separators,-1)
				list_type_id_analysis_method_id2index[tup] = len(list_type_id_analysis_method_id_ls)
				list_type_id_analysis_method_id_ls.append(tup)
				list_type_analysis_method_label_ls.append('')
				continue
			list_type_short_name = GeneListType.get(list_type_id).short_name
			for analysis_method_id in analysis_method_id_ls:
				analysis_method_short_name = AnalysisMethod.get(analysis_method_id).short_name
				tup = (list_type_id, analysis_method_id)
				list_type_id_analysis_method_id2index[tup] = len(list_type_id_analysis_method_id_ls)
				list_type_id_analysis_method_id_ls.append(tup)
				list_type_analysis_method_label_ls.append('%s_%s_%s'%(analysis_method_short_name, list_type_short_name, list_type_id))
		return_data = PassingData()
		return_data.list_type_id_analysis_method_id_ls = list_type_id_analysis_method_id_ls
		return_data.list_type_id_analysis_method_id2index = list_type_id_analysis_method_id2index
		return_data.list_type_analysis_method_label_ls = list_type_analysis_method_label_ls
		sys.stderr.write("Done.\n")
		return return_data
示例#2
0
	def getResultsMethodIDInfo(self, db, call_method_id_ls, min_distance, get_closest, min_MAF):
		"""
		2008-09-05
			use results_by_gene.id as main result id
		"""
		sys.stderr.write("Gettiing ResultsMethodIDInfo ...")
		results_method_id_info = PassingData()
		results_method_id_ls = []
		results_method_id2index = {}
		results_method_id_label_ls = []
		rows = db.metadata.bind.execute("select distinct rg.id, rg.results_method_id, r.analysis_method_id, r.phenotype_method_id, \
			p.biology_category_id from %s rg, %s r, %s p \
			where rg.results_method_id=r.id and p.id=r.phenotype_method_id and r.call_method_id in (%s) \
			and rg.min_distance=%s and rg.get_closest=%s and rg.min_MAF>=%s-0.0001 and rg.min_MAF<=%s+0.0001 \
			order by p.biology_category_id, r.phenotype_method_id, r.analysis_method_id"%(ResultsByGene.table.name, \
					ResultsMethod.table.name, PhenotypeMethod.table.name, repr(call_method_id_ls)[1:-1], min_distance, get_closest, min_MAF, min_MAF))
		prev_phenotype_method_id = None
		prev_biology_category_id = None
		no_of_separators = 0
		for row in rows:
			if prev_biology_category_id==None:
				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
				results_method_id2index[-no_of_separators] = len(results_method_id_ls)
				results_method_id_ls.append(-no_of_separators)
				results_method_id_label_ls.append('')
			
			if prev_phenotype_method_id == None:
				prev_phenotype_method_id = row.phenotype_method_id
			elif row.phenotype_method_id!=prev_phenotype_method_id:
				prev_phenotype_method_id = row.phenotype_method_id
				#add a blank phenotype id as separator
				no_of_separators += 1
				results_method_id2index[-no_of_separators] = len(results_method_id_ls)
				results_method_id_ls.append(-no_of_separators)
				results_method_id_label_ls.append('')
			results_method_id2index[row.id] = len(results_method_id_ls)
			results_method_id_ls.append(row.id)
			am = AnalysisMethod.get(row.analysis_method_id)
			pm = PhenotypeMethod.get(row.phenotype_method_id)
			results_method_id_label_ls.append('%s_%s_%s'%(am.short_name, pm.short_name, pm.id))
		results_method_id_info.results_method_id_ls = results_method_id_ls
		results_method_id_info.results_method_id2index = results_method_id2index
		results_method_id_info.results_method_id_label_ls = results_method_id_label_ls
		sys.stderr.write("%s results. Done.\n"%(len(results_method_id_ls)))
		return results_method_id_info
    def orderListTypeAnalysisMethodID(self, list_type_id_ls,
                                      analysis_method_id_ls):
        """
		2008-08-29
			deal with separator (list_type_id=-1) in list_type_id_ls
		"""
        sys.stderr.write("Orderinig list type id and analysis_method id ... ")
        list_type_id_analysis_method_id_ls = []
        list_type_id_analysis_method_id2index = {}
        list_type_analysis_method_label_ls = []
        no_of_separators = 0
        for list_type_id in list_type_id_ls:
            if list_type_id == -1:  #separator
                no_of_separators += 1
                tup = (-no_of_separators, -1)
                list_type_id_analysis_method_id2index[tup] = len(
                    list_type_id_analysis_method_id_ls)
                list_type_id_analysis_method_id_ls.append(tup)
                list_type_analysis_method_label_ls.append('')
                continue
            list_type_short_name = GeneListType.get(list_type_id).short_name
            for analysis_method_id in analysis_method_id_ls:
                analysis_method_short_name = AnalysisMethod.get(
                    analysis_method_id).short_name
                tup = (list_type_id, analysis_method_id)
                list_type_id_analysis_method_id2index[tup] = len(
                    list_type_id_analysis_method_id_ls)
                list_type_id_analysis_method_id_ls.append(tup)
                list_type_analysis_method_label_ls.append(
                    '%s_%s_%s' % (analysis_method_short_name,
                                  list_type_short_name, list_type_id))
        return_data = PassingData()
        return_data.list_type_id_analysis_method_id_ls = list_type_id_analysis_method_id_ls
        return_data.list_type_id_analysis_method_id2index = list_type_id_analysis_method_id2index
        return_data.list_type_analysis_method_label_ls = list_type_analysis_method_label_ls
        sys.stderr.write("Done.\n")
        return return_data