From 99e1151d5603b1bbf52141166d72e6e32203bb62 Mon Sep 17 00:00:00 2001 From: Zachary Sloan Date: Tue, 16 Jul 2013 23:24:57 +0000 Subject: Wrote code that can get a dataset's type for every single GN dataset; previously we could not view traits in datasets that were not in the DBType table in the database --- wqflask/base/data_set.py | 90 +++++++++++++++++++++++++++++++++++++----------- wqflask/base/trait.py | 12 ++++--- 2 files changed, 77 insertions(+), 25 deletions(-) (limited to 'wqflask/base') diff --git a/wqflask/base/data_set.py b/wqflask/base/data_set.py index 03b24230..30221503 100755 --- a/wqflask/base/data_set.py +++ b/wqflask/base/data_set.py @@ -48,32 +48,67 @@ from MySQLdb import escape_string as escape from pprint import pformat as pf # Used by create_database to instantiate objects +# Each subclass will add to this DS_NAME_MAP = {} def create_dataset(dataset_name, dataset_type = None): - #print("dataset_name:", dataset_name) - + + print("dataset_type:", dataset_type) if not dataset_type: - query = """ - SELECT DBType.Name - FROM DBList, DBType - WHERE DBList.Name = '{}' and - DBType.Id = DBList.DBTypeId - """.format(escape(dataset_name)) - #print("query is: ", pf(query)) - dataset_type = g.db.execute(query).fetchone().Name + dataset_type = Dataset_Getter(dataset_name) + #dataset_type = get_dataset_type_from_json(dataset_name) - #dataset_type = cursor.fetchone()[0] - #print("[blubber] dataset_type:", pf(dataset_type)) + print("dataset_type is:", dataset_type) + #query = """ + # SELECT DBType.Name + # FROM DBList, DBType + # WHERE DBList.Name = '{}' and + # DBType.Id = DBList.DBTypeId + # """.format(escape(dataset_name)) + #dataset_type = g.db.execute(query).fetchone().Name - dataset_ob = DS_NAME_MAP[dataset_type] - #dataset_class = getattr(data_set, dataset_ob) - #print("dataset_ob:", dataset_ob) - #print("DS_NAME_MAP:", pf(DS_NAME_MAP)) + dataset_ob = DS_NAME_MAP[dataset_type] dataset_class = globals()[dataset_ob] return dataset_class(dataset_name) + +#def get_dataset_type_from_json(dataset_name): + +class Dataset_Types(object): + + def __init__(self): + self.datasets = {} + file_name = "wqflask/static/new/javascript/dataset_menu_structure.json" + with open(file_name, 'r') as fh: + data = json.load(fh) + + print("*" * 70) + for species in data['datasets']: + for group in data['datasets'][species]: + for dataset_type in data['datasets'][species][group]: + for dataset in data['datasets'][species][group][dataset_type]: + print("dataset is:", dataset) + + short_dataset_name = dataset[0] + if dataset_type == "Phenotypes": + new_type = "Publish" + elif dataset_type == "Genotypes": + new_type = "Geno" + else: + new_type = "ProbeSet" + self.datasets[short_dataset_name] = new_type + + def __call__(self, name): + return self.datasets[name] + +# Do the intensive work at startup one time only +Dataset_Getter = Dataset_Types() + +# +#print("Running at startup:", get_dataset_type_from_json("HBTRC-MLPFC_0611")) + + def create_datasets_list(): key = "all_datasets" result = Redis.get(key) @@ -212,7 +247,7 @@ class DatasetGroup(object): marker_class = Markers self.markers = marker_class(self.name) - + def get_f1_parent_strains(self): try: @@ -225,7 +260,7 @@ class DatasetGroup(object): self.f1list = [f1, f12] if maternal and paternal: self.parlist = [maternal, paternal] - + def read_genotype_file(self): '''Read genotype from .geno file instead of database''' #if self.group == 'BXD300': @@ -375,6 +410,9 @@ class PhenotypeDataSet(DataSet): DS_NAME_MAP['Publish'] = 'PhenotypeDataSet' def setup(self): + + print("IS A PHENOTYPEDATASET") + # Fields in the database table self.search_fields = ['Phenotype.Post_publication_description', 'Phenotype.Pre_publication_description', @@ -445,14 +483,24 @@ class PhenotypeDataSet(DataSet): def get_trait_info(self, trait_list, species = ''): for this_trait in trait_list: if not this_trait.haveinfo: - this_trait.retrieveInfo(QTL=1) + this_trait.retrieve_info(get_qtl_info=True) description = this_trait.post_publication_description + + #If the dataset is confidential and the user has access to confidential + #phenotype traits, then display the pre-publication description instead + #of the post-publication description if this_trait.confidential: continue # for now - if not webqtlUtil.hasAccessToConfidentialPhenotypeTrait(privilege=self.privilege, userName=self.userName, authorized_users=this_trait.authorized_users): + + if not webqtlUtil.hasAccessToConfidentialPhenotypeTrait( + privilege=self.privilege, + userName=self.userName, + authorized_users=this_trait.authorized_users): + description = this_trait.pre_publication_description - this_trait.description_display = unicode(description, "utf8") + + this_trait.description_display = description if not this_trait.year.isdigit(): this_trait.pubmed_text = "N/A" diff --git a/wqflask/base/trait.py b/wqflask/base/trait.py index db76ddea..6648047c 100755 --- a/wqflask/base/trait.py +++ b/wqflask/base/trait.py @@ -320,7 +320,11 @@ class GeneralTrait(object): #XZ: assign SQL query result to trait attributes. for i, field in enumerate(self.dataset.display_fields): print(" mike: {} -> {} - {}".format(field, type(trait_info[i]), trait_info[i])) - setattr(self, field, trait_info[i]) + holder = trait_info[i] + if isinstance(trait_info[i], basestring): + print("is basestring") + holder = unicode(trait_info[i], "utf8") + setattr(self, field, holder) if self.dataset.type == 'Publish': self.confidential = 0 @@ -329,9 +333,9 @@ class GeneralTrait(object): self.homologeneid = None - print("self.geneid is:", self.geneid) - print(" type:", type(self.geneid)) - print("self.dataset.group.name is:", self.dataset.group.name) + #print("self.geneid is:", self.geneid) + #print(" type:", type(self.geneid)) + #print("self.dataset.group.name is:", self.dataset.group.name) if self.dataset.type == 'ProbeSet' and self.dataset.group and self.geneid: #XZ, 05/26/2010: From time to time, this query get error message because some geneid values in database are not number. #XZ: So I have to test if geneid is number before execute the query. -- cgit v1.2.3 From 1a3a456eb7635337a966913f2e2e75c8a89bb92e Mon Sep 17 00:00:00 2001 From: Zachary Sloan Date: Wed, 17 Jul 2013 23:06:32 +0000 Subject: Fixed gen_select_dataset.py Appended redis installation info to notes --- misc/gn_installation_notes.txt | 40 +++++ wqflask/base/webqtlConfigLocal.py | 4 +- wqflask/maintenance/gen_select_dataset.py | 2 +- .../new/javascript/dataset_menu_structure.json | 176 ++++++++++----------- 4 files changed, 131 insertions(+), 91 deletions(-) (limited to 'wqflask/base') diff --git a/misc/gn_installation_notes.txt b/misc/gn_installation_notes.txt index 7545a5b8..913021db 100644 --- a/misc/gn_installation_notes.txt +++ b/misc/gn_installation_notes.txt @@ -181,6 +181,46 @@ ssh-keygen -l -f /etc/ssh/ssh_host_rsa_key ============================================ +Installing redis server + +In the dls directory: +$ wget http://redis.googlecode.com/files/redis-2.6.14.tar.gz +$ tar xzf redis-2.6.14.tar.gz +$ cd redis-2.6.14 +$ make + +Run redis (from inside redis-2.6.14 directory): +src/redis-server + +For the rest of the installation instructions, refer to: +http://redis.io/topics/quickstart + +To continue installation (from the README): + +In order to install Redis binaries into /usr/local/bin just use: + + % make install + +Make install will just install binaries in your system, but will not configure +init scripts and configuration files in the appropriate place. This is not +needed if you want just to play a bit with Redis, but if you are installing +it the proper way for a production system, we have a script doing this +for Ubuntu and Debian systems: + + % cd utils + % ./install_server + +The script will ask you a few questions and will setup everything you need +to run Redis properly as a background daemon that will start again on +system reboots. + +In the redis config file (/etc/redis/6379.conf) uncomment the following line: +bind 127.0.0.1 + +This is so only the local computer has access + +============================================ + Using Yolk Install Yolk: diff --git a/wqflask/base/webqtlConfigLocal.py b/wqflask/base/webqtlConfigLocal.py index abaeff93..cc53866b 100755 --- a/wqflask/base/webqtlConfigLocal.py +++ b/wqflask/base/webqtlConfigLocal.py @@ -5,12 +5,12 @@ MYSQL_SERVER = 'gn.cazhbciu2y1i.us-east-1.rds.amazonaws.com' DB_NAME = 'db_webqtl' DB_USER = 'webqtl' -DB_PASSWD = 'f2ZypIflRM' +DB_PASSWD = 'zK150dVzyvclGY5aCzavcK' MYSQL_UPDSERVER = 'gn.cazhbciu2y1i.us-east-1.rds.amazonaws.com' DB_UPDNAME = 'db_webqtl' DB_UPDUSER = 'webqtl' -DB_UPDPASSWD = 'f2ZypIflRM' +DB_UPDPASSWD = 'zK150dVzyvclGY5aCzavcK' GNROOT = '/home/zas1024/gene/' ROOT_URL = 'http://50.16.251.170' diff --git a/wqflask/maintenance/gen_select_dataset.py b/wqflask/maintenance/gen_select_dataset.py index 4c544192..b6bf5bfd 100644 --- a/wqflask/maintenance/gen_select_dataset.py +++ b/wqflask/maintenance/gen_select_dataset.py @@ -41,7 +41,6 @@ from pprint import pformat as pf from base import webqtlConfig - # build MySql database connection Con = MySQLdb.Connect(db=webqtlConfig.DB_NAME, host=webqtlConfig.MYSQL_SERVER, @@ -148,6 +147,7 @@ def build_datasets(species, group, type_name): def main(): """Generates and outputs (as json file) the data for the main dropdown menus on the home page""" + species = get_species() groups = get_groups(species) types = get_types(groups) diff --git a/wqflask/wqflask/static/new/javascript/dataset_menu_structure.json b/wqflask/wqflask/static/new/javascript/dataset_menu_structure.json index 88bdcb11..a4d88ab2 100644 --- a/wqflask/wqflask/static/new/javascript/dataset_menu_structure.json +++ b/wqflask/wqflask/static/new/javascript/dataset_menu_structure.json @@ -63,14 +63,14 @@ ] ], "Leaf": [ - [ - "B1LI0809M5", - "Barley1 Leaf INOC TTKS (Aug09) MAS5" - ], [ "B1LI0809R", "Barley1 Leaf INOC TTKS (Aug09) RMA" ], + [ + "B1LI0809M5", + "Barley1 Leaf INOC TTKS (Aug09) MAS5" + ], [ "B1MI0809M5", "Barley1 Leaf MOCK TTKS (Aug09) MAS5" @@ -113,13 +113,13 @@ "B30_K_1206_M", "Barley1 Leaf MAS 5.0 SCRI (Dec06)" ], - [ - "B30_K_1206_R", - "Barley1 Leaf gcRMA SCRI (Dec06)" - ], [ "B30_K_1206_Rn", "Barley1 Leaf gcRMAn SCRI (Dec06)" + ], + [ + "B30_K_1206_R", + "Barley1 Leaf gcRMA SCRI (Dec06)" ] ], "Phenotypes": [ @@ -211,14 +211,14 @@ }, "AD-cases-controls-Myers": { "Brain": [ - [ - "GSE15222_F_N_RI_0409", - "GSE15222 Human Brain Normal Myers (Apr09) RankInv" - ], [ "GSE15222_F_A_RI_0409", "GSE15222 Human Brain Alzheimer Myers (Apr09) RankInv" ], + [ + "GSE15222_F_N_RI_0409", + "GSE15222 Human Brain Normal Myers (Apr09) RankInv" + ], [ "GSE15222_F_RI_0409", "GSE15222 Human Brain Myers (Apr09) RankInv" @@ -547,13 +547,13 @@ "NCI_Agil_Mam_Tum_RMA_0409", "NCI Mammary LMT miRNA v2 (Apr09) RMA" ], - [ - "MA_M_0704_M", - "NCI Mammary mRNA M430 (July04) MAS5" - ], [ "MA_M_0704_R", "NCI Mammary mRNA M430 (July04) RMA" + ], + [ + "MA_M_0704_M", + "NCI Mammary mRNA M430 (July04) MAS5" ] ], "Phenotypes": [ @@ -597,13 +597,13 @@ ] ], "Liver": [ - [ - "LVF2_M_0704_M", - "(B6 x BTBR)F2-ob/ob Liver mRNA M430 (Jul04) MAS5" - ], [ "LVF2_M_0704_R", "(B6 x BTBR)F2-ob/ob Liver mRNA M430 (Jul04) RMA" + ], + [ + "LVF2_M_0704_M", + "(B6 x BTBR)F2-ob/ob Liver mRNA M430 (Jul04) MAS5" ] ], "Phenotypes": [ @@ -631,13 +631,13 @@ "BRF2_M_0304_P", "OHSU/VA B6D2F2 Brain mRNA M430A (Mar04) PDNN" ], - [ - "BRF2_M_0304_M", - "OHSU/VA B6D2F2 Brain mRNA M430A (Mar04) MAS5" - ], [ "BRF2_M_0304_R", "OHSU/VA B6D2F2 Brain mRNA M430A (Mar04) RMA" + ], + [ + "BRF2_M_0304_M", + "OHSU/VA B6D2F2 Brain mRNA M430A (Mar04) MAS5" ] ], "Genotypes": [ @@ -727,6 +727,10 @@ ] ], "Striatum": [ + [ + "SA_M2_0905_R", + "OHSU/VA B6D2F2 Striatum M430v2 (Sep05) RMA" + ], [ "SA_M2_0905_M", "OHSU/VA B6D2F2 Striatum M430v2 (Sep05) MAS5" @@ -734,37 +738,33 @@ [ "SA_M2_0905_P", "OHSU/VA B6D2F2 Striatum M430v2 (Sep05) PDNN" - ], - [ - "SA_M2_0905_R", - "OHSU/VA B6D2F2 Striatum M430v2 (Sep05) RMA" ] ] }, "BHF2": { "Adipose": [ - [ - "UCLA_BHF2_ADIPOSE_FEMALE", - "UCLA BHF2 Adipose Female mlratio" - ], [ "UCLA_BHF2_ADIPOSE_MALE", "UCLA BHF2 Adipose Male mlratio" ], + [ + "UCLA_BHF2_ADIPOSE_FEMALE", + "UCLA BHF2 Adipose Female mlratio" + ], [ "UCLA_BHF2_ADIPOSE_0605", "UCLA BHF2 Adipose (June05) mlratio" ] ], "Brain": [ - [ - "UCLA_BHF2_BRAIN_FEMALE", - "UCLA BHF2 Brain Female mlratio" - ], [ "UCLA_BHF2_BRAIN_MALE", "UCLA BHF2 Brain Male mlratio" ], + [ + "UCLA_BHF2_BRAIN_FEMALE", + "UCLA BHF2 Brain Female mlratio" + ], [ "UCLA_BHF2_BRAIN_0605", "UCLA BHF2 Brain (June05) mlratio" @@ -777,28 +777,28 @@ ] ], "Liver": [ - [ - "UCLA_BHF2_LIVER_FEMALE", - "UCLA BHF2 Liver Female mlratio" - ], [ "UCLA_BHF2_LIVER_MALE", "UCLA BHF2 Liver Male mlratio" ], + [ + "UCLA_BHF2_LIVER_FEMALE", + "UCLA BHF2 Liver Female mlratio" + ], [ "UCLA_BHF2_LIVER_0605", "UCLA BHF2 Liver (June05) mlratio" ] ], "Muscle": [ - [ - "UCLA_BHF2_MUSCLE_FEMALE", - "UCLA BHF2 Muscle Female mlratio **" - ], [ "UCLA_BHF2_MUSCLE_MALE", "UCLA BHF2 Muscle Male mlratio **" ], + [ + "UCLA_BHF2_MUSCLE_FEMALE", + "UCLA BHF2 Muscle Female mlratio **" + ], [ "UCLA_BHF2_MUSCLE_0605", "UCLA BHF2 Muscle (June05) mlratio **" @@ -923,6 +923,10 @@ "BR_U_1105_P", "UTHSC Brain mRNA U74Av2 (Nov05) PDNN" ], + [ + "BR_U_0805_M", + "UTHSC Brain mRNA U74Av2 (Aug05) MAS5" + ], [ "BR_U_0805_R", "UTHSC Brain mRNA U74Av2 (Aug05) RMA" @@ -931,10 +935,6 @@ "BR_U_0805_P", "UTHSC Brain mRNA U74Av2 (Aug05) PDNN" ], - [ - "BR_U_0805_M", - "UTHSC Brain mRNA U74Av2 (Aug05) MAS5" - ], [ "CB_M_0204_P", "INIA Brain mRNA M430 (Feb04) PDNN" @@ -955,6 +955,10 @@ ] ], "Cerebellum": [ + [ + "CB_M_1004_M", + "SJUT Cerebellum mRNA M430 (Oct04) MAS5" + ], [ "CB_M_1004_R", "SJUT Cerebellum mRNA M430 (Oct04) RMA" @@ -963,10 +967,6 @@ "CB_M_1004_P", "SJUT Cerebellum mRNA M430 (Oct04) PDNN" ], - [ - "CB_M_1004_M", - "SJUT Cerebellum mRNA M430 (Oct04) MAS5" - ], [ "CB_M_1003_M", "SJUT Cerebellum mRNA M430 (Oct03) MAS5" @@ -1131,13 +1131,13 @@ "MA_M2_0806_P", "Mouse Kidney M430v2 Sex Balanced (Aug06) PDNN" ], - [ - "MA_M2_0706_R", - "Mouse Kidney M430v2 (Jul06) RMA" - ], [ "MA_M2_0706_P", "Mouse Kidney M430v2 (Jul06) PDNN" + ], + [ + "MA_M2_0706_R", + "Mouse Kidney M430v2 (Jul06) RMA" ] ], "Leucocytes": [ @@ -1155,6 +1155,10 @@ "GenEx_BXD_liverEt_M5_0912", "GenEx BXD EtOH Liver Affy M430 2.0 (Sep12) MAS5 Both Sexes **" ], + [ + "GenEx_BXD_liverSal_RMA_F_0211", + "GenEx BXD Sal Liver Affy M430 2.0 (Feb11) RMA Females **" + ], [ "GenEx_BXD_liverEt_M5F_0912", "GenEx BXD EtOH Liver Affy M430 2.0 (Sep12) MAS5 Females **" @@ -1163,10 +1167,6 @@ "GenEx_BXD_liverEt_M5M_0912", "GenEx BXD EtOH Liver Affy M430 2.0 (Sep12) MAS5 Males **" ], - [ - "GenEx_BXD_liverSal_RMA_F_0211", - "GenEx BXD Sal Liver Affy M430 2.0 (Feb11) RMA Females **" - ], [ "GenEx_BXD_liverSal_RMA_M_0211", "GenEx BXD Sal Liver Affy M430 2.0 (Feb11) RMA Males **" @@ -1227,14 +1227,14 @@ ] ], "Neocortex": [ - [ - "DevNeocortex_ILM6.2P3RInv_1111", - "BIDMC/UTHSC Dev Neocortex P3 ILMv6.2 (Nov11) RankInv" - ], [ "DevNeocortex_ILM6.2P14RInv_1111", "BIDMC/UTHSC Dev Neocortex P14 ILMv6.2 (Nov11) RankInv" ], + [ + "DevNeocortex_ILM6.2P3RInv_1111", + "BIDMC/UTHSC Dev Neocortex P3 ILMv6.2 (Nov11) RankInv" + ], [ "HQFNeoc_1210v2_RankInv", "HQF BXD Neocortex ILM6v1.1 (Dec10v2) RankInv" @@ -1247,13 +1247,13 @@ "HQFNeoc_0208_RankInv", "HQF BXD Neocortex ILM6v1.1 (Feb08) RankInv" ], - [ - "DevNeocortex_ILM6.2P14RInv_1110", - "BIDMC/UTHSC Dev Neocortex P14 ILMv6.2 (Nov10) RankInv" - ], [ "DevNeocortex_ILM6.2P3RInv_1110", "BIDMC/UTHSC Dev Neocortex P3 ILMv6.2 (Nov10) RankInv" + ], + [ + "DevNeocortex_ILM6.2P14RInv_1110", + "BIDMC/UTHSC Dev Neocortex P14 ILMv6.2 (Nov10) RankInv" ] ], "Nucleus Accumbens": [ @@ -1293,6 +1293,10 @@ ] ], "Prefrontal Cortex": [ + [ + "VCUEtOH_1206_R", + "VCU BXD PFC EtOH M430 2.0 (Dec06) RMA" + ], [ "VCUSal_1206_R", "VCU BXD PFC Sal M430 2.0 (Dec06) RMA" @@ -1301,10 +1305,6 @@ "VCUSal_1006_R", "VCU BXD PFC Et vs Sal M430 2.0 (Dec06) Sscore" ], - [ - "VCUEtOH_1206_R", - "VCU BXD PFC EtOH M430 2.0 (Dec06) RMA" - ], [ "VCU_PF_Air_0111_R", "VCU BXD PFC CIE Air M430 2.0 (Jan11) RMA **" @@ -1447,6 +1447,10 @@ ] ], "Ventral Tegmental Area": [ + [ + "VCUEtOH_0609_R", + "VCU BXD VTA EtOH M430 2.0 (Jun09) RMA **" + ], [ "VCUSal_0609_R", "VCU BXD VTA Sal M430 2.0 (Jun09) RMA **" @@ -1454,10 +1458,6 @@ [ "VCUEtvsSal_0609_R", "VCU BXD VTA Et vs Sal M430 2.0 (Jun09) Sscore **" - ], - [ - "VCUEtOH_0609_R", - "VCU BXD VTA EtOH M430 2.0 (Jun09) RMA **" ] ] }, @@ -1573,13 +1573,13 @@ ] ], "Hippocampus": [ - [ - "HC_M2CB_1205_P", - "Hippocampus Consortium M430v2 CXB (Dec05) PDNN" - ], [ "HC_M2CB_1205_R", "Hippocampus Consortium M430v2 CXB (Dec05) RMA" + ], + [ + "HC_M2CB_1205_P", + "Hippocampus Consortium M430v2 CXB (Dec05) PDNN" ] ], "Phenotypes": [ @@ -1711,6 +1711,10 @@ ] ], "Prefrontal Cortex": [ + [ + "VCUEtOH_0806_R", + "VCU LXS PFC EtOH M430A 2.0 (Aug06) RMA **" + ], [ "VCUSal_0806_R", "VCU LXS PFC Sal M430A 2.0 (Aug06) RMA" @@ -1718,10 +1722,6 @@ [ "VCUEt_vs_Sal_0806_R", "VCU LXS PFC Et vs Sal M430A 2.0 (Aug06) Sscore **" - ], - [ - "VCUEtOH_0806_R", - "VCU LXS PFC EtOH M430A 2.0 (Aug06) RMA **" ] ] }, @@ -1733,13 +1733,13 @@ ] ], "Hippocampus": [ - [ - "HC_M2_0606_MDP", - "Hippocampus Consortium M430v2 (Jun06) RMA MDP" - ], [ "UMUTAffyExon_0209_RMA_MDP", "UMUTAffy Hippocampus Exon (Feb09) RMA MDP" + ], + [ + "HC_M2_0606_MDP", + "Hippocampus Consortium M430v2 (Jun06) RMA MDP" ] ], "Liver": [ -- cgit v1.2.3