aboutsummaryrefslogtreecommitdiff
path: root/wqflask
diff options
context:
space:
mode:
authorBonfaceKilz2020-08-28 14:50:37 +0300
committerBonfaceKilz2020-08-28 14:50:37 +0300
commit45323bed6b567f8bd3c87f5fbe610cd602d228bc (patch)
treea0429091e044d0a2a31e5d5ec773ad777891adef /wqflask
parent70dbeeb5832711ed5271434e482c18bc7ea095b8 (diff)
parent433b41086d3f61a94778d7b244c0d0276794e59e (diff)
downloadgenenetwork2-45323bed6b567f8bd3c87f5fbe610cd602d228bc.tar.gz
Merge branch 'testing' into build/python3-migration
Diffstat (limited to 'wqflask')
-rw-r--r--wqflask/base/data_set.py3
-rw-r--r--wqflask/wqflask/marker_regression/qtlreaper_mapping.py42
-rw-r--r--wqflask/wqflask/marker_regression/run_mapping.py41
-rw-r--r--wqflask/wqflask/templates/admin/manage_user.html79
4 files changed, 142 insertions, 23 deletions
diff --git a/wqflask/base/data_set.py b/wqflask/base/data_set.py
index 07704e4c..295f5c48 100644
--- a/wqflask/base/data_set.py
+++ b/wqflask/base/data_set.py
@@ -152,7 +152,8 @@ Publish or ProbeSet. E.g.
if t in ['pheno', 'other_pheno']:
name = name.replace("Publish", "")
- if bool(len(g.db.execute(sql_query_mapping[t].format(name)))):
+
+ if bool(len(g.db.execute(sql_query_mapping[t].format(name)).fetchone())):
self.datasets[name] = dataset_name_mapping[t]
self.redis_instance.set("dataset_structure", json.dumps(self.datasets))
return True
diff --git a/wqflask/wqflask/marker_regression/qtlreaper_mapping.py b/wqflask/wqflask/marker_regression/qtlreaper_mapping.py
index 189c1985..78b1f7b0 100644
--- a/wqflask/wqflask/marker_regression/qtlreaper_mapping.py
+++ b/wqflask/wqflask/marker_regression/qtlreaper_mapping.py
@@ -37,6 +37,8 @@ def run_reaper(this_trait, this_dataset, samples, vals, json_data, num_perm, boo
opt_list.append("--permu_output " + webqtlConfig.GENERATED_IMAGE_DIR + permu_filename + ".txt")
if control_marker != "" and do_control == "true":
opt_list.append("-c " + control_marker)
+ if manhattan_plot != True:
+ opt_list.append("--interval 1")
reaper_command = REAPER_COMMAND + ' --geno {0}/{1}.geno --traits {2}/gn2/{3}.txt {4} -o {5}{6}.txt'.format(flat_files('genotype'),
genofile_name,
@@ -85,9 +87,17 @@ def parse_reaper_output(gwa_filename, permu_filename, bootstrap_filename):
p_values = []
marker_obs = []
+ only_cm = False
+ only_mb = False
+
with open("{}{}.txt".format(webqtlConfig.GENERATED_IMAGE_DIR, gwa_filename)) as output_file:
for line in output_file:
if line.startswith("ID\t"):
+ if len(line.split("\t")) < 8:
+ if 'cM' in line.split("\t"):
+ only_cm = True
+ else:
+ only_mb = True
continue
else:
marker = {}
@@ -96,16 +106,30 @@ def parse_reaper_output(gwa_filename, permu_filename, bootstrap_filename):
marker['chr'] = int(line.split("\t")[2])
except:
marker['chr'] = line.split("\t")[2]
- marker['cM'] = float(line.split("\t")[3])
- if float(line.split("\t")[4]) > 1000:
- marker['Mb'] = float(line.split("\t")[4])/1000000
+ if only_cm or only_mb:
+ if only_cm:
+ marker['cM'] = float(line.split("\t")[3])
+ else:
+ if float(line.split("\t")[3]) > 1000:
+ marker['Mb'] = float(line.split("\t")[3])/1000000
+ else:
+ marker['Mb'] = float(line.split("\t")[3])
+ if float(line.split("\t")[6]) != 1:
+ marker['p_value'] = float(line.split("\t")[6])
+ marker['lrs_value'] = float(line.split("\t")[4])
+ marker['lod_score'] = marker['lrs_value'] / 4.61
+ marker['additive'] = float(line.split("\t")[5])
else:
- marker['Mb'] = float(line.split("\t")[4])
- if float(line.split("\t")[7]) != 1:
- marker['p_value'] = float(line.split("\t")[7])
- marker['lrs_value'] = float(line.split("\t")[5])
- marker['lod_score'] = marker['lrs_value'] / 4.61
- marker['additive'] = float(line.split("\t")[6])
+ marker['cM'] = float(line.split("\t")[3])
+ if float(line.split("\t")[4]) > 1000:
+ marker['Mb'] = float(line.split("\t")[4])/1000000
+ else:
+ marker['Mb'] = float(line.split("\t")[4])
+ if float(line.split("\t")[7]) != 1:
+ marker['p_value'] = float(line.split("\t")[7])
+ marker['lrs_value'] = float(line.split("\t")[5])
+ marker['lod_score'] = marker['lrs_value'] / 4.61
+ marker['additive'] = float(line.split("\t")[6])
marker_obs.append(marker)
#ZS: Results have to be reordered because the new reaper returns results sorted alphabetically by chr for some reason, resulting in chr 1 being followed by 10, etc
diff --git a/wqflask/wqflask/marker_regression/run_mapping.py b/wqflask/wqflask/marker_regression/run_mapping.py
index 7ae84b16..c606cf53 100644
--- a/wqflask/wqflask/marker_regression/run_mapping.py
+++ b/wqflask/wqflask/marker_regression/run_mapping.py
@@ -372,10 +372,15 @@ class RunMapping(object):
self.annotations_for_browser = []
highest_chr = 1 #This is needed in order to convert the highest chr to X/Y
for marker in results:
+ if 'Mb' in marker:
+ this_ps = marker['Mb']*1000000
+ else:
+ this_ps = marker['cM']*1000000
+
browser_marker = dict(
chr = str(marker['chr']),
rs = marker['name'],
- ps = marker['Mb']*1000000,
+ ps = this_ps,
url = "/show_trait?trait_id=" + marker['name'] + "&dataset=" + self.dataset.group.name + "Geno"
)
@@ -384,7 +389,7 @@ class RunMapping(object):
name = str(marker['name']),
chr = str(marker['chr']),
rs = marker['name'],
- pos = marker['Mb']*1000000,
+ pos = this_ps,
url = "/show_trait?trait_id=" + marker['name'] + "&dataset=" + self.dataset.group.name + "Geno"
)
else:
@@ -392,7 +397,7 @@ class RunMapping(object):
name = str(marker['name']),
chr = str(marker['chr']),
rs = marker['name'],
- pos = marker['Mb']*1000000
+ pos = this_ps
)
#if 'p_value' in marker:
# logger.debug("P EXISTS:", marker['p_value'])
@@ -531,10 +536,10 @@ def export_mapping_results(dataset, trait, markers, results_path, mapping_scale,
output_file.write("\n")
output_file.write("Name,Chr,")
if score_type.lower() == "-log(p)":
- score_type = "'-log(p)"
- if mapping_scale == "physic":
+ score_type = "-log(p)"
+ if 'Mb' in markers[0]:
output_file.write("Mb," + score_type)
- else:
+ if 'cM' in markers[0]:
output_file.write("Cm," + score_type)
if "additive" in list(markers[0].keys()):
output_file.write(",Additive")
@@ -542,8 +547,12 @@ def export_mapping_results(dataset, trait, markers, results_path, mapping_scale,
output_file.write(",Dominance")
output_file.write("\n")
for i, marker in enumerate(markers):
- output_file.write(marker['name'] + "," + str(marker['chr']) + "," + str(marker['Mb']) + ",")
- if "lod_score" in list(marker.keys()):
+ output_file.write(marker['name'] + "," + str(marker['chr']) + ",")
+ if 'Mb' in marker:
+ output_file.write(str(marker['Mb']) + ",")
+ if 'cM' in marker:
+ output_file.write(str(marker['cM']) + ",")
+ if "lod_score" in marker.keys():
output_file.write(str(marker['lod_score']))
else:
output_file.write(str(marker['lrs_value']))
@@ -667,16 +676,22 @@ def get_chr_lengths(mapping_scale, mapping_method, dataset, qtl_results):
except:
chr_as_num = 20
if chr_as_num > this_chr or i == (len(qtl_results) - 1):
- chr_lengths.append({ "chr": str(this_chr), "size": str(highest_pos)})
- this_chr = chr_as_num
- highest_pos = 0
+ if i == (len(qtl_results) - 1):
+ if mapping_method == "reaper":
+ highest_pos = float(result['cM']) * 1000000
+ else:
+ highest_pos = float(result['Mb']) * 1000000
+ chr_lengths.append({ "chr": str(this_chr), "size": str(highest_pos)})
+ else:
+ chr_lengths.append({ "chr": str(this_chr), "size": str(highest_pos)})
+ this_chr = chr_as_num
else:
if mapping_method == "reaper":
if float(result['cM']) > highest_pos:
- highest_pos = float(result['cM'])
+ highest_pos = float(result['cM']) * 1000000
else:
if float(result['Mb']) > highest_pos:
- highest_pos = float(result['Mb'])
+ highest_pos = float(result['Mb']) * 1000000
return chr_lengths
diff --git a/wqflask/wqflask/templates/admin/manage_user.html b/wqflask/wqflask/templates/admin/manage_user.html
new file mode 100644
index 00000000..7afe075f
--- /dev/null
+++ b/wqflask/wqflask/templates/admin/manage_user.html
@@ -0,0 +1,79 @@
+{% extends "base.html" %}
+{% block title %}View and Edit Group{% endblock %}
+{% block css %}
+ <link rel="stylesheet" type="text/css" href="{{ url_for('css', filename='DataTables/css/jquery.dataTables.css') }}" />
+ <link rel="stylesheet" type="text/css" href="/static/new/packages/DataTables/extensions/buttons.dataTables.css">
+ <link rel="stylesheet" type="text/css" href="/static/new/css/show_trait.css" />
+{% endblock %}
+{% block content %}
+<!-- Start of body -->
+ <div class="container">
+ {% if 'full_name' in user_details %}
+ <div class="page-header">
+ <h1>User details for: {{ user_details.full_name }}</h1>
+ </div>
+ {% endif %}
+ <form id="user_form" action="/user/manage" method="POST">
+ <div class="row">
+ <div id="user_info_div" class="col-xs-8" style="margin-right: 30px; min-width: 800px; max-width: 1000px;">
+ <div class="form-horizontal">
+ <div class="form-group">
+ <label for="email_address" style="text-align: left;" class="col-xs-2">Email Address:</label>
+ <div style="margin-left: 20px; text-align: left;" class="col-xs-2 controls">
+ <span id="email_address">{% if 'email_address' in user_details %}{{ user_details.email_address }}{% else %}N/A{% endif %}</span>
+ </div>
+ </div>
+ <div class="form-group">
+ <label for="full_name" style="text-align: left;" class="col-xs-2">User Name:</label>
+ <div style="margin-left: 20px; text-align: left;" class="col-xs-2 controls">
+ <span id="full_name" class="old_user_attribute">{% if 'full_name' in user_details %}{{ user_details.full_name }}{% else %}N/A{% endif %}</span>
+ <input type="text" name="new_full_name" style="display: none; width: 500px;" class="form-control new_user_attribute" placeholder="{% if 'full_name' in user_details %}{{ user_details.full_name }}{% else %}N/A{% endif %}">
+ </div>
+ </div>
+ <div class="form-group">
+ <label for="organization" style="text-align: left;" class="col-xs-2">Organization:</label>
+ <div style="margin-left: 20px; text-align: left;" class="col-xs-2 controls">
+ <span id="organization" class="old_user_attribute">{% if 'organization' in user_details %}{{ user_details.organization }}{% else %}N/A{% endif %}</span>
+ <input type="text" name="new_organization" style="display: none; width: 500px;" class="form-control new_user_attribute" placeholder="{% if 'organization' in user_details %}{{ user_details.organization }}{% else %}N/A{% endif %}">
+ </div>
+ </div>
+ <div class="form-group">
+ <label for="change_user_details" style="text-align: left;" class="col-xs-2"></label>
+ <div style="margin-left: 20px; text-align: left;" class="col-xs-2 controls">
+ <input type="button" id="change_user_details" value="Change Details">
+ <input type="button" id="save_changes" value="Save Changes" style="display: none;">
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+ </form>
+ </div>
+
+<!-- End of body -->
+
+{% endblock %}
+
+{% block js %}
+ <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='DataTables/js/jquery.dataTables.min.js') }}"></script>
+
+ <script type="text/javascript" charset="utf-8">
+ $(document).ready( function () {
+ $('#change_user_details').click(function(){
+ $('.new_user_attribute').css("display", "inline-block");
+ $('.old_user_attribute').css("display", "none");
+ $('#change_user_details').css("display", "none");
+ $('#save_changes').css("display", "inline-block");
+ });
+
+ $('#save_changes').click(function(){
+ $('.new_user_attribute').each(function(){
+ if ($(this).val() == ""){
+ $(this).val($(this).attr("placeholder"))
+ }
+ });
+ $('#user_form').submit();
+ });
+ });
+ </script>
+{% endblock %}