aboutsummaryrefslogtreecommitdiff
path: root/wqflask
diff options
context:
space:
mode:
Diffstat (limited to 'wqflask')
-rw-r--r--wqflask/base/data_set.py110
-rw-r--r--wqflask/base/mrna_assay_tissue_data.py2
-rw-r--r--wqflask/base/species.py6
-rw-r--r--wqflask/base/trait.py70
-rw-r--r--wqflask/maintenance/convert_geno_to_bimbam.py4
-rw-r--r--wqflask/maintenance/generate_kinship_from_bimbam.py2
-rw-r--r--wqflask/maintenance/geno_to_json.py4
-rw-r--r--wqflask/maintenance/print_benchmark.py2
-rw-r--r--wqflask/tests/unit/base/test_data_set.py7
-rw-r--r--wqflask/utility/__init__.py4
-rw-r--r--wqflask/utility/benchmark.py2
-rw-r--r--wqflask/utility/gen_geno_ob.py6
-rw-r--r--wqflask/utility/genofile_parser.py4
-rw-r--r--wqflask/utility/helper_functions.py59
-rw-r--r--wqflask/utility/temp_data.py2
-rw-r--r--wqflask/wqflask/api/gen_menu.py7
-rw-r--r--wqflask/wqflask/comparison_bar_chart/comparison_bar_chart.py2
-rw-r--r--wqflask/wqflask/correlation/corr_scatter_plot.py2
-rw-r--r--wqflask/wqflask/correlation/show_corr_results.py2
-rw-r--r--wqflask/wqflask/correlation_matrix/show_corr_matrix.py2
-rw-r--r--wqflask/wqflask/ctl/ctl_analysis.py2
-rw-r--r--wqflask/wqflask/db_info.py2
-rw-r--r--wqflask/wqflask/do_search.py2
-rw-r--r--wqflask/wqflask/docs.py2
-rw-r--r--wqflask/wqflask/external_tools/send_to_bnw.py2
-rw-r--r--wqflask/wqflask/external_tools/send_to_geneweaver.py2
-rw-r--r--wqflask/wqflask/external_tools/send_to_webgestalt.py2
-rw-r--r--wqflask/wqflask/gsearch.py2
-rw-r--r--wqflask/wqflask/heatmap/heatmap.py2
-rw-r--r--wqflask/wqflask/marker_regression/display_mapping_results.py2
-rw-r--r--wqflask/wqflask/marker_regression/run_mapping.py2
-rw-r--r--wqflask/wqflask/network_graph/network_graph.py2
-rw-r--r--wqflask/wqflask/news.py2
-rw-r--r--wqflask/wqflask/search_results.py2
-rw-r--r--wqflask/wqflask/server_side.py2
-rw-r--r--wqflask/wqflask/show_trait/SampleList.py2
-rw-r--r--wqflask/wqflask/show_trait/show_trait.py318
-rw-r--r--wqflask/wqflask/snp_browser/snp_browser.py2
-rw-r--r--wqflask/wqflask/static/new/javascript/dataset_select_menu_edit_trait.js253
-rw-r--r--wqflask/wqflask/templates/edit_trait.html86
-rwxr-xr-x[-rw-r--r--]wqflask/wqflask/templates/index_page.html273
-rwxr-xr-xwqflask/wqflask/templates/index_page_orig.html349
-rw-r--r--wqflask/wqflask/templates/submit_trait.html34
-rw-r--r--wqflask/wqflask/update_search_results.py2
-rw-r--r--wqflask/wqflask/user_manager.py22
-rw-r--r--wqflask/wqflask/user_session.py2
-rw-r--r--wqflask/wqflask/views.py337
-rw-r--r--wqflask/wqflask/wgcna/wgcna_analysis.py2
48 files changed, 1012 insertions, 999 deletions
diff --git a/wqflask/base/data_set.py b/wqflask/base/data_set.py
index 44325d5b..3183363b 100644
--- a/wqflask/base/data_set.py
+++ b/wqflask/base/data_set.py
@@ -17,7 +17,10 @@
# at rwilliams@uthsc.edu and xzhou15@uthsc.edu
#
# This module is used by GeneNetwork project (www.genenetwork.org)
-
+from dataclasses import dataclass
+from dataclasses import field
+from dataclasses import InitVar
+from typing import Optional, Dict
from db.call import fetchall, fetchone, fetch1
from utility.logger import getLogger
from utility.tools import USE_GN_SERVER, USE_REDIS, flat_files, flat_file_exists, GN2_BASE_URL
@@ -59,7 +62,8 @@ logger = getLogger(__name__)
DS_NAME_MAP = {}
-def create_dataset(dataset_name, dataset_type=None, get_samplelist=True, group_name=None):
+def create_dataset(dataset_name, dataset_type=None,
+ get_samplelist=True, group_name=None):
if dataset_name == "Temp":
dataset_type = "Temp"
@@ -74,11 +78,10 @@ def create_dataset(dataset_name, dataset_type=None, get_samplelist=True, group_n
return dataset_class(dataset_name, get_samplelist)
+@dataclass
class DatasetType:
-
- def __init__(self, redis_instance):
- """Create a dictionary of samples where the value is set to Geno,
-Publish or ProbeSet. E.g.
+ """Create a dictionary of samples where the value is set to Geno,
+ Publish or ProbeSet. E.g.
{'AD-cases-controls-MyersGeno': 'Geno',
'AD-cases-controls-MyersPublish': 'Publish',
@@ -89,21 +92,28 @@ Publish or ProbeSet. E.g.
'All Phenotypes': 'Publish',
'B139_K_1206_M': 'ProbeSet',
'B139_K_1206_R': 'ProbeSet' ...
-
+ }
"""
+ redis_instance: InitVar[Redis]
+ datasets: Optional[Dict] = field(init=False, default_factory=dict)
+ data: Optional[Dict] = field(init=False)
+
+ def __post_init__(self, redis_instance):
self.redis_instance = redis_instance
- self.datasets = {}
- data = self.redis_instance.get("dataset_structure")
+ data = redis_instance.get("dataset_structure")
if data:
self.datasets = json.loads(data)
- else: # ZS: I don't think this should ever run unless Redis is emptied
+ else:
+ # ZS: I don't think this should ever run unless Redis is
+ # emptied
try:
data = json.loads(requests.get(
- GN2_BASE_URL + "/api/v_pre1/gen_dropdown", timeout=5).content)
- 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]:
+ GN2_BASE_URL + "/api/v_pre1/gen_dropdown",
+ timeout=5).content)
+ 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]:
short_dataset_name = dataset[1]
if dataset_type == "Phenotypes":
new_type = "Publish"
@@ -112,15 +122,15 @@ Publish or ProbeSet. E.g.
else:
new_type = "ProbeSet"
self.datasets[short_dataset_name] = new_type
- except:
+ except Exception: # Do nothing
pass
-
- self.redis_instance.set("dataset_structure", json.dumps(self.datasets))
+ self.redis_instance.set("dataset_structure",
+ json.dumps(self.datasets))
+ self.data = data
def set_dataset_key(self, t, name):
- """If name is not in the object's dataset dictionary, set it, and update
- dataset_structure in Redis
-
+ """If name is not in the object's dataset dictionary, set it, and
+ update dataset_structure in Redis
args:
t: Type of dataset structure which can be: 'mrna_expr', 'pheno',
'other_pheno', 'geno'
@@ -128,19 +138,20 @@ Publish or ProbeSet. E.g.
"""
sql_query_mapping = {
- 'mrna_expr': ("""SELECT ProbeSetFreeze.Id FROM """ +
- """ProbeSetFreeze WHERE ProbeSetFreeze.Name = "{}" """),
- 'pheno': ("""SELECT InfoFiles.GN_AccesionId """ +
- """FROM InfoFiles, PublishFreeze, InbredSet """ +
- """WHERE InbredSet.Name = '{}' AND """ +
- """PublishFreeze.InbredSetId = InbredSet.Id AND """ +
- """InfoFiles.InfoPageName = PublishFreeze.Name"""),
- 'other_pheno': ("""SELECT PublishFreeze.Name """ +
- """FROM PublishFreeze, InbredSet """ +
- """WHERE InbredSet.Name = '{}' AND """ +
- """PublishFreeze.InbredSetId = InbredSet.Id"""),
- 'geno': ("""SELECT GenoFreeze.Id FROM GenoFreeze WHERE """ +
- """GenoFreeze.Name = "{}" """)
+ 'mrna_expr': ("SELECT ProbeSetFreeze.Id FROM "
+ "ProbeSetFreeze WHERE "
+ "ProbeSetFreeze.Name = \"%s\" "),
+ 'pheno': ("SELECT InfoFiles.GN_AccesionId "
+ "FROM InfoFiles, PublishFreeze, InbredSet "
+ "WHERE InbredSet.Name = '%s' AND "
+ "PublishFreeze.InbredSetId = InbredSet.Id AND "
+ "InfoFiles.InfoPageName = PublishFreeze.Name"),
+ 'other_pheno': ("SELECT PublishFreeze.Name "
+ "FROM PublishFreeze, InbredSet "
+ "WHERE InbredSet.Name = '%s' AND "
+ "PublishFreeze.InbredSetId = InbredSet.Id"),
+ 'geno': ("SELECT GenoFreeze.Id FROM GenoFreeze WHERE "
+ "GenoFreeze.Name = \"%s\" ")
}
dataset_name_mapping = {
@@ -154,22 +165,22 @@ Publish or ProbeSet. E.g.
if t in ['pheno', 'other_pheno']:
group_name = name.replace("Publish", "")
- results = g.db.execute(sql_query_mapping[t].format(group_name)).fetchone()
+ results = g.db.execute(sql_query_mapping[t] % group_name).fetchone()
if results:
self.datasets[name] = dataset_name_mapping[t]
self.redis_instance.set("dataset_structure", json.dumps(self.datasets))
return True
-
return None
def __call__(self, name):
-
if name not in self.datasets:
for t in ["mrna_expr", "pheno", "other_pheno", "geno"]:
- # This has side-effects, with the end result being a truth-y value
+ # This has side-effects, with the end result being a
+ # truth-y value
if(self.set_dataset_key(t, name)):
break
- return self.datasets.get(name, None) # Return None if name has not been set
+ # Return None if name has not been set
+ return self.datasets.get(name, None)
# Do the intensive work at startup one time only
@@ -209,7 +220,7 @@ def create_datasets_list():
return datasets
-class Markers(object):
+class Markers:
"""Todo: Build in cacheing so it saves us reading the same file more than once"""
def __init__(self, name):
@@ -262,8 +273,6 @@ class Markers(object):
elif isinstance(p_values, dict):
filtered_markers = []
for marker in self.markers:
- #logger.debug("marker[name]", marker['name'])
- #logger.debug("p_values:", p_values)
if marker['name'] in p_values:
#logger.debug("marker {} IS in p_values".format(i))
marker['p_value'] = p_values[marker['name']]
@@ -276,10 +285,6 @@ class Markers(object):
marker['lrs_value'] = - \
math.log10(marker['p_value']) * 4.61
filtered_markers.append(marker)
- # else:
- #logger.debug("marker {} NOT in p_values".format(i))
- # self.markers.remove(marker)
- #del self.markers[i]
self.markers = filtered_markers
@@ -306,13 +311,12 @@ class HumanMarkers(Markers):
marker['Mb'] = float(splat[3]) / 1000000
self.markers.append(marker)
- #logger.debug("markers is: ", pf(self.markers))
def add_pvalues(self, p_values):
super(HumanMarkers, self).add_pvalues(p_values)
-class DatasetGroup(object):
+class DatasetGroup:
"""
Each group has multiple datasets; each species has multiple groups.
@@ -520,7 +524,6 @@ def datasets(group_name, this_group=None):
break
if tissue_already_exists:
- #logger.debug("dataset_menu:", dataset_menu[i]['datasets'])
dataset_menu[i]['datasets'].append((dataset, dataset_short))
else:
dataset_menu.append(dict(tissue=tissue_name,
@@ -537,7 +540,7 @@ def datasets(group_name, this_group=None):
return dataset_menu
-class DataSet(object):
+class DataSet:
"""
DataSet class defines a dataset in webqtl, can be either Microarray,
Published phenotype, genotype, or user input dataset(temp)
@@ -569,10 +572,6 @@ class DataSet(object):
self.group.get_samplelist()
self.species = species.TheSpecies(self)
- def get_desc(self):
- """Gets overridden later, at least for Temp...used by trait's get_given_name"""
- return None
-
def get_accession_id(self):
if self.type == "Publish":
results = g.db.execute("""select InfoFiles.GN_AccesionId from InfoFiles, PublishFreeze, InbredSet where
@@ -730,9 +729,6 @@ class PhenotypeDataSet(DataSet):
DS_NAME_MAP['Publish'] = 'PhenotypeDataSet'
def setup(self):
-
- #logger.debug("IS A PHENOTYPEDATASET")
-
# Fields in the database table
self.search_fields = ['Phenotype.Post_publication_description',
'Phenotype.Pre_publication_description',
diff --git a/wqflask/base/mrna_assay_tissue_data.py b/wqflask/base/mrna_assay_tissue_data.py
index f1929518..1f8224af 100644
--- a/wqflask/base/mrna_assay_tissue_data.py
+++ b/wqflask/base/mrna_assay_tissue_data.py
@@ -11,7 +11,7 @@ from utility.db_tools import escape
from utility.logger import getLogger
logger = getLogger(__name__ )
-class MrnaAssayTissueData(object):
+class MrnaAssayTissueData:
def __init__(self, gene_symbols=None):
self.gene_symbols = gene_symbols
diff --git a/wqflask/base/species.py b/wqflask/base/species.py
index 2771d116..eae3325a 100644
--- a/wqflask/base/species.py
+++ b/wqflask/base/species.py
@@ -6,7 +6,7 @@ from flask import Flask, g
from utility.logger import getLogger
logger = getLogger(__name__ )
-class TheSpecies(object):
+class TheSpecies:
def __init__(self, dataset=None, species_name=None):
if species_name != None:
self.name = species_name
@@ -15,7 +15,7 @@ class TheSpecies(object):
self.dataset = dataset
self.chromosomes = Chromosomes(dataset=self.dataset)
-class IndChromosome(object):
+class IndChromosome:
def __init__(self, name, length):
self.name = name
self.length = length
@@ -25,7 +25,7 @@ class IndChromosome(object):
"""Chromosome length in megabases"""
return self.length / 1000000
-class Chromosomes(object):
+class Chromosomes:
def __init__(self, dataset=None, species=None):
self.chromosomes = collections.OrderedDict()
if species != None:
diff --git a/wqflask/base/trait.py b/wqflask/base/trait.py
index b4b4452a..5574128d 100644
--- a/wqflask/base/trait.py
+++ b/wqflask/base/trait.py
@@ -51,7 +51,7 @@ def create_trait(**kw):
return None
-class GeneralTrait(object):
+class GeneralTrait:
"""
Trait class defines a trait in webqtl, can be either Microarray,
Published phenotype, genotype, or user input trait
@@ -345,74 +345,6 @@ def jsonable(trait):
return dict()
-def jsonable_table_row(trait, dataset_name, index):
- """Return a list suitable for json and intended to be displayed in a table
-
- Actual turning into json doesn't happen here though"""
-
- dataset = create_dataset(dataset_name)
-
- if dataset.type == "ProbeSet":
- if trait.mean == "":
- mean = "N/A"
- else:
- mean = "%.3f" % round(float(trait.mean), 2)
- if trait.additive == "":
- additive = "N/A"
- else:
- additive = "%.3f" % round(float(trait.additive), 2)
- return ['<input type="checkbox" name="searchResult" class="checkbox trait_checkbox" value="' + hmac.data_hmac('{}:{}'.format(str(trait.name), dataset.name)) + '">',
- index,
- '<a href="/show_trait?trait_id=' +
- str(trait.name)+'&dataset='+dataset.name +
- '">'+str(trait.name)+'</a>',
- trait.symbol,
- trait.description_display,
- trait.location_repr,
- mean,
- trait.LRS_score_repr,
- trait.LRS_location_repr,
- additive]
- elif dataset.type == "Publish":
- if trait.additive == "":
- additive = "N/A"
- else:
- additive = "%.2f" % round(float(trait.additive), 2)
- if trait.pubmed_id:
- return ['<input type="checkbox" name="searchResult" class="checkbox trait_checkbox" value="' + hmac.data_hmac('{}:{}'.format(str(trait.name), dataset.name)) + '">',
- index,
- '<a href="/show_trait?trait_id=' +
- str(trait.name)+'&dataset='+dataset.name +
- '">'+str(trait.name)+'</a>',
- trait.description_display,
- trait.authors,
- '<a href="' + trait.pubmed_link + '">' + trait.pubmed_text + '</href>',
- trait.LRS_score_repr,
- trait.LRS_location_repr,
- additive]
- else:
- return ['<input type="checkbox" name="searchResult" class="checkbox trait_checkbox" value="' + hmac.data_hmac('{}:{}'.format(str(trait.name), dataset.name)) + '">',
- index,
- '<a href="/show_trait?trait_id=' +
- str(trait.name)+'&dataset='+dataset.name +
- '">'+str(trait.name)+'</a>',
- trait.description_display,
- trait.authors,
- trait.pubmed_text,
- trait.LRS_score_repr,
- trait.LRS_location_repr,
- additive]
- elif dataset.type == "Geno":
- return ['<input type="checkbox" name="searchResult" class="checkbox trait_checkbox" value="' + hmac.data_hmac('{}:{}'.format(str(trait.name), dataset.name)) + '">',
- index,
- '<a href="/show_trait?trait_id=' +
- str(trait.name)+'&dataset='+dataset.name +
- '">'+str(trait.name)+'</a>',
- trait.location_repr]
- else:
- return dict()
-
-
def retrieve_trait_info(trait, dataset, get_qtl_info=False):
assert dataset, "Dataset doesn't exist"
diff --git a/wqflask/maintenance/convert_geno_to_bimbam.py b/wqflask/maintenance/convert_geno_to_bimbam.py
index d49742f2..0853b3ac 100644
--- a/wqflask/maintenance/convert_geno_to_bimbam.py
+++ b/wqflask/maintenance/convert_geno_to_bimbam.py
@@ -22,7 +22,7 @@ from pprint import pformat as pf
class EmptyConfigurations(Exception): pass
-class Marker(object):
+class Marker:
def __init__(self):
self.name = None
self.chr = None
@@ -30,7 +30,7 @@ class Marker(object):
self.Mb = None
self.genotypes = []
-class ConvertGenoFile(object):
+class ConvertGenoFile:
def __init__(self, input_file, output_files):
self.input_file = input_file
diff --git a/wqflask/maintenance/generate_kinship_from_bimbam.py b/wqflask/maintenance/generate_kinship_from_bimbam.py
index 60257b28..3e4d1741 100644
--- a/wqflask/maintenance/generate_kinship_from_bimbam.py
+++ b/wqflask/maintenance/generate_kinship_from_bimbam.py
@@ -13,7 +13,7 @@ sys.path.append("..")
import os
import glob
-class GenerateKinshipMatrices(object):
+class GenerateKinshipMatrices:
def __init__(self, group_name, geno_file, pheno_file):
self.group_name = group_name
self.geno_file = geno_file
diff --git a/wqflask/maintenance/geno_to_json.py b/wqflask/maintenance/geno_to_json.py
index 7e7fd241..f5f7e0e7 100644
--- a/wqflask/maintenance/geno_to_json.py
+++ b/wqflask/maintenance/geno_to_json.py
@@ -29,7 +29,7 @@ class EmptyConfigurations(Exception): pass
-class Marker(object):
+class Marker:
def __init__(self):
self.name = None
self.chr = None
@@ -37,7 +37,7 @@ class Marker(object):
self.Mb = None
self.genotypes = []
-class ConvertGenoFile(object):
+class ConvertGenoFile:
def __init__(self, input_file, output_file):
diff --git a/wqflask/maintenance/print_benchmark.py b/wqflask/maintenance/print_benchmark.py
index b24ce4f1..a1046c86 100644
--- a/wqflask/maintenance/print_benchmark.py
+++ b/wqflask/maintenance/print_benchmark.py
@@ -5,7 +5,7 @@ import time
from pprint import pformat as pf
-class TheCounter(object):
+class TheCounter:
Counters = {}
def __init__(self):
diff --git a/wqflask/tests/unit/base/test_data_set.py b/wqflask/tests/unit/base/test_data_set.py
index 96563a16..ee5d6f06 100644
--- a/wqflask/tests/unit/base/test_data_set.py
+++ b/wqflask/tests/unit/base/test_data_set.py
@@ -31,14 +31,12 @@ class TestDataSetTypes(unittest.TestCase):
def tearDown(self):
self.app_context.pop()
- @mock.patch('base.data_set.g')
- def test_data_set_type(self, db_mock):
+ def test_data_set_type(self):
"""Test that DatasetType returns correctly if the Redis Instance is not empty
and the name variable exists in the dictionary
"""
with app.app_context():
- db_mock.get = mock.Mock()
redis_mock = mock.Mock()
redis_mock.get.return_value = self.test_dataset
self.assertEqual(DatasetType(redis_mock)
@@ -89,8 +87,7 @@ class TestDataSetTypes(unittest.TestCase):
'"B139_K_1206_M": "ProbeSet", '
'"B139_K_1206_R": "ProbeSet", '
'"Test": "ProbeSet"}'))
-
- db_mock.db.execute.assert_called_with(
+ db_mock.db.execute.assert_called_once_with(
("SELECT ProbeSetFreeze.Id FROM ProbeSetFreeze " +
"WHERE ProbeSetFreeze.Name = \"Test\" ")
)
diff --git a/wqflask/utility/__init__.py b/wqflask/utility/__init__.py
index 204ff59a..df926884 100644
--- a/wqflask/utility/__init__.py
+++ b/wqflask/utility/__init__.py
@@ -2,7 +2,7 @@ from pprint import pformat as pf
# Todo: Move these out of __init__
-class Bunch(object):
+class Bunch:
"""Like a dictionary but using object notation"""
def __init__(self, **kw):
self.__dict__ = kw
@@ -11,7 +11,7 @@ class Bunch(object):
return pf(self.__dict__)
-class Struct(object):
+class Struct:
'''The recursive class for building and representing objects with.
From http://stackoverflow.com/a/6573827/1175849
diff --git a/wqflask/utility/benchmark.py b/wqflask/utility/benchmark.py
index ea5a0ab6..91ea91e8 100644
--- a/wqflask/utility/benchmark.py
+++ b/wqflask/utility/benchmark.py
@@ -6,7 +6,7 @@ from utility.tools import LOG_BENCH
from utility.logger import getLogger
logger = getLogger(__name__ )
-class Bench(object):
+class Bench:
entries = collections.OrderedDict()
def __init__(self, name=None, write_output=LOG_BENCH):
diff --git a/wqflask/utility/gen_geno_ob.py b/wqflask/utility/gen_geno_ob.py
index 81085ffe..0a381c9b 100644
--- a/wqflask/utility/gen_geno_ob.py
+++ b/wqflask/utility/gen_geno_ob.py
@@ -1,7 +1,7 @@
import utility.logger
logger = utility.logger.getLogger(__name__ )
-class genotype(object):
+class genotype:
"""
Replacement for reaper.Dataset so we can remove qtlreaper use while still generating mapping output figure
"""
@@ -119,7 +119,7 @@ class genotype(object):
self.chromosomes.append(chr_ob)
-class Chr(object):
+class Chr:
def __init__(self, name, geno_ob):
self.name = name
self.loci = []
@@ -140,7 +140,7 @@ class Chr(object):
def add_marker(self, marker_row):
self.loci.append(Locus(self.geno_ob, marker_row))
-class Locus(object):
+class Locus:
def __init__(self, geno_ob, marker_row = None):
self.chr = None
self.name = None
diff --git a/wqflask/utility/genofile_parser.py b/wqflask/utility/genofile_parser.py
index 0b736176..f8e96d19 100644
--- a/wqflask/utility/genofile_parser.py
+++ b/wqflask/utility/genofile_parser.py
@@ -12,7 +12,7 @@ import simplejson as json
from pprint import pformat as pf
-class Marker(object):
+class Marker:
def __init__(self):
self.name = None
self.chr = None
@@ -21,7 +21,7 @@ class Marker(object):
self.genotypes = []
-class ConvertGenoFile(object):
+class ConvertGenoFile:
def __init__(self, input_file):
self.mb_exists = False
diff --git a/wqflask/utility/helper_functions.py b/wqflask/utility/helper_functions.py
index 46eeb35d..12fd6be5 100644
--- a/wqflask/utility/helper_functions.py
+++ b/wqflask/utility/helper_functions.py
@@ -4,20 +4,23 @@ from base.species import TheSpecies
from utility import hmac
-from flask import Flask, g
+from flask import g
import logging
-logger = logging.getLogger(__name__ )
+logger = logging.getLogger(__name__)
+
def get_species_dataset_trait(self, start_vars):
- #assert type(read_genotype) == type(bool()), "Expecting boolean value for read_genotype"
if "temp_trait" in list(start_vars.keys()):
- if start_vars['temp_trait'] == "True":
- self.dataset = data_set.create_dataset(dataset_name = "Temp", dataset_type = "Temp", group_name = start_vars['group'])
- else:
- self.dataset = data_set.create_dataset(start_vars['dataset'])
+ if start_vars['temp_trait'] == "True":
+ self.dataset = data_set.create_dataset(
+ dataset_name="Temp",
+ dataset_type="Temp",
+ group_name=start_vars['group'])
+ else:
+ self.dataset = data_set.create_dataset(start_vars['dataset'])
else:
- self.dataset = data_set.create_dataset(start_vars['dataset'])
+ self.dataset = data_set.create_dataset(start_vars['dataset'])
logger.debug("After creating dataset")
self.species = TheSpecies(dataset=self.dataset)
logger.debug("After creating species")
@@ -27,9 +30,6 @@ def get_species_dataset_trait(self, start_vars):
get_qtl_info=True)
logger.debug("After creating trait")
- #if read_genotype:
- #self.dataset.group.read_genotype_file()
- #self.genotype = self.dataset.group.genotype
def get_trait_db_obs(self, trait_db_list):
if isinstance(trait_db_list, str):
@@ -42,28 +42,29 @@ def get_trait_db_obs(self, trait_db_list):
assert hmac_string==hmac.hmac_creation(data), "Data tampering?"
trait_name, dataset_name = data.split(":")[:2]
if dataset_name == "Temp":
- dataset_ob = data_set.create_dataset(dataset_name=dataset_name, dataset_type="Temp", group_name=trait_name.split("_")[2])
+ dataset_ob = data_set.create_dataset(
+ dataset_name=dataset_name, dataset_type="Temp",
+ group_name=trait_name.split("_")[2])
else:
dataset_ob = data_set.create_dataset(dataset_name)
trait_ob = create_trait(dataset=dataset_ob,
- name=trait_name,
- cellid=None)
+ name=trait_name,
+ cellid=None)
if trait_ob:
self.trait_list.append((trait_ob, dataset_ob))
-def get_species_groups():
-
- species_query = "SELECT SpeciesId, MenuName FROM Species"
- species_ids_and_names = g.db.execute(species_query).fetchall()
-
- species_and_groups = []
- for species_id, species_name in species_ids_and_names:
- this_species_groups = {}
- this_species_groups['species'] = species_name
- groups_query = "SELECT InbredSetName FROM InbredSet WHERE SpeciesId = %s" % (species_id)
- groups = [group[0] for group in g.db.execute(groups_query).fetchall()]
-
- this_species_groups['groups'] = groups
- species_and_groups.append(this_species_groups)
- return species_and_groups
+def get_species_groups():
+ """Group each species into a group"""
+ _menu = {}
+ for species, group_name in g.db.execute(
+ "SELECT s.MenuName, i.InbredSetName FROM InbredSet i "
+ "INNER JOIN Species s ON s.SpeciesId = i.SpeciesId "
+ "ORDER BY i.SpeciesId ASC, i.Name ASC").fetchall():
+ if _menu.get(species):
+ _menu = _menu[species].append(group_name)
+ else:
+ _menu[species] = [group_name]
+ return [{"species": key,
+ "groups": value} for key, value in
+ list(_menu.items())]
diff --git a/wqflask/utility/temp_data.py b/wqflask/utility/temp_data.py
index 4144ae00..b2cbd458 100644
--- a/wqflask/utility/temp_data.py
+++ b/wqflask/utility/temp_data.py
@@ -2,7 +2,7 @@ from redis import Redis
import simplejson as json
-class TempData(object):
+class TempData:
def __init__(self, temp_uuid):
self.temp_uuid = temp_uuid
diff --git a/wqflask/wqflask/api/gen_menu.py b/wqflask/wqflask/api/gen_menu.py
index 18afc5ad..eaddecd7 100644
--- a/wqflask/wqflask/api/gen_menu.py
+++ b/wqflask/wqflask/api/gen_menu.py
@@ -23,12 +23,7 @@ def get_species():
"""Build species list"""
results = g.db.execute(
"SELECT Name, MenuName FROM Species ORDER BY OrderId").fetchall()
-
- species = []
- for result in results:
- species.append([str(result[0]), str(result[1])])
-
- return species
+ return [[name, menu_name] for name, menu_name in results]
def get_groups(species):
diff --git a/wqflask/wqflask/comparison_bar_chart/comparison_bar_chart.py b/wqflask/wqflask/comparison_bar_chart/comparison_bar_chart.py
index 92de6073..5855ccf0 100644
--- a/wqflask/wqflask/comparison_bar_chart/comparison_bar_chart.py
+++ b/wqflask/wqflask/comparison_bar_chart/comparison_bar_chart.py
@@ -31,7 +31,7 @@ from MySQLdb import escape_string as escape
from flask import Flask, g
-class ComparisonBarChart(object):
+class ComparisonBarChart:
def __init__(self, start_vars):
trait_db_list = [trait.strip() for trait in start_vars['trait_list'].split(',')]
diff --git a/wqflask/wqflask/correlation/corr_scatter_plot.py b/wqflask/wqflask/correlation/corr_scatter_plot.py
index c87776bb..d5dc26f5 100644
--- a/wqflask/wqflask/correlation/corr_scatter_plot.py
+++ b/wqflask/wqflask/correlation/corr_scatter_plot.py
@@ -11,7 +11,7 @@ import numpy as np
import utility.logger
logger = utility.logger.getLogger(__name__ )
-class CorrScatterPlot(object):
+class CorrScatterPlot:
"""Page that displays a correlation scatterplot with a line fitted to it"""
def __init__(self, params):
diff --git a/wqflask/wqflask/correlation/show_corr_results.py b/wqflask/wqflask/correlation/show_corr_results.py
index fb4dc4f4..cb341e79 100644
--- a/wqflask/wqflask/correlation/show_corr_results.py
+++ b/wqflask/wqflask/correlation/show_corr_results.py
@@ -58,7 +58,7 @@ TISSUE_METHODS = [METHOD_TISSUE_PEARSON, METHOD_TISSUE_RANK]
TISSUE_MOUSE_DB = 1
-class CorrelationResults(object):
+class CorrelationResults:
def __init__(self, start_vars):
# get trait list from db (database name)
# calculate correlation with Base vector and targets
diff --git a/wqflask/wqflask/correlation_matrix/show_corr_matrix.py b/wqflask/wqflask/correlation_matrix/show_corr_matrix.py
index f77761d8..d0b4a156 100644
--- a/wqflask/wqflask/correlation_matrix/show_corr_matrix.py
+++ b/wqflask/wqflask/correlation_matrix/show_corr_matrix.py
@@ -41,7 +41,7 @@ Redis = get_redis_conn()
THIRTY_DAYS = 60 * 60 * 24 * 30
-class CorrelationMatrix(object):
+class CorrelationMatrix:
def __init__(self, start_vars):
trait_db_list = [trait.strip() for trait in start_vars['trait_list'].split(',')]
diff --git a/wqflask/wqflask/ctl/ctl_analysis.py b/wqflask/wqflask/ctl/ctl_analysis.py
index 72b4f3a3..1556e370 100644
--- a/wqflask/wqflask/ctl/ctl_analysis.py
+++ b/wqflask/wqflask/ctl/ctl_analysis.py
@@ -39,7 +39,7 @@ r_write_table = ro.r["write.table"] # Map the write.table function
r_data_frame = ro.r["data.frame"] # Map the write.table function
r_as_numeric = ro.r["as.numeric"] # Map the write.table function
-class CTL(object):
+class CTL:
def __init__(self):
logger.info("Initialization of CTL")
#log = r_file("/tmp/genenetwork_ctl.log", open = "wt")
diff --git a/wqflask/wqflask/db_info.py b/wqflask/wqflask/db_info.py
index f420b472..25e624ef 100644
--- a/wqflask/wqflask/db_info.py
+++ b/wqflask/wqflask/db_info.py
@@ -10,7 +10,7 @@ from utility.logger import getLogger
logger = getLogger(__name__)
-class InfoPage(object):
+class InfoPage:
def __init__(self, start_vars):
self.info = None
self.gn_accession_id = None
diff --git a/wqflask/wqflask/do_search.py b/wqflask/wqflask/do_search.py
index 00636563..364a3eed 100644
--- a/wqflask/wqflask/do_search.py
+++ b/wqflask/wqflask/do_search.py
@@ -17,7 +17,7 @@ from utility.logger import getLogger
logger = getLogger(__name__)
-class DoSearch(object):
+class DoSearch:
"""Parent class containing parameters/functions used for all searches"""
# Used to translate search phrases into classes
diff --git a/wqflask/wqflask/docs.py b/wqflask/wqflask/docs.py
index 23fc3cad..207767c4 100644
--- a/wqflask/wqflask/docs.py
+++ b/wqflask/wqflask/docs.py
@@ -5,7 +5,7 @@ from flask import g
from utility.logger import getLogger
logger = getLogger(__name__)
-class Docs(object):
+class Docs:
def __init__(self, entry, start_vars={}):
sql = """
diff --git a/wqflask/wqflask/external_tools/send_to_bnw.py b/wqflask/wqflask/external_tools/send_to_bnw.py
index efa17f05..c5c79e98 100644
--- a/wqflask/wqflask/external_tools/send_to_bnw.py
+++ b/wqflask/wqflask/external_tools/send_to_bnw.py
@@ -24,7 +24,7 @@ from utility import helper_functions, corr_result_helpers
import utility.logger
logger = utility.logger.getLogger(__name__ )
-class SendToBNW(object):
+class SendToBNW:
def __init__(self, start_vars):
trait_db_list = [trait.strip() for trait in start_vars['trait_list'].split(',')]
helper_functions.get_trait_db_obs(self, trait_db_list)
diff --git a/wqflask/wqflask/external_tools/send_to_geneweaver.py b/wqflask/wqflask/external_tools/send_to_geneweaver.py
index 4c958a88..47e4c53a 100644
--- a/wqflask/wqflask/external_tools/send_to_geneweaver.py
+++ b/wqflask/wqflask/external_tools/send_to_geneweaver.py
@@ -29,7 +29,7 @@ from utility import helper_functions, corr_result_helpers
import utility.logger
logger = utility.logger.getLogger(__name__ )
-class SendToGeneWeaver(object):
+class SendToGeneWeaver:
def __init__(self, start_vars):
trait_db_list = [trait.strip() for trait in start_vars['trait_list'].split(',')]
helper_functions.get_trait_db_obs(self, trait_db_list)
diff --git a/wqflask/wqflask/external_tools/send_to_webgestalt.py b/wqflask/wqflask/external_tools/send_to_webgestalt.py
index 2f068792..e1e5e655 100644
--- a/wqflask/wqflask/external_tools/send_to_webgestalt.py
+++ b/wqflask/wqflask/external_tools/send_to_webgestalt.py
@@ -29,7 +29,7 @@ from utility import helper_functions, corr_result_helpers
import utility.logger
logger = utility.logger.getLogger(__name__ )
-class SendToWebGestalt(object):
+class SendToWebGestalt:
def __init__(self, start_vars):
trait_db_list = [trait.strip() for trait in start_vars['trait_list'].split(',')]
helper_functions.get_trait_db_obs(self, trait_db_list)
diff --git a/wqflask/wqflask/gsearch.py b/wqflask/wqflask/gsearch.py
index 907f1180..9bf23d57 100644
--- a/wqflask/wqflask/gsearch.py
+++ b/wqflask/wqflask/gsearch.py
@@ -18,7 +18,7 @@ from utility.type_checking import is_float, is_int, is_str, get_float, get_int,
from utility.logger import getLogger
logger = getLogger(__name__)
-class GSearch(object):
+class GSearch:
def __init__(self, kw):
assert('type' in kw)
diff --git a/wqflask/wqflask/heatmap/heatmap.py b/wqflask/wqflask/heatmap/heatmap.py
index cca5a4fc..20e3559a 100644
--- a/wqflask/wqflask/heatmap/heatmap.py
+++ b/wqflask/wqflask/heatmap/heatmap.py
@@ -14,7 +14,7 @@ Redis = Redis()
logger = getLogger(__name__ )
-class Heatmap(object):
+class Heatmap:
def __init__(self, start_vars, temp_uuid):
trait_db_list = [trait.strip() for trait in start_vars['trait_list'].split(',')]
diff --git a/wqflask/wqflask/marker_regression/display_mapping_results.py b/wqflask/wqflask/marker_regression/display_mapping_results.py
index 6a5fe2f6..4074f098 100644
--- a/wqflask/wqflask/marker_regression/display_mapping_results.py
+++ b/wqflask/wqflask/marker_regression/display_mapping_results.py
@@ -152,7 +152,7 @@ class HtmlGenWrapper:
return map_
-class DisplayMappingResults(object):
+class DisplayMappingResults:
"""Inteval Mapping Plot Page"""
cMGraphInterval = 5
GRAPH_MIN_WIDTH = 900
diff --git a/wqflask/wqflask/marker_regression/run_mapping.py b/wqflask/wqflask/marker_regression/run_mapping.py
index 8f051c14..7dd0bcb6 100644
--- a/wqflask/wqflask/marker_regression/run_mapping.py
+++ b/wqflask/wqflask/marker_regression/run_mapping.py
@@ -45,7 +45,7 @@ from base.webqtlConfig import TMPDIR, GENERATED_TEXT_DIR
import utility.logger
logger = utility.logger.getLogger(__name__ )
-class RunMapping(object):
+class RunMapping:
def __init__(self, start_vars, temp_uuid):
helper_functions.get_species_dataset_trait(self, start_vars)
diff --git a/wqflask/wqflask/network_graph/network_graph.py b/wqflask/wqflask/network_graph/network_graph.py
index 132e1884..c99fce01 100644
--- a/wqflask/wqflask/network_graph/network_graph.py
+++ b/wqflask/wqflask/network_graph/network_graph.py
@@ -28,7 +28,7 @@ from utility import corr_result_helpers
from utility.tools import GN2_BRANCH_URL
-class NetworkGraph(object):
+class NetworkGraph:
def __init__(self, start_vars):
trait_db_list = [trait.strip()
diff --git a/wqflask/wqflask/news.py b/wqflask/wqflask/news.py
index 0675ec4b..861a93f2 100644
--- a/wqflask/wqflask/news.py
+++ b/wqflask/wqflask/news.py
@@ -1,6 +1,6 @@
from flask import g
-class News(object):
+class News:
def __init__(self):
sql = """
diff --git a/wqflask/wqflask/search_results.py b/wqflask/wqflask/search_results.py
index cb01a2af..fd7c132b 100644
--- a/wqflask/wqflask/search_results.py
+++ b/wqflask/wqflask/search_results.py
@@ -24,7 +24,7 @@ from utility.type_checking import is_str
from utility.logger import getLogger
logger = getLogger(__name__ )
-class SearchResultPage(object):
+class SearchResultPage:
#maxReturn = 3000
def __init__(self, kw):
diff --git a/wqflask/wqflask/server_side.py b/wqflask/wqflask/server_side.py
index 5f764767..48761fa0 100644
--- a/wqflask/wqflask/server_side.py
+++ b/wqflask/wqflask/server_side.py
@@ -2,7 +2,7 @@
-class ServerSideTable(object):
+class ServerSideTable:
"""
This class is used to do server-side processing
on the DataTables table such as paginating, sorting,
diff --git a/wqflask/wqflask/show_trait/SampleList.py b/wqflask/wqflask/show_trait/SampleList.py
index 857e4456..f955f632 100644
--- a/wqflask/wqflask/show_trait/SampleList.py
+++ b/wqflask/wqflask/show_trait/SampleList.py
@@ -8,7 +8,7 @@ from pprint import pformat as pf
from utility import Plot
from utility import Bunch
-class SampleList(object):
+class SampleList:
def __init__(self,
dataset,
sample_names,
diff --git a/wqflask/wqflask/show_trait/show_trait.py b/wqflask/wqflask/show_trait/show_trait.py
index 6892f02b..f9c5fbe6 100644
--- a/wqflask/wqflask/show_trait/show_trait.py
+++ b/wqflask/wqflask/show_trait/show_trait.py
@@ -1,7 +1,5 @@
import string
-import os
import datetime
-import pickle
import uuid
import requests
import json as json
@@ -11,75 +9,80 @@ from collections import OrderedDict
import numpy as np
import scipy.stats as ss
-from flask import Flask, g
+from flask import g
from base import webqtlConfig
-from base import webqtlCaseData
from wqflask.show_trait.SampleList import SampleList
from base.trait import create_trait
from base import data_set
-from db import webqtlDatabaseFunction
-from utility import webqtlUtil, Plot, Bunch, helper_functions
+from utility import helper_functions
from utility.authentication_tools import check_owner_or_admin
from utility.tools import locate_ignore_error
from utility.redis_tools import get_redis_conn, get_resource_id
+from utility.logger import getLogger
+
+
Redis = get_redis_conn()
ONE_YEAR = 60 * 60 * 24 * 365
-from pprint import pformat as pf
-
-from utility.logger import getLogger
-logger = getLogger(__name__ )
+logger = getLogger(__name__)
###############################################
#
-# Todo: Put in security to ensure that user has permission to access confidential data sets
-# And add i.p.limiting as necessary
+# Todo: Put in security to ensure that user has permission to access
+# confidential data sets And add i.p.limiting as necessary
#
##############################################
-class ShowTrait(object):
+class ShowTrait:
def __init__(self, kw):
if 'trait_id' in kw and kw['dataset'] != "Temp":
self.temp_trait = False
self.trait_id = kw['trait_id']
helper_functions.get_species_dataset_trait(self, kw)
self.resource_id = get_resource_id(self.dataset, self.trait_id)
- self.admin_status = check_owner_or_admin(resource_id=self.resource_id)
+ self.admin_status = check_owner_or_admin(
+ resource_id=self.resource_id)
elif 'group' in kw:
self.temp_trait = True
- self.trait_id = "Temp_"+kw['species']+ "_" + kw['group'] + "_" + datetime.datetime.now().strftime("%m%d%H%M%S")
+ self.trait_id = "Temp_"+kw['species'] + "_" + kw['group'] + \
+ "_" + datetime.datetime.now().strftime("%m%d%H%M%S")
self.temp_species = kw['species']
self.temp_group = kw['group']
- self.dataset = data_set.create_dataset(dataset_name = "Temp", dataset_type = "Temp", group_name = self.temp_group)
+ self.dataset = data_set.create_dataset(
+ dataset_name="Temp", dataset_type="Temp", group_name=self.temp_group)
- # Put values in Redis so they can be looked up later if added to a collection
+ # Put values in Redis so they can be looked up later if
+ # added to a collection
Redis.set(self.trait_id, kw['trait_paste'], ex=ONE_YEAR)
self.trait_vals = kw['trait_paste'].split()
self.this_trait = create_trait(dataset=self.dataset,
name=self.trait_id,
cellid=None)
- self.admin_status = check_owner_or_admin(dataset=self.dataset, trait_id=self.trait_id)
+ self.admin_status = check_owner_or_admin(
+ dataset=self.dataset, trait_id=self.trait_id)
else:
self.temp_trait = True
self.trait_id = kw['trait_id']
self.temp_species = self.trait_id.split("_")[1]
self.temp_group = self.trait_id.split("_")[2]
- self.dataset = data_set.create_dataset(dataset_name = "Temp", dataset_type = "Temp", group_name = self.temp_group)
+ self.dataset = data_set.create_dataset(
+ dataset_name="Temp", dataset_type="Temp", group_name=self.temp_group)
self.this_trait = create_trait(dataset=self.dataset,
name=self.trait_id,
cellid=None)
self.trait_vals = Redis.get(self.trait_id).split()
- self.admin_status = check_owner_or_admin(dataset=self.dataset, trait_id=self.trait_id)
+ self.admin_status = check_owner_or_admin(
+ dataset=self.dataset, trait_id=self.trait_id)
- #ZS: Get verify/rna-seq link URLs
+ # ZS: Get verify/rna-seq link URLs
try:
blatsequence = self.this_trait.blatseq
if not blatsequence:
- #XZ, 06/03/2009: ProbeSet name is not unique among platforms. We should use ProbeSet Id instead.
+ # XZ, 06/03/2009: ProbeSet name is not unique among platforms. We should use ProbeSet Id instead.
query1 = """SELECT Probe.Sequence, Probe.Name
FROM Probe, ProbeSet, ProbeSetFreeze, ProbeSetXRef
WHERE ProbeSetXRef.ProbeSetFreezeId = ProbeSetFreeze.Id AND
@@ -96,10 +99,10 @@ class ShowTrait(object):
if int(seqt[1][-1]) % 2 == 1:
blatsequence += string.strip(seqt[0])
- #--------Hongqiang add this part in order to not only blat ProbeSet, but also blat Probe
+ # --------Hongqiang add this part in order to not only blat ProbeSet, but also blat Probe
blatsequence = '%3E' + self.this_trait.name + '%0A' + blatsequence + '%0A'
- #XZ, 06/03/2009: ProbeSet name is not unique among platforms. We should use ProbeSet Id instead.
+ # XZ, 06/03/2009: ProbeSet name is not unique among platforms. We should use ProbeSet Id instead.
query2 = """SELECT Probe.Sequence, Probe.Name
FROM Probe, ProbeSet, ProbeSetFreeze, ProbeSetXRef
WHERE ProbeSetXRef.ProbeSetFreezeId = ProbeSetFreeze.Id AND
@@ -110,24 +113,29 @@ class ShowTrait(object):
seqs = g.db.execute(query2).fetchall()
for seqt in seqs:
- if int(seqt[1][-1]) %2 == 1:
- blatsequence += '%3EProbe_' + seqt[1].strip() + '%0A' + seqt[0].strip() + '%0A'
+ if int(seqt[1][-1]) % 2 == 1:
+ blatsequence += '%3EProbe_' + \
+ seqt[1].strip() + '%0A' + seqt[0].strip() + '%0A'
if self.dataset.group.species == "rat":
- self.UCSC_BLAT_URL = webqtlConfig.UCSC_BLAT % ('rat', 'rn6', blatsequence)
+ self.UCSC_BLAT_URL = webqtlConfig.UCSC_BLAT % (
+ 'rat', 'rn6', blatsequence)
self.UTHSC_BLAT_URL = ""
elif self.dataset.group.species == "mouse":
- self.UCSC_BLAT_URL = webqtlConfig.UCSC_BLAT % ('mouse', 'mm10', blatsequence)
- self.UTHSC_BLAT_URL = webqtlConfig.UTHSC_BLAT % ('mouse', 'mm10', blatsequence)
+ self.UCSC_BLAT_URL = webqtlConfig.UCSC_BLAT % (
+ 'mouse', 'mm10', blatsequence)
+ self.UTHSC_BLAT_URL = webqtlConfig.UTHSC_BLAT % (
+ 'mouse', 'mm10', blatsequence)
elif self.dataset.group.species == "human":
- self.UCSC_BLAT_URL = webqtlConfig.UCSC_BLAT % ('human', 'hg38', blatsequence)
+ self.UCSC_BLAT_URL = webqtlConfig.UCSC_BLAT % (
+ 'human', 'hg38', blatsequence)
self.UTHSC_BLAT_URL = ""
else:
self.UCSC_BLAT_URL = ""
self.UTHSC_BLAT_URL = ""
except:
- self.UCSC_BLAT_URL = ""
- self.UTHSC_BLAT_URL = ""
+ self.UCSC_BLAT_URL = ""
+ self.UTHSC_BLAT_URL = ""
if self.dataset.type == "ProbeSet":
self.show_probes = "True"
@@ -138,17 +146,13 @@ class ShowTrait(object):
self.ncbi_summary = get_ncbi_summary(self.this_trait)
- #Get nearest marker for composite mapping
+ # Get nearest marker for composite mapping
if not self.temp_trait:
if check_if_attr_exists(self.this_trait, 'locus_chr') and self.dataset.type != "Geno" and self.dataset.type != "Publish":
- self.nearest_marker = get_nearest_marker(self.this_trait, self.dataset)
- #self.nearest_marker1 = get_nearest_marker(self.this_trait, self.dataset)[0]
- #self.nearest_marker2 = get_nearest_marker(self.this_trait, self.dataset)[1]
+ self.nearest_marker = get_nearest_marker(
+ self.this_trait, self.dataset)
else:
self.nearest_marker = ""
- #self.nearest_marker1 = ""
- #self.nearest_marker2 = ""
-
self.make_sample_lists()
@@ -168,29 +172,40 @@ class ShowTrait(object):
categorical_var_list = []
if not self.temp_trait:
- categorical_var_list = get_categorical_variables(self.this_trait, self.sample_groups[0]) #ZS: Only using first samplelist, since I think mapping only uses those samples
+ # ZS: Only using first samplelist, since I think mapping only uses those samples
+ categorical_var_list = get_categorical_variables(
+ self.this_trait, self.sample_groups[0])
- #ZS: Get list of chromosomes to select for mapping
+ # ZS: Get list of chromosomes to select for mapping
self.chr_list = [["All", -1]]
for i, this_chr in enumerate(self.dataset.species.chromosomes.chromosomes):
- self.chr_list.append([self.dataset.species.chromosomes.chromosomes[this_chr].name, i])
+ self.chr_list.append(
+ [self.dataset.species.chromosomes.chromosomes[this_chr].name, i])
self.genofiles = self.dataset.group.get_genofiles()
- if "QTLReaper" or "R/qtl" in dataset.group.mapping_names: #ZS: No need to grab scales from .geno file unless it's using a mapping method that reads .geno files
+ # ZS: No need to grab scales from .geno file unless it's using
+ # a mapping method that reads .geno files
+ if "QTLReaper" or "R/qtl" in dataset.group.mapping_names:
if self.genofiles:
self.scales_in_geno = get_genotype_scales(self.genofiles)
else:
- self.scales_in_geno = get_genotype_scales(self.dataset.group.name + ".geno")
+ self.scales_in_geno = get_genotype_scales(
+ self.dataset.group.name + ".geno")
else:
self.scales_in_geno = {}
self.has_num_cases = has_num_cases(self.this_trait)
- #ZS: Needed to know whether to display bar chart + get max sample name length in order to set table column width
+ # ZS: Needed to know whether to display bar chart + get max
+ # sample name length in order to set table column width
self.num_values = 0
- self.binary = "true" #ZS: So it knows whether to display the Binary R/qtl mapping method, which doesn't work unless all values are 0 or 1
- self.negative_vals_exist = "false" #ZS: Since we don't want to show log2 transform option for situations where it doesn't make sense
+ # ZS: So it knows whether to display the Binary R/qtl mapping
+ # method, which doesn't work unless all values are 0 or 1
+ self.binary = "true"
+ # ZS: Since we don't want to show log2 transform option for
+ # situations where it doesn't make sense
+ self.negative_vals_exist = "false"
max_samplename_width = 1
for group in self.sample_groups:
for sample in group.sample_list:
@@ -203,7 +218,8 @@ class ShowTrait(object):
if sample.value < 0:
self.negative_vals_exist = "true"
- #ZS: Check whether any attributes have few enough distinct values to show the "Block samples by group" option
+ # ZS: Check whether any attributes have few enough distinct
+ # values to show the "Block samples by group" option
self.categorical_attr_exists = "false"
for attribute in self.sample_groups[0].attributes:
if len(self.sample_groups[0].attributes[attribute].distinct_values) <= 10:
@@ -212,7 +228,8 @@ class ShowTrait(object):
sample_column_width = max_samplename_width * 8
- self.stats_table_width, self.trait_table_width = get_table_widths(self.sample_groups, sample_column_width, self.has_num_cases)
+ self.stats_table_width, self.trait_table_width = get_table_widths(
+ self.sample_groups, sample_column_width, self.has_num_cases)
if self.num_values >= 5000:
self.maf = 0.01
@@ -243,9 +260,9 @@ class ShowTrait(object):
hddn['dataset'] = self.dataset.name
hddn['temp_trait'] = False
if self.temp_trait:
- hddn['temp_trait'] = True
- hddn['group'] = self.temp_group
- hddn['species'] = self.temp_species
+ hddn['temp_trait'] = True
+ hddn['group'] = self.temp_group
+ hddn['species'] = self.temp_species
hddn['use_outliers'] = False
hddn['method'] = "gemma"
hddn['selected_chr'] = -1
@@ -258,7 +275,6 @@ class ShowTrait(object):
if not self.temp_trait:
if hasattr(self.this_trait, 'locus_chr') and self.this_trait.locus_chr != "" and self.dataset.type != "Geno" and self.dataset.type != "Publish":
hddn['control_marker'] = self.nearest_marker
- #hddn['control_marker'] = self.nearest_marker1+","+self.nearest_marker2
hddn['do_control'] = False
hddn['maf'] = 0.05
hddn['mapping_scale'] = "physic"
@@ -266,39 +282,46 @@ class ShowTrait(object):
hddn['export_data'] = ""
hddn['export_format'] = "excel"
if len(self.scales_in_geno) < 2:
- hddn['mapping_scale'] = self.scales_in_geno[list(self.scales_in_geno.keys())[0]][0][0]
+ hddn['mapping_scale'] = self.scales_in_geno[list(
+ self.scales_in_geno.keys())[0]][0][0]
- # We'll need access to this_trait and hddn in the Jinja2 Template, so we put it inside self
+ # We'll need access to this_trait and hddn in the Jinja2
+ # Template, so we put it inside self
self.hddn = hddn
- js_data = dict(trait_id = self.trait_id,
- trait_symbol = trait_symbol,
- short_description = short_description,
- unit_type = trait_units,
- dataset_type = self.dataset.type,
- species = self.dataset.group.species,
- scales_in_geno = self.scales_in_geno,
- data_scale = self.dataset.data_scale,
- sample_group_types = self.sample_group_types,
- sample_lists = sample_lists,
- se_exists = self.sample_groups[0].se_exists,
- has_num_cases = self.has_num_cases,
- attributes = self.sample_groups[0].attributes,
- categorical_attr_exists = self.categorical_attr_exists,
- categorical_vars = ",".join(categorical_var_list),
- num_values = self.num_values,
- qnorm_values = self.qnorm_vals,
- zscore_values = self.z_scores,
- sample_column_width = sample_column_width,
- temp_uuid = self.temp_uuid)
+ js_data = dict(trait_id=self.trait_id,
+ trait_symbol=trait_symbol,
+ short_description=short_description,
+ unit_type=trait_units,
+ dataset_type=self.dataset.type,
+ species=self.dataset.group.species,
+ scales_in_geno=self.scales_in_geno,
+ data_scale=self.dataset.data_scale,
+ sample_group_types=self.sample_group_types,
+ sample_lists=sample_lists,
+ se_exists=self.sample_groups[0].se_exists,
+ has_num_cases=self.has_num_cases,
+ attributes=self.sample_groups[0].attributes,
+ categorical_attr_exists=self.categorical_attr_exists,
+ categorical_vars=",".join(categorical_var_list),
+ num_values=self.num_values,
+ qnorm_values=self.qnorm_vals,
+ zscore_values=self.z_scores,
+ sample_column_width=sample_column_width,
+ temp_uuid=self.temp_uuid)
self.js_data = js_data
def get_external_links(self):
- #ZS: There's some weirdness here because some fields don't exist while others are empty strings
- self.pubmed_link = webqtlConfig.PUBMEDLINK_URL % self.this_trait.pubmed_id if check_if_attr_exists(self.this_trait, 'pubmed_id') else None
- self.ncbi_gene_link = webqtlConfig.NCBI_LOCUSID % self.this_trait.geneid if check_if_attr_exists(self.this_trait, 'geneid') else None
- self.omim_link = webqtlConfig.OMIM_ID % self.this_trait.omim if check_if_attr_exists(self.this_trait, 'omim') else None
- self.homologene_link = webqtlConfig.HOMOLOGENE_ID % self.this_trait.homologeneid if check_if_attr_exists(self.this_trait, 'homologeneid') else None
+ # ZS: There's some weirdness here because some fields don't
+ # exist while others are empty strings
+ self.pubmed_link = webqtlConfig.PUBMEDLINK_URL % self.this_trait.pubmed_id if check_if_attr_exists(
+ self.this_trait, 'pubmed_id') else None
+ self.ncbi_gene_link = webqtlConfig.NCBI_LOCUSID % self.this_trait.geneid if check_if_attr_exists(
+ self.this_trait, 'geneid') else None
+ self.omim_link = webqtlConfig.OMIM_ID % self.this_trait.omim if check_if_attr_exists(
+ self.this_trait, 'omim') else None
+ self.homologene_link = webqtlConfig.HOMOLOGENE_ID % self.this_trait.homologeneid if check_if_attr_exists(
+ self.this_trait, 'homologeneid') else None
self.genbank_link = None
if check_if_attr_exists(self.this_trait, 'genbankid'):
@@ -320,14 +343,16 @@ class ShowTrait(object):
self.panther_link = webqtlConfig.PANTHER_URL % self.this_trait.symbol
self.ebi_gwas_link = webqtlConfig.EBIGWAS_URL % self.this_trait.symbol
self.protein_atlas_link = webqtlConfig.PROTEIN_ATLAS_URL % self.this_trait.symbol
- #self.open_targets_link = webqtlConfig.OPEN_TARGETS_URL % self.this_trait.symbol
if self.dataset.group.species == "mouse" or self.dataset.group.species == "human":
- self.rgd_link = webqtlConfig.RGD_URL % (self.this_trait.symbol, self.dataset.group.species.capitalize())
+ self.rgd_link = webqtlConfig.RGD_URL % (
+ self.this_trait.symbol, self.dataset.group.species.capitalize())
if self.dataset.group.species == "mouse":
- self.genemania_link = webqtlConfig.GENEMANIA_URL % ("mus-musculus", self.this_trait.symbol)
+ self.genemania_link = webqtlConfig.GENEMANIA_URL % (
+ "mus-musculus", self.this_trait.symbol)
else:
- self.genemania_link = webqtlConfig.GENEMANIA_URL % ("homo-sapiens", self.this_trait.symbol)
+ self.genemania_link = webqtlConfig.GENEMANIA_URL % (
+ "homo-sapiens", self.this_trait.symbol)
if self.dataset.group.species == "mouse":
self.aba_link = webqtlConfig.ABA_URL % self.this_trait.symbol
@@ -345,12 +370,16 @@ class ShowTrait(object):
if chr and transcript_start and transcript_end and self.this_trait.refseq_transcriptid:
transcript_start = int(transcript_start*1000000)
transcript_end = int(transcript_end*1000000)
- self.ucsc_blat_link = webqtlConfig.UCSC_REFSEQ % ('mm10', self.this_trait.refseq_transcriptid, chr, transcript_start, transcript_end)
+ self.ucsc_blat_link = webqtlConfig.UCSC_REFSEQ % (
+ 'mm10', self.this_trait.refseq_transcriptid, chr, transcript_start, transcript_end)
if self.dataset.group.species == "rat":
- self.rgd_link = webqtlConfig.RGD_URL % (self.this_trait.symbol, self.dataset.group.species.capitalize())
- self.phenogen_link = webqtlConfig.PHENOGEN_URL % (self.this_trait.symbol)
- self.genemania_link = webqtlConfig.GENEMANIA_URL % ("rattus-norvegicus", self.this_trait.symbol)
+ self.rgd_link = webqtlConfig.RGD_URL % (
+ self.this_trait.symbol, self.dataset.group.species.capitalize())
+ self.phenogen_link = webqtlConfig.PHENOGEN_URL % (
+ self.this_trait.symbol)
+ self.genemania_link = webqtlConfig.GENEMANIA_URL % (
+ "rattus-norvegicus", self.this_trait.symbol)
query = """SELECT kgID, chromosome, txStart, txEnd
FROM GeneList_rn33
@@ -363,12 +392,15 @@ class ShowTrait(object):
kgId = chr = transcript_start = transcript_end = None
if chr and transcript_start and transcript_end and kgId:
- transcript_start = int(transcript_start*1000000) # Convert to bases from megabases
+ # Convert to bases from megabases
+ transcript_start = int(transcript_start*1000000)
transcript_end = int(transcript_end*1000000)
- self.ucsc_blat_link = webqtlConfig.UCSC_REFSEQ % ('rn6', kgId, chr, transcript_start, transcript_end)
+ self.ucsc_blat_link = webqtlConfig.UCSC_REFSEQ % (
+ 'rn6', kgId, chr, transcript_start, transcript_end)
if self.this_trait.geneid and (self.dataset.group.species == "mouse" or self.dataset.group.species == "rat" or self.dataset.group.species == "human"):
- self.biogps_link = webqtlConfig.BIOGPS_URL % (self.dataset.group.species, self.this_trait.geneid)
+ self.biogps_link = webqtlConfig.BIOGPS_URL % (
+ self.dataset.group.species, self.this_trait.geneid)
self.gemma_link = webqtlConfig.GEMMA_URL % self.this_trait.geneid
if self.dataset.group.species == "human":
@@ -389,47 +421,52 @@ class ShowTrait(object):
if self.temp_trait == True:
dataset_menu = data_set.datasets(this_group)
else:
- dataset_menu = data_set.datasets(this_group, self.dataset.group)
+ dataset_menu = data_set.datasets(
+ this_group, self.dataset.group)
dataset_menu_selected = None
if len(dataset_menu):
if self.dataset:
dataset_menu_selected = self.dataset.name
- return_results_menu = (100, 200, 500, 1000, 2000, 5000, 10000, 15000, 20000)
+ return_results_menu = (100, 200, 500, 1000,
+ 2000, 5000, 10000, 15000, 20000)
return_results_menu_selected = 500
- self.corr_tools = dict(dataset_menu = dataset_menu,
- dataset_menu_selected = dataset_menu_selected,
- return_results_menu = return_results_menu,
- return_results_menu_selected = return_results_menu_selected,)
+ self.corr_tools = dict(dataset_menu=dataset_menu,
+ dataset_menu_selected=dataset_menu_selected,
+ return_results_menu=return_results_menu,
+ return_results_menu_selected=return_results_menu_selected,)
def make_sample_lists(self):
all_samples_ordered = self.dataset.group.all_samples_ordered()
-
+
parent_f1_samples = []
if self.dataset.group.parlist and self.dataset.group.f1list:
parent_f1_samples = self.dataset.group.parlist + self.dataset.group.f1list
primary_sample_names = list(all_samples_ordered)
-
if not self.temp_trait:
other_sample_names = []
for sample in list(self.this_trait.data.keys()):
if (self.this_trait.data[sample].name2 != self.this_trait.data[sample].name):
if ((self.this_trait.data[sample].name2 in primary_sample_names) and
- (self.this_trait.data[sample].name not in primary_sample_names)):
- primary_sample_names.append(self.this_trait.data[sample].name)
- primary_sample_names.remove(self.this_trait.data[sample].name2)
+ (self.this_trait.data[sample].name not in primary_sample_names)):
+ primary_sample_names.append(
+ self.this_trait.data[sample].name)
+ primary_sample_names.remove(
+ self.this_trait.data[sample].name2)
all_samples_set = set(all_samples_ordered)
if sample not in all_samples_set:
all_samples_ordered.append(sample)
other_sample_names.append(sample)
- #ZS: CFW is here because the .geno file doesn't properly contain its full list of samples. This should probably be fixed.
+ # ZS: CFW is here because the .geno file doesn't properly
+ # contain its full list of samples. This should probably
+ # be fixed.
if self.dataset.group.species == "human" or (set(primary_sample_names) == set(parent_f1_samples)) or self.dataset.group.name == "CFW":
primary_sample_names += other_sample_names
other_sample_names = []
@@ -439,33 +476,34 @@ class ShowTrait(object):
else:
primary_header = "Samples"
- primary_samples = SampleList(dataset = self.dataset,
- sample_names=primary_sample_names,
- this_trait=self.this_trait,
- sample_group_type='primary',
- header=primary_header)
+ primary_samples = SampleList(dataset=self.dataset,
+ sample_names=primary_sample_names,
+ this_trait=self.this_trait,
+ sample_group_type='primary',
+ header=primary_header)
- #if other_sample_names and self.dataset.group.species != "human" and self.dataset.group.name != "CFW":
+ # if other_sample_names and self.dataset.group.species !=
+ # "human" and self.dataset.group.name != "CFW":
if len(other_sample_names) > 0:
- other_sample_names.sort() #Sort other samples
+ other_sample_names.sort() # Sort other samples
if parent_f1_samples:
other_sample_names = parent_f1_samples + other_sample_names
other_samples = SampleList(dataset=self.dataset,
- sample_names=other_sample_names,
- this_trait=self.this_trait,
- sample_group_type='other',
- header="Other")
+ sample_names=other_sample_names,
+ this_trait=self.this_trait,
+ sample_group_type='other',
+ header="Other")
self.sample_groups = (primary_samples, other_samples)
else:
self.sample_groups = (primary_samples,)
else:
- primary_samples = SampleList(dataset = self.dataset,
- sample_names=primary_sample_names,
- this_trait=self.trait_vals,
- sample_group_type='primary',
- header="%s Only" % (self.dataset.group.name))
+ primary_samples = SampleList(dataset=self.dataset,
+ sample_names=primary_sample_names,
+ this_trait=self.trait_vals,
+ sample_group_type='primary',
+ header="%s Only" % (self.dataset.group.name))
self.sample_groups = (primary_samples,)
self.primary_sample_names = primary_sample_names
@@ -539,7 +577,8 @@ def get_z_scores(sample_groups):
def get_nearest_marker(this_trait, this_db):
this_chr = this_trait.locus_chr
this_mb = this_trait.locus_mb
- #One option is to take flanking markers, another is to take the two (or one) closest
+ # One option is to take flanking markers, another is to take the
+ # two (or one) closest
query = """SELECT Geno.Name
FROM Geno, GenoXRef, GenoFreeze
WHERE Geno.Chr = '{}' AND
@@ -552,7 +591,6 @@ def get_nearest_marker(this_trait, this_db):
if result == []:
return ""
- #return "", ""
else:
return result[0][0]
@@ -617,10 +655,13 @@ def check_if_attr_exists(the_trait, id_type):
def get_ncbi_summary(this_trait):
if check_if_attr_exists(this_trait, 'geneid'):
- #ZS: Need to switch this try/except to something that checks the output later
+ # ZS: Need to switch this try/except to something that checks
+ # the output later
try:
- response = requests.get("http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esummary.fcgi?db=gene&id=%s&retmode=json" % this_trait.geneid)
- summary = json.loads(response.content)['result'][this_trait.geneid]['summary']
+ response = requests.get(
+ "http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esummary.fcgi?db=gene&id=%s&retmode=json" % this_trait.geneid)
+ summary = json.loads(response.content)[
+ 'result'][this_trait.geneid]['summary']
return summary
except:
return None
@@ -636,13 +677,15 @@ def get_categorical_variables(this_trait, sample_list):
attribute_vals = []
for sample_name in list(this_trait.data.keys()):
if sample_list.attributes[attribute].name in this_trait.data[sample_name].extra_attributes:
- attribute_vals.append(this_trait.data[sample_name].extra_attributes[sample_list.attributes[attribute].name])
+ attribute_vals.append(
+ this_trait.data[sample_name].extra_attributes[sample_list.attributes[attribute].name])
else:
attribute_vals.append("N/A")
num_distinct = len(set(attribute_vals))
if num_distinct < 10:
- categorical_var_list.append(sample_list.attributes[attribute].name)
+ categorical_var_list.append(
+ sample_list.attributes[attribute].name)
return categorical_var_list
@@ -652,7 +695,8 @@ def get_genotype_scales(genofiles):
if isinstance(genofiles, list):
for the_file in genofiles:
file_location = the_file['location']
- geno_scales[file_location] = get_scales_from_genofile(file_location)
+ geno_scales[file_location] = get_scales_from_genofile(
+ file_location)
else:
geno_scales[genofiles] = get_scales_from_genofile(genofiles)
@@ -661,8 +705,8 @@ def get_genotype_scales(genofiles):
def get_scales_from_genofile(file_location):
geno_path = locate_ignore_error(file_location, 'genotype')
-
- if not geno_path: #ZS: This is just to allow the code to run when
+ # ZS: This is just to allow the code to run when
+ if not geno_path:
return [["physic", "Mb"]]
cm_and_mb_cols_exist = True
cm_column = None
@@ -670,7 +714,9 @@ def get_scales_from_genofile(file_location):
with open(geno_path, "r") as geno_fh:
for i, line in enumerate(geno_fh):
if line[0] == "#" or line[0] == "@":
- if "@scale" in line: #ZS: If the scale is made explicit in the metadata, use that
+ # ZS: If the scale is made explicit in the metadata,
+ # use that
+ if "@scale" in line:
scale = line.split(":")[1].strip()
if scale == "morgan":
return [["morgan", "cM"]]
@@ -690,12 +736,16 @@ def get_scales_from_genofile(file_location):
mb_column = 3
break
- #ZS: This attempts to check whether the cM and Mb columns are 'real', since some .geno files have one column be a copy of the other column, or have one column that is all 0s
+ # ZS: This attempts to check whether the cM and Mb columns are
+ # 'real', since some .geno files have one column be a copy of
+ # the other column, or have one column that is all 0s
cm_all_zero = True
mb_all_zero = True
cm_mb_all_equal = True
for i, line in enumerate(geno_fh):
- if first_marker_line <= i < first_marker_line + 10: #ZS: I'm assuming there won't be more than 10 markers where the position is listed as 0
+ # ZS: I'm assuming there won't be more than 10 markers
+ # where the position is listed as 0
+ if first_marker_line <= i < first_marker_line + 10:
if cm_column:
cm_val = line.split("\t")[cm_column].strip()
if cm_val != "0":
@@ -711,8 +761,8 @@ def get_scales_from_genofile(file_location):
if i > first_marker_line + 10:
break
-
- #ZS: This assumes that both won't be all zero, since if that's the case mapping shouldn't be an option to begin with
+ # ZS: This assumes that both won't be all zero, since if that's
+ # the case mapping shouldn't be an option to begin with
if mb_all_zero:
return [["morgan", "cM"]]
elif cm_mb_all_equal:
diff --git a/wqflask/wqflask/snp_browser/snp_browser.py b/wqflask/wqflask/snp_browser/snp_browser.py
index a52399a2..8658abf8 100644
--- a/wqflask/wqflask/snp_browser/snp_browser.py
+++ b/wqflask/wqflask/snp_browser/snp_browser.py
@@ -9,7 +9,7 @@ logger = getLogger(__name__)
from base import species
from base import webqtlConfig
-class SnpBrowser(object):
+class SnpBrowser:
def __init__(self, start_vars):
self.strain_lists = get_browser_sample_lists()
diff --git a/wqflask/wqflask/static/new/javascript/dataset_select_menu_edit_trait.js b/wqflask/wqflask/static/new/javascript/dataset_select_menu_edit_trait.js
new file mode 100644
index 00000000..1d4a94d9
--- /dev/null
+++ b/wqflask/wqflask/static/new/javascript/dataset_select_menu_edit_trait.js
@@ -0,0 +1,253 @@
+var apply_default, check_search_term, dataset_info, group_info, make_default, open_window, populate_dataset, populate_group, populate_species, populate_type, process_json, redo_dropdown;
+process_json = function(data) {
+ window.jdata = data;
+ populate_species();
+ if ($('#type').length > 0) { //This is to determine if it's the index page or the submit_trait page (which only has species and group selection and no make default option)
+ return apply_default();
+ }
+};
+
+$.ajax('/api/v_pre1/gen_dropdown', {
+ dataType: 'json',
+ success: process_json
+});
+
+populate_species = function() {
+ var species_list;
+ species_list = this.jdata.species;
+ redo_dropdown($('#species'), species_list);
+ return populate_group();
+};
+window.populate_species = populate_species;
+populate_group = function() {
+ var group_list, species;
+ console.log("in populate group");
+ species = $('#species').val();
+ group_list = this.jdata.groups[species];
+ for (_i = 0, _len = group_list.length; _i < (_len - 1); _i++) {
+ if (group_list[_i][0] == "BXD300"){
+ group_list.splice(_i, 1)
+ }
+ }
+ redo_dropdown($('#group'), group_list);
+ if ($('#type').length > 0) { //This is to determine if it's the index page or the submit_trait page (which only has species and group selection and no make default option)
+ return populate_type();
+ }
+};
+window.populate_group = populate_group;
+populate_type = function() {
+ var group, species, type_list;
+ console.log("in populate type");
+ species = $('#species').val();
+ group = $('#group').val();
+ type_list = this.jdata.types[species][group];
+ redo_dropdown($('#type'), type_list);
+ return populate_dataset();
+};
+window.populate_type = populate_type;
+populate_dataset = function() {
+ var dataset_list, group, species, type;
+ console.log("in populate dataset");
+ species = $('#species').val();
+ group = $('#group').val();
+ type = $('#type').val();
+ console.log("sgt:", species, group, type);
+ dataset_list = this.jdata.datasets[species][group][type];
+ console.log("pop_dataset:", dataset_list);
+ return redo_dropdown($('#dataset'), dataset_list);
+};
+window.populate_dataset = populate_dataset;
+redo_dropdown = function(dropdown, items) {
+ var item, _i, _len, _results;
+ console.log("in redo:", dropdown, items);
+ dropdown.empty();
+ _results = [];
+
+ if (dropdown.attr('id') == "group"){
+ group_family_list = [];
+ for (_i = 0, _len = items.length; _i < _len; _i++) {
+ item = items[_i];
+ group_family = item[2].toString().split(":")[1]
+ group_family_list.push([item[0], item[1], group_family])
+ }
+
+ current_family = ""
+ this_opt_group = null
+ for (_i = 0, _len = group_family_list.length; _i < _len; _i++) {
+ item = group_family_list[_i];
+ if (item[2] != "None" && current_family == ""){
+ current_family = item[2]
+ this_opt_group = $("<optgroup label=\"" + item[2] + "\">")
+ this_opt_group.append($("<option />").val(item[0]).text(item[1]));
+ } else if (current_family != "" && item[2] == current_family){
+ this_opt_group.append($("<option />").val(item[0]).text(item[1]));
+ if (_i == group_family_list.length - 1){
+ _results.push(dropdown.append(this_opt_group))
+ }
+ } else if (current_family != "" && item[2] != current_family && item[2] != "None"){
+ current_family = item[2]
+ _results.push(dropdown.append(this_opt_group))
+ this_opt_group = $("<optgroup label=\"" + current_family + "\">")
+ this_opt_group.append($("<option />").val(item[0]).text(item[1]));
+ if (_i == group_family_list.length - 1){
+ _results.push(dropdown.append(this_opt_group))
+ }
+ } else if (current_family != "" && this_opt_group != null && item[2] == "None"){
+ _results.push(dropdown.append(this_opt_group))
+ current_family = ""
+ _results.push(dropdown.append($("<option />").val(item[0]).text(item[1])));
+ } else {
+ _results.push(dropdown.append($("<option />").val(item[0]).text(item[1])));
+ }
+ }
+ } else if (dropdown.attr('id') == "type"){
+ type_family_list = [];
+ for (_i = 0, _len = items.length; _i < _len; _i++) {
+ item = items[_i];
+ type_family_list.push([item[0], item[1], item[2]])
+ }
+
+ current_family = ""
+ this_opt_group = null
+ for (_i = 0, _len = type_family_list.length; _i < _len; _i++) {
+ item = type_family_list[_i];
+ if (item[2] != "None" && current_family == ""){
+ current_family = item[2]
+ this_opt_group = $("<optgroup label=\"" + item[2] + "\">")
+ this_opt_group.append($("<option />").val(item[0]).text(item[1]));
+ if (_i == type_family_list.length - 1){
+ _results.push(dropdown.append(this_opt_group))
+ }
+ } else if (current_family != "" && item[2] == current_family){
+ this_opt_group.append($("<option />").val(item[0]).text(item[1]));
+ if (_i == type_family_list.length - 1){
+ _results.push(dropdown.append(this_opt_group))
+ }
+ } else if (current_family != "" && item[2] != current_family && item[2] != "None"){
+ current_family = item[2]
+ _results.push(dropdown.append(this_opt_group))
+ this_opt_group = $("<optgroup label=\"" + current_family + "\">")
+ this_opt_group.append($("<option />").val(item[0]).text(item[1]));
+ if (_i == type_family_list.length - 1){
+ _results.push(dropdown.append(this_opt_group))
+ }
+ } else {
+ _results.push(dropdown.append(this_opt_group))
+ current_family = ""
+ _results.push(dropdown.append($("<option />").val(item[0]).text(item[1])));
+ }
+ }
+ } else {
+ for (_i = 0, _len = items.length; _i < _len; _i++) {
+ item = items[_i];
+ if (item.length > 2){
+ _results.push(dropdown.append($("<option data-id=\""+item[0]+"\" />").val(item[1]).text(item[2])));
+ } else {
+ _results.push(dropdown.append($("<option />").val(item[0]).text(item[1])));
+ }
+ }
+ }
+
+ return _results;
+};
+$('#species').change((function(_this) {
+ return function() {
+ return populate_group();
+ };
+})(this));
+$('#group').change((function(_this) {
+ return function() {
+ if ($('#type').length > 0) { //This is to determine if it's the index page or the submit_trait page (which only has species and group selection and no make default option)
+ return populate_type();
+ }
+ else {
+ return false
+ }
+ };
+})(this));
+$('#type').change((function(_this) {
+ return function() {
+ return populate_dataset();
+ };
+})(this));
+open_window = function(url, name) {
+ var options;
+ options = "menubar=yes,toolbar=yes,titlebar=yes,location=yes,resizable=yes,status=yes,scrollbars=yes,directories=yes,width=900";
+ return open(url, name, options).focus();
+};
+group_info = function() {
+ var group, species, url;
+ species = $('#species').val();
+ group = $('#group').val();
+ url = "http://gn1.genenetwork.org/" + species + "Cross.html#" + group;
+ return open_window(url, "Group Info");
+};
+$('#group_info').click(group_info);
+dataset_info = function() {
+ var dataset, url;
+ accession_id = $('#dataset option:selected').data("id");
+ name = $('#dataset option:selected').val();
+ if (accession_id != "None") {
+ url = "http://genenetwork.org/webqtl/main.py?FormID=sharinginfo&GN_AccessionId=" + accession_id + "&InfoPageName=" + name;
+ } else {
+ url = "http://genenetwork.org/webqtl/main.py?FormID=sharinginfo&InfoPageName=" + name;
+ }
+ return open_window(url, "Dataset Info");
+};
+$('#dataset_info').click(dataset_info);
+make_default = function() {
+ var holder, item, jholder, _i, _len, _ref;
+ alert("The current settings are now your default.")
+ holder = {};
+ _ref = ['species', 'group', 'type', 'dataset'];
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ item = _ref[_i];
+ holder[item] = $("#" + item).val();
+ }
+ jholder = JSON.stringify(holder);
+ return $.cookie('search_defaults', jholder, {
+ expires: 365
+ });
+};
+apply_default = function() {
+ var defaults, item, populate_function, _i, _len, _ref, _results;
+ defaults = $.cookie('search_defaults');
+ if (defaults) {
+ defaults = $.parseJSON(defaults);
+ } else {
+ defaults = {
+ species: "mouse",
+ group: "BXD",
+ type: "Hippocampus mRNA",
+ dataset: "HC_M2_0606_P"
+ };
+ }
+
+ _ref = [['species', 'group'], ['group', 'type'], ['type', 'dataset'], ['dataset', null]];
+ _results = [];
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ item = _ref[_i];
+ $("#" + item[0]).val(defaults[item[0]]);
+ if (item[1]) {
+ populate_function = "populate_" + item[1];
+ console.log("Calling:", populate_function);
+ _results.push(window[populate_function]());
+ } else {
+ _results.push(void 0);
+ }
+ }
+ return _results;
+};
+check_search_term = function() {
+ var or_search_term, and_search_term;
+ or_search_term = $('#or_search').val();
+ and_search_term = $('#and_search').val();
+ console.log("or_search_term:", or_search_term);
+ console.log("and_search_term:", and_search_term);
+ if (or_search_term === "" && and_search_term === "") {
+ alert("Please enter one or more search terms or search equations.");
+ return false;
+ }
+};
+$("#make_default").click(make_default);
+$("#btsearch").click(check_search_term);
diff --git a/wqflask/wqflask/templates/edit_trait.html b/wqflask/wqflask/templates/edit_trait.html
new file mode 100644
index 00000000..b9a31fc6
--- /dev/null
+++ b/wqflask/wqflask/templates/edit_trait.html
@@ -0,0 +1,86 @@
+{% extends "base.html" %}
+{% block title %}Trait Submission{% endblock %}
+{% block content %}
+<!-- Start of body -->
+ <form method="post" action="/show_temp_trait">
+ <div class="container-fluid">
+
+ {{ flash_me() }}
+
+ <div class="row" style="width: 1400px !important;">
+ <div class="col-xs-3">
+ <section id="description">
+ <div>
+ <h2 style="color: #5a5a5a;">Introduction</h2>
+ <hr>
+ <p>The trait values that you enter are statistically compared with verified genotypes collected at a set of microsatellite markers in each RI set. The markers are drawn from a set of over 750, but for each set redundant markers have been removed, preferentially retaining those that are most informative.</p>
+ <p>These error-checked RI mapping data match theoretical expectations for RI strain sets. The cumulative adjusted length of the RI maps are approximately 1400 cM, a value that matches those of both MIT maps and Chromosome Committee Report maps. See our <a target="_blank" href="http://www.nervenet.org/papers/BXN.html">full description</a> of the genetic data collected as part of the WebQTL project.</p>
+ </div>
+ </section>
+ <br>
+ <section id="description">
+ <div>
+ <h2 style="color: #5a5a5a;">About Your Data</h2>
+ <hr>
+ <p>You can open a separate window giving the number of strains for each data set and sample data.</p>
+ <p>None of your submitted data is copied or stored by this system except during the actual processing of your submission. By the time the reply page displays in your browser, your submission has been cleared from this system.</p>
+ </div>
+ </section>
+ </div>
+ <div style="padding-left:20px" class="col-xs-6" style="width: 600px !important;">
+ <section id="submission_form">
+ <div class="form-group">
+ <h2 style="color: #5a5a5a;">Edit Trait Form</h2>
+ <hr>
+ <div style="margin-bottom: 150px;" class="form-horizontal">
+ <h3>Choose Dataset to Edit:</h3>
+ <br>
+ <div class="col-xs-10">
+ <!-- Species -->
+ <div class="form-group">
+ <label for="species" class="col-xs-2 control-label">Species: </label>
+ <div class="col-xs-4 controls">
+ <select name="species" id="species" class="form-control span3" style="width: 280px !important;"></select>
+ </div>
+ </div>
+ <!-- Group -->
+ <div class="form-group">
+ <label for="group" class="col-xs-2 control-label">Group: </label>
+ <div class="col-xs-4 controls">
+ <select name="group" id="group" class="form-control span3" style="width: 280px !important;"></select>
+ </div>
+ </div>
+ <!-- Type -->
+ <div class="form-group">
+ <label for="group" class="col-xs-2 control-label">Type: </label>
+ <div class="col-xs-4 controls">
+ <select name="type" id="type" class="form-control span3" style="width: 280px !important;"></select>
+ </div>
+ </div>
+ <!-- Dataset -->
+ <div class="form-group">
+ <label for="group" class="col-xs-2 control-label">DataSet: </label>
+ <div class="col-xs-4 controls">
+ <select name="dataset" id="dataset" class="form-control span3" style="width: 280px !important;"></select>
+ </div>
+ </div>
+ </div>
+ <div class="controls" style="display:block; margin-left: 40%; margin-right: 20%;">
+ <input type="submit" style="width: 110px; margin-right: 25px;" class="btn btn-primary form-control col-xs-2" value="Submit Trait">
+ <input type="reset" style="width: 110px;" class="btn btn-primary form-control col-xs-2" value="Reset">
+ </div>
+ </div>
+ </section>
+ </div>
+ </div>
+ </div>
+ </form>
+
+{%endblock%}
+
+ {% block js %}
+ <script src="/static/new/javascript/dataset_select_menu_edit_trait.js"></script>
+ <script>
+ gn_server_url = "{{ gn_server_url }}";
+ </script>
+{% endblock %}
diff --git a/wqflask/wqflask/templates/index_page.html b/wqflask/wqflask/templates/index_page.html
index 31846f87..942776e7 100644..100755
--- a/wqflask/wqflask/templates/index_page.html
+++ b/wqflask/wqflask/templates/index_page.html
@@ -1,88 +1,77 @@
{% extends "base.html" %}
{% block title %}GeneNetwork{% endblock %}
+{% block css %}
+<style TYPE="text/css">
+ p.interact { display: none; }
+</style>
+{% endblock %}
{% block content %}
<!-- Start of body -->
-
-<!--
- <header class="jumbotron subhead" id="overview">
- <div class="container">
- <h1>GeneNetwork</h1>
- <p class="lead">Open source bioinformatics for systems genetics</p>
- </div>
- </header>
--->
-
- <div class="container-fluid">
+ <div class="container-fluid" style="min-width: 1210px;">
{{ flash_me() }}
- <div class="row" style="width: 1400px !important;">
+ <div class="row" style="width: 100%;">
- <div class="col-xs-5">
+ <div class="col-xs-4" style="margin-right:50px; min-width: 530px; max-width: 550px;">
<section id="search">
- <div class="page-header">
+ <div>
<h1>Select and search</h1>
</div>
- <form method="get" action="/search" name="SEARCHFORM">
+ <form method="get" action="/search" target="_blank" name="SEARCHFORM">
<fieldset>
<div style="padding: 20px" class="form-horizontal">
<div class="form-group">
<label for="species" class="col-xs-1 control-label" style="width: 65px !important;">Species:</label>
- <div class="col-xs-10 controls input-append" style="padding-right: 0px;">
- <div class="col-xs-8">
- <select name="species" id="species" class="form-control span3" style="width: 280px !important;"></select>
- </div>
- <div class="col-xs-4">
- <button type="button" id="make_default" class="btn btn-primary form-control">Make Default</button>
+ <div class="col-xs-10 controls input-append" style="display: flex; padding-left: 20px;">
+ <div class="col-8">
+ <select name="species" id="species" class="form-control" style="width: 280px !important;"><option>Loading...</option></select>
</div>
</div>
</div>
<div class="form-group">
<label for="group" class="col-xs-1 control-label" style="width: 65px !important;">Group:</label>
- <div class="col-xs-10 controls input-append">
- <div class="col-xs-8">
- <select name="group" id="group" class="form-control span3" style="width: 280px !important;"></select>
+ <div class="col-xs-10 controls input-append" style="display: flex; padding-left: 20px;">
+ <div class="col-9">
+ <select name="group" id="group" class="form-control" style="width: 340px !important;"><option>Loading...</option></select>
<i class="icon-question-sign"></i>
</div>
+ <div class="col-3" style="margin-left: 10px;">
+ <button type="button" id="group_info" class="btn btn-primary form-control" style="width: 50px !important;">Info</button>
+ </div>
</div>
</div>
<div class="form-group">
<label for="tissue" class="col-xs-1 control-label" style="width: 65px !important;">Type:</label>
- <div class="col-xs-10 controls">
- <div class="col-xs-8">
- <select name="type" id="type" class="form-control span3" style="width: 280px !important;"></select>
+ <div class="col-xs-10 controls input-append" style="display: flex; padding-left: 20px;">
+ <div class="col-9">
+ <select name="type" id="type" class="form-control" style="width: 340px !important;"><option>Loading...</option></select>
+ </div>
+ <div class="col-3" style="margin-left: 10px;">
+ <button type="button" id="dataset_info" class="btn btn-primary form-control" style="width: 50px !important;">Info</button>
</div>
</div>
</div>
<div class="form-group">
<label for="dataset" class="col-xs-1 control-label" style="width: 65px !important;">Dataset:</label>
- <div class="col-xs-10 controls input-append">
- <div class="col-xs-10">
- <select name="dataset" id="dataset" class="form-control span5" style="width: 340px !important;"></select>
+ <div class="col-xs-10 controls" style="display: flex; padding-left: 20px;">
+ <div class="col-9">
+ <select name="dataset" id="dataset" class="form-control" style="max-width: 550px; width: 450px !important;"><option>Loading...</option></select>
<i class="icon-question-sign"></i>
</div>
- <div class="col-xs-2">
- <button type="button" id="dataset_info" class="btn btn-primary form-control" style="width: 75px !important;">Info</button>
- </div>
</div>
</div>
-
- <!-- USER HELP -->
- <!--<p>Databases marked with <b>**</b>-->
- <!-- suffix are not public yet.<br>-->
- <!-- Access requires <a href="/account.html" target=-->
- <!-- "_blank" class="fs14">user login</a>.</p>-->
<!-- GET ANY SEARCH -->
<div class="form-group">
<label for="or_search" class="col-xs-1 control-label" style="padding-left: 0px; padding-right: 0px; width: 65px !important;">Get Any:</label>
- <div class="col-xs-10 controls">
- <div class="col-xs-8">
- <textarea onkeydown="pressed(event)" name="search_terms_or" rows="1" class="form-control search-query" style="max-width: 550px; width: 450px !important;" id="or_search"></textarea>
+ <div class="col-xs-10 controls" style="padding-left: 20px;">
+ <div class="col-8">
+ <textarea onkeydown="pressed(event)" name="search_terms_or" rows="1" class="form-control search-query" style="resize: vertical; max-width: 550px; width: 450px !important;" id="or_search"></textarea>
</div>
</div>
</div>
@@ -90,8 +79,8 @@
<!-- GET ANY HELP -->
<div class="form-group">
<label for="btsearch" class="col-xs-1 control-label" style="width: 65px !important;"></label>
- <div class="col-xs-10 controls">
- <div class="col-xs-12 controls">
+ <div class="col-xs-10 controls" style="padding-left: 20px;">
+ <div class="col-12 controls">
Enter terms, genes, ID numbers in the <b>Search</b> field.<br>
Use <b>*</b> or <b>?</b> wildcards (Cyp*a?, synap*).<br>
Use <b>quotes</b> for terms such as <i>"tyrosine kinase"</i>.
@@ -101,29 +90,30 @@
<div class="form-group">
<label for="and_search" class="col-xs-1 control-label" style="padding-left: 0px; padding-right: 0px; width: 65px !important;">Combined:</label>
- <div class="col-xs-10 controls">
- <div class="col-xs-8">
- <textarea onkeydown="pressed(event)" name="search_terms_and" rows="1" class="form-control search-query" style="max-width: 550px; width: 450px !important;" id="and_search"></textarea>
+ <div class="col-xs-10 controls" style="padding-left: 20px;">
+ <div class="col-8">
+ <textarea onkeydown="pressed(event)" name="search_terms_and" rows="1" class="form-control search-query" style="resize: vertical; max-width: 550px; width: 450px !important;" id="and_search"></textarea>
</div>
</div>
</div>
<div class="form-group">
<label for="btsearch" class="col-xs-1 control-label" style="width: 65px !important;"></label>
- <div class="col-xs-10 controls">
- <div class="col-xs-2 controls" style="width: 100px !important;">
+ <div class="col-xs-10 controls" style="display: flex; padding-left: 20px;">
+ <div class="col-2 controls">
<input id="btsearch" type="submit" class="btn btn-primary form-control" value="Search">
</div>
+ <div class="col-2 controls" style="padding-left: 20px;">
+ <button type="button" id="make_default" class="btn btn-primary form-control">Make Default</button>
+ </div>
</div>
</div>
<!-- SEARCH, MAKE DEFAULT -->
-
<div class="form-group">
</div>
<input type="hidden" name="FormID" value="searchResult" class="form-control">
- <!--!<input type="hidden" name="RISet" value="BXD">-->
</div>
</fieldset>
</form>
@@ -133,33 +123,43 @@
<h2>Advanced commands</h2>
</div>
- <p>You can also use advanced commands. Copy these simple examples into the Get Any or Combined search fields:</p>
+ <p>You can also use advanced commands. Copy these simple examples into the Get Any field for single term searches and Combined for searches with multiple terms:</p>
<ul>
<li><b>POSITION=(chr1 25 30)</b> finds genes, markers, or transcripts on
chromosome 1 between 25 and 30 Mb.</li>
- <li><b>MEAN=(15 16) LRS=(23 46)</b> in the <b>Combined</b> field finds
- highly expressed genes (15 to 16 log2 units) AND with peak <a href="{{ url_for('glossary_blueprint.glossary') }}#L">LRS</a>
- linkage between 23 and 46.</li>
+ <li><b>MEAN=(15 16)</b> in the <b>Combined</b> field finds
+ highly expressed genes (15 to 16 log2 units)</li>
<li><b>RANGE=(1.5 2.5)</b> in the <b>Any</b> field finds traits with values with a specified fold-range (minimum = 1).
Useful for finding "housekeeping genes" <b>(1.0 1.2)</b> or highly variable molecular assays <b>(10 100)</b>.</li>
+ <li><b>LRS=(15 1000)</b> or <b>LOD=(2 8)</b> finds all traits with peak LRS or LOD scores between lower and upper limits.</li>
+
+ <li><b>LRS=(9 999 Chr4 122 155)</b> finds all traits on Chr 4 from 122 and 155 Mb with LRS scores between 9 and 999.</li>
+
+ <li><b>cisLRS=(15 1000 5)</b> or <b>cisLOD=(2 8 5)</b> finds all cis eQTLs with peak LRS or LOD scores between lower and upper limits,
+ with an <b>inclusion</b> zone of 5 Mb around the parent gene.</li>
+
+ <li><b>transLRS=(15 1000 5)</b> or <b>transLOD=(2 8 5)</b> finds all trans eQTLs with peak LRS or LOD scores between lower and upper limits,
+ with an <b>exclusion</b> zone of 5 Mb around the parent gene. You can also add a fourth term specifying which chromosome you want the transLRS to be on
+ (for example transLRS=(15 1000 5 7) would find all trans eQTLs with peak LRS on chromosome 7 that is also a trans eQTL with exclusionary zone of 5Mb).</li>
+
+ <li><b>POSITION=(Chr4 122 130) cisLRS=(9 999 10)</b>
+ finds all traits on Chr 4 from 122 and 155 Mb with cisLRS scores
+ between 9 and 999 and an inclusion zone of 10 Mb.</li>
+
<li><b>RIF=mitochondrial</b> searches RNA databases for <a href="https://en.wikipedia.org/wiki/GeneRIF">
GeneRIF</a> links.</li>
- <li><b>WIKI=nicotine</b> searches <a href="http://www.genenetwork.org/webqtl/main.py?FormID=geneWiki">
+ <li><b>WIKI=nicotine</b> searches <a href="http://gn1.genenetwork.org/webqtl/main.py?FormID=geneWiki">
GeneWiki</a> for genes that you or other users have annotated
with the word <i>nicotine</i>.</li>
<li><b>GO:0045202</b> searches for synapse-associated genes listed in the
- <a href="http://amigo.geneontology.org/amigo/medial_search?q=GO%3A0045202">Gene Ontology</a>.</li>
-
- <li><b>GO:0045202 LRS=(9 99 Chr4 122 155) cisLRS=(9 999 10)</b>
- finds synapse-associated genes with <a href="{{ url_for('glossary_blueprint.glossary') }}#E">
- cis eQTL</a> on Chr 4 from 122 and 155 Mb with LRS scores
- between 9 and 999.</li>
+ <a href="http://amigo.geneontology.org/amigo/medial_search?q=GO%3A0045202">
+ Gene Ontology</a>.</li>
<li><b>RIF=diabetes LRS=(9 999 Chr2 100 105) transLRS=(9 999 10)</b>
finds diabetes-associated transcripts with peak <a href="{{ url_for('glossary_blueprint.glossary') }}#E">
@@ -168,99 +168,57 @@
</ul>
</section>
</div>
- <div style="padding-left:120px" class="col-xs-4" style="width: 600px !important;">
- <!--
- <section id="tour-info">
- <div class="page-header">
- <h1>Tour and more info</h1>
- </div>
-
- <h3>Thirty minute tour</h3>
- <p>
- Take the 30 minute
- GeneNetwork <a href="http://www.genenetwork.org/tutorial/WebQTLTour/" class="fs14">tour</a> that includes screen shots and
- typical steps in the analysis.
- </p>
-
- <h3>Even more info</h3>
- <p>
- For information about
- resources and methods, select the Info buttons next to the Group
- and Database fields above.
- </p>
-
- <p>The <a href="/conditionsofUse.html">conditions</a>
- and <a href="/statusandContact.html">contact
- </a> pages have information on the status of data sets
- and advice on their use and citation.</p>
+ <div class="col-xs-4" style="width: 600px !important;">
+ <section id="affiliates">
+ <div class="page-header">
+ <h1>Affiliates</h1>
+ <ul>
+ <li><b><a href="http://gn1.genenetwork.org">GeneNetwork 1</a> at UTHSC</b></li>
+ <li><span class="broken_link" href="http://ucscbrowser.genenetwork.org/">Genome Browser</span> at UTHSC</li>
+ <li><a href="https://systems-genetics.org/">Systems Genetics</a> at EPFL</li>
+ <li><a href="http://bnw.genenetwork.org/">Bayesian Network Web Server</a> at UTHSC</li>
+ <li><a href="https://www.geneweaver.org/">GeneWeaver</a></li>
+ <li><a href="https://phenogen.org/">PhenoGen</a> at University of Colorado</li>
+ <li><a href="http://www.webgestalt.org/">WebGestalt</a> at Baylor</li>
+ </ul>
+ </div>
</section>
- -->
-
+ <section id="news-section">
+ <div class="page-header">
+ <h1>News</h1>
+ <div id="tweets" style="height: 300px; overflow: scroll; overflow-x: hidden;"></div>
+ <div align="right">
+ <a href="https://twitter.com/GeneNetwork2">more news items...</a>
+ </div>
+ </div>
+ </section>
<section id="websites">
<div class="page-header">
- <h1>Affiliates and mirrors</h1>
+ <h1>Github</h1>
+ <ul>
+ <li><a href="https://github.com/genenetwork/genenetwork2">GN2 Source Code</a></li>
+ <li><a href="https://github.com/genenetwork/genenetwork">GN1 Source Code</a></li>
+ <li><a href="https://github.com/genenetwork/sysmaintenance">System Maintenance Code</a></li>
+ </ul>
</div>
- <h3>Websites affiliated with GeneNetwork</h3>
- <ul>
- <li><span class="broken_link" href="http://ucscbrowser.genenetwork.org/">Genome Browser</span> at UTHSC</li>
-
- <li><a href="http://galaxy.genenetwork.org/">Galaxy</a> at
- UTHSC</li>
-
- <li>GeneNetwork 1 at <span class="broken_link" href="http://ec2.genenetwork.org/">Amazon
- Cloud (EC2)</span></li>
-
- <li>GeneNetwork 1 Source Code at <a href="http://sourceforge.net/projects/genenetwork/">SourceForge</a></li>
-
- <li>GeneNetwork 2 Source Code at <a href="https://github.com/genenetwork/genenetwork2">GitHub</a></li>
- </ul>
- <h3>GN1 Mirror and development sites</h3>
-
- <ul>
- <li><a href="http://gn1.genenetwork.org/">Main GN1 site at UTHSC</a> (main site)</li>
- <li><span class="broken_link" href="http://genenetwork.helmholtz-hzi.de/">Germany at the HZI</span></li>
- <li><a href="http://genenetwork.org/">Memphis at the U of M</a></li>
- </ul>
- </section>
-
- <!--<section id="getting-started">
+ </section>
+ <section id="websites">
<div class="page-header">
- <h1>Getting started</h1>
+ <h1>Links</h1>
</div>
-
- <ol style="font-size:12px;font-family:verdana;color:black">
- <li>Select <b>Species</b> (or All)</li>
-
- <li>Select <b>Group</b> (a specific sample)</li>
-
- <li>Select <b>Type</b> of data:
-
+ <h3>GeneNetwork v2:</h3>
+ <ul>
+ <li><a href="http://genenetwork.org/">Main website</a> at UTHSC</li>
+ </ul>
+ <h3>GeneNetwork v1:</h3>
<ul>
- <li>Phenotype (traits)</li>
-
- <li>Genotype (markers)</li>
-
- <li>Expression (mRNAs)</li>
+ <li><a href="http://gn1.genenetwork.org/">Main website</a> at UTHSC</li>
+ <li><span class="broken_link" href="http://artemis.uthsc.edu/">Time Machine</span>: Full GN versions from 2009 to 2016 (mm9)</li>
+ Cloud (EC2)</a></li>
</ul>
- </li>
-
- <li>Select a <b>Dataset</b></li>
-
- <li>Enter terms in the search field: words,
- genes, ID numbers, probes, advanced search commands</li>
-
- <li>Click the <b>Search</b> button</li>
-
- <li>Optional: Use the <b>Make Default</b> button to save your preferences</li>
- </ol>
-
- <h3>User Guide</h3>
- <h5>Read the
- <a href="http://www.genenetwork.org/index4.html">
- user guide</a>.</h5>
-
- </section>-->
+ <script type="text/javascript" src="//rf.revolvermaps.com/0/0/8.js?i=526mdlpknyd&amp;m=0&amp;c=ff0000&amp;cr1=ffffff&amp;f=arial&amp;l=33" async="async"></script>
+ </section>
</div>
</div>
</div>
@@ -268,11 +226,7 @@
{%endblock%}
{% block js %}
-
- <script>
- gn_server_url = "{{ gn_server_url }}";
- </script>
- <script src="/static/new/javascript/dataset_select_menu.js"></script>
+ <script src="/static/new/javascript/dataset_select_menu_orig.js"></script>
<script>
function pressed(e) {
@@ -288,4 +242,21 @@
}
</script>
+ <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='javascript-twitter-post-fetcher/js/twitterFetcher_min.js') }}"></script>
+
+ <script type="text/javascript">
+ var configProfile = {
+ "profile": {"screenName": 'GeneNetwork2'},
+ "domId": 'tweets',
+ "maxTweets": 5,
+ "enableLinks": true,
+ "showUser": false,
+ "showTime": true,
+ "showImages": true,
+ "lang": 'en'
+ };
+ twitterFetcher.fetch(configProfile);
+ </script>
+
+
{% endblock %}
diff --git a/wqflask/wqflask/templates/index_page_orig.html b/wqflask/wqflask/templates/index_page_orig.html
deleted file mode 100755
index 7f82b35c..00000000
--- a/wqflask/wqflask/templates/index_page_orig.html
+++ /dev/null
@@ -1,349 +0,0 @@
-{% extends "base.html" %}
-{% block title %}GeneNetwork{% endblock %}
-{% block css %}
-<style TYPE="text/css">
- p.interact { display: none; }
-</style>
-{% endblock %}
-{% block content %}
-<!-- Start of body -->
-
-<!--
- <header class="jumbotron subhead" id="overview">
- <div class="container">
- <h1>GeneNetwork</h1>
- <p class="lead">Open source bioinformatics for systems genetics</p>
- </div>
- </header>
--->
-
- <div class="container-fluid" style="min-width: 1210px;">
-
- {{ flash_me() }}
-
- <div class="row" style="width: 100%;">
-
- <div class="col-xs-4" style="margin-right:50px; min-width: 530px; max-width: 550px;">
- <section id="search">
- <div>
- <h1>Select and search</h1>
- </div>
- <form method="get" action="/search" target="_blank" name="SEARCHFORM">
- <fieldset>
- <div style="padding: 20px" class="form-horizontal">
-
- <div class="form-group">
- <label for="species" class="col-xs-1 control-label" style="width: 65px !important;">Species:</label>
- <div class="col-xs-10 controls input-append" style="display: flex; padding-left: 20px;">
- <div class="col-8">
- <select name="species" id="species" class="form-control" style="width: 280px !important;"><option>Loading...</option></select>
- </div>
- </div>
- </div>
-
- <div class="form-group">
- <label for="group" class="col-xs-1 control-label" style="width: 65px !important;">Group:</label>
- <div class="col-xs-10 controls input-append" style="display: flex; padding-left: 20px;">
- <div class="col-9">
- <select name="group" id="group" class="form-control" style="width: 340px !important;"><option>Loading...</option></select>
- <i class="icon-question-sign"></i>
- </div>
- <div class="col-3" style="margin-left: 10px;">
- <button type="button" id="group_info" class="btn btn-primary form-control" style="width: 50px !important;">Info</button>
- </div>
- </div>
- </div>
-
- <div class="form-group">
- <label for="tissue" class="col-xs-1 control-label" style="width: 65px !important;">Type:</label>
- <div class="col-xs-10 controls input-append" style="display: flex; padding-left: 20px;">
- <div class="col-9">
- <select name="type" id="type" class="form-control" style="width: 340px !important;"><option>Loading...</option></select>
- </div>
- <div class="col-3" style="margin-left: 10px;">
- <button type="button" id="dataset_info" class="btn btn-primary form-control" style="width: 50px !important;">Info</button>
- </div>
- </div>
- </div>
-
- <div class="form-group">
- <label for="dataset" class="col-xs-1 control-label" style="width: 65px !important;">Dataset:</label>
- <div class="col-xs-10 controls" style="display: flex; padding-left: 20px;">
- <div class="col-9">
- <select name="dataset" id="dataset" class="form-control" style="max-width: 550px; width: 450px !important;"><option>Loading...</option></select>
- <i class="icon-question-sign"></i>
- </div>
- </div>
- </div>
-
- <!-- USER HELP -->
- <!--<p >Databases marked with <b>**</b>-->
- <!-- suffix are not public yet.<br>-->
- <!-- Access requires <a href="/account.html" target=-->
- <!-- "_blank" class="fs14">user login</a>.</p>-->
- <!-- GET ANY SEARCH -->
-
- <div class="form-group">
- <label for="or_search" class="col-xs-1 control-label" style="padding-left: 0px; padding-right: 0px; width: 65px !important;">Get Any:</label>
- <div class="col-xs-10 controls" style="padding-left: 20px;">
- <div class="col-8">
- <textarea onkeydown="pressed(event)" name="search_terms_or" rows="1" class="form-control search-query" style="resize: vertical; max-width: 550px; width: 450px !important;" id="or_search"></textarea>
- </div>
- </div>
- </div>
-
- <!-- GET ANY HELP -->
- <div class="form-group">
- <label for="btsearch" class="col-xs-1 control-label" style="width: 65px !important;"></label>
- <div class="col-xs-10 controls" style="padding-left: 20px;">
- <div class="col-12 controls">
- Enter terms, genes, ID numbers in the <b>Search</b> field.<br>
- Use <b>*</b> or <b>?</b> wildcards (Cyp*a?, synap*).<br>
- Use <b>quotes</b> for terms such as <i>"tyrosine kinase"</i>.
- </div>
- </div>
- </div>
-
- <div class="form-group">
- <label for="and_search" class="col-xs-1 control-label" style="padding-left: 0px; padding-right: 0px; width: 65px !important;">Combined:</label>
- <div class="col-xs-10 controls" style="padding-left: 20px;">
- <div class="col-8">
- <textarea onkeydown="pressed(event)" name="search_terms_and" rows="1" class="form-control search-query" style="resize: vertical; max-width: 550px; width: 450px !important;" id="and_search"></textarea>
- </div>
- </div>
- </div>
-
- <div class="form-group">
- <label for="btsearch" class="col-xs-1 control-label" style="width: 65px !important;"></label>
- <div class="col-xs-10 controls" style="display: flex; padding-left: 20px;">
- <div class="col-2 controls">
- <input id="btsearch" type="submit" class="btn btn-primary form-control" value="Search">
- </div>
- <div class="col-2 controls" style="padding-left: 20px;">
- <button type="button" id="make_default" class="btn btn-primary form-control">Make Default</button>
- </div>
- </div>
- </div>
-
- <!-- SEARCH, MAKE DEFAULT -->
-
- <div class="form-group">
- </div>
-
- <input type="hidden" name="FormID" value="searchResult" class="form-control">
- <!--!<input type="hidden" name="RISet" value="BXD">-->
- </div>
- </fieldset>
- </form>
- </section>
- <section id="advanced">
- <div class="page-header">
- <h2>Advanced commands</h2>
- </div>
-
- <p>You can also use advanced commands. Copy these simple examples into the Get Any field for single term searches and Combined for searches with multiple terms:</p>
-
- <ul>
- <li><b>POSITION=(chr1 25 30)</b> finds genes, markers, or transcripts on
- chromosome 1 between 25 and 30 Mb.</li>
-
- <li><b>MEAN=(15 16)</b> in the <b>Combined</b> field finds
- highly expressed genes (15 to 16 log2 units)</li>
-
- <li><b>RANGE=(1.5 2.5)</b> in the <b>Any</b> field finds traits with values with a specified fold-range (minimum = 1).
- Useful for finding "housekeeping genes" <b>(1.0 1.2)</b> or highly variable molecular assays <b>(10 100)</b>.</li>
-
- <li><b>LRS=(15 1000)</b> or <b>LOD=(2 8)</b> finds all traits with peak LRS or LOD scores between lower and upper limits.</li>
-
- <li><b>LRS=(9 999 Chr4 122 155)</b> finds all traits on Chr 4 from 122 and 155 Mb with LRS scores between 9 and 999.</li>
-
- <li><b>cisLRS=(15 1000 5)</b> or <b>cisLOD=(2 8 5)</b> finds all cis eQTLs with peak LRS or LOD scores between lower and upper limits,
- with an <b>inclusion</b> zone of 5 Mb around the parent gene.</li>
-
- <li><b>transLRS=(15 1000 5)</b> or <b>transLOD=(2 8 5)</b> finds all trans eQTLs with peak LRS or LOD scores between lower and upper limits,
- with an <b>exclusion</b> zone of 5 Mb around the parent gene. You can also add a fourth term specifying which chromosome you want the transLRS to be on
- (for example transLRS=(15 1000 5 7) would find all trans eQTLs with peak LRS on chromosome 7 that is also a trans eQTL with exclusionary zone of 5Mb).</li>
-
- <li><b>POSITION=(Chr4 122 130) cisLRS=(9 999 10)</b>
- finds all traits on Chr 4 from 122 and 155 Mb with cisLRS scores
- between 9 and 999 and an inclusion zone of 10 Mb.</li>
-
- <li><b>RIF=mitochondrial</b> searches RNA databases for <a href="https://en.wikipedia.org/wiki/GeneRIF">
- GeneRIF</a> links.</li>
-
- <li><b>WIKI=nicotine</b> searches <a href="http://gn1.genenetwork.org/webqtl/main.py?FormID=geneWiki">
- GeneWiki</a> for genes that you or other users have annotated
- with the word <i>nicotine</i>.</li>
-
- <li><b>GO:0045202</b> searches for synapse-associated genes listed in the
- <a href="http://amigo.geneontology.org/amigo/medial_search?q=GO%3A0045202">
- Gene Ontology</a>.</li>
-
- <li><b>RIF=diabetes LRS=(9 999 Chr2 100 105) transLRS=(9 999 10)</b>
- finds diabetes-associated transcripts with peak <a href="{{ url_for('glossary_blueprint.glossary') }}#E">
- trans eQTLs</a> on Chr 2 between 100 and 105 Mb with LRS
- scores between 9 and 999.</li>
- </ul>
- </section>
- </div>
-
- <div class="col-xs-4" style="width: 600px !important;">
- <section id="affiliates">
- <div class="page-header">
- <h1>Affiliates</h1>
- <ul>
- <li><b><a href="http://gn1.genenetwork.org">GeneNetwork 1</a> at UTHSC</b></li>
- <li><span class="broken_link" href="http://ucscbrowser.genenetwork.org/">Genome Browser</span> at UTHSC</li>
- <li><a href="https://systems-genetics.org/">Systems Genetics</a> at EPFL</li>
- <li><a href="http://bnw.genenetwork.org/">Bayesian Network Web Server</a> at UTHSC</li>
- <li><a href="https://www.geneweaver.org/">GeneWeaver</a></li>
- <li><a href="https://phenogen.org/">PhenoGen</a> at University of Colorado</li>
- <li><a href="http://www.webgestalt.org/">WebGestalt</a> at Baylor</li>
- </ul>
- </div>
- </section>
- <section id="news-section">
- <div class="page-header">
- <h1>News</h1>
- <div id="tweets" style="height: 300px; overflow: scroll; overflow-x: hidden;"></div>
- <div align="right">
- <a href="https://twitter.com/GeneNetwork2">more news items...</a>
- </div>
- </div>
- </section>
- <section id="websites">
- <div class="page-header">
- <h1>Github</h1>
- <ul>
- <li><a href="https://github.com/genenetwork/genenetwork2">GN2 Source Code</a></li>
- <li><a href="https://github.com/genenetwork/genenetwork">GN1 Source Code</a></li>
- <!--<li><a href="https://github.com/genenetwork/gn-docs/wiki">GN2 Document Wiki</a></li>-->
- <li><a href="https://github.com/genenetwork/sysmaintenance">System Maintenance Code</a></li>
- </ul>
- </div>
- </section>
- <!--
- <section id="tour-info">
- <div class="page-header">
- <h1>Tour and more info</h1>
- </div>
-
- <h3>Thirty minute tour</h3>
- <p>
- Take the 30 minute
- GeneNetwork <a href="http://www.genenetwork.org/tutorial/WebQTLTour/" class="fs14">tour</a> that includes screen shots and
- typical steps in the analysis.
- </p>
-
- <h3>Even more info</h3>
- <p>
- For information about
- resources and methods, select the Info buttons next to the Group
- and Database fields above.
- </p>
-
- <p>The <a href="/conditionsofUse.html">conditions</a>
- and <a href="/statusandContact.html">contact
- </a> pages have information on the status of data sets
- and advice on their use and citation.</p>
-
- </section>
-
- </section>
- -->
- <section id="websites">
- <div class="page-header">
- <h1>Links</h1>
- </div>
- <h3>GeneNetwork v2:</h3>
- <ul>
- <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>
- <li><a href="http://gn1.genenetwork.org/">Main website</a> at UTHSC</li>
- <li><span class="broken_link" href="http://artemis.uthsc.edu/">Time Machine</span>: Full GN versions from 2009 to 2016 (mm9)</li>
- Cloud (EC2)</a></li>
- </ul>
- <script type="text/javascript" src="//rf.revolvermaps.com/0/0/8.js?i=526mdlpknyd&amp;m=0&amp;c=ff0000&amp;cr1=ffffff&amp;f=arial&amp;l=33" async="async"></script>
- </section>
-
- <!--<section id="getting-started">
- <div class="page-header">
- <h1>Getting started</h1>
- </div>
-
- <ol style="font-size:12px;font-family:verdana;color:black">
- <li>Select <b>Species</b> (or All)</li>
-
- <li>Select <b>Group</b> (a specific sample)</li>
-
- <li>Select <b>Type</b> of data:
-
- <ul>
- <li>Phenotype (traits)</li>
-
- <li>Genotype (markers)</li>
-
- <li>Expression (mRNAs)</li>
- </ul>
- </li>
-
- <li>Select a <b>Dataset</b></li>
-
- <li>Enter terms in the search field: words,
- genes, probes, advanced search commands</li>
-
- <li>Click the <b>Search</b> button</li>
-
- <li>Optional: Use the <b>Make Default</b> button to save your preferences</li>
- </ol>
-
- <h3>User Guide</h3>
- <h5>Read the
- <a href="http://gn1.genenetwork.org/index4.html">
- user guide</a>.</h5>
-
- </section>-->
- </div>
- </div>
- </div>
-
-{%endblock%}
-
-{% block js %}
- <script src="/static/new/javascript/dataset_select_menu_orig.js"></script>
-
- <script>
- function pressed(e) {
- // Has the enter key been pressed?
- if ( (window.event ? event.keyCode : e.which) == 13) {
- e.preventDefault();
- // If enter key has been pressed and the search fields are non-empty
- // manually submit the <form>
- if( event.target.value.trim() != "" ) {
- document.forms[1].submit();
- }
- }
- }
- </script>
-
- <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='javascript-twitter-post-fetcher/js/twitterFetcher_min.js') }}"></script>
-
- <script type="text/javascript">
- var configProfile = {
- "profile": {"screenName": 'GeneNetwork2'},
- "domId": 'tweets',
- "maxTweets": 5,
- "enableLinks": true,
- "showUser": false,
- "showTime": true,
- "showImages": true,
- "lang": 'en'
- };
- twitterFetcher.fetch(configProfile);
- </script>
-
-
-{% endblock %}
diff --git a/wqflask/wqflask/templates/submit_trait.html b/wqflask/wqflask/templates/submit_trait.html
index 68b06f55..3572b0a9 100644
--- a/wqflask/wqflask/templates/submit_trait.html
+++ b/wqflask/wqflask/templates/submit_trait.html
@@ -14,7 +14,7 @@
<h2 style="color: #5a5a5a;">Introduction</h2>
<hr>
<p>The trait values that you enter are statistically compared with verified genotypes collected at a set of microsatellite markers in each RI set. The markers are drawn from a set of over 750, but for each set redundant markers have been removed, preferentially retaining those that are most informative.</p>
- <p>These error-checked RI mapping data match theoretical expectations for RI strain sets. The cumulative adjusted length of the RI maps are approximately 1400 cM, a value that matches those of both MIT maps and Chromosome Committee Report maps. See our full description of the genetic data collected as part of the WebQTL project.</p>
+ <p>These error-checked RI mapping data match theoretical expectations for RI strain sets. The cumulative adjusted length of the RI maps are approximately 1400 cM, a value that matches those of both MIT maps and Chromosome Committee Report maps. See our <a target="_blank" href="http://www.nervenet.org/papers/BXN.html">full description</a> of the genetic data collected as part of the WebQTL project.</p>
</div>
</section>
<br>
@@ -53,7 +53,7 @@
</div>
</div>
</div>
- <div style="padding-bottom: 50px;" class="form-horizontal">
+ <div style="padding-bottom: 50px; margin-bottom:400px" class="form-horizontal">
<h3>2. Enter Trait Data:</h3>
<h4 style="color:red;">File uploading isn't enabled yet, but is coming soon.</h4>
<br>
@@ -61,18 +61,6 @@
<img src="/static/new/images/step2.gif">
</div>
<div class="col-xs-10">
- <!--
- <div class="form-group" style="padding-left: 15px;">
- <p>
- <b>From a File:</b> You can enter data by entering a file name here. The file should contain a series of numbers representing trait values.
- The values can be on one line separated by spaces or tabs, or they can be on separate lines. Include one value for each progeny individual
- or recombinant inbred line. Represent missing values with a non-numeric character such as "x". If you have chosen a recombinant inbred set,
- when you submit your data will be displayed in a form where you can confirm and/or edit them. If you enter a file name here, any data that
- you paste into the next section will be ignored.
- </p>
- <input type="file" name="trait_file" style="border-width: 1px; border-style: solid; border-color: #999999;">
- </div>
- -->
<div class="form-group" style="padding-left: 15px;">
<p>
<b>Paste or Type Multiple Values:</b> You can enter data by pasting a series of numbers representing trait values into this area.
@@ -89,6 +77,24 @@
<input type="reset" style="width: 110px;" class="btn btn-primary form-control col-xs-2" value="Reset">
</div>
</div>
+ <div style="padding-bottom: 50px;" class="form-horizontal">
+ <h3>3. Enable Use of Trait Variance:</h3>
+ <div class="col-xs-2" style=""display: flex; align-items: center;">
+ <img src="/static/new/images/step3.gif">
+ </div>
+ <div class="col-xs-10">
+ <div class="form-group" style="padding-left: 15px;">
+ <p>
+ <b>Name Your Trait:</b> <span style="color:red;">(optional)</span>
+ </p>
+ <textarea name="trait_name" rows="1" cols="30"></textarea>
+ </div>
+ </div>
+ <div class="controls" style="display:block; margin-left: 40%; margin-right: 20%;">
+ <input type="submit" style="width: 110px; margin-right: 25px;" class="btn btn-primary form-control col-xs-2" value="Submit Trait">
+ <input type="reset" style="width: 110px;" class="btn btn-primary form-control col-xs-2" value="Reset">
+ </div>
+ </div>
</section>
</div>
</div>
diff --git a/wqflask/wqflask/update_search_results.py b/wqflask/wqflask/update_search_results.py
index 672f95b1..22a46ef2 100644
--- a/wqflask/wqflask/update_search_results.py
+++ b/wqflask/wqflask/update_search_results.py
@@ -10,7 +10,7 @@ from utility.benchmark import Bench
from utility.logger import getLogger
logger = getLogger(__name__)
-class GSearch(object):
+class GSearch:
def __init__(self, kw):
self.type = kw['type']
diff --git a/wqflask/wqflask/user_manager.py b/wqflask/wqflask/user_manager.py
index 7b25b68e..fcec3b67 100644
--- a/wqflask/wqflask/user_manager.py
+++ b/wqflask/wqflask/user_manager.py
@@ -58,7 +58,7 @@ def timestamp():
return datetime.datetime.utcnow().isoformat()
-class AnonUser(object):
+class AnonUser:
"""Anonymous user handling"""
cookie_name = 'anon_user_v1'
@@ -158,7 +158,7 @@ def create_signed_cookie():
logger.debug("uuid_signed:", uuid_signed)
return the_uuid, uuid_signed
-class UserSession(object):
+class UserSession:
"""Logged in user handling"""
cookie_name = 'session_id_v1'
@@ -353,12 +353,12 @@ def set_cookie(response):
response.set_cookie(g.cookie_session.cookie_name, g.cookie_session.cookie)
return response
-class UsersManager(object):
+class UsersManager:
def __init__(self):
self.users = model.User.query.all()
logger.debug("Users are:", self.users)
-class UserManager(object):
+class UserManager:
def __init__(self, kw):
self.user_id = kw['user_id']
logger.debug("In UserManager locals are:", pf(locals()))
@@ -377,7 +377,7 @@ class UserManager(object):
#logger.debug(" ---> self.datasets:", self.datasets)
-class RegisterUser(object):
+class RegisterUser:
def __init__(self, kw):
self.thank_you_mode = False
self.errors = []
@@ -454,7 +454,7 @@ def set_password(password, user):
)
-class VerificationEmail(object):
+class VerificationEmail:
template_name = "email/verification.txt"
key_prefix = "verification_code"
subject = "GeneNetwork email verification"
@@ -511,7 +511,7 @@ class ForgotPasswordEmail(VerificationEmail):
send_email(toaddr, msg.as_string())
-class Password(object):
+class Password:
def __init__(self, unencrypted_password, salt, iterations, keylength, hashfunc):
hashfunc = getattr(hashlib, hashfunc)
logger.debug("hashfunc is:", hashfunc)
@@ -589,7 +589,7 @@ def password_reset_step2():
return response
-class DecodeUser(object):
+class DecodeUser:
def __init__(self, code_prefix):
verify_url_hmac(request.url)
@@ -695,7 +695,7 @@ def get_github_user_details(access_token):
result = requests.get(GITHUB_API_URL, params={"access_token":access_token})
return result.json()
-class LoginUser(object):
+class LoginUser:
remember_time = 60 * 60 * 24 * 30 # One month in seconds
def __init__(self):
@@ -1039,12 +1039,12 @@ def send_email(toaddr, msg, fromaddr="no-reply@genenetwork.org"):
server.quit()
logger.info("Successfully sent email to "+toaddr)
-class GroupsManager(object):
+class GroupsManager:
def __init__(self, kw):
self.datasets = create_datasets_list()
-class RolesManager(object):
+class RolesManager:
def __init__(self):
self.roles = model.Role.query.all()
logger.debug("Roles are:", self.roles)
diff --git a/wqflask/wqflask/user_session.py b/wqflask/wqflask/user_session.py
index c5a577df..cc0ac744 100644
--- a/wqflask/wqflask/user_session.py
+++ b/wqflask/wqflask/user_session.py
@@ -63,7 +63,7 @@ def manage_user():
return render_template("admin/manage_user.html", user_details = user_details)
-class UserSession(object):
+class UserSession:
"""Logged in user handling"""
user_cookie_name = 'session_id_v2'
diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py
index 2c0ba586..81ccaf7d 100644
--- a/wqflask/wqflask/views.py
+++ b/wqflask/wqflask/views.py
@@ -1,20 +1,17 @@
"""Main routing table for GN2"""
-import traceback # for error page
+import traceback # for error page
import os # for error gifs
import random # for random error gif
import datetime # for errors
-import time # for errors
import sys
import csv
import simplejson as json
-import yaml
import xlsxwriter
import io # Todo: Use cStringIO?
from zipfile import ZipFile, ZIP_DEFLATED
-import gc
import numpy as np
import pickle as pickle
import uuid
@@ -24,23 +21,26 @@ import base64
import array
import sqlalchemy
from wqflask import app
-from flask import g, Response, request, make_response, render_template, send_from_directory, jsonify, redirect, url_for, send_file
+from flask import g
+from flask import Response
+from flask import request
+from flask import make_response
+from flask import render_template
+from flask import send_from_directory
+from flask import redirect
+from flask import url_for
+from flask import send_file
-from wqflask import group_manager
-from wqflask import resource_manager
from wqflask import search_results
-from wqflask import export_traits
-from wqflask import gsearch
-from wqflask import update_search_results
-from wqflask import docs
-from wqflask import news
from wqflask import server_side
from wqflask.submit_bnw import get_bnw_input
-from base.data_set import create_dataset, DataSet # Used by YAML in marker_regression
+from base.data_set import create_dataset # Used by YAML in marker_regression
from wqflask.show_trait import show_trait
from wqflask.show_trait import export_trait_data
from wqflask.heatmap import heatmap
-from wqflask.external_tools import send_to_bnw, send_to_webgestalt, send_to_geneweaver
+from wqflask.external_tools import send_to_bnw
+from wqflask.external_tools import send_to_webgestalt
+from wqflask.external_tools import send_to_geneweaver
from wqflask.comparison_bar_chart import comparison_bar_chart
from wqflask.marker_regression import run_mapping
from wqflask.marker_regression import display_mapping_results
@@ -59,24 +59,31 @@ from wqflask.docs import Docs, update_text
from wqflask.db_info import InfoPage
from utility import temp_data
-from utility.tools import SQL_URI, TEMPDIR, USE_REDIS, USE_GN_SERVER, GN_SERVER_URL, GN_VERSION, JS_TWITTER_POST_FETCHER_PATH, JS_GUIX_PATH, CSS_PATH
+from utility.tools import SQL_URI
+from utility.tools import TEMPDIR
+from utility.tools import USE_REDIS
+from utility.tools import GN_SERVER_URL
+from utility.tools import GN_VERSION
+from utility.tools import JS_TWITTER_POST_FETCHER_PATH
+from utility.tools import JS_GUIX_PATH
from utility.helper_functions import get_species_groups
from utility.authentication_tools import check_resource_availability
from utility.redis_tools import get_redis_conn
-Redis = get_redis_conn()
+
from base.webqtlConfig import GENERATED_IMAGE_DIR, DEFAULT_PRIVILEGES
from utility.benchmark import Bench
from pprint import pformat as pf
-from wqflask import collect
from wqflask.database import db_session
-import werkzeug
import utility.logger
-logger = utility.logger.getLogger(__name__ )
+
+Redis = get_redis_conn()
+
+logger = utility.logger.getLogger(__name__)
@app.before_request
@@ -84,13 +91,14 @@ def connect_db():
logger.info("@app.before_request connect_db")
db = getattr(g, '_database', None)
if db is None:
- g.db = g._database = sqlalchemy.create_engine(SQL_URI, encoding="latin1")
+ g.db = g._database = sqlalchemy.create_engine(
+ SQL_URI, encoding="latin1")
logger.debug(g.db)
+
@app.before_request
def check_access_permissions():
logger.debug("@app.before_request check_access_permissions")
- available = True
if 'dataset' in request.args:
permissions = DEFAULT_PRIVILEGES
if request.args['dataset'] != "Temp":
@@ -99,7 +107,8 @@ def check_access_permissions():
if dataset.type == "Temp":
permissions = DEFAULT_PRIVILEGES
elif 'trait_id' in request.args:
- permissions = check_resource_availability(dataset, request.args['trait_id'])
+ permissions = check_resource_availability(
+ dataset, request.args['trait_id'])
elif dataset.type != "Publish":
permissions = check_resource_availability(dataset)
@@ -110,6 +119,7 @@ def check_access_permissions():
if permissions['data'] == 'no-access':
return redirect(url_for("no_access_page"))
+
@app.teardown_appcontext
def shutdown_session(exception=None):
db = getattr(g, '_database', None)
@@ -118,6 +128,7 @@ def shutdown_session(exception=None):
db_session.remove()
g.db = None
+
@app.errorhandler(Exception)
def handle_bad_request(e):
err_msg = str(e)
@@ -128,25 +139,30 @@ def handle_bad_request(e):
logger.error(traceback.format_exc())
now = datetime.datetime.utcnow()
time_str = now.strftime('%l:%M%p UTC %b %d, %Y')
- formatted_lines = [request.url + " ("+time_str+")"]+traceback.format_exc().splitlines()
+ formatted_lines = [request.url +
+ " ("+time_str+")"]+traceback.format_exc().splitlines()
# Handle random animations
# Use a cookie to have one animation on refresh
animation = request.cookies.get(err_msg[:32])
if not animation:
- list = [fn for fn in os.listdir("./wqflask/static/gif/error") if fn.endswith(".gif") ]
+ list = [fn for fn in os.listdir(
+ "./wqflask/static/gif/error") if fn.endswith(".gif")]
animation = random.choice(list)
- resp = make_response(render_template("error.html", message=err_msg, stack=formatted_lines, error_image=animation, version=GN_VERSION))
+ resp = make_response(render_template("error.html", message=err_msg,
+ stack=formatted_lines, error_image=animation, version=GN_VERSION))
# logger.error("Set cookie %s with %s" % (err_msg, animation))
resp.set_cookie(err_msg[:32], animation)
return resp
+
@app.route("/authentication_needed")
def no_access_page():
return render_template("new_security/not_authenticated.html")
+
@app.route("/")
def index_page():
logger.info("Sending index_page")
@@ -156,13 +172,7 @@ def index_page():
import_collections = params['import_collections']
if import_collections == "true":
g.user_session.import_traits_to_user(params['anon_id'])
- #if USE_GN_SERVER:
- # # The menu is generated using GN_SERVER
- # return render_template("index_page.html", gn_server_url = GN_SERVER_URL, version=GN_VERSION)
- #else:
-
- # Old style static menu (OBSOLETE)
- return render_template("index_page_orig.html", version=GN_VERSION)
+ return render_template("index_page.html", version=GN_VERSION)
@app.route("/tmp/<img_path>")
@@ -177,7 +187,7 @@ def tmp_page(img_path):
imgB64 = base64.b64encode(imgdata)
bytesarray = array.array('B', imgB64)
return render_template("show_image.html",
- img_base64 = bytesarray )
+ img_base64=bytesarray)
@app.route("/js/<path:filename>")
@@ -189,6 +199,7 @@ def js(filename):
name = name.replace('js_alt/', '')
return send_from_directory(js_path, name)
+
@app.route("/css/<path:filename>")
def css(filename):
js_path = JS_GUIX_PATH
@@ -198,10 +209,12 @@ def css(filename):
name = name.replace('js_alt/', '')
return send_from_directory(js_path, name)
+
@app.route("/twitter/<path:filename>")
def twitter(filename):
return send_from_directory(JS_TWITTER_POST_FETCHER_PATH, filename)
+
@app.route("/search", methods=('GET',))
def search_page():
logger.info("in search_page")
@@ -209,7 +222,8 @@ def search_page():
result = None
if USE_REDIS:
with Bench("Trying Redis cache"):
- key = "search_results:v1:" + json.dumps(request.args, sort_keys=True)
+ key = "search_results:v1:" + \
+ json.dumps(request.args, sort_keys=True)
logger.debug("key is:", pf(key))
result = Redis.get(key)
if result:
@@ -232,6 +246,7 @@ def search_page():
else:
return render_template("search_error.html")
+
@app.route("/search_table", methods=('GET',))
def search_page_table():
logger.info("in search_page table")
@@ -242,7 +257,7 @@ def search_page_table():
logger.info(type(the_search.trait_list))
logger.info(the_search.trait_list)
-
+
current_page = server_side.ServerSideTable(
len(the_search.trait_list),
the_search.trait_list,
@@ -252,6 +267,7 @@ def search_page_table():
return flask.jsonify(current_page)
+
@app.route("/gsearch", methods=('GET',))
def gsearchact():
logger.info(request.url)
@@ -262,17 +278,14 @@ def gsearchact():
elif type == "phenotype":
return render_template("gsearch_pheno.html", **result)
+
@app.route("/gsearch_updating", methods=('POST',))
def gsearch_updating():
logger.info("REQUEST ARGS:", request.values)
logger.info(request.url)
result = UpdateGSearch(request.args).__dict__
return result['results']
- # type = request.args['type']
- # if type == "gene":
- # return render_template("gsearch_gene_updating.html", **result)
- # elif type == "phenotype":
- # return render_template("gsearch_pheno.html", **result)
+
@app.route("/docedit")
def docedit():
@@ -292,41 +305,59 @@ def generated_file(filename):
logger.info(request.url)
return send_from_directory(GENERATED_IMAGE_DIR, filename)
+
@app.route("/help")
def help():
logger.info(request.url)
doc = Docs("help", request.args)
return render_template("docs.html", **doc.__dict__)
+
@app.route("/wgcna_setup", methods=('POST',))
def wcgna_setup():
- logger.info("In wgcna, request.form is:", request.form) # We are going to get additional user input for the analysis
+ # We are going to get additional user input for the analysis
+ logger.info("In wgcna, request.form is:", request.form)
logger.info(request.url)
- return render_template("wgcna_setup.html", **request.form) # Display them using the template
+ # Display them using the template
+ return render_template("wgcna_setup.html", **request.form)
+
@app.route("/wgcna_results", methods=('POST',))
def wcgna_results():
logger.info("In wgcna, request.form is:", request.form)
logger.info(request.url)
- wgcna = wgcna_analysis.WGCNA() # Start R, load the package and pointers and create the analysis
- wgcnaA = wgcna.run_analysis(request.form) # Start the analysis, a wgcnaA object should be a separate long running thread
- result = wgcna.process_results(wgcnaA) # After the analysis is finished store the result
- return render_template("wgcna_results.html", **result) # Display them using the template
+ # Start R, load the package and pointers and create the analysis
+ wgcna = wgcna_analysis.WGCNA()
+ # Start the analysis, a wgcnaA object should be a separate long running thread
+ wgcnaA = wgcna.run_analysis(request.form)
+ # After the analysis is finished store the result
+ result = wgcna.process_results(wgcnaA)
+ # Display them using the template
+ return render_template("wgcna_results.html", **result)
+
@app.route("/ctl_setup", methods=('POST',))
def ctl_setup():
- logger.info("In ctl, request.form is:", request.form) # We are going to get additional user input for the analysis
+ # We are going to get additional user input for the analysis
+ logger.info("In ctl, request.form is:", request.form)
logger.info(request.url)
- return render_template("ctl_setup.html", **request.form) # Display them using the template
+ # Display them using the template
+ return render_template("ctl_setup.html", **request.form)
+
@app.route("/ctl_results", methods=('POST',))
def ctl_results():
logger.info("In ctl, request.form is:", request.form)
logger.info(request.url)
- ctl = ctl_analysis.CTL() # Start R, load the package and pointers and create the analysis
- ctlA = ctl.run_analysis(request.form) # Start the analysis, a ctlA object should be a separate long running thread
- result = ctl.process_results(ctlA) # After the analysis is finished store the result
- return render_template("ctl_results.html", **result) # Display them using the template
+ # Start R, load the package and pointers and create the analysis
+ ctl = ctl_analysis.CTL()
+ # Start the analysis, a ctlA object should be a separate long running thread
+ ctlA = ctl.run_analysis(request.form)
+ # After the analysis is finished store the result
+ result = ctl.process_results(ctlA)
+ # Display them using the template
+ return render_template("ctl_results.html", **result)
+
@app.route("/news")
def news():
@@ -340,40 +371,50 @@ def intro():
return render_template("docs.html", **doc.__dict__)
-
@app.route("/tutorials")
def tutorials():
- #doc = Docs("links", request.args)
- #return render_template("docs.html", **doc.__dict__)
return render_template("tutorials.html")
+
@app.route("/credits")
def credits():
- #doc = Docs("links", request.args)
- #return render_template("docs.html", **doc.__dict__)
return render_template("credits.html")
+
@app.route("/update_text", methods=('POST',))
def update_page():
update_text(request.form)
doc = Docs(request.form['entry_type'], request.form)
return render_template("docs.html", **doc.__dict__)
+
@app.route("/submit_trait")
def submit_trait_form():
logger.info(request.url)
species_and_groups = get_species_groups()
- return render_template("submit_trait.html", **{'species_and_groups' : species_and_groups, 'gn_server_url' : GN_SERVER_URL, 'version' : GN_VERSION})
+ return render_template(
+ "submit_trait.html",
+ species_and_groups=species_and_groups,
+ gn_server_url=GN_SERVER_URL,
+ version=GN_VERSION)
+
+
+@app.route("/edit_trait_form")
+def edit_trait_page():
+ species_and_groups = get_species_groups()
+ return render_template(
+ "edit_trait.html",
+ species_and_groups=species_and_groups,
+ gn_server_url=GN_SERVER_URL,
+ version=GN_VERSION)
+
@app.route("/create_temp_trait", methods=('POST',))
def create_temp_trait():
logger.info(request.url)
-
- #template_vars = submit_trait.SubmitTrait(request.form)
-
doc = Docs("links")
return render_template("links.html", **doc.__dict__)
- #return render_template("show_trait.html", **template_vars.__dict__)
+
@app.route('/export_trait_excel', methods=('POST',))
def export_trait_excel():
@@ -381,9 +422,11 @@ def export_trait_excel():
logger.info("In export_trait_excel")
logger.info("request.form:", request.form)
logger.info(request.url)
- trait_name, sample_data = export_trait_data.export_sample_table(request.form)
+ trait_name, sample_data = export_trait_data.export_sample_table(
+ request.form)
- logger.info("sample_data - type: %s -- size: %s" % (type(sample_data), len(sample_data)))
+ logger.info("sample_data - type: %s -- size: %s" %
+ (type(sample_data), len(sample_data)))
buff = io.BytesIO()
workbook = xlsxwriter.Workbook(buff, {'in_memory': True})
@@ -397,7 +440,8 @@ def export_trait_excel():
return Response(excel_data,
mimetype='application/vnd.ms-excel',
- headers={"Content-Disposition":"attachment;filename="+ trait_name + ".xlsx"})
+ headers={"Content-Disposition": "attachment;filename=" + trait_name + ".xlsx"})
+
@app.route('/export_trait_csv', methods=('POST',))
def export_trait_csv():
@@ -405,9 +449,11 @@ def export_trait_csv():
logger.info("In export_trait_csv")
logger.info("request.form:", request.form)
logger.info(request.url)
- trait_name, sample_data = export_trait_data.export_sample_table(request.form)
+ trait_name, sample_data = export_trait_data.export_sample_table(
+ request.form)
- logger.info("sample_data - type: %s -- size: %s" % (type(sample_data), len(sample_data)))
+ logger.info("sample_data - type: %s -- size: %s" %
+ (type(sample_data), len(sample_data)))
buff = io.StringIO()
writer = csv.writer(buff)
@@ -418,7 +464,8 @@ def export_trait_csv():
return Response(csv_data,
mimetype='text/csv',
- headers={"Content-Disposition":"attachment;filename="+ trait_name + ".csv"})
+ headers={"Content-Disposition": "attachment;filename=" + trait_name + ".csv"})
+
@app.route('/export_traits_csv', methods=('POST',))
def export_traits_csv():
@@ -443,7 +490,8 @@ def export_traits_csv():
else:
return Response(file_list[0][1],
mimetype='text/csv',
- headers={"Content-Disposition":"attachment;filename=" + file_list[0][0]})
+ headers={"Content-Disposition": "attachment;filename=" + file_list[0][0]})
+
@app.route('/export_perm_data', methods=('POST',))
def export_perm_data():
@@ -454,7 +502,8 @@ def export_perm_data():
now = datetime.datetime.now()
time_str = now.strftime('%H:%M_%d%B%Y')
- file_name = "Permutation_" + perm_info['num_perm'] + "_" + perm_info['trait_name'] + "_" + time_str
+ file_name = "Permutation_" + \
+ perm_info['num_perm'] + "_" + perm_info['trait_name'] + "_" + time_str
the_rows = [
["#Permutation Test"],
@@ -468,10 +517,14 @@ def export_perm_data():
["#N_genotypes: " + str(perm_info['n_genotypes'])],
["#Genotype_file: " + perm_info['genofile']],
["#Units_linkage: " + perm_info['units_linkage']],
- ["#Permutation_stratified_by: " + ", ".join([ str(cofactor) for cofactor in perm_info['strat_cofactors']])],
- ["#RESULTS_1: Suggestive LRS(p=0.63) = " + str(np.percentile(np.array(perm_info['perm_data']), 67))],
- ["#RESULTS_2: Significant LRS(p=0.05) = " + str(np.percentile(np.array(perm_info['perm_data']), 95))],
- ["#RESULTS_3: Highly Significant LRS(p=0.01) = " + str(np.percentile(np.array(perm_info['perm_data']), 99))],
+ ["#Permutation_stratified_by: " +
+ ", ".join([str(cofactor) for cofactor in perm_info['strat_cofactors']])],
+ ["#RESULTS_1: Suggestive LRS(p=0.63) = " +
+ str(np.percentile(np.array(perm_info['perm_data']), 67))],
+ ["#RESULTS_2: Significant LRS(p=0.05) = " + str(
+ np.percentile(np.array(perm_info['perm_data']), 95))],
+ ["#RESULTS_3: Highly Significant LRS(p=0.01) = " + str(
+ np.percentile(np.array(perm_info['perm_data']), 99))],
["#Comment: Results sorted from low to high peak linkage"]
]
@@ -485,38 +538,29 @@ def export_perm_data():
return Response(csv_data,
mimetype='text/csv',
- headers={"Content-Disposition":"attachment;filename=" + file_name + ".csv"})
+ headers={"Content-Disposition": "attachment;filename=" + file_name + ".csv"})
+
@app.route("/show_temp_trait", methods=('POST',))
def show_temp_trait_page():
logger.info(request.url)
template_vars = show_trait.ShowTrait(request.form)
- #logger.info("js_data before dump:", template_vars.js_data)
template_vars.js_data = json.dumps(template_vars.js_data,
default=json_default_handler,
indent=" ")
- # Sorting the keys messes up the ordered dictionary, so don't do that
- #sort_keys=True)
-
- #logger.info("js_data after dump:", template_vars.js_data)
- #logger.info("show_trait template_vars:", pf(template_vars.__dict__))
return render_template("show_trait.html", **template_vars.__dict__)
+
@app.route("/show_trait")
def show_trait_page():
logger.info(request.url)
template_vars = show_trait.ShowTrait(request.args)
- #logger.info("js_data before dump:", template_vars.js_data)
template_vars.js_data = json.dumps(template_vars.js_data,
default=json_default_handler,
indent=" ")
- # Sorting the keys messes up the ordered dictionary, so don't do that
- #sort_keys=True)
-
- #logger.info("js_data after dump:", template_vars.js_data)
- #logger.info("show_trait template_vars:", pf(template_vars.__dict__))
return render_template("show_trait.html", **template_vars.__dict__)
+
@app.route("/heatmap", methods=('POST',))
def heatmap_page():
logger.info("In heatmap, request.form is:", pf(request.form))
@@ -528,7 +572,8 @@ def heatmap_page():
traits = [trait.strip() for trait in start_vars['trait_list'].split(',')]
if traits[0] != "":
version = "v5"
- key = "heatmap:{}:".format(version) + json.dumps(start_vars, sort_keys=True)
+ key = "heatmap:{}:".format(
+ version) + json.dumps(start_vars, sort_keys=True)
logger.info("key is:", pf(key))
with Bench("Loading cache"):
result = Redis.get(key)
@@ -549,7 +594,8 @@ def heatmap_page():
result = template_vars.__dict__
for item in list(template_vars.__dict__.keys()):
- logger.info(" ---**--- {}: {}".format(type(template_vars.__dict__[item]), item))
+ logger.info(
+ " ---**--- {}: {}".format(type(template_vars.__dict__[item]), item))
pickled_result = pickle.dumps(result, pickle.HIGHEST_PROTOCOL)
logger.info("pickled result length:", len(pickled_result))
@@ -560,10 +606,12 @@ def heatmap_page():
rendered_template = render_template("heatmap.html", **result)
else:
- rendered_template = render_template("empty_collection.html", **{'tool':'Heatmap'})
+ rendered_template = render_template(
+ "empty_collection.html", **{'tool': 'Heatmap'})
return rendered_template
+
@app.route("/bnw_page", methods=('POST',))
def bnw_page():
logger.info("In run BNW, request.form is:", pf(request.form))
@@ -578,10 +626,12 @@ def bnw_page():
result = template_vars.__dict__
rendered_template = render_template("bnw_page.html", **result)
else:
- rendered_template = render_template("empty_collection.html", **{'tool':'BNW'})
+ rendered_template = render_template(
+ "empty_collection.html", **{'tool': 'BNW'})
return rendered_template
+
@app.route("/webgestalt_page", methods=('POST',))
def webgestalt_page():
logger.info("In run WebGestalt, request.form is:", pf(request.form))
@@ -596,10 +646,12 @@ def webgestalt_page():
result = template_vars.__dict__
rendered_template = render_template("webgestalt_page.html", **result)
else:
- rendered_template = render_template("empty_collection.html", **{'tool':'WebGestalt'})
+ rendered_template = render_template(
+ "empty_collection.html", **{'tool': 'WebGestalt'})
return rendered_template
+
@app.route("/geneweaver_page", methods=('POST',))
def geneweaver_page():
logger.info("In run WebGestalt, request.form is:", pf(request.form))
@@ -614,10 +666,12 @@ def geneweaver_page():
result = template_vars.__dict__
rendered_template = render_template("geneweaver_page.html", **result)
else:
- rendered_template = render_template("empty_collection.html", **{'tool':'GeneWeaver'})
+ rendered_template = render_template(
+ "empty_collection.html", **{'tool': 'GeneWeaver'})
return rendered_template
+
@app.route("/comparison_bar_chart", methods=('POST',))
def comp_bar_chart_page():
logger.info("In comp bar chart, request.form is:", pf(request.form))
@@ -629,26 +683,30 @@ def comp_bar_chart_page():
if traits[0] != "":
template_vars = comparison_bar_chart.ComparisonBarChart(request.form)
template_vars.js_data = json.dumps(template_vars.js_data,
- default=json_default_handler,
- indent=" ")
+ default=json_default_handler,
+ indent=" ")
result = template_vars.__dict__
- rendered_template = render_template("comparison_bar_chart.html", **result)
+ rendered_template = render_template(
+ "comparison_bar_chart.html", **result)
else:
- rendered_template = render_template("empty_collection.html", **{'tool':'Comparison Bar Chart'})
+ rendered_template = render_template(
+ "empty_collection.html", **{'tool': 'Comparison Bar Chart'})
return rendered_template
+
@app.route("/mapping_results_container")
def mapping_results_container_page():
return render_template("mapping_results_container.html")
+
@app.route("/loading", methods=('POST',))
def loading_page():
logger.info(request.url)
initial_start_vars = request.form
start_vars_container = {}
- n_samples = 0 #ZS: So it can be displayed on loading page
+ n_samples = 0 # ZS: So it can be displayed on loading page
if 'wanted_inputs' in initial_start_vars:
wanted = initial_start_vars['wanted_inputs'].split(",")
start_vars = {}
@@ -661,16 +719,17 @@ def loading_page():
else:
sample_vals_dict = json.loads(start_vars['sample_vals'])
if 'group' in start_vars:
- dataset = create_dataset(start_vars['dataset'], group_name = start_vars['group'])
+ dataset = create_dataset(
+ start_vars['dataset'], group_name=start_vars['group'])
else:
dataset = create_dataset(start_vars['dataset'])
- genofile_samplelist = []
samples = start_vars['primary_samples'].split(",")
if 'genofile' in start_vars:
if start_vars['genofile'] != "":
genofile_string = start_vars['genofile']
dataset.group.genofile = genofile_string.split(":")[0]
- genofile_samples = run_mapping.get_genofile_samplelist(dataset)
+ genofile_samples = run_mapping.get_genofile_samplelist(
+ dataset)
if len(genofile_samples) > 1:
samples = genofile_samples
@@ -690,6 +749,7 @@ def loading_page():
return rendered_template
+
@app.route("/run_mapping", methods=('POST',))
def mapping_results_page():
initial_start_vars = request.form
@@ -760,9 +820,10 @@ def mapping_results_page():
start_vars[key] = value
version = "v3"
- key = "mapping_results:{}:".format(version) + json.dumps(start_vars, sort_keys=True)
+ key = "mapping_results:{}:".format(
+ version) + json.dumps(start_vars, sort_keys=True)
with Bench("Loading cache"):
- result = None # Just for testing
+ result = None # Just for testing
#result = Redis.get(key)
#logger.info("************************ Starting result *****************")
@@ -782,12 +843,12 @@ def mapping_results_page():
rendered_template = render_template("mapping_error.html")
return rendered_template
except:
- rendered_template = render_template("mapping_error.html")
- return rendered_template
+ rendered_template = render_template("mapping_error.html")
+ return rendered_template
template_vars.js_data = json.dumps(template_vars.js_data,
- default=json_default_handler,
- indent=" ")
+ default=json_default_handler,
+ indent=" ")
result = template_vars.__dict__
@@ -802,18 +863,20 @@ def mapping_results_page():
imgB64 = base64.b64encode(imgdata)
bytesarray = array.array('B', imgB64)
result['pair_scan_array'] = bytesarray
- rendered_template = render_template("pair_scan_results.html", **result)
+ rendered_template = render_template(
+ "pair_scan_results.html", **result)
else:
- gn1_template_vars = display_mapping_results.DisplayMappingResults(result).__dict__
+ gn1_template_vars = display_mapping_results.DisplayMappingResults(
+ result).__dict__
with Bench("Rendering template"):
- #if (gn1_template_vars['mapping_method'] == "gemma") or (gn1_template_vars['mapping_method'] == "plink"):
- #gn1_template_vars.pop('qtlresults', None)
- rendered_template = render_template("mapping_results.html", **gn1_template_vars)
+ rendered_template = render_template(
+ "mapping_results.html", **gn1_template_vars)
return rendered_template
-@app.route("/export_mapping_results", methods = ('POST',))
+
+@app.route("/export_mapping_results", methods=('POST',))
def export_mapping_results():
logger.info("request.form:", request.form)
logger.info(request.url)
@@ -821,32 +884,35 @@ def export_mapping_results():
results_csv = open(file_path, "r").read()
response = Response(results_csv,
mimetype='text/csv',
- headers={"Content-Disposition":"attachment;filename=mapping_results.csv"})
+ headers={"Content-Disposition": "attachment;filename=mapping_results.csv"})
return response
-@app.route("/export_corr_matrix", methods = ('POST',))
+
+@app.route("/export_corr_matrix", methods=('POST',))
def export_corr_matrix():
file_path = request.form.get("export_filepath")
file_name = request.form.get("export_filename")
results_csv = open(file_path, "r").read()
response = Response(results_csv,
mimetype='text/csv',
- headers={"Content-Disposition":"attachment;filename=" + file_name + ".csv"})
+ headers={"Content-Disposition": "attachment;filename=" + file_name + ".csv"})
return response
-@app.route("/export", methods = ('POST',))
+
+@app.route("/export", methods=('POST',))
def export():
logger.info("request.form:", request.form)
logger.info(request.url)
svg_xml = request.form.get("data", "Invalid data")
filename = request.form.get("filename", "manhattan_plot_snp")
response = Response(svg_xml, mimetype="image/svg+xml")
- response.headers["Content-Disposition"] = "attachment; filename=%s"%filename
+ response.headers["Content-Disposition"] = "attachment; filename=%s" % filename
return response
-@app.route("/export_pdf", methods = ('POST',))
+
+@app.route("/export_pdf", methods=('POST',))
def export_pdf():
import cairosvg
logger.info("request.form:", request.form)
@@ -854,12 +920,12 @@ def export_pdf():
svg_xml = request.form.get("data", "Invalid data")
logger.info("svg_xml:", svg_xml)
filename = request.form.get("filename", "interval_map_pdf")
- filepath = GENERATED_IMAGE_DIR+filename
pdf_file = cairosvg.svg2pdf(bytestring=svg_xml)
response = Response(pdf_file, mimetype="application/pdf")
- response.headers["Content-Disposition"] = "attachment; filename=%s"%filename
+ response.headers["Content-Disposition"] = "attachment; filename=%s" % filename
return response
+
@app.route("/network_graph", methods=('POST',))
def network_graph_page():
logger.info("In network_graph, request.form is:", pf(request.form))
@@ -874,7 +940,8 @@ def network_graph_page():
return render_template("network_graph.html", **template_vars.__dict__)
else:
- return render_template("empty_collection.html", **{'tool':'Network Graph'})
+ return render_template("empty_collection.html", **{'tool': 'Network Graph'})
+
@app.route("/corr_compute", methods=('POST',))
def corr_compute_page():
@@ -883,6 +950,7 @@ def corr_compute_page():
template_vars = show_corr_results.CorrelationResults(request.form)
return render_template("correlation_page.html", **template_vars.__dict__)
+
@app.route("/corr_matrix", methods=('POST',))
def corr_matrix_page():
logger.info("In corr_matrix, request.form is:", pf(request.form))
@@ -898,7 +966,8 @@ def corr_matrix_page():
return render_template("correlation_matrix.html", **template_vars.__dict__)
else:
- return render_template("empty_collection.html", **{'tool':'Correlation Matrix'})
+ return render_template("empty_collection.html", **{'tool': 'Correlation Matrix'})
+
@app.route("/corr_scatter_plot")
def corr_scatter_plot_page():
@@ -909,6 +978,7 @@ def corr_scatter_plot_page():
indent=" ")
return render_template("corr_scatterplot.html", **template_vars.__dict__)
+
@app.route("/snp_browser", methods=('GET',))
def snp_browser_page():
logger.info(request.url)
@@ -916,12 +986,14 @@ def snp_browser_page():
return render_template("snp_browser.html", **template_vars.__dict__)
+
@app.route("/db_info", methods=('GET',))
def db_info_page():
template_vars = InfoPage(request.args)
return render_template("info_page.html", **template_vars.__dict__)
+
@app.route("/snp_browser_table", methods=('GET',))
def snp_browser_table():
logger.info(request.url)
@@ -935,31 +1007,36 @@ def snp_browser_table():
return flask.jsonify(current_page)
+
@app.route("/tutorial/WebQTLTour", methods=('GET',))
def tutorial_page():
- #ZS: Currently just links to GN1
+ # ZS: Currently just links to GN1
logger.info(request.url)
return redirect("http://gn1.genenetwork.org/tutorial/WebQTLTour/")
+
@app.route("/tutorial/security", methods=('GET',))
def security_tutorial_page():
- #ZS: Currently just links to GN1
+ # ZS: Currently just links to GN1
logger.info(request.url)
return render_template("admin/security_help.html")
+
@app.route("/submit_bnw", methods=('POST',))
def submit_bnw():
logger.info(request.url)
- template_vars = get_bnw_input(request.form)
- return render_template("empty_collection.html", **{'tool':'Correlation Matrix'})
+ return render_template("empty_collection.html", **{'tool': 'Correlation Matrix'})
# Take this out or secure it before putting into production
+
+
@app.route("/get_temp_data")
def get_temp_data():
logger.info(request.url)
temp_uuid = request.args['key']
return flask.jsonify(temp_data.TempData(temp_uuid).get_all())
+
@app.route("/browser_input", methods=('GET',))
def browser_inputs():
""" Returns JSON from tmp directory for the purescript genome browser"""
@@ -973,8 +1050,9 @@ def browser_inputs():
##########################################################################
+
def json_default_handler(obj):
- '''Based on http://stackoverflow.com/a/2680060/1175849'''
+ """Based on http://stackoverflow.com/a/2680060/1175849"""
# Handle datestamps
if hasattr(obj, 'isoformat'):
return obj.isoformat()
@@ -984,9 +1062,6 @@ def json_default_handler(obj):
# Handle custom objects
if hasattr(obj, '__dict__'):
return obj.__dict__
- #elif type(obj) == "Dataset":
- # logger.info("Not going to serialize Dataset")
- # return None
else:
raise TypeError('Object of type %s with value of %s is not JSON serializable' % (
type(obj), repr(obj)))
diff --git a/wqflask/wqflask/wgcna/wgcna_analysis.py b/wqflask/wqflask/wgcna/wgcna_analysis.py
index 6bf75216..21516b30 100644
--- a/wqflask/wqflask/wgcna/wgcna_analysis.py
+++ b/wqflask/wqflask/wgcna/wgcna_analysis.py
@@ -42,7 +42,7 @@ r_png = ro.r["png"] # Map the png function for plotting
r_dev_off = ro.r["dev.off"] # Map the dev.off function
-class WGCNA(object):
+class WGCNA:
def __init__(self):
# To log output from stdout/stderr to a file add `r_sink(log)`
print("Initialization of WGCNA")