示例#1
0
	def index(self):
		#c.call_method_ls = DisplayresultsController.getCallMethodLsJson()		
		c.callMethodLsURL = h.url_for(controller="DisplayResults", action="getCallMethodLsJson", id=None)
		#c.gene_list_ls = DisplayresultsgeneController.getGeneListTypeLsGivenTypeAndPhenotypeMethodAndAnalysisMethodJson()
		c.geneListLsURL = h.url_for(controller="DisplayResultsGene", action="getGeneListTypeLsGivenTypeAndPhenotypeMethodAndAnalysisMethodJson", id=None)
		c.callMethodOnChangeURL = h.url_for(controller="DisplayResults", action="getPhenotypeMethodLsJson", id=None)
		c.haplotypeImgURL = h.url_for(controller='HaplotypeView', action='getPlot', id=None)
		return render('/HaplotypeView.html')
示例#2
0
	def trend(self, id=None): 
		"""
		2009-5-3
			
		"""
		c.trendDataURL = h.url_for(controller='Phenotype', action='getTrendData', id=None)
		c.trendAnnotationDataURL = h.url_for(controller='Phenotype', action='getTrendAnnotationData', id=None)
		c.multiPhenotypeDataURL = h.url_for(controller='Phenotype', action='getMultiPhenotypeData', id=None,\
										call_method_id=int(config['app_conf']['good_call_method_id']))
		return render('/PhenotypeTrend.html')
示例#3
0
	def index(self):
		"""
		2009-11-30
		"""
		# Return a rendered template
		#   return render('/template.mako')
		# or, Return a response
		c.getCallMethodLsJsonURL = h.url_for(controller="associationoverlap", action="getCallMethodLsJson")
		c.getOverlappingDataAcrossPhenotypesURL = h.url_for(controller="associationoverlap", action="getOverlappingDataAcrossPhenotypes")
		c.getNoOfTopSNPsLsJsonURL = h.url_for(controller="associationoverlap", action="getNoOfTopSNPsLsJson")
		return render("AssociationOverlap.html")
示例#4
0
	def index(self):
		# Return a rendered template
		#   return render('/template.mako')
		# or, Return a response
		# return 'Hello World'
		c.find250kAccessionsURL = h.url_for(controller="Accession", action="find250kAccessions", id=None)
		return render('/Accession.html')
示例#5
0
	def haploGroup(self, id=None):
		"""
		2009-4-5
			server end to return haplotype group json data structure
		"""
		if id is None:
			id = 1
		c.haplo_group_id = id
		c.getHaploGroupURL = h.url_for(controller="Accession", action="getHaploGroup", id=id)
		return render('/HaploGroup.html')
示例#6
0
	def index(self):
		"""
		2009-11-11
			add c.getPhenotypeURL
		2009-10-8
			first try to get the call_method_id from the URL parameters. if it's null, use the published_call_method_id instead.
		2009-7-2
			update c.displayResultsGeneURL to h.url_for(controller="DisplayResultsGene", action='showResultsGeneForOnePhenotype')
		"""
		# Return a rendered template
		#   return render('/template.mako')
		# or, Return a response
		c.call_method_id = request.params.get('call_method_id', config['app_conf']['published_call_method_id'])
		c.getPhenotypeCategoryLsURL = h.url_for(controller="DisplayResults", action="getPhenotypeCategoryLs")
		c.getPhenotypeTableDataURL = h.url_for(controller="DisplayResults", action="getPhenotypeTableData")
		c.getGWAURL = h.url_for(controller="DisplayResults", action="showGWA")
		c.getPhenotypeURL = h.url_for(controller='Phenotype')
		c.displayResultsGeneURL = h.url_for(controller="DisplayResultsGene", action='showResultsGeneForOnePhenotype')
		
		return render("GWASPhenotypes.html")
示例#7
0
	def index(self, id=None):
		"""
		2009-4-6
			display a summary page given a phenotype id
		"""
		# Return a rendered template
		#   return render('/template.mako')
		# or, Return a response
		c.phenotype_method_id = request.params.get('phenotype_method_id', id)
		if c.phenotype_method_id:
			c.phenotype_method_id = int(c.phenotype_method_id)
		pm = model.Stock_250kDB.PhenotypeMethod.get(c.phenotype_method_id)
		c.phenotype_method_short_name = pm.short_name
		c.phenotype_method_description = pm.method_description
		
		c.call_method_id = request.params.get('call_method_id', int(config['app_conf']['published_call_method_id']))
		c.callInfoURL = h.url_for(controller='DisplayResults', action='fetchCallInfoData', id=None,\
							phenotype_method_id=c.phenotype_method_id, call_method_id=c.call_method_id)
		c.phenotypeHistImageURL = h.url_for(controller='DisplayResults', action='getPhenotypeHistImage', id=None, \
										phenotype_method_id=c.phenotype_method_id, call_method_id=c.call_method_id)
		c.callPhenotypeQQImageURL = h.url_for(controller='DisplayResults', action='getCallPhenotypeQQImage', id=None,\
											phenotype_method_id=c.phenotype_method_id, call_method_id=c.call_method_id)
		c.phenotypeHistogramDataURL = h.url_for(controller='Phenotype', action='getPhenotypeHistogramData', id=c.phenotype_method_id)
		return render('/OnePhenotype.html')
示例#8
0
	def showGWA(self):
		"""
		2009-4-23
		"""
		
		c.phenotype_method_id = int(request.params.get('phenotype_method_id', 1))
		c.call_method_id = int(request.params.get('call_method_id', config['app_conf']['published_call_method_id']))
		c.phenotypeSummaryURL = h.url_for(controller="Phenotype", action=None, phenotype_method_id=c.phenotype_method_id, call_method_id=c.call_method_id)
		c.GWABaseURL = h.url_for(controller='DisplayResults', action='fetchOne', phenotype_method_id=c.phenotype_method_id, call_method_id=c.call_method_id)
		c.SNPBaseURL = h.url_for(controller='SNP', action=None, phenotype_method_id=c.phenotype_method_id, call_method_id=c.call_method_id)
		c.getAnalysisMethodLsURL = h.url_for(controller='DisplayResults', action='getAnalysisMethodLsJson', phenotype_method_id=c.phenotype_method_id, call_method_id=c.call_method_id)
		"""
		# 2009-4-25 no way to pass this 2D (int, string) array to the template! 
		analysis_method_ls = self.getAnalysisMethodLs(c.call_method_id, c.phenotype_method_id)
		c.analysis_method_ls = []
		str_func = lambda x: '%s'%x
		for analysis_method_entry in analysis_method_ls:
			analysis_method_entry = map(str_func, analysis_method_entry)
			c.analysis_method_ls.append('[' + ','.join(analysis_method_entry) + ']')
			#c.analysis_method_ls.append(analysis_method_entry)
		#c.analysis_method_ls = simplejson.dumps(c.analysis_method_ls)
		c.analysis_method_ls = '[' + ','.join(c.analysis_method_ls) + ']'
		"""
		pm = model.Stock_250kDB.PhenotypeMethod.get(c.phenotype_method_id)
		c.phenotype_method_short_name = pm.short_name
		c.phenotype_method_description = pm.method_description
		
		c.callInfoURL = h.url_for(controller='DisplayResults', action='fetchCallInfoData', id=None,\
							phenotype_method_id=c.phenotype_method_id, call_method_id=c.call_method_id)
		c.phenotypeHistImageURL = h.url_for(controller='DisplayResults', action='getPhenotypeHistImage', id=None, \
										phenotype_method_id=c.phenotype_method_id, call_method_id=c.call_method_id)
		c.callPhenotypeQQImageURL = h.url_for(controller='DisplayResults', action='getCallPhenotypeQQImage', id=None,\
											phenotype_method_id=c.phenotype_method_id, call_method_id=c.call_method_id)
		c.phenotypeHistogramDataURL = h.url_for(controller='Phenotype', action='getPhenotypeHistogramData', id=c.phenotype_method_id)
		
		return render('/GWASOnePhenotype.html')
示例#9
0
	def index(self):
		# Return a rendered template
		#   return render('/template.mako')
		# or, Return a response
		c.motionChartFormActionURL = h.url_for(controller="utils", action="uploadForMotionChart");
		return render('/Utils.html')
示例#10
0
	def findAccessions(cls, condition=None, extra_tables=None):
		"""
		2009-4-19
			add argument 'extra_tables'
		2009-4-14
			become classmethod
		2009-4-3
			find accession with name exact matching name, nativename, stockparent or alias
		"""
		if condition:
			condition = 'where %s'%condition
		else:
			condition = ""
		table_str = '%s v'%cls.ecotype_central_view
		if extra_tables:
			table_str += ', %s'%extra_tables
		rows = model.db.metadata.bind.execute("select v.* from %s %s"%\
													(table_str, condition))
		# dictionary to test whether one ecotype is in one dataset
		if getattr(model, 'ecotype_id_set_2010', None)==None:	#this lead to faster access next time. mysteriously, every call to self.ecotype_id_set_2010 (property) would lead to its execution everytime. no reference is stored.
			model.ecotype_id_set_2010 = cls.ecotype_id_set_2010()
			model.ecotype_id_set_384 = cls.ecotype_id_set_384()
			model.ecotype_id_set_perlegen = cls.ecotype_id_set_perlegen()
			model.ecotype_id_set_250k =  cls.ecotype_id_set_250k()
			model.ecotype_id_set_250k_in_pipeline = cls.ecotype_id_set_250k_in_pipeline()
		
		dataset_name2ecotype_id_set = {'2010': model.ecotype_id_set_2010,
							'384': model.ecotype_id_set_384,
							'perlegen': model.ecotype_id_set_perlegen,
							'250k': model.ecotype_id_set_250k}
		
		#3rd finally construct the full data and turn it into json
		column_name_type_ls = [("ecotypeid", ("number", "Ecotype ID")), ("tg_ecotypeid", ("number", "Unique Ecotype ID")), \
							("name", ("string","Name")), \
							("nativename", ("string","Native Name")), ("alias", ("string","Alias")), \
							("stockparent",("string", "Stock Parent")), ("haplo_group_id",("string", "149SNP Haplo-Group")), \
							("2010",("string", "2010")), \
							("384",("string", "384")), \
							("perlegen",("string", "perlegen")), \
							("250k",("string", "250k")), \
							("latitude",("number", "Latitude")), ("longitude",("number", "Longitude")), \
							("geographic_integrity",("string", "Geographic Info Quality")),\
							("site_name", ("string", "Collection Site")), ("country", ("string", "Country")),\
							("collector", ("string", "Collector")), ("collectiondate", ("date", "Collection Date"))]
		
		description = dict(column_name_type_ls)
		return_ls = []
		for row in rows:
			entry = dict()
			for column_name_type in column_name_type_ls:
				column_name = column_name_type[0]
				column_type = column_name_type[1][0]
				
				if column_type=='string':
					default_value = ''
				elif column_type =='number':
					default_value = -1
				elif column_type=='date':
					default_value = datetime.date(2050, 1, 1)
				else:
					default_value = None
				
				if column_name == 'collector':
					column_value = '%s %s'%(row.firstname, row.surname)
				elif column_name == '2010' or column_name=='384' or column_name=='perlegen' or column_name=='250k':
					if row.tg_ecotypeid in dataset_name2ecotype_id_set[column_name]:
						column_value = 'yes'
					elif column_name=='250k' and row.tg_ecotypeid in model.ecotype_id_set_250k_in_pipeline:
						column_value = 'in pipeline'
					else:
						column_value = 'no'
				elif column_name=='haplo_group_id':
					column_value = getattr(row, column_name, default_value)
					#haplo_group_name = model.Stock.HaploGroup.get(column_value).short_name
					if column_value:
						column_value = "<a href=%s target='_blank'>%s</a>"%(h.url_for(controller="Accession", action='haploGroup', id=column_value), column_value)
				else:
					column_value = getattr(row, column_name, default_value)
				entry[column_name] = column_value
			return_ls.append(entry)
		
		data_table = gviz_api.DataTable(description)
		data_table.LoadData(return_ls)
		column_ls = [row[0] for row in column_name_type_ls]
		json_result = data_table.ToJSon(columns_order=column_ls)	#ToJSonResponse only works with google.visualization.Query
		response.headers['Content-Type'] = 'application/json'
		return json_result