about summary refs log tree commit diff
diff options
context:
space:
mode:
authorzsloan2021-02-25 19:37:55 +0000
committerzsloan2021-02-25 19:37:55 +0000
commit74a6e3f3d21edb9204b8e6e1188b04424c2f7446 (patch)
tree40c9c4b986849033a5916293a3b2f107293acf7d
parent398174af99d6e50af9e10bbb95f78bcf74388f81 (diff)
downloadgenenetwork2-74a6e3f3d21edb9204b8e6e1188b04424c2f7446.tar.gz
Phenotype regular search now runs without trait creation
-rw-r--r--wqflask/wqflask/do_search.py23
-rw-r--r--wqflask/wqflask/search_results.py29
2 files changed, 33 insertions, 19 deletions
diff --git a/wqflask/wqflask/do_search.py b/wqflask/wqflask/do_search.py
index 00636563..1478d2b6 100644
--- a/wqflask/wqflask/do_search.py
+++ b/wqflask/wqflask/do_search.py
@@ -189,10 +189,25 @@ class PhenotypeSearch(DoSearch):
     DoSearch.search_types['Publish'] = "PhenotypeSearch"
 
     base_query = """SELECT PublishXRef.Id,
-                PublishFreeze.createtime as thistable,
-                Publication.PubMed_ID as Publication_PubMed_ID,
-                Phenotype.Post_publication_description as Phenotype_Name
-                FROM Phenotype, PublishFreeze, Publication, PublishXRef """
+                CAST(Phenotype.`Pre_publication_description` AS BINARY),
+                CAST(Phenotype.`Post_publication_description` AS BINARY),
+                Publication.`Authors`,
+                Publication.`Year`,
+                Publication.`PubMed_ID`,
+                PublishXRef.`mean`,
+                PublishXRef.`LRS`,
+                PublishXRef.`additive`,
+                PublishXRef.`Locus`,
+                InbredSet.`InbredSetCode`,
+                Geno.`Chr`,
+                Geno.`Mb`
+                FROM Species
+                INNER JOIN InbredSet ON InbredSet.`SpeciesId` = Species.`Id`
+                INNER JOIN PublishXRef ON PublishXRef.`InbredSetId` = InbredSet.`Id`
+                INNER JOIN PublishFreeze ON PublishFreeze.`InbredSetId` = InbredSet.`Id`
+                INNER JOIN Publication ON Publication.`Id` = PublishXRef.`PublicationId`
+                INNER JOIN Phenotype ON Phenotype.`Id` = PublishXRef.`PhenotypeId`
+                LEFT JOIN Geno ON PublishXRef.Locus = Geno.Name AND Geno.SpeciesId = Species.Id """
 
     search_fields = ('Phenotype.Post_publication_description',
                     'Phenotype.Pre_publication_description',
diff --git a/wqflask/wqflask/search_results.py b/wqflask/wqflask/search_results.py
index 8edf6147..b8e9f5de 100644
--- a/wqflask/wqflask/search_results.py
+++ b/wqflask/wqflask/search_results.py
@@ -124,8 +124,8 @@ class SearchResultPage(object):
 
             trait_dict['display_name'] = result[0]
             if self.dataset.type == "Publish":
-                if self.dataset.group_code:
-                    trait_dict['display_name'] = self.dataset.group_code + "_" + result[0]
+                if self.dataset.group.code:
+                    trait_dict['display_name'] = self.dataset.group.code + "_" + str(result[0])
 
             trait_dict['dataset'] = self.dataset.name
             trait_dict['hmac'] = hmac.data_hmac('{}:{}'.format(trait_dict['name'], trait_dict['dataset']))
@@ -173,35 +173,34 @@ class SearchResultPage(object):
                 trait_dict['pubmed_text'] = "N/A"
                 trait_dict['mean'] = "N/A"
                 trait_dict['additive'] = "N/A"
-                pre_pub_description = result[2].strip()
-                post_pub_description = result[3].strip()
-                if result[1] != "NULL" and result[1] != None:
-                    trait_dict['pubmed_id'] = result[1]
+                pre_pub_description = "N/A" if result[1] is None else result[1].strip()
+                post_pub_description = "N/A" if result[2] is None else result[2].strip()
+                if result[5] != "NULL" and result[5] != None:
+                    trait_dict['pubmed_id'] = result[5]
                     trait_dict['pubmed_link'] = PUBMEDLINK_URL % trait_dict['pubmed_id']
                     trait_dict['description'] = post_pub_description
                 else:
                     trait_dict['description'] = pre_pub_description
 
-                if result[6].isdigit():
-                    trait_dict['pubmed_text'] = result[6]
+                if result[4].isdigit():
+                    trait_dict['pubmed_text'] = result[4]
 
-                trait_dict['authors'] = result[5]
+                trait_dict['authors'] = result[3]
 
-                if result[4] != "" and result[4] != None:
-                    trait_dict['mean'] = f"{result[4]:.3f}"
+                if result[6] != "" and result[6] != None:
+                    trait_dict['mean'] = f"{result[6]:.3f}"
 
                 try:
-                    trait_dict['lod_score'] = f"{float(result[5]) / 4.61:.1f}"
+                    trait_dict['lod_score'] = f"{float(result[7]) / 4.61:.1f}"
                 except:
                     trait_dict['lod_score'] = "N/A"
 
                 try:
-                    trait_dict['lrs_location'] = f"Chr{result[9]}: {float(result[10]):.6f}"
+                    trait_dict['lrs_location'] = f"Chr{result[11]}: {float(result[12]):.6f}"
                 except:
                     trait_dict['lrs_location'] = "N/A"
 
-                if result[5] != "":
-                    trait_dict['additive'] = f"{result[6]:.3f}"
+                trait_dict['additive'] = "N/A" if not result[8] else f"{result[8]:.3f}"
 
             # Convert any bytes in dict to a normal utf-8 string
             for key in trait_dict.keys():