aboutsummaryrefslogtreecommitdiff
path: root/wqflask
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2022-09-06 13:41:34 +0300
committerFrederick Muriuki Muriithi2022-09-06 13:41:34 +0300
commit96d7b81cff1b4cf9334b5e37556e0323ac9ef154 (patch)
tree322b53cd649a9f342d100bb40ebb32800f856d88 /wqflask
parenta5b999a249cf5434e4a2a7fe21cf9b26357bc69f (diff)
downloadgenenetwork2-96d7b81cff1b4cf9334b5e37556e0323ac9ef154.tar.gz
Refactor: Use joins for queries
Use joins to relate tables when fetching data.
Diffstat (limited to 'wqflask')
-rw-r--r--wqflask/wqflask/correlation/rust_correlation.py22
1 files changed, 13 insertions, 9 deletions
diff --git a/wqflask/wqflask/correlation/rust_correlation.py b/wqflask/wqflask/correlation/rust_correlation.py
index 5109c72e..a4a08a54 100644
--- a/wqflask/wqflask/correlation/rust_correlation.py
+++ b/wqflask/wqflask/correlation/rust_correlation.py
@@ -23,15 +23,19 @@ def query_probes_metadata(dataset, trait_list):
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
+ ProbeSet.Symbol,ProbeSetXRef.mean,ProbeSet.description,
+ ProbeSetXRef.additive,ProbeSetXRef.LRS,Geno.Chr, Geno.Mb
+ FROM ProbeSet INNER JOIN ProbeSetXRef
+ ON ProbeSet.Id=ProbeSetXRef.ProbeSetId
+ INNER JOIN Geno
+ ON ProbeSetXRef.Locus = Geno.Name
+ INNER JOIN Species
+ ON Geno.SpeciesId = Species.Id
+ WHERE ProbeSet.Name in ({}) AND
+ Species.Name = %s AND
+ ProbeSetXRef.ProbeSetFreezeId IN (
+ SELECT ProbeSetFreeze.Id
+ FROM ProbeSetFreeze WHERE ProbeSetFreeze.Name = %s)
""".format(", ".join(["%s"] * len(trait_list)))
cursor.execute(query,