aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexanderlacuna2020-10-29 16:14:32 +0300
committerAlexanderlacuna2020-10-29 16:14:32 +0300
commit480217fdde68589ad84799c3b5df2c61608494ad (patch)
treea39c1be021bfe59869435ea97cfb93890609a2a0
parent18304a9b20bd4180b40be8296df26c2a0acf62fa (diff)
parent6e6911b466c2727b16a190d8b714f55d7842d7e2 (diff)
downloadgenenetwork2-480217fdde68589ad84799c3b5df2c61608494ad.tar.gz
Merge branch 'testing' of https://github.com/genenetwork/genenetwork2 into test-branch
-rwxr-xr-xscripts/maintenance/readProbeSetSE_v7.py6
-rw-r--r--wqflask/tests/utility/test_hmac.py13
-rw-r--r--wqflask/tests/wqflask/test_user_session.py15
-rw-r--r--wqflask/utility/hmac.py2
-rw-r--r--wqflask/wqflask/marker_regression/display_mapping_results.py2
-rw-r--r--wqflask/wqflask/marker_regression/plink_mapping.py4
-rw-r--r--wqflask/wqflask/show_trait/export_trait_data.py18
-rw-r--r--wqflask/wqflask/snp_browser/snp_browser.py6
-rw-r--r--wqflask/wqflask/static/new/javascript/show_trait.js73
9 files changed, 110 insertions, 29 deletions
diff --git a/scripts/maintenance/readProbeSetSE_v7.py b/scripts/maintenance/readProbeSetSE_v7.py
index edd9e7b0..2cfe2e07 100755
--- a/scripts/maintenance/readProbeSetSE_v7.py
+++ b/scripts/maintenance/readProbeSetSE_v7.py
@@ -72,14 +72,14 @@ GeneList = []
isCont = 1
header = fp.readline()
header = header.strip().split('\t')
-header = list(map(string.strip, header))
+header = [item.strip() for item in header]
nfield = len(header)
line = fp.readline()
kj = 0
while line:
line2 = line.strip().split('\t')
- line2 = list(map(string.strip, line2))
+ line2 = [item.strip() for item in line2]
if len(line2) != nfield:
isCont = 0
print(("Error : " + line))
@@ -110,7 +110,7 @@ isCont = 1
fp.seek(0)
header = fp.readline()
header = header.strip().split('\t')
-header = list(map(string.strip, header))
+header = [item.strip() for item in header]
header = list(map(translateAlias, header))
header = header[dataStart:]
Ids = []
diff --git a/wqflask/tests/utility/test_hmac.py b/wqflask/tests/utility/test_hmac.py
index 7c61c0a6..4e3652f8 100644
--- a/wqflask/tests/utility/test_hmac.py
+++ b/wqflask/tests/utility/test_hmac.py
@@ -17,6 +17,19 @@ class TestHmacUtil(unittest.TestCase):
"""Test hmac creation with a utf-8 string"""
self.assertEqual(hmac_creation("ファイ"), "7410466338cfe109e946")
+ @mock.patch("utility.hmac.app.config",
+ {'SECRET_HMAC_CODE': ('\x08\xdf\xfa\x93N\x80'
+ '\xd9\\H@\\\x9f`\x98d^'
+ '\xb4a;\xc6OM\x946a\xbc'
+ '\xfc\x80:*\xebc')})
+ def test_hmac_creation_with_cookie(self):
+ """Test hmac creation with a cookie"""
+ cookie = "3f4c1dbf-5b56-4260-87d6-f35445bda37e:af4fcf5eace9e7c864ce"
+ uuid_, _, signature = cookie.partition(":")
+ self.assertEqual(
+ hmac_creation(uuid_),
+ "af4fcf5eace9e7c864ce")
+
@mock.patch("utility.hmac.app.config", {'SECRET_HMAC_CODE': "secret"})
def test_data_hmac(self):
"""Test data_hmac fn with a utf-8 string"""
diff --git a/wqflask/tests/wqflask/test_user_session.py b/wqflask/tests/wqflask/test_user_session.py
new file mode 100644
index 00000000..ebb0334a
--- /dev/null
+++ b/wqflask/tests/wqflask/test_user_session.py
@@ -0,0 +1,15 @@
+"""Test cases for some methods in user_session.py"""
+
+import unittest
+from wqflask.user_session import verify_cookie
+
+
+class TestUserSession(unittest.TestCase):
+ def test_verify_cookie(self):
+ """
+ Test cookie verification
+ """
+ self.assertEqual(
+ "3f4c1dbf-5b56-4260-87d6-f35445bda37e",
+ verify_cookie(("3f4c1dbf-5b56-4260-87d6-"
+ "f35445bda37e:af4fcf5eace9e7c864ce")))
diff --git a/wqflask/utility/hmac.py b/wqflask/utility/hmac.py
index 6623f69a..29891677 100644
--- a/wqflask/utility/hmac.py
+++ b/wqflask/utility/hmac.py
@@ -10,7 +10,7 @@ def hmac_creation(stringy):
"""Helper function to create the actual hmac"""
secret = app.config['SECRET_HMAC_CODE']
- hmaced = hmac.new(bytearray(secret, "utf-8"),
+ hmaced = hmac.new(bytearray(secret, "latin-1"),
bytearray(stringy, "utf-8"),
hashlib.sha1)
hm = hmaced.hexdigest()
diff --git a/wqflask/wqflask/marker_regression/display_mapping_results.py b/wqflask/wqflask/marker_regression/display_mapping_results.py
index aa3f8518..65eba7e3 100644
--- a/wqflask/wqflask/marker_regression/display_mapping_results.py
+++ b/wqflask/wqflask/marker_regression/display_mapping_results.py
@@ -2809,7 +2809,7 @@ class DisplayMappingResults(object):
f"end={theGO['TxEnd']}&"
f"geneName={theGO['GeneSymbol']}&"
f"s1={self.diffCol[0]}&s2=%d"),
- theGO["snpCount"] # The text to display
+ str(theGO["snpCount"]) # The text to display
)
snpString.set_blank_target()
snpString.set_attribute("class", "normalsize")
diff --git a/wqflask/wqflask/marker_regression/plink_mapping.py b/wqflask/wqflask/marker_regression/plink_mapping.py
index 6c38c34f..fd91b6ca 100644
--- a/wqflask/wqflask/marker_regression/plink_mapping.py
+++ b/wqflask/wqflask/marker_regression/plink_mapping.py
@@ -84,7 +84,7 @@ def get_samples_from_ped_file(dataset):
while line:
lineList = line.strip().split('\t')
- lineList = list(map(string.strip, lineList))
+ lineList = [item.strip() for item in lineList]
sample_name = lineList[0]
sample_list.append(sample_name)
@@ -157,6 +157,6 @@ def parse_plink_output(output_filename, species):
def build_line_list(line=None):
line_list = line.strip().split(' ')# irregular number of whitespaces between columns
line_list = [item for item in line_list if item !='']
- line_list = list(map(string.strip, line_list))
+ line_list = [item.strip() for item in line_list]
return line_list
diff --git a/wqflask/wqflask/show_trait/export_trait_data.py b/wqflask/wqflask/show_trait/export_trait_data.py
index 48feb492..379b746c 100644
--- a/wqflask/wqflask/show_trait/export_trait_data.py
+++ b/wqflask/wqflask/show_trait/export_trait_data.py
@@ -14,10 +14,16 @@ def export_sample_table(targs):
final_sample_data = meta_data
+ column_headers = ["Name", "Value"]
+ if any(sample["se"] for sample in sample_data['primary_samples']):
+ column_headers.append("SE")
+ if any(sample["num_cases"] for sample in sample_data['primary_samples']):
+ column_headers.append("N")
+
+ final_sample_data.append(column_headers)
for sample_group in ['primary_samples', 'other_samples']:
for row in sample_data[sample_group]:
sorted_row = dict_to_sorted_list(row)
- print("sorted_row is:", pf(sorted_row))
final_sample_data.append(sorted_row)
return trait_name, final_sample_data
@@ -39,7 +45,15 @@ def get_export_metadata(trait_id, dataset_name):
metadata.append(["Title: " + (this_trait.title if this_trait.title else "N/A")])
metadata.append(["Journal: " + (this_trait.journal if this_trait.journal else "N/A")])
metadata.append(["Dataset Link: http://gn1.genenetwork.org/webqtl/main.py?FormID=sharinginfo&InfoPageName=" + dataset.name])
- metadata.append([])
+ else:
+ metadata.append(["Record ID: " + trait_id])
+ metadata.append(["Trait URL: " + "http://genenetwork.org/show_trait?trait_id=" + trait_id + "&dataset=" + dataset_name])
+ if this_trait.symbol:
+ metadata.append(["Symbol: " + this_trait.symbol])
+ metadata.append(["Dataset: " + dataset.name])
+ metadata.append(["Group: " + dataset.group.name])
+
+ metadata.append([])
return metadata
diff --git a/wqflask/wqflask/snp_browser/snp_browser.py b/wqflask/wqflask/snp_browser/snp_browser.py
index 2df71b12..6c3fcf53 100644
--- a/wqflask/wqflask/snp_browser/snp_browser.py
+++ b/wqflask/wqflask/snp_browser/snp_browser.py
@@ -457,7 +457,7 @@ class SnpBrowser(object):
function_list = []
if function_details:
function_list = function_details.strip().split(",")
- function_list = list(map(string.strip, function_list))
+ function_list = [item.strip() for item in function_list]
function_list[0] = function_list[0].title()
function_details = ", ".join(item for item in function_list)
function_details = function_details.replace("_", " ")
@@ -723,11 +723,11 @@ def get_effect_details_by_category(effect_name = None, effect_value = None):
codon_effect_group_list = ['Start Lost', 'Stop Gained', 'Stop Lost', 'Nonsynonymous', 'Synonymous']
effect_detail_list = effect_value.strip().split('|')
- effect_detail_list = list(map(string.strip, effect_detail_list))
+ effect_detail_list = [item.strip() for item in effect_detail_list]
for index, item in enumerate(effect_detail_list):
item_list = item.strip().split(',')
- item_list = list(map(string.strip, item_list))
+ item_list = [item.strip() for item in item_list]
gene_id = item_list[0]
gene_name = item_list[1]
diff --git a/wqflask/wqflask/static/new/javascript/show_trait.js b/wqflask/wqflask/static/new/javascript/show_trait.js
index 397adb52..a34811f8 100644
--- a/wqflask/wqflask/static/new/javascript/show_trait.js
+++ b/wqflask/wqflask/static/new/javascript/show_trait.js
@@ -885,26 +885,65 @@ $('#qnorm').click(switch_qnorm_data);
get_sample_table_data = function(table_name) {
var samples;
samples = [];
- $('#' + table_name).find('.value_se').each((function(_this) {
- return function(_index, element) {
- var attribute_info, key, row_data, _ref;
- row_data = {};
- row_data.name = $.trim($(element).find('.column_name-Sample').text());
- row_data.value = $(element).find('.edit-sample-value:eq(0)').val();
- if ($(element).find('.edit-sample-se').length > 0) {
- row_data.se = $(element).find('.edit-sample-se').val();
+
+ var se_exists = false;
+ var n_exists = false;
+
+ if ($('#' + table_name).length){
+ table_api = $('#' + table).DataTable();
+ sample_vals = [];
+
+ name_nodes = table_api.column(2).nodes().to$();
+ val_nodes = table_api.column(3).nodes().to$();
+ if (js_data.se_exists){
+ var_nodes = table_api.column(5).nodes().to$();
+ if (js_data.has_num_cases) {
+ n_nodes = table_api.column(6).nodes().to$();
}
- if ($(element).find('.edit_sample_num_cases').length > 0) {
- row_data.num_cases = $(element).find('.edit_sample_num_cases').val();
+ } else {
+ if (js_data.has_num_cases){
+ n_nodes = table_api.column(4).nodes().to$();
}
- attr_keys = Object.keys(js_data.attributes).sort()
- for (i=0; i < attr_keys.length; i++) {
- attribute_info = js_data.attributes[attr_keys[i]];
- row_data[attribute_info.name] = $.trim($(element).find('.column_name-' + attribute_info.name.replace(" ", "_").replace("/", "\\/")).text());
+ }
+
+ for (_j = 0; _j < val_nodes.length; _j++){
+ sample_val = val_nodes[_j].childNodes[0].value
+ sample_name = $.trim(name_nodes[_j].childNodes[0].textContent)
+ if (is_number(sample_val) && sample_val !== "") {
+ sample_val = parseFloat(sample_val);
+ if (typeof var_nodes == 'undefined'){
+ sample_var = null;
+ } else {
+ sample_var = var_nodes[_j].childNodes[0].value;
+ if (is_number(sample_var)) {
+ sample_var = parseFloat(sample_var);
+ se_exists = true;
+ } else {
+ sample_var = null;
+ }
+ }
+ if (typeof n_nodes == 'undefined'){
+ sample_n = null;
+ } else {
+ sample_n = n_nodes[_j].childNodes[0].value;
+ if (is_number(sample_n)) {
+ n_exists = true;
+ sample_n = parseInt(sample_n);
+ } else {
+ sample_n = null;
+ }
+ }
+ row_dict = {
+ name: sample_name,
+ value: sample_val,
+ se: sample_var,
+ num_cases: sample_n
+ }
+ samples.push(row_dict)
}
- return samples.push(row_data);
- };
- })(this));
+ }
+ }
+
return samples;
};
export_sample_table_data = function() {