aboutsummaryrefslogtreecommitdiff
path: root/wqflask
diff options
context:
space:
mode:
authorZachary Sloan2013-01-03 15:54:53 -0600
committerZachary Sloan2013-01-03 15:54:53 -0600
commit25fccfb3447012c3f2a75e3f54520e700d801487 (patch)
tree8f9f0edd5897819e3d9d0277162436202d6cc7bd /wqflask
parent5b26284d86552491f57fc3a2477a2d97adcba9d7 (diff)
downloadgenenetwork2-25fccfb3447012c3f2a75e3f54520e700d801487.tar.gz
Created template for marek regression page and made the compute button direct
to it added asbolute_import in data_set.py and trait.py Made several minor changes and deleted commented out code in trait.py
Diffstat (limited to 'wqflask')
-rwxr-xr-xwqflask/base/data_set.py7
-rwxr-xr-xwqflask/base/trait.py78
-rw-r--r--wqflask/wqflask/do_search.py2
-rwxr-xr-xwqflask/wqflask/show_trait/show_trait.py133
-rw-r--r--wqflask/wqflask/static/new/javascript/show_trait_mapping_tools.coffee18
-rw-r--r--wqflask/wqflask/static/new/javascript/show_trait_mapping_tools.js15
-rw-r--r--wqflask/wqflask/templates/marker_regression.html51
-rw-r--r--wqflask/wqflask/templates/show_trait_mapping_tools.html8
-rw-r--r--wqflask/wqflask/views.py63
9 files changed, 160 insertions, 215 deletions
diff --git a/wqflask/base/data_set.py b/wqflask/base/data_set.py
index 612b9209..36d4acaf 100755
--- a/wqflask/base/data_set.py
+++ b/wqflask/base/data_set.py
@@ -16,11 +16,11 @@
# Contact Drs. Robert W. Williams and Xiaodong Zhou (2010)
# at rwilliams@uthsc.edu and xzhou15@uthsc.edu
#
-#
+#we
#
# This module is used by GeneNetwork project (www.genenetwork.org)
-from __future__ import print_function, division
+from __future__ import absolute_import, print_function, division
import os
from flask import Flask, g
@@ -29,7 +29,7 @@ from htmlgen import HTMLgen2 as HT
import reaper
-import webqtlConfig
+from base import webqtlConfig
from base import species
from dbFunction import webqtlDatabaseFunction
from utility import webqtlUtil
@@ -50,6 +50,7 @@ def create_dataset(dataset_name):
WHERE DBList.Name = '%s' and
DBType.Id = DBList.DBTypeId
""" % (escape(dataset_name))
+ print("query is: ", pf(query))
dataset_type = g.db.execute(query).fetchone().Name
#dataset_type = cursor.fetchone()[0]
diff --git a/wqflask/base/trait.py b/wqflask/base/trait.py
index 8c9e3b10..241bf2ab 100755
--- a/wqflask/base/trait.py
+++ b/wqflask/base/trait.py
@@ -1,12 +1,12 @@
-from __future__ import division, print_function
+from __future__ import absolute_import, division, print_function
import string
from htmlgen import HTMLgen2 as HT
-import webqtlConfig
-from webqtlCaseData import webqtlCaseData
-from data_set import create_dataset
+from base import webqtlConfig
+from base.webqtlCaseData import webqtlCaseData
+from base.data_set import create_dataset
from dbFunction import webqtlDatabaseFunction
from utility import webqtlUtil
@@ -24,76 +24,28 @@ class GeneralTrait:
def __init__(self, **kw):
print("in GeneralTrait")
- self.dataset = kw.get('dataset', None) # database name
- self.name = kw.get('name', None) # Trait ID, ProbeSet ID, Published ID, etc.
- self.cellid = kw.get('cellid', None)
+ self.dataset = kw.get('dataset') # database name
+ self.name = kw.get('name') # Trait ID, ProbeSet ID, Published ID, etc.
+ self.cellid = kw.get('cellid')
self.identification = kw.get('identification', 'un-named trait')
- #self.group = kw.get('group', None)
self.haveinfo = kw.get('haveinfo', False)
- self.sequence = kw.get('sequence', None) # Blat sequence, available for ProbeSet
+ self.sequence = kw.get('sequence') # Blat sequence, available for ProbeSet
self.data = kw.get('data', {})
-
+
if kw.get('fullname'):
name2 = value.split("::")
if len(name2) == 2:
self.dataset, self.name = name2
+ # self.cellid is set to None above
elif len(name2) == 3:
self.dataset, self.name, self.cellid = name2
-
- #if self.dataset and isinstance(self.dataset, basestring):
- self.dataset = create_dataset(self.dataset)
- print("self.dataset is:", self.dataset, type(self.dataset))
- #if self.dataset:
-
- #self.dataset.get_group()
+ self.dataset = create_dataset(self.dataset)
- #if self.dataset.type == "Temp":
- # self.cursor.execute('''
- # SELECT
- # InbredSet.Name
- # FROM
- # InbredSet, Temp
- # WHERE
- # Temp.InbredSetId = InbredSet.Id AND
- # Temp.Name = "%s"
- # ''', self.name)
- # self.group = self.cursor.fetchone()[0]
- #else:
- # self.group = self.dataset.get_group()
-
- #print("trinity, self.group is:", self.group)
-
- #
- # In ProbeSet, there are maybe several annotations match one sequence
- # so we need use sequence(BlatSeq) as the identification, when we update
- # one annotation, we update the others who match the sequence also.
- #
- # Hongqiang Li, 3/3/2008
- #
-
- #XZ, 05/08/2009: This block is not neccessary. We can add 'BlatSeq' into disfield.
- # The variable self.sequence should be changed to self.BlatSeq
- # It also should be changed in other places where it are used.
-
- #if self.dataset:
- #if self.dataset.type == 'ProbeSet':
- # print("Doing ProbeSet Query")
- # query = '''
- # SELECT
- # ProbeSet.BlatSeq
- # FROM
- # ProbeSet, ProbeSetFreeze, ProbeSetXRef
- # WHERE
- # ProbeSet.Id=ProbeSetXRef.ProbeSetId and
- # ProbeSetFreeze.Id = ProbeSetXRef.ProbeSetFreezeId and
- # ProbeSet.Name = %s and
- # ProbeSetFreeze.Name = %s
- # ''', (self.name, self.dataset.name)
- # print("query is:", query)
- # self.sequence = g.db.execute(*query).fetchone()[0]
- # #self.sequence = self.cursor.fetchone()[0]
- # print("self.sequence is:", self.sequence)
+ # Todo: These two lines are necessary most of the time, but perhaps not all of the time
+ # So we could add a simple if statement to short-circuit this if necessary
+ self.retrieve_info()
+ self.retrieve_sample_data()
def get_name(self):
diff --git a/wqflask/wqflask/do_search.py b/wqflask/wqflask/do_search.py
index fc45395c..a2eddfc6 100644
--- a/wqflask/wqflask/do_search.py
+++ b/wqflask/wqflask/do_search.py
@@ -63,7 +63,7 @@ class DoSearch(object):
class MrnaAssaySearch(DoSearch):
"""A search within an mRNA expression dataset"""
- DoSearch.search_types['ProbeSet'] = "ProbeSetSearch"
+ DoSearch.search_types['ProbeSet'] = "MrnaAssaySearch"
base_query = """SELECT ProbeSet.Name as TNAME,
0 as thistable,
diff --git a/wqflask/wqflask/show_trait/show_trait.py b/wqflask/wqflask/show_trait/show_trait.py
index c605cb58..807761a2 100755
--- a/wqflask/wqflask/show_trait/show_trait.py
+++ b/wqflask/wqflask/show_trait/show_trait.py
@@ -34,45 +34,26 @@ from pprint import pformat as pf
class ShowTrait(object):
- def __init__(self, args):
- print("in ShowTrait, args are:", args)
- #self.group = args.group
- self.trait_id = args['trait_id']
+ def __init__(self, kw):
+ print("in ShowTrait, kw are:", kw)
+ self.trait_id = kw['trait_id']
- self.dataset = create_dataset(args['dataset'])
-
- #self.dataset = create_dataset(args['dataset'])
- self.cell_id = None
+ self.dataset = create_dataset(kw['dataset'])
+
+ #self.cell_id = None
- #assert self.openMysql(), "No database!"
- #print("red3 fd.group:", fd.group)
- this_trait = self.get_this_trait()
+ this_trait = GeneralTrait(dataset=self.dataset.name,
+ name=self.trait_id,
+ cellid=None)
- #print("red4 fd.group:", fd.group)
- ##read genotype file
- #fd.group = this_trait.group
- #print("[red5] fd.group is:", fd.group)
self.dataset.group.read_genotype_file()
- #fd.readGenotype()
if not self.dataset.group.genotype:
- self.read_data(include_f1=True) #incf1=1)
+ self.read_data(include_f1=True)
- ## determine data editing page format
- #variance_data_page = 0
- #if fd.formID == 'varianceChoice':
- # variance_data_page = 1
- #
- #if variance_data_page:
- # fmID='dataEditing'
- #else:
- # if fd.enablevariance:
- # fmID='pre_dataEditing'
- # else:
- # fmID='dataEditing'
-
+
# Todo: Add back in the ones we actually need from below, as we discover we need them
hddn = OrderedDict()
@@ -111,55 +92,19 @@ class ShowTrait(object):
# export_data = None
# )
- #if fd.enablevariance:
- # hddn['enablevariance']='ON'
- #if fd.incparentsf1:
- # hddn['incparentsf1']='ON'
-
#if this_trait:
- # hddn['fullname'] = str(this_trait)
- # try:
- # hddn['normalPlotTitle'] = this_trait.symbol
- # hddn['normalPlotTitle'] += ": "
- # hddn['normalPlotTitle'] += this_trait.name
- # except:
- # hddn['normalPlotTitle'] = str(this_trait.name)
- # hddn['fromDataEditingPage'] = 1
# if this_trait.dataset and this_trait.dataset.type and this_trait.dataset.type == 'ProbeSet':
- # hddn['trait_type'] = this_trait.dataset.type
- # if this_trait.cellid:
- # hddn['cellid'] = this_trait.cellid
- # else:
# self.cursor.execute("SELECT h2 from ProbeSetXRef WHERE DataId = %d" %
# this_trait.mysqlid)
# heritability = self.cursor.fetchone()
- # hddn['heritability'] = heritability
- #
- # hddn['attribute_names'] = ""
- #
+
#hddn['mappingMethodId'] = webqtlDatabaseFunction.getMappingMethod (cursor=self.cursor,
# groupName=fd.group)
- #
- #if fd.identification:
- # hddn['identification'] = fd.identification
- #else:
- # hddn['identification'] = "Un-named trait" #If no identification, set identification to un-named
-
- self.dispTraitInformation(args, "", hddn, this_trait) #Display trait information + function buttons
- if this_trait == None:
- this_trait = webqtlTrait(data=args['allTraitData'], dataset=None)
+ self.dispTraitInformation(kw, "", hddn, this_trait) #Display trait information + function buttons
- ## Variance submit page only
- #if fd.enablevariance and not variance_data_page:
- # pass
- # #title2Body.append("Click the next button to go to the variance submission form.",
- # # HT.Center(next,reset))
- #else:
- # pass
- # # We'll get this part working later
- # print("Calling dispBasicStatistics")
- # self.dispBasicStatistics(fd, this_trait)
+ #if this_trait == None:
+ # this_trait = webqtlTrait(data=kw['allTraitData'], dataset=None)
self.build_correlation_tools(this_trait)
@@ -168,9 +113,6 @@ class ShowTrait(object):
if self.dataset.group.allsamples:
hddn['allsamples'] = string.join(self.dataset.group.allsamples, ' ')
- #if args['varianceDispName'] != 'Variance':
- # hddn['isSE'] = "yes"
-
# We'll need access to this_trait and hddn in the Jinja2 Template, so we put it inside self
self.this_trait = this_trait
self.hddn = hddn
@@ -188,34 +130,23 @@ class ShowTrait(object):
self.js_data = js_data
- def get_this_trait(self):
- # When is traitInfos used?
- #if traitInfos:
- # database, ProbeSetID, CellID = traitInfos
- #else:
- #dataset = self.fd['dataset']
- #trait_id = self.fd['trait_id']
- #cell_id = self.fd.get('CellID')
-
- this_trait = GeneralTrait(dataset=self.dataset.name,
- name=self.trait_id,
- cellid=self.cell_id)
-
- ##identification, etc.
- self.identification = '%s : %s' % (self.dataset.shortname, self.trait_id)
- this_trait.returnURL = webqtlConfig.CGIDIR + webqtlConfig.SCRIPTFILE + '?FormID=showDatabase&database=%s\
- &ProbeSetID=%s&group=%s&parentsf1=on' %(self.dataset, self.trait_id, self.dataset.group.name)
-
- if self.cell_id:
- self.identification = '%s/%s'%(self.identification, self.cell_id)
- this_trait.returnURL = '%s&CellID=%s' % (this_trait.returnURL, self.cell_id)
-
- print("yellow1:", self.dataset.group)
- this_trait.retrieve_info()
- print("yellow2:", self.dataset.group)
- this_trait.retrieve_sample_data()
- print("yellow3:", self.dataset.group)
- return this_trait
+ #def get_this_trait(self):
+ # this_trait = GeneralTrait(dataset=self.dataset.name,
+ # name=self.trait_id,
+ # cellid=self.cell_id)
+ #
+ # ###identification, etc.
+ # #self.identification = '%s : %s' % (self.dataset.shortname, self.trait_id)
+ # #this_trait.returnURL = webqtlConfig.CGIDIR + webqtlConfig.SCRIPTFILE + '?FormID=showDatabase&database=%s\
+ # # &ProbeSetID=%s&group=%s&parentsf1=on' %(self.dataset, self.trait_id, self.dataset.group.name)
+ # #
+ # #if self.cell_id:
+ # # self.identification = '%s/%s'%(self.identification, self.cell_id)
+ # # this_trait.returnURL = '%s&CellID=%s' % (this_trait.returnURL, self.cell_id)
+ #
+ # this_trait.retrieve_info()
+ # this_trait.retrieve_sample_data()
+ # return this_trait
def read_data(self, include_f1=False):
diff --git a/wqflask/wqflask/static/new/javascript/show_trait_mapping_tools.coffee b/wqflask/wqflask/static/new/javascript/show_trait_mapping_tools.coffee
index b1f5b186..d0fc869d 100644
--- a/wqflask/wqflask/static/new/javascript/show_trait_mapping_tools.coffee
+++ b/wqflask/wqflask/static/new/javascript/show_trait_mapping_tools.coffee
@@ -1,11 +1,17 @@
$ ->
- run_marker_regression = ->
- console.log("In marker regression")
- url = "/marker_regression"
+ submit_special = ->
+ # Add submit_special class plus a data-url field to any button
+ # And it will submit to that url
+ # No js changes necessary
+ console.log("In submit_special")
+ console.log("this is:", this)
+ console.log("$(this) is:", $(this))
+ url = $(this).data("url")
+ console.log("url is:", url)
$("#trait_data_form").attr("action", url);
$("#trait_data_form").submit()
- $("#do_marker_regression").click(run_marker_regression)
+ $(".submit_special").click(submit_special)
composite_mapping_fields = ->
@@ -14,10 +20,10 @@ $ ->
$("#use_composite_choice").change(composite_mapping_fields)
+ #### Todo: Redo below so its like submit_special and requires no js hardcoding
toggle_enable_disable = (elem) ->
- $(elem).prop("disabled", !$(elem.prop("disabled")))
+ $(elem).prop("disabled", !$(elem).prop("disabled"))
-
$("#choose_closet_control").change(->
toggle_enable_disable("#control_locus")
)
diff --git a/wqflask/wqflask/static/new/javascript/show_trait_mapping_tools.js b/wqflask/wqflask/static/new/javascript/show_trait_mapping_tools.js
index c8328498..c6766288 100644
--- a/wqflask/wqflask/static/new/javascript/show_trait_mapping_tools.js
+++ b/wqflask/wqflask/static/new/javascript/show_trait_mapping_tools.js
@@ -2,21 +2,24 @@
(function() {
$(function() {
- var composite_mapping_fields, run_marker_regression, toggle_enable_disable;
- run_marker_regression = function() {
+ var composite_mapping_fields, submit_special, toggle_enable_disable;
+ submit_special = function() {
var url;
- console.log("In marker regression");
- url = "/marker_regression";
+ console.log("In submit_special");
+ console.log("this is:", this);
+ console.log("$(this) is:", $(this));
+ url = $(this).data("url");
+ console.log("url is:", url);
$("#trait_data_form").attr("action", url);
return $("#trait_data_form").submit();
};
- $("#do_marker_regression").click(run_marker_regression);
+ $(".submit_special").click(submit_special);
composite_mapping_fields = function() {
return $(".composite_fields").toggle();
};
$("#use_composite_choice").change(composite_mapping_fields);
toggle_enable_disable = function(elem) {
- return $(elem).prop("disabled", !$(elem.prop("disabled")));
+ return $(elem).prop("disabled", !$(elem).prop("disabled"));
};
$("#choose_closet_control").change(function() {
return toggle_enable_disable("#control_locus");
diff --git a/wqflask/wqflask/templates/marker_regression.html b/wqflask/wqflask/templates/marker_regression.html
new file mode 100644
index 00000000..db2de604
--- /dev/null
+++ b/wqflask/wqflask/templates/marker_regression.html
@@ -0,0 +1,51 @@
+{% extends "base.html" %}
+{% block title %}Marker Regression{% endblock %}
+{% block content %} <!-- Start of body -->
+
+ <header class="jumbotron subhead" id="overview">
+ <div class="container">
+ <h1>Marker Regression</h1>
+ <p class="lead">
+ {{ this_trait.name }}: {{ this_trait.description_fmt }}
+ </p>
+ </div>
+ </header>
+
+ <dl class="dl-horizontal">
+ <dt>Aliases</dt>
+ <dd>{{ this_trait.alias_fmt }}</dd>
+
+ <dt>Location</dt>
+ <dd>{{ this_trait.location_fmt }}</dd>
+
+ <dt>Database</dt>
+ <dd>
+ <a href="{{ url_for('static', filename='/dbdoc/' + dataset.fullname + '.html') }}" target="_blank">
+ {{ dataset.name }}
+ </a>
+ </dd>
+
+ {% if this_trait.probe_set_specificity %}
+ <dt>
+ <a href="/blatInfo.html" target="_blank"
+ title="Values higher than 2 for the specificity are good">
+ BLAT Specifity
+ </a>
+ </dt>
+ <dd>{{ "%.1f" % (this_trait.probe_set_specificity) }}</dd>
+ {% endif %}
+ {% if this_trait.probe_set_blat_score %}
+ <dt>BLAT Score</dt>
+ <dd>{{ "%i" % (this_trait.probe_set_blat_score) }}</dd>
+ {% endif %}
+ </dl>
+
+ <!-- End of body -->
+
+{% endblock %}
+
+{% block js %}
+ <script>
+ js_data = {{ js_data | safe }}
+ </script>
+{% endblock %} \ No newline at end of file
diff --git a/wqflask/wqflask/templates/show_trait_mapping_tools.html b/wqflask/wqflask/templates/show_trait_mapping_tools.html
index 8436703d..72b152fa 100644
--- a/wqflask/wqflask/templates/show_trait_mapping_tools.html
+++ b/wqflask/wqflask/templates/show_trait_mapping_tools.html
@@ -101,7 +101,8 @@
<div class="control-group">
<div class="controls">
- <button id="do_interval_mapping" class="btn btn-inverse"
+ <button class="btn btn-inverse submit_special"
+ data-url="/interval_mapping"
title="Compute Interval Mapping">
<i class="icon-ok-circle icon-white"></i> Compute
</button>
@@ -135,8 +136,9 @@
<div class="control-group">
<div class="controls">
- <button id="do_marker_regression"
- class="btn btn-inverse" title="Compute Marker Regression">
+ <button class="btn btn-inverse submit_special"
+ data-url="/marker_regression"
+ title="Compute Marker Regression">
<i class="icon-ok-circle icon-white"></i> Compute
</button>
</div>
diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py
index 503b0972..f6c0dfb0 100644
--- a/wqflask/wqflask/views.py
+++ b/wqflask/wqflask/views.py
@@ -18,6 +18,7 @@ from flask import render_template, request, make_response, Response, Flask, g, c
from wqflask import search_results
from wqflask.show_trait import show_trait
from wqflask.show_trait import export_trait_data
+from wqflask.marker_regression import marker_regression
from wqflask.correlation import CorrelationPage
from wqflask.dataSharing import SharingInfo, SharingInfoPage
@@ -89,27 +90,6 @@ def whats_new_page():
print("\nnews_item is: %s\n" % (news_item))
return render_template("whats_new.html", news_items=news_items)
-
-@app.route("/show_trait")
-def show_trait_page():
- # Here it's currently too complicated not to use an fd that is a webqtlFormData
- #fd = webqtlFormData.webqtlFormData(request.args)
- #print("stp y1:", pf(vars(fd)))
- template_vars = show_trait.ShowTrait(request.args)
-
- print("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)
-
- print("js_data after dump:", template_vars.js_data)
-
- print("show_trait template_vars:", pf(template_vars.__dict__))
- return render_template("show_trait.html", **template_vars.__dict__)
-
@app.route('/export_trait_csv', methods=('POST',))
def export_trait_excel():
"""Excel file consisting of the sample data from the trait data and analysis page"""
@@ -150,33 +130,52 @@ def export_trait_csv():
mimetype='text/csv',
headers={"Content-Disposition":"attachment;filename=test.csv"})
+@app.route("/show_trait")
+def show_trait_page():
+ # Here it's currently too complicated not to use an fd that is a webqtlFormData
+ #fd = webqtlFormData.webqtlFormData(request.args)
+ #print("stp y1:", pf(vars(fd)))
+ template_vars = show_trait.ShowTrait(request.args)
+ print("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)
+
+ print("js_data after dump:", template_vars.js_data)
+ print("show_trait template_vars:", pf(template_vars.__dict__))
+ return render_template("show_trait.html", **template_vars.__dict__)
+
+@app.route("/marker_regression", methods=('POST',))
+def marker_regression_page():
+ template_vars = marker_regression.MarkerRegression(request.form)
+ #print("js_data before dump:", template_vars.js_data)
+ #template_vars.js_data = json.dumps(template_vars.js_data,
+ # default=json_default_handler,
+ # indent=" ")
+ #print("js_data after dump:", template_vars.js_data)
+ print("marker_regression template_vars:", pf(template_vars.__dict__))
+ return render_template("marker_regression.html", **template_vars.__dict__)
@app.route("/corr_compute", methods=('POST',))
def corr_compute_page():
- #print("In corr_compute, request.args is:", pf(request.form))
+ print("In corr_compute, request.args is:", pf(request.form))
fd = webqtlFormData.webqtlFormData(request.form)
- print("Have fd")
template_vars = CorrelationPage.CorrelationPage(fd)
- print("Made it to rendering")
return render_template("correlation_page.html", **template_vars.__dict__)
@app.route("/int_mapping", methods=('POST',))
def interval_mapping_page():
- fd = webqtlFormData.webqtlFormData(request.form)
- print("Have fd")
- template_vars = CorrelationPage.CorrelationPage(fd)
- print("Made it to rendering")
- return render_template("correlation_page.html", **template_vars.__dict__)
-
+ template_vars = interval_mapping.IntervalMapping(request.args)
+ return render_template("interval_mapping.html", **template_vars.__dict__)
# Todo: Can we simplify this? -Sam
def sharing_info_page():
"""Info page displayed when the user clicks the "Info" button next to the dataset selection"""
print("In sharing_info_page")
fd = webqtlFormData.webqtlFormData(request.args)
- print("2Have fd")
template_vars = SharingInfoPage.SharingInfoPage(fd)
- print("2 Made it to rendering")
return template_vars