diff options
25 files changed, 237 insertions, 71 deletions
diff --git a/doc/API_readme.md b/doc/API_readme.md index 652376a0..be6668dc 100644 --- a/doc/API_readme.md +++ b/doc/API_readme.md @@ -6,17 +6,17 @@ To get a list of species with data available in GN (and their associated names and ids): ``` -curl http://gn2.genenetwork.org/api/v_pre1/species +curl http://genenetwork.org/api/v_pre1/species [ { "FullName": "Mus musculus", "Id": 1, "Name": "mouse", "TaxonomyId": 10090 }, ... { "FullName": "Populus trichocarpa", "Id": 10, "Name": "poplar", "TaxonomyId": 3689 } ] ``` Or to get a single species info: ``` -curl http://gn2.genenetwork.org/api/v_pre1/species/mouse +curl http://genenetwork.org/api/v_pre1/species/mouse ``` OR ``` -curl http://gn2.genenetwork.org/api/v_pre1/species/mouse.json +curl http://genenetwork.org/api/v_pre1/species/mouse.json ``` *For all queries where the last field is a user-specified name/ID, there will be the option to append a file format type. Currently there is only JSON (and it will default to JSON if none is provided), but other formats will be added later* @@ -26,33 +26,33 @@ curl http://gn2.genenetwork.org/api/v_pre1/species/mouse.json This query can optionally filter by species: ``` -curl http://gn2.genenetwork.org/api/v_pre1/groups (for all species) +curl http://genenetwork.org/api/v_pre1/groups (for all species) ``` OR ``` -curl http://gn2.genenetwork.org/api/v_pre1/groups/mouse (for just mouse groups/RISets) +curl http://genenetwork.org/api/v_pre1/groups/mouse (for just mouse groups/RISets) [ { "DisplayName": "BXD", "FullName": "BXD RI Family", "GeneticType": "riset", "Id": 1, "MappingMethodId": "1", "Name": "BXD", "SpeciesId": 1, "public": 2 }, ... { "DisplayName": "AIL LGSM F34 and F39-43 (GBS)", "FullName": "AIL LGSM F34 and F39-43 (GBS)", "GeneticType": "intercross", "Id": 72, "MappingMethodId": "2", "Name": "AIL-LGSM-F34-F39-43-GBS", "SpeciesId": 1, "public": 2 } ] ``` ## Fetch Genotypes for Group/RISet ## ``` -curl http://gn2.genenetwork.org/api/v_pre1/genotypes/bimbam/BXD -curl http://gn2.genenetwork.org/api/v_pre1/genotypes/BXD.bimbam +curl http://genenetwork.org/api/v_pre1/genotypes/bimbam/BXD +curl http://genenetwork.org/api/v_pre1/genotypes/BXD.bimbam ``` Returns a group's genotypes in one of several formats - bimbam, rqtl2, or geno (a format used by qtlreaper which is just a CSV file consisting of marker positions and genotypes) Rqtl2 genotype queries can also include the dataset name and will return a zip of the genotypes, phenotypes, and gene map (marker names/positions). For example: ``` -curl http://gn2.genenetwork.org/api/v_pre1/genotypes/rqtl2/BXD/HC_M2_0606_P.zip +curl http://genenetwork.org/api/v_pre1/genotypes/rqtl2/BXD/HC_M2_0606_P.zip ``` ## Fetch Datasets ## ``` -curl http://gn2.genenetwork.org/api/v_pre1/datasets/bxd +curl http://genenetwork.org/api/v_pre1/datasets/bxd ``` OR ``` -curl http://gn2.genenetwork.org/api/v_pre1/datasets/mouse/bxd +curl http://genenetwork.org/api/v_pre1/datasets/mouse/bxd [ { "AvgID": 1, "CreateTime": "Fri, 01 Aug 2003 00:00:00 GMT", "DataScale": "log2", "FullName": "UTHSC/ETHZ/EPFL BXD Liver Polar Metabolites Extraction A, CD Cohorts (Mar 2017) log2", "Id": 1, "Long_Abbreviation": "BXDMicroArray_ProbeSet_August03", "ProbeFreezeId": 3, "ShortName": "Brain U74Av2 08/03 MAS5", "Short_Abbreviation": "Br_U_0803_M", "confidentiality": 0, "public": 0 }, ... { "AvgID": 3, "CreateTime": "Tue, 14 Aug 2018 00:00:00 GMT", "DataScale": "log2", "FullName": "EPFL/LISP BXD CD Liver Affy Mouse Gene 1.0 ST (Aug18) RMA", "Id": 859, "Long_Abbreviation": "EPFLMouseLiverCDRMAApr18", "ProbeFreezeId": 181, "ShortName": "EPFL/LISP BXD CD Liver Affy Mouse Gene 1.0 ST (Aug18) RMA", "Short_Abbreviation": "EPFLMouseLiverCDRMA0818", "confidentiality": 0, "public": 1 } ] ``` (I added the option to specify species just in case we end up with the same group name across multiple species at some point, though it's currently unnecessary) @@ -61,11 +61,11 @@ curl http://gn2.genenetwork.org/api/v_pre1/datasets/mouse/bxd ### For mRNA Assay/"ProbeSet" ### ``` -curl http://gn2.genenetwork.org/api/v_pre1/dataset/HC_M2_0606_P +curl http://genenetwork.org/api/v_pre1/dataset/HC_M2_0606_P ``` OR ``` -curl http://gn2.genenetwork.org/api/v_pre1/dataset/bxd/HC_M2_0606_P``` +curl http://genenetwork.org/api/v_pre1/dataset/bxd/HC_M2_0606_P``` { "confidential": 0, "data_scale": "log2", "dataset_type": "mRNA expression", "full_name": "Hippocampus Consortium M430v2 (Jun06) PDNN", "id": 112, "name": "HC_M2_0606_P", "public": 2, "short_name": "Hippocampus M430v2 BXD 06/06 PDNN", "tissue": "Hippocampus mRNA", "tissue_id": 9 } ``` (This also has the option to specify group/riset) @@ -73,26 +73,26 @@ curl http://gn2.genenetwork.org/api/v_pre1/dataset/bxd/HC_M2_0606_P``` ### For "Phenotypes" (basically non-mRNA Expression; stuff like weight, sex, etc) ### For these traits, the query fetches publication info and takes the group and phenotype 'ID' as input. For example: ``` -curl http://gn2.genenetwork.org/api/v_pre1/dataset/bxd/10001 +curl http://genenetwork.org/api/v_pre1/dataset/bxd/10001 { "dataset_type": "phenotype", "description": "Central nervous system, morphology: Cerebellum weight, whole, bilateral in adults of both sexes [mg]", "id": 10001, "name": "CBLWT2", "pubmed_id": 11438585, "title": "Genetic control of the mouse cerebellum: identification of quantitative trait loci modulating size and architecture", "year": "2001" } ``` ## Fetch Sample Data for Dataset ## ``` -curl http://gn2.genenetwork.org/api/v_pre1/sample_data/HSNIH-PalmerPublish.csv +curl http://genenetwork.org/api/v_pre1/sample_data/HSNIH-PalmerPublish.csv ``` Returns a CSV file with sample/strain names as the columns and trait IDs as rows ## Fetch Sample Data for Single Trait ## ``` -curl http://gn2.genenetwork.org/api/v_pre1/sample_data/HC_M2_0606_P/1436869_at +curl http://genenetwork.org/api/v_pre1/sample_data/HC_M2_0606_P/1436869_at [ { "data_id": 23415463, "sample_name": "129S1/SvImJ", "sample_name_2": "129S1/SvImJ", "se": 0.123, "value": 8.201 }, { "data_id": 23415463, "sample_name": "A/J", "sample_name_2": "A/J", "se": 0.046, "value": 8.413 }, { "data_id": 23415463, "sample_name": "AKR/J", "sample_name_2": "AKR/J", "se": 0.134, "value": 8.856 }, ... ] ``` ## Fetch Trait List for Dataset ## ``` -curl http://gn2.genenetwork.org/api/v_pre1/traits/HXBBXHPublish.json +curl http://genenetwork.org/api/v_pre1/traits/HXBBXHPublish.json [ { "Additive": 0.0499967532467532, "Id": 10001, "LRS": 16.2831307029479, "Locus": "rs106114574", "PhenotypeId": 1449, "PublicationId": 319, "Sequence": 1 }, ... ] ``` @@ -101,7 +101,7 @@ Both JSON and CSV formats can be specified, with JSON as default. There is also ## Fetch Trait Info (Name, Description, Location, etc) ## ### For mRNA Expression/"ProbeSet" ### ``` -curl http://gn2.genenetwork.org/api/v_pre1/trait/HC_M2_0606_P/1436869_at +curl http://genenetwork.org/api/v_pre1/trait/HC_M2_0606_P/1436869_at { "additive": -0.214087568058076, "alias": "HHG1; HLP3; HPE3; SMMCI; Dsh; Hhg1", "chr": "5", "description": "sonic hedgehog (hedgehog)", "id": 99602, "locus": "rs8253327", "lrs": 12.7711275309832, "mb": 28.457155, "mean": 9.27909090909091, "name": "1436869_at", "p_value": 0.306, "se": null, "symbol": "Shh" } ``` @@ -110,7 +110,7 @@ For phenotypes this just gets the max LRS, its location, and additive effect (a Since each group/riset only has one phenotype "dataset", this query takes either the group/riset name or the group/riset name + "Publish" (for example "BXDPublish", which is the dataset name in the DB) as input ``` -curl http://gn2.genenetwork.org/api/v_pre1/trait/BXD/10001 +curl http://genenetwork.org/api/v_pre1/trait/BXD/10001 { "additive": 2.39444435069444, "id": 4, "locus": "rs48756159", "lrs": 13.4974911471087 } ``` @@ -130,7 +130,7 @@ Each method's query takes the following parameters respectively (more will be ad Example query: ``` -curl http://gn2.genenetwork.org/api/v_pre1/mapping?trait_id=10015&db=BXDPublish&method=gemma&use_loco=true +curl http://genenetwork.org/api/v_pre1/mapping?trait_id=10015&db=BXDPublish&method=gemma&use_loco=true ``` ### R/qtl ### @@ -146,7 +146,7 @@ curl http://gn2.genenetwork.org/api/v_pre1/mapping?trait_id=10015&db=BXDPublish& Example query: ``` -curl http://gn2.genenetwork.org/api/v_pre1/mapping?trait_id=1418701_at&db=HC_M2_0606_P&method=rqtl&num_perm=100 +curl http://genenetwork.org/api/v_pre1/mapping?trait_id=1418701_at&db=HC_M2_0606_P&method=rqtl&num_perm=100 ``` Some combinations of methods/models may not make sense. The R/qtl manual should be referred to for any questions on its use (specifically the scanone function in this case) @@ -164,6 +164,6 @@ This query currently takes the following parameters (though more will be added): Example query: ``` -curl http://gn2.genenetwork.org/api/v_pre1/correlation?trait_id=1427571_at&db=HC_M2_0606_P&target_db=BXDPublish&type=sample&return_count=100 +curl http://genenetwork.org/api/v_pre1/correlation?trait_id=1427571_at&db=HC_M2_0606_P&target_db=BXDPublish&type=sample&return_count=100 [ { "#_strains": 6, "p_value": 0.004804664723032055, "sample_r": -0.942857142857143, "trait": 20511 }, { "#_strains": 6, "p_value": 0.004804664723032055, "sample_r": -0.942857142857143, "trait": 20724 }, { "#_strains": 12, "p_value": 1.8288943424888848e-05, "sample_r": -0.9233615170820528, "trait": 13536 }, { "#_strains": 7, "p_value": 0.006807187408935392, "sample_r": 0.8928571428571429, "trait": 10157 }, { "#_strains": 7, "p_value": 0.006807187408935392, "sample_r": -0.8928571428571429, "trait": 20392 }, ... ] ``` diff --git a/wqflask/base/data_set.py b/wqflask/base/data_set.py index ebf3f021..8652e6b7 100644 --- a/wqflask/base/data_set.py +++ b/wqflask/base/data_set.py @@ -56,7 +56,7 @@ from pprint import pformat as pf from db.gn_server import menu_main from db.call import fetchall,fetchone,fetch1 -from utility.tools import USE_GN_SERVER, USE_REDIS, flat_files, flat_file_exists +from utility.tools import USE_GN_SERVER, USE_REDIS, flat_files, flat_file_exists, GN2_BASE_URL from utility.logger import getLogger logger = getLogger(__name__ ) @@ -67,7 +67,6 @@ DS_NAME_MAP = {} def create_dataset(dataset_name, rebuild=True, dataset_type = None, get_samplelist = True, group_name = None): if not dataset_type: dataset_type = Dataset_Getter(dataset_name) - logger.debug("dataset_type", dataset_type) dataset_ob = DS_NAME_MAP[dataset_type] dataset_class = globals()[dataset_ob] @@ -95,8 +94,7 @@ Publish or ProbeSet. E.g. """ self.datasets = {} if rebuild: #ZS: May make this the only option - data = json.loads(requests.get("http://gn2.genenetwork.org/api/v_pre1/gen_dropdown").content) - logger.debug("THE DATA:", data) + data = json.loads(requests.get(GN2_BASE_URL + "/api/v_pre1/gen_dropdown").content) #data = gen_menu.gen_dropdown_json() else: file_name = "wqflask/static/new/javascript/dataset_menu_structure.json" @@ -120,7 +118,65 @@ Publish or ProbeSet. E.g. logger.debugf(5, "datasets",self.datasets) def __call__(self, name): - return self.datasets[name] + if name not in self.datasets: + mrna_expr_query = """ + SELECT + ProbeSetFreeze.Id + FROM + ProbeSetFreeze + WHERE + ProbeSetFreeze.Name = "{0}" + """.format(name) + + results = g.db.execute(geno_query).fetchall() + if len(results): + self.datasets[name] = "ProbeSet" + return self.datasets[name] + + group_name = name.replace("Publish", "") + + pheno_query = """SELECT InfoFiles.GN_AccesionId + FROM InfoFiles, PublishFreeze, InbredSet + WHERE InbredSet.Name = '{0}' AND + PublishFreeze.InbredSetId = InbredSet.Id AND + InfoFiles.InfoPageName = PublishFreeze.Name""".format(group_name) + + results = g.db.execute(pheno_query).fetchall() + if len(results): + self.datasets[name] = "Publish" + return self.datasets[name] + + #ZS: For when there isn't an InfoFiles ID; not sure if this and the preceding query are both necessary + other_pheno_query = """SELECT PublishFreeze.Name + FROM PublishFreeze, InbredSet + WHERE InbredSet.Name = '{}' AND + PublishFreeze.InbredSetId = InbredSet.Id""".format(group_name) + + results = g.db.execute(other_pheno_query).fetchall() + if len(results): + self.datasets[name] = "Publish" + return self.datasets[name] + + geno_query = """ + SELECT + GenoFreezeId + FROM + GenoFreeze + WHERE + GenoFreeze.Name = "{0}" + {1} + """.format(name) + + results = g.db.execute(geno_query).fetchall() + if len(results): + self.datasets[name] = "Geno" + return self.datasets[name] + + #ZS: It shouldn't ever reach this + return None + + else: + return self.datasets[name] # Do the intensive work at startup one time only Dataset_Getter = Dataset_Types() diff --git a/wqflask/base/trait.py b/wqflask/base/trait.py index 5525472e..e454c593 100644 --- a/wqflask/base/trait.py +++ b/wqflask/base/trait.py @@ -14,6 +14,7 @@ from base.data_set import create_dataset from db import webqtlDatabaseFunction from utility import webqtlUtil from utility import hmac +from utility.tools import GN2_BASE_URL from wqflask import app @@ -135,9 +136,9 @@ class GeneralTrait(object): alias = 'Not available' if self.symbol: - human_response = requests.get("http://gn2.genenetwork.org/gn3/gene/aliases/" + self.symbol.upper()) - mouse_response = requests.get("http://gn2.genenetwork.org/gn3/gene/aliases/" + self.symbol.capitalize()) - other_response = requests.get("http://gn2.genenetwork.org/gn3/gene/aliases/" + self.symbol.lower()) + human_response = requests.get(GN2_BASE_URL + "gn3/gene/aliases/" + self.symbol.upper()) + mouse_response = requests.get(GN2_BASE_URL + "gn3/gene/aliases/" + self.symbol.capitalize()) + other_response = requests.get(GN2_BASE_URL + "gn3/gene/aliases/" + self.symbol.lower()) if human_response and mouse_response and other_response: alias_list = json.loads(human_response.content) + json.loads(mouse_response.content) + json.loads(other_response.content) diff --git a/wqflask/utility/tools.py b/wqflask/utility/tools.py index 0fbedccb..9354ece6 100644 --- a/wqflask/utility/tools.py +++ b/wqflask/utility/tools.py @@ -234,6 +234,8 @@ def show_settings(): GN_VERSION = get_setting('GN_VERSION') HOME = get_setting('HOME') WEBSERVER_MODE = get_setting('WEBSERVER_MODE') +GN2_BASE_URL = get_setting('GN2_BASE_URL') +GN2_BRANCH_URL = get_setting('GN2_BRANCH_URL') GN_SERVER_URL = get_setting('GN_SERVER_URL') SERVER_PORT = get_setting_int('SERVER_PORT') SQL_URI = get_setting('SQL_URI') diff --git a/wqflask/wqflask/api/gen_menu.py b/wqflask/wqflask/api/gen_menu.py index 7d2d243c..64a413c2 100644 --- a/wqflask/wqflask/api/gen_menu.py +++ b/wqflask/wqflask/api/gen_menu.py @@ -47,7 +47,6 @@ def get_species(): """Build species list""" results = g.db.execute("""SELECT Name, MenuName FROM Species - WHERE Species.Name != 'macaque monkey' ORDER BY OrderId""").fetchall() species = [] diff --git a/wqflask/wqflask/ctl/ctl_analysis.py b/wqflask/wqflask/ctl/ctl_analysis.py index 6fda02fd..4415b86a 100644 --- a/wqflask/wqflask/ctl/ctl_analysis.py +++ b/wqflask/wqflask/ctl/ctl_analysis.py @@ -20,7 +20,7 @@ from base import data_set from base import trait as TRAIT from utility import helper_functions -from utility.tools import locate +from utility.tools import locate, GN2_BRANCH_URL from rpy2.robjects.packages import importr @@ -56,6 +56,8 @@ class CTL(object): self.edges_list = [] logger.info("Obtained pointers to CTL functions") + self.gn2_url = GN2_BRANCH_URL + def addNode(self, gt): node_dict = { 'data' : {'id' : str(gt.name) + ":" + str(gt.dataset.name), 'sid' : str(gt.name), diff --git a/wqflask/wqflask/do_search.py b/wqflask/wqflask/do_search.py index 05caa100..b0ca5ced 100644 --- a/wqflask/wqflask/do_search.py +++ b/wqflask/wqflask/do_search.py @@ -13,6 +13,7 @@ import sys # sys.path.append("..") Never in a running webserver from db import webqtlDatabaseFunction +from utility.tools import GN2_BASE_URL import logging from utility.logger import getLogger @@ -919,7 +920,7 @@ def get_aliases(symbol, species): return [] filtered_aliases = [] - response = requests.get("http://gn2.genenetwork.org/gn3/gene/aliases/" + symbol_string) + response = requests.get(GN2_BASE_URL + "/gn3/gene/aliases/" + symbol_string) if response: alias_list = json.loads(response.content) diff --git a/wqflask/wqflask/marker_regression/display_mapping_results.py b/wqflask/wqflask/marker_regression/display_mapping_results.py index a7e11738..2a53b60e 100644 --- a/wqflask/wqflask/marker_regression/display_mapping_results.py +++ b/wqflask/wqflask/marker_regression/display_mapping_results.py @@ -166,6 +166,7 @@ class DisplayMappingResults(object): #Needing for form submission when doing single chr mapping or remapping after changing options self.samples = start_vars['samples'] self.vals = start_vars['vals'] + self.transform = start_vars['transform'] self.mapping_method = start_vars['mapping_method'] self.mapping_results_path = start_vars['mapping_results_path'] if self.mapping_method == "rqtl_geno": @@ -233,6 +234,8 @@ class DisplayMappingResults(object): self.covariates = start_vars['covariates'] if 'maf' in start_vars.keys(): self.maf = start_vars['maf'] + else: + self.maf = "" if 'output_files' in start_vars.keys(): self.output_files = start_vars['output_files'] if 'use_loco' in start_vars.keys() and self.mapping_method == "gemma": diff --git a/wqflask/wqflask/marker_regression/rqtl_mapping.py b/wqflask/wqflask/marker_regression/rqtl_mapping.py index aae8e602..e1aa290b 100644 --- a/wqflask/wqflask/marker_regression/rqtl_mapping.py +++ b/wqflask/wqflask/marker_regression/rqtl_mapping.py @@ -36,7 +36,10 @@ def run_rqtl_geno(vals, samples, dataset, method, model, permCheck, num_perm, pe generate_cross_from_geno(dataset) GENOtoCSVR = ro.r["GENOtoCSVR"] # Map the local GENOtoCSVR function crossfilelocation = TMPDIR + crossname + ".cross" - genofilelocation = locate(dataset.group.genofile, "genotype") + if dataset.group.genofile: + genofilelocation = locate(dataset.group.genofile, "genotype") + else: + genofilelocation = locate(dataset.group.name + ".geno", "genotype") cross_object = GENOtoCSVR(genofilelocation, crossfilelocation) # TODO: Add the SEX if that is available if manhattan_plot: @@ -91,9 +94,11 @@ def run_rqtl_geno(vals, samples, dataset, method, model, permCheck, num_perm, pe perm_data_frame = scanone(cross_object, pheno_col = "the_pheno", n_perm = num_perm, model=model, method=method) perm_output, suggestive, significant = process_rqtl_perm_results(num_perm, perm_data_frame) # Functions that sets the thresholds for the webinterface - return perm_output, suggestive, significant, process_rqtl_results(result_data_frame, dataset.group.species) + the_scale = check_mapping_scale(genofilelocation) + return perm_output, suggestive, significant, process_rqtl_results(result_data_frame, dataset.group.species), the_scale else: - return process_rqtl_results(result_data_frame, dataset.group.species) + the_scale = check_mapping_scale(genofilelocation) + return process_rqtl_results(result_data_frame, dataset.group.species), the_scale def generate_cross_from_rdata(dataset): rdata_location = locate(dataset.group.name + ".RData", "genotype/rdata") @@ -286,4 +291,20 @@ def process_rqtl_results(result, species_name): # TODO: how to make this marker['lod_score'] = output[i][2] qtl_results.append(marker) - return qtl_results
\ No newline at end of file + return qtl_results + +def check_mapping_scale(genofile_location): + scale = "physic" + with open(genofile_location, "r") as geno_fh: + for line in geno_fh: + if line[0] == "@" or line[0] == "#": + + if "@scale" in line: + scale = line.split(":")[1].strip() + break + else: + continue + else: + break + + return scale
\ No newline at end of file diff --git a/wqflask/wqflask/marker_regression/run_mapping.py b/wqflask/wqflask/marker_regression/run_mapping.py index e191902c..589be702 100644 --- a/wqflask/wqflask/marker_regression/run_mapping.py +++ b/wqflask/wqflask/marker_regression/run_mapping.py @@ -150,6 +150,10 @@ class RunMapping(object): self.suggestive = "" self.significant = "" self.pair_scan = False # Initializing this since it is checked in views to determine which template to use + if 'transform' in start_vars: + self.transform = start_vars['transform'] + else: + self.transform = "" self.score_type = "LRS" #ZS: LRS or LOD self.mapping_scale = "physic" self.num_perm = 0 @@ -241,7 +245,6 @@ class RunMapping(object): perm_strata = get_perm_strata(self.this_trait, primary_samples, self.categorical_vars, self.samples) self.score_type = "LOD" - #self.mapping_scale = "morgan" self.control_marker = start_vars['control_marker'] self.do_control = start_vars['do_control'] if 'mapmethod_rqtl_geno' in start_vars: @@ -252,9 +255,9 @@ class RunMapping(object): #if start_vars['pair_scan'] == "true": # self.pair_scan = True if self.permCheck and self.num_perm > 0: - self.perm_output, self.suggestive, self.significant, results = rqtl_mapping.run_rqtl_geno(self.vals, self.samples, self.dataset, self.method, self.model, self.permCheck, self.num_perm, perm_strata, self.do_control, self.control_marker, self.manhattan_plot, self.pair_scan, self.covariates) + self.perm_output, self.suggestive, self.significant, results, self.mapping_scale = rqtl_mapping.run_rqtl_geno(self.vals, self.samples, self.dataset, self.method, self.model, self.permCheck, self.num_perm, perm_strata, self.do_control, self.control_marker, self.manhattan_plot, self.pair_scan, self.covariates) else: - results = rqtl_mapping.run_rqtl_geno(self.vals, self.samples, self.dataset, self.method, self.model, self.permCheck, self.num_perm, perm_strata, self.do_control, self.control_marker, self.manhattan_plot, self.pair_scan, self.covariates) + results, self.mapping_scale = rqtl_mapping.run_rqtl_geno(self.vals, self.samples, self.dataset, self.method, self.model, self.permCheck, self.num_perm, perm_strata, self.do_control, self.control_marker, self.manhattan_plot, self.pair_scan, self.covariates) elif self.mapping_method == "reaper": if "startMb" in start_vars: #ZS: Check if first time page loaded, so it can default to ON if "additiveCheck" in start_vars: diff --git a/wqflask/wqflask/network_graph/network_graph.py b/wqflask/wqflask/network_graph/network_graph.py index a332db46..152e4168 100644 --- a/wqflask/wqflask/network_graph/network_graph.py +++ b/wqflask/wqflask/network_graph/network_graph.py @@ -47,6 +47,7 @@ from utility.TDCell import TDCell from base.trait import GeneralTrait from base import data_set from utility import webqtlUtil, helper_functions, corr_result_helpers +from utility.tools import GN2_BRANCH_URL from db import webqtlDatabaseFunction import utility.webqtlUtil #this is for parallel computing only. from wqflask.correlation import correlation_functions @@ -195,6 +196,7 @@ class NetworkGraph(object): self.nodes_list.append(node_dict) self.elements = json.dumps(self.nodes_list + self.edges_list) + self.gn2_url = GN2_BRANCH_URL groups = [] for sample in self.all_sample_list: diff --git a/wqflask/wqflask/search_results.py b/wqflask/wqflask/search_results.py index 698389ab..8f702d58 100644 --- a/wqflask/wqflask/search_results.py +++ b/wqflask/wqflask/search_results.py @@ -28,6 +28,7 @@ from flask import render_template, Flask, g from utility import formatting from utility import hmac +from utility.tools import GN2_BASE_URL from utility.type_checking import is_float, is_int, is_str, get_float, get_int, get_string from utility.logger import getLogger @@ -295,7 +296,7 @@ def get_aliases(symbol_list, species): symbols_string = ",".join(updated_symbols) filtered_aliases = [] - response = requests.get("http://gn2.genenetwork.org/gn3/gene/aliases2/" + symbols_string) + response = requests.get(GN2_BASE_URL + "/gn3/gene/aliases2/" + symbols_string) if response: alias_lists = json.loads(response.content) seen = set() diff --git a/wqflask/wqflask/static/new/javascript/ctl_graph.js b/wqflask/wqflask/static/new/javascript/ctl_graph.js index 94bd7e9d..bd950592 100644 --- a/wqflask/wqflask/static/new/javascript/ctl_graph.js +++ b/wqflask/wqflask/static/new/javascript/ctl_graph.js @@ -82,18 +82,12 @@ window.onload=function() { function create_qtips(cy){ cy.nodes().qtip({ content: function(){ - gn_link = '<b>'+'<a href="http://gn2.genenetwork.org/show_trait?trait_id=' + this.data().sid + '&dataset=' + this.data().dataset + '" >'+this.data().id +'</a>'+'</b><br>' + gn_link = '<b>'+'<a href="' + gn2_url + '/show_trait?trait_id=' + this.data().sid + '&dataset=' + this.data().dataset + '" >'+this.data().id +'</a>'+'</b><br>' ncbi_link = '<a href="http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?db=gene&cmd=Retrieve&dopt=Graphics&list_uids=' + this.data().geneid + '" >NCBI<a>'+'<br>' omim_link = '<a href="http://www.ncbi.nlm.nih.gov/omim/' + this.data().omim + '" >OMIM<a>'+'<br>' qtip_content = gn_link + ncbi_link + omim_link return qtip_content - //return '<b>'+'<a href="http://gn2.genenetwork.org/show_trait?trait_id=' + this.data().id + '&dataset=' + this.data().dataset + '" >'+this.data().id +'<a>'+'</b>' }, - // content: { - // title: '<b>'+'<a href="http://gn2.genenetwork.org/show_trait?trait_id=' + this.target() + '&dataset=' + this.dataset() + '" >'+this.target() +'<a>'+'</b>', - // text: this.target, - // button: true - // }, position: { my: 'top center', at: 'bottom center' diff --git a/wqflask/wqflask/static/new/javascript/dataset_select_menu_orig.js b/wqflask/wqflask/static/new/javascript/dataset_select_menu_orig.js index fad600d2..794804f4 100644 --- a/wqflask/wqflask/static/new/javascript/dataset_select_menu_orig.js +++ b/wqflask/wqflask/static/new/javascript/dataset_select_menu_orig.js @@ -74,7 +74,6 @@ redo_dropdown = function(dropdown, items) { this_opt_group = null for (_i = 0, _len = group_family_list.length; _i < _len; _i++) { item = group_family_list[_i]; - console.log("THE ITEM:", item) if (item[2] != "None" && current_family == ""){ current_family = item[2] this_opt_group = $("<optgroup label=\"" + item[2] + "\">") diff --git a/wqflask/wqflask/static/new/javascript/network_graph.js b/wqflask/wqflask/static/new/javascript/network_graph.js index 4d507a18..02c3b817 100644 --- a/wqflask/wqflask/static/new/javascript/network_graph.js +++ b/wqflask/wqflask/static/new/javascript/network_graph.js @@ -85,7 +85,7 @@ window.onload=function() { cy.nodes().qtip({ content: function(){ qtip_content = '' - gn_link = '<b>'+'<a href="http://gn2.genenetwork.org/show_trait?trait_id=' + this.data().id.split(":")[0] + '&dataset=' + this.data().id.split(":")[1] + '" >'+this.data().id +'</a>'+'</b><br>' + gn_link = '<b>'+'<a href="' + gn2_url + '/show_trait?trait_id=' + this.data().id.split(":")[0] + '&dataset=' + this.data().id.split(":")[1] + '" >'+this.data().id +'</a>'+'</b><br>' qtip_content += gn_link if (typeof(this.data().geneid) !== 'undefined'){ ncbi_link = '<a href="http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?db=gene&cmd=Retrieve&dopt=Graphics&list_uids=' + this.data().geneid + '" >NCBI<a>'+'<br>' @@ -115,7 +115,7 @@ window.onload=function() { correlation_line = '<b>Sample r: ' + this.data().correlation + '</b><br>' p_value_line = 'Sample p(r): ' + this.data().p_value + '<br>' overlap_line = 'Overlap: ' + this.data().overlap + '<br>' - scatter_plot = '<a href="http://gn2-zach.genenetwork.org/corr_scatter_plot?dataset_1=' + this.data().source.split(":")[1] + '&dataset_2=' + this.data().target.split(":")[1] + '&trait_1=' + this.data().source.split(":")[0] + '&trait_2=' + this.data().target.split(":")[0] + '" >View Scatterplot</a>' + scatter_plot = '<a href="' + gn2_url + '/corr_scatter_plot?dataset_1=' + this.data().source.split(":")[1] + '&dataset_2=' + this.data().target.split(":")[1] + '&trait_1=' + this.data().source.split(":")[0] + '&trait_2=' + this.data().target.split(":")[0] + '" >View Scatterplot</a>' return correlation_line + p_value_line + overlap_line + scatter_plot }, position: { diff --git a/wqflask/wqflask/static/new/javascript/show_trait.js b/wqflask/wqflask/static/new/javascript/show_trait.js index 28d13345..d94a2347 100644 --- a/wqflask/wqflask/static/new/javascript/show_trait.js +++ b/wqflask/wqflask/static/new/javascript/show_trait.js @@ -367,6 +367,8 @@ make_table = function() { var header, key, row, row_line, table, the_id, the_rows, value, _i, _len, _ref, _ref1; if (js_data.trait_symbol != null) { header = "<thead><tr><th style=\"color: white; background-color: #369; text-align: center;\" colspan=\"100%\">Trait " + js_data.trait_id + " - " + js_data.trait_symbol + "</th></tr><tr><th style=\"text-align: right; padding-left: 5px;\">Statistic</th>"; + } else if (js_data.dataset_type == "Geno"){ + header = "<thead><tr><th style=\"color: white; background-color: #369; text-align: center;\" colspan=\"100%\">Marker " + js_data.trait_id + "</th></tr><tr><th style=\"text-align: right; padding-left: 5px;\">Statistic</th>"; } else { header = "<thead><tr><th style=\"color: white; background-color: #369; text-align: center;\" colspan=\"100%\">Trait " + js_data.trait_id + ": " + js_data.short_description + "</th></tr><tr><th style=\"text-align: right; padding-left: 5px;\">Statistic</th>"; } diff --git a/wqflask/wqflask/templates/base.html b/wqflask/wqflask/templates/base.html index 487cf3f2..f9d4e859 100644 --- a/wqflask/wqflask/templates/base.html +++ b/wqflask/wqflask/templates/base.html @@ -132,13 +132,15 @@ This site is currently operated by <a href="mailto:rwilliams@uthsc.edu">Rob Williams</a>, <a href="http://thebird.nl/">Pjotr Prins</a>, + <a href="http://www.senresearch.org">Saunak Sen</a>, <a href="mailto:zachary.a.sloan@gmail.com">Zachary Sloan</a>, <a href="mailto:acenteno@uthsc.edu">Arthur Centeno</a>, and <a href="mailto:cfische7@uthsc.edu">Christian Fischer</a>. </p> <p>Design and code by Pjotr Prins, Zach Sloan, Arthur Centeno, Christan Fischer, Danny Arends, Sam Ockman, Lei Yan, Xiaodong Zhou, Christian Fernandez, - Ning Liu, Rudi Alberts, Elissa Chesler, Sujoy Roy, Evan G. Williams, Alexander G. Williams, Kenneth Manly, Jintao Wang, and Robert W. Williams, - <a href="http://genenetwork.org/credit.html">colleagues</a>.</p> + Ning Liu, Rudi Alberts, Elissa Chesler, Sujoy Roy, Evan G. Williams, Alexander G. Williams, Kenneth Manly, Jintao Wang, Robert W. Williams, and + <!--<a href="http://genenetwork.org/credit.html">colleagues</a>.</p>--> + <a href="/credits">colleagues</a>.</p> <br /> <p>GeneNetwork support from:</p> <ul> diff --git a/wqflask/wqflask/templates/credits.html b/wqflask/wqflask/templates/credits.html new file mode 100644 index 00000000..95c424cc --- /dev/null +++ b/wqflask/wqflask/templates/credits.html @@ -0,0 +1,55 @@ +{% extends "base.html" %} +{% block title %}Credit{% endblock %} +{% block content %} + +<Table width= "100%" cellSpacing=0 cellPadding=5><TR> +<!-- Body Start from Here --> +<TD valign="top" height="200" width="100%"> + <P class="title"><H2>Web site design and coding</H2></P> + <UL> +<LI> <A HREF="mailto:rwilliams@uthsc.edu">Robert W Williams</a> +<LI>Kenneth Manly (design and QTL mapping, 1995-2007) +<LI>Jintao Wang (lead programmer, 2001–2006) +<LI><a href="http://www.nervenet.org/main/people.html">Arthur G. Centeno (IT Analyst III, 2001–present)</a> +<LI><a href="http://www.nervenet.org/main/people.html">Zachary Sloan (IT Analyst III, 2009–present)</a> +<LI><a href="http://www.nervenet.org/main/people.html">Lei Yan (systems and web services interface 2008-2018)</a> +<LI><a href="http://www.nervenet.org/main/people.html">Xusheng Wang (data analysis, 2008-2012)</a> +<LI><a href="http://www.nervenet.org/main/people.html">Xiaodong Zhou (lead programmer 2009–2011)</a> +<LI>Ning Liu (programmer 2008–2009)</LI> +<LI>Zhaohui Sun (SNP browser, programmer 2007) +<LI>Yanhua Qu (data entry, 2005-2008) +<LI>Stephen Pitts (programmer) +<LI>Hongqiang Li (lead programmer, 2007-2009) +<LI><A HREF="http://www.jax.org/news/archives/2009/chesler.html">Elissa Chesler</A> (design of QTL Heat Map, Compare Correlations, 2004-2006) +<LI>Kevitt Adler (systems, 2006-2008) +<LI>Robert Crowell (SNP Browser, 2006-2007) +<LI>David Crowell (partial correlations, 2008-2009) +<LI>Evan G. Williams (SNP and Variant Browser, data entry, 2004-2006) +<LI>Alex G Williams (QTL Maps GUI, 2003-2006) + </UL> + <P class="title"><H2>Published and Unpublished Phenotype Data</H2></P> + <UL> + <LI><A HREF="http://www.nervenet.org/people/lulu_cv.html">Lu Lu</A> + <LI> <A HREF="http://www.jax.org/news/archives/2009/chesler.html">Elissa J. Chesler</A> + <LI><a href="http://www.ohsu.edu/som-BehNeuro/Faculty/Crabbe.html">John C Crabbe</a>, OHSU + <LI><a href="http://www.ohsu.edu/som-BehNeuro/Faculty/Belknap.html">John K Belknap</a>, OHSU + <LI>Mary-Kathleen Sullivan + <LI>Emily English + <LI>Byron Jones + <LI>Ryan McNieve + <LI>Nathan Copeland + </UL> + <P class="title"><H2>Genotype / Genomic Data</H2></P> + <UL> + <LI> <A HREF="http://www.nervenet.org/people/lulu_cv.html">Lu Lu</A> + <LI><a href="http://www.nervenet.org/people/Gu_cv.html">Jing Gu</a> + <LI>Shuhua Qi + <LI>John Hogenesch + <LI>Timothy Wiltshire + <LI><a href="http://www.nervenet.org/people/Yanhua_cv.html">Yanhua Qu</a> + </UL> + <P></P> +</TD> +</TR></TABLE> + +{% endblock %} diff --git a/wqflask/wqflask/templates/ctl_results.html b/wqflask/wqflask/templates/ctl_results.html index d85075a9..0108d93a 100644 --- a/wqflask/wqflask/templates/ctl_results.html +++ b/wqflask/wqflask/templates/ctl_results.html @@ -61,6 +61,7 @@ <script> elements_list = {{ elements | safe }} + gn2_url = "{{ gn2_url | safe }}" </script> <script language="javascript" type="text/javascript" src="/static/new/packages/DataTables/js/jquery.js"></script> diff --git a/wqflask/wqflask/templates/index_page.html b/wqflask/wqflask/templates/index_page.html index 0116245d..f8720d39 100644 --- a/wqflask/wqflask/templates/index_page.html +++ b/wqflask/wqflask/templates/index_page.html @@ -219,9 +219,9 @@ <h3>GN1 Mirror and development sites</h3> <ul> - <li><a href="http://www.genenetwork.org/">Main GN1 site at UTHSC</a> (main site)</li> + <li><a href="http://gn1.genenetwork.org/">Main GN1 site at UTHSC</a> (main site)</li> <li><a href="http://genenetwork.helmholtz-hzi.de/">Germany at the HZI</a></li> - <li><a href="http://gn2.genenetwork.org/">Memphis at the U of M</a></li> + <li><a href="http://genenetwork.org/">Memphis at the U of M</a></li> </ul> </section> diff --git a/wqflask/wqflask/templates/index_page_orig.html b/wqflask/wqflask/templates/index_page_orig.html index 963531cb..06b71f53 100755 --- a/wqflask/wqflask/templates/index_page_orig.html +++ b/wqflask/wqflask/templates/index_page_orig.html @@ -254,8 +254,8 @@ </div> <h3>GeneNetwork v2:</h3> <ul> - <li><a href="http://gn2.genenetwork.org/">Main website</a> at UTHSC</li> - <!--<li><a href="http://test-gn2.genenetwork.org/">Testing website</a> at UTHSC</li>--> + <li><a href="http://genenetwork.org/">Main website</a> at UTHSC</li> + <!--<li><a href="http://test-genenetwork.org/">Testing website</a> at UTHSC</li>--> </ul> <h3>GeneNetwork v1:</h3> <ul> diff --git a/wqflask/wqflask/templates/mapping_results.html b/wqflask/wqflask/templates/mapping_results.html index ba0ebef9..7e05be18 100644 --- a/wqflask/wqflask/templates/mapping_results.html +++ b/wqflask/wqflask/templates/mapping_results.html @@ -36,7 +36,7 @@ <input type="hidden" name="value:{{ sample }}" value="{{ vals[loop.index - 1] }}"> {% endfor %} <input type="hidden" name="num_vals" value="{{ n_samples }}"> - <input type="hidden" name="maf"> + <input type="hidden" name="maf" value="{{ maf }}"> <input type="hidden" name="use_loco" value="{{ use_loco }}"> <input type="hidden" name="selected_chr" value="{{ selectedChr }}"> <input type="hidden" name="manhattan_plot" value="{{ manhattan_plot }}"> @@ -45,10 +45,14 @@ <input type="hidden" name="num_bootstrap" value="{{ nboot }}"> <input type="hidden" name="do_control" value="{{ doControl }}"> <input type="hidden" name="control_marker" value="{{ controlLocus }}"> - <input type="hidden" name="covariates" values="{{ covariates }}"> + <input type="hidden" name="covariates" value="{{ covariates }}"> <input type="hidden" name="mapmethod_rqtl_geno" value="{{ mapmethod_rqtl_geno }}"> <input type="hidden" name="mapmodel_rqtl_geno" value="{{ mapmodel_rqtl_geno }}"> <input type="hidden" name="pair_scan" value="{{ pair_scan }}"> + <input type="hidden" name="transform" value="{{ transform }}"> + <input type="hidden" name="tool_used" value="Mapping"> + <input type="hidden" name="wanted_inputs" value=""> + <input type="hidden" name="form_url" value="/run_mapping"> <div class="container"> <div class="col-xs-5"> @@ -422,11 +426,19 @@ }); + var mapping_input_list = ['temp_uuid', 'trait_id', 'dataset', 'tool_used', 'form_url', 'method', 'transform', 'trimmed_markers', 'selected_chr', 'chromosomes', 'mapping_scale', + 'score_type', 'suggestive', 'significant', 'num_perm', 'permCheck', 'perm_output', 'perm_strata', 'categorical_vars', 'num_bootstrap', 'bootCheck', 'bootstrap_results', + 'LRSCheck', 'covariates', 'maf', 'use_loco', 'manhattan_plot', 'control_marker', 'control_marker_db', 'do_control', 'genofile', + 'pair_scan', 'startMb', 'endMb', 'graphWidth', 'lrsMax', 'additiveCheck', 'showSNP', 'showGenes', 'viewLegend', 'haplotypeAnalystCheck', + 'mapmethod_rqtl_geno', 'mapmodel_rqtl_geno', 'temp_trait', 'group', 'species', 'reaper_version', 'primary_samples', 'num_vals'] + + $('input[name=wanted_inputs]').val(mapping_input_list.join(",")); + chrView = function(this_chr, chr_mb_list) { $('input[name=selected_chr]').val(this_chr) $('input[name=chr_mb_list]').val(chr_mb_list) - $('#marker_regression_form').attr('action', '/run_mapping'); + $('#marker_regression_form').attr('action', '/loading'); return $('#marker_regression_form').submit(); }; @@ -436,13 +448,13 @@ $('input[name=endMb]').val(end_mb) //$('input[name=mb_range]').val(start_mb + "," + end_mb) - $('#marker_regression_form').attr('action', '/run_mapping'); + $('#marker_regression_form').attr('action', '/loading'); return $('#marker_regression_form').submit(); }; remap = function() { $('input[name=selected_chr]').val($('select[name=chromosomes]').val()); - $('#marker_regression_form').attr('action', '/run_mapping'); + $('#marker_regression_form').attr('action', '/loading'); return $('#marker_regression_form').submit(); }; diff --git a/wqflask/wqflask/templates/network_graph.html b/wqflask/wqflask/templates/network_graph.html index 4492dd3f..25af7bb1 100644 --- a/wqflask/wqflask/templates/network_graph.html +++ b/wqflask/wqflask/templates/network_graph.html @@ -137,6 +137,7 @@ <script> elements_list = {{ elements | safe }} + gn2_url = "{{ gn2_url | safe }}" </script> <script language="javascript" type="text/javascript" src="/static/new/packages/DataTables/js/jquery.js"></script> diff --git a/wqflask/wqflask/user_login.py b/wqflask/wqflask/user_login.py index 40d9925c..edd272c2 100644 --- a/wqflask/wqflask/user_login.py +++ b/wqflask/wqflask/user_login.py @@ -42,9 +42,6 @@ def basic_info(): user_agent = request.headers.get('User-Agent')) def encode_password(pass_gen_fields, unencrypted_password): - logger.debug("THE TYPE:", type(pass_gen_fields)) - logger.debug("pass_gen_fields:", pass_gen_fields) - logger.debug("hashfunc:", pass_gen_fields['hashfunc']) hashfunc = getattr(hashlib, pass_gen_fields['hashfunc']) salt = base64.b64decode(pass_gen_fields['salt']) diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py index 76857650..7d3dfa48 100644 --- a/wqflask/wqflask/views.py +++ b/wqflask/wqflask/views.py @@ -305,6 +305,12 @@ def tutorials(): #return render_template("docs.html", **doc.__dict__) return render_template("tutorials.html") +@app.route("/credits") +def credits(): + #doc = docs.Docs("links", request.args) + #return render_template("docs.html", **doc.__dict__) + return render_template("credits.html") + @app.route("/environments") def environments(): doc = docs.Docs("environments", request.args) @@ -583,18 +589,23 @@ def loading_page(): if key in wanted or key.startswith(('value:')): start_vars[key] = value - if 'primary_samples' in start_vars: - samples = start_vars['primary_samples'].split(",") - for sample in samples: - value = start_vars.get('value:' + sample) - if value != "x": - num_vals += 1 + if 'num_vals' in start_vars: + num_vals = int(start_vars['num_vals']) + else: + if 'primary_samples' in start_vars: + samples = start_vars['primary_samples'].split(",") + for sample in samples: + value = start_vars.get('value:' + sample) + if value != "x": + num_vals += 1 start_vars['num_vals'] = num_vals + start_vars['wanted_inputs'] = initial_start_vars['wanted_inputs'] start_vars_container['start_vars'] = start_vars else: start_vars_container['start_vars'] = initial_start_vars + rendered_template = render_template("loading.html", **start_vars_container) return rendered_template @@ -658,7 +669,8 @@ def mapping_results_page(): 'mapmodel_rqtl_geno', 'temp_trait', 'reaper_version', - 'num_vals' + 'num_vals', + 'transform' ) start_vars = {} for key, value in initial_start_vars.iteritems(): |