From 25fccfb3447012c3f2a75e3f54520e700d801487 Mon Sep 17 00:00:00 2001
From: Zachary Sloan
Date: Thu, 3 Jan 2013 15:54:53 -0600
Subject: 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
---
wqflask/base/data_set.py | 7 +-
wqflask/base/trait.py | 78 +++---------
wqflask/wqflask/do_search.py | 2 +-
wqflask/wqflask/show_trait/show_trait.py | 133 +++++----------------
.../new/javascript/show_trait_mapping_tools.coffee | 18 ++-
.../new/javascript/show_trait_mapping_tools.js | 15 ++-
wqflask/wqflask/templates/marker_regression.html | 51 ++++++++
.../templates/show_trait_mapping_tools.html | 8 +-
wqflask/wqflask/views.py | 63 +++++-----
9 files changed, 160 insertions(+), 215 deletions(-)
create mode 100644 wqflask/wqflask/templates/marker_regression.html
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 %}
+
+
+ {{ this_trait.name }}: {{ this_trait.description_fmt }}
+ Marker Regression
+