From 7d089d58d9e62fba6d61f17f93148054cf7e6730 Mon Sep 17 00:00:00 2001 From: Alexander_Kabui Date: Thu, 18 Aug 2022 23:36:56 +0300 Subject: bulk fetch n number of traits type probeset --- wqflask/wqflask/correlation/rust_correlation.py | 28 +++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'wqflask') diff --git a/wqflask/wqflask/correlation/rust_correlation.py b/wqflask/wqflask/correlation/rust_correlation.py index 5c22efbf..fc8ab508 100644 --- a/wqflask/wqflask/correlation/rust_correlation.py +++ b/wqflask/wqflask/correlation/rust_correlation.py @@ -15,6 +15,34 @@ from gn3.computations.rust_correlation import parse_tissue_corr_data from gn3.db_utils import database_connector +def query_probes_metadata(dataset, results): + + """query traits metadata in bulk for probeset""" + + with database_connector() as conn: + with conn.cursor() as cursor: + + query = """ + SELECT ProbeSet.Name,ProbeSet.Chr,ProbeSet.Mb, + Symbol,mean,description,additive,LRS,Geno.Chr, Geno.Mb + from Geno, Species,ProbeSet,ProbeSetXRef,ProbeSetFreeze + where ProbeSet.Name in ({}) and + Species.Name = %s and + Geno.Name = ProbeSetXRef.Locus and + Geno.SpeciesId = Species.Id and + ProbeSet.Id=ProbeSetXRef.ProbeSetId and + ProbeSetFreeze.Id = ProbeSetXRef.ProbeSetFreezeId and + ProbeSetFreeze.Name = %s + """.format(", ".join(["%s"] * len(trait_list))) + + cursor.execute(query, + (tuple(trait_list) + + (dataset.group.species,) + (dataset.name,)) + ) + + return cursor.fetchall() + + def chunk_dataset(dataset, steps, name): results = [] -- cgit v1.2.3