def diabetes(request): cursor = connections['default'].dict_cursor() query = 'SELECT * FROM interpretome_clinical.diabetes_old_with_sizes ORDER BY study_size DESC;' cursor.execute(query) all_snps = cursor.fetchall() snps = helpers.create_multi_snp_dict(all_snps) order_snps = [] for snp in all_snps: order_snps.append(snp['dbsnp']) output = {'snps': snps, 'dbsnps': order_snps} return http.HttpResponse(simplejson.dumps(output), mimetype = 'application/json')
def diabetes(request): cursor = connections['default'].dict_cursor() query = 'SELECT * FROM interpretome_clinical.diabetes_old_with_sizes ORDER BY study_size DESC;' cursor.execute(query) all_snps = cursor.fetchall() snps = helpers.create_multi_snp_dict(all_snps) order_snps = [] for snp in all_snps: order_snps.append(snp['dbsnp']) output = {'snps': snps, 'dbsnps': order_snps} return http.HttpResponse(simplejson.dumps(output), mimetype='application/json')
def exercise(request): '''Get SNP data for an exercise.''' exercise = request.GET.get('exercise', None) # Defaults fields = '*' where_clause = '' db = 'interpretome_exercises' table = exercise # Supported exercises exercises = [ 'ashley_cad', 'tang_ancestry', 'altman_pgx', 'butte_diabetes', 'assimes_cad', 'snyder_binding', 'class_writeups', 'mignot_narcolepsy', 'kim_aging', 'eqtl', 'longevity', 'selection', 'neandertal' ] if exercise not in exercises: return http.HttpResponseBadRequest() # Set query parameters if exercise == 'longevity': where_clause = 'ORDER BY log10_bf DESC' elif exercise == 'selection': pop = request.REQUEST.get('population') where_clause = "WHERE pop = '%s' AND selected IS NOT NULL" % pop query = '''SELECT %(fields)s FROM %(db)s.%(table)s %(where)s ''' % { 'fields': fields, 'db': db, 'table': table, 'where': where_clause } # Get type of snp_dict cursor = connections['default'].dict_cursor() cursor.execute(query) snps = {} if exercise in ('snyder_binding'): result = cursor.fetchall() snps['snps'] = helpers.create_multi_snp_dict(result) else: result = cursor.fetchall() snps['snps'] = helpers.create_snp_dict(result) # Post-processing if exercise == 'longevity': snps['sorted_dbsnps'] = [e['dbsnp'] for e in result] return http.HttpResponse(simplejson.dumps(snps), mimetype='application/json')
def exercise(request): '''Get SNP data for an exercise.''' exercise = request.GET.get('exercise', None) # Defaults fields = '*' where_clause = '' db = 'interpretome_exercises' table = exercise # Supported exercises exercises = ['ashley_cad', 'tang_ancestry', 'altman_pgx', 'butte_diabetes', 'assimes_cad', 'snyder_binding', 'class_writeups', 'mignot_narcolepsy', 'kim_aging', 'eqtl', 'longevity', 'selection', 'neandertal'] if exercise not in exercises: return http.HttpResponseBadRequest() # Set query parameters if exercise == 'longevity': where_clause = 'ORDER BY log10_bf DESC' elif exercise == 'selection': pop = request.REQUEST.get('population') where_clause = "WHERE pop = '%s' AND selected IS NOT NULL" % pop query = '''SELECT %(fields)s FROM %(db)s.%(table)s %(where)s ''' % {'fields': fields, 'db': db, 'table': table, 'where': where_clause} # Get type of snp_dict cursor = connections['default'].dict_cursor() cursor.execute(query) snps = {} if exercise in ('snyder_binding'): result = cursor.fetchall() snps['snps'] = helpers.create_multi_snp_dict(result) else: result = cursor.fetchall() snps['snps'] = helpers.create_snp_dict(result) # Post-processing if exercise == 'longevity': snps['sorted_dbsnps'] = [e['dbsnp'] for e in result] return http.HttpResponse(simplejson.dumps(snps), mimetype = 'application/json')