about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMuriithi Frederick Muriuki2018-02-05 15:38:26 +0300
committerMuriithi Frederick Muriuki2018-02-05 15:38:26 +0300
commit93f6d69691d109ba4090c2eba82a72df13fbb060 (patch)
tree301d62706082e3b76f84fd4b69bf76a8591d5c47
parentafaea1b1297d0cf08565746799d2900a6981823a (diff)
parent4ae2d548127eeeaa7cec0baf1b788005b5e8e51d (diff)
downloadgenenetwork2-93f6d69691d109ba4090c2eba82a72df13fbb060.tar.gz
Merge remote-tracking branch 'origin/testing' into testing
-rwxr-xr-xbin/genenetwork292
-rw-r--r--etc/VERSION2
-rw-r--r--etc/default_settings.py2
-rw-r--r--wqflask/__init__.py1
-rw-r--r--wqflask/run_gunicorn.py19
-rw-r--r--wqflask/runserver.py2
-rw-r--r--wqflask/wqflask/marker_regression/marker_regression.py10
-rw-r--r--wqflask/wqflask/marker_regression/marker_regression_gn1.py17
-rw-r--r--wqflask/wqflask/static/new/javascript/dataset_menu_structure.json24
-rw-r--r--wqflask/wqflask/static/new/javascript/show_trait_mapping_tools.js1
-rw-r--r--wqflask/wqflask/templates/loading.html18
-rw-r--r--wqflask/wqflask/templates/marker_regression_gn1.html22
-rw-r--r--wqflask/wqflask/templates/show_trait.html2
-rw-r--r--wqflask/wqflask/templates/show_trait_details.html31
-rw-r--r--wqflask/wqflask/templates/show_trait_mapping_tools.html174
-rw-r--r--wqflask/wqflask/views.py3
-rw-r--r--wqflask/wsgi.py4
17 files changed, 295 insertions, 129 deletions
diff --git a/bin/genenetwork2 b/bin/genenetwork2
index ccd9b1d9..34fbc72e 100755
--- a/bin/genenetwork2
+++ b/bin/genenetwork2
@@ -1,8 +1,11 @@
 #! /bin/bash
 #
+# This is the startup script for GN2. It sets the environment variables to pick
+# up a Guix profile and allows for overriding parameters.
+#
 # Typical usage
 #
-#   env GN2_PROFILE=~/opt/genenetwork2-phewas ./bin/genenetwork2
+#   env GN2_PROFILE=~/opt/genenetwork2-phewas ./bin/genenetwork2 ~/my_settings.py
 #
 # Where GN2_PROFILE points to the GNU Guix profile used for deployment.
 #
@@ -22,8 +25,26 @@
 # a -c switch, e.g.
 #
 #   env GN2_PROFILE=~/opt/gn-latest-guix ./bin/genenetwork2 ~/my_overrides.json -c ./wqflask/maintenance/gen_select_dataset.py
+#
+# For development you may want to run
+#
+#   env GN2_PROFILE=~/opt/gn-latest-guix WEBSERVER_MODE=DEBUG LOG_LEVEL=DEBUG ./bin/genenetwork2
+#
+# For staging and production we use gunicorn. Run with something like
+# (note you have to provide the server port). Provide a settings file!
+#
+#   env GN2_PROFILE=~/opt/gn-latest-guix SERVER_PORT=5003 ./bin/genenetwork2 ./etc/default_settings.py -gunicorn-prod
+#
+# For development use
+#
+#   env GN2_PROFILE=~/opt/gn-latest-guix SERVER_PORT=5003 ./bin/genenetwork2 ./etc/default_settings.py -gunicorn-dev
+#
+# For extra flexibility you can also provide gunicorn parameters yourself with something like
+#
+#   env GN2_PROFILE=~/opt/gn-latest-guix ./bin/genenetwork2 ./etc/default_settings.py -gunicorn "--bind 0.0.0.0:5003 --workers=1 wsgi"
 
-SCRIPT=$(readlink -f "$0")
+SCRIPT=$(realpath "$0")
+echo SCRIPT=$SCRIPT
 GN2_BASE_DIR=$(dirname $(dirname "$SCRIPT"))
 GN2_ID=$(cat /etc/hostname):$(basename $GN2_BASE_DIR)
 
@@ -42,15 +63,27 @@ else
 fi
 echo GN_VERSION=$GN_VERSION
 
+if [ "$1" = "-c" -o "$1" = "-gunicorn" ]; then
+    echo "Can not use $1 switch without default settings file"
+    exit 1
+fi
 # Handle settings parameter (can be .py or .json)
-settings=$1
+if [ ! -z $1 ]; then
+    settings=$(realpath "$1")
+    if [ ! -e $settings ]; then
+        settings=$GN2_BASE_DIR/etc/default_settings.py
+    else
+        shift
+    fi
+fi
+
 ext="${settings##*.}"
-if [ -z "$settings" -o "$ext" = "json" -o "$ext" = "JSON" ]; then
+if [ "$ext" = "json" -o "$ext" = "JSON" ]; then
     overrides=$settings
-    settings=$GN2_BASE_DIR/etc/default_settings.py
 else
-    shift
+    echo $settings
 fi
+
 if [ ! -e $settings ]; then
     echo "ERROR: can not locate settings file - pass it in the command line"
     exit 1
@@ -72,6 +105,8 @@ if [ -z $GN2_PROFILE ] ; then
     if [ -d $GN2_PROFILE ]; then
         echo "Best guess is $GN2_PROFILE"
     fi
+    echo "ERROR: always set GN2_PROFILE"
+    exit 1
 fi
 if [ -z $GN2_PROFILE ]; then
     read -p "PRESS [ENTER] TO CONTINUE..."
@@ -91,6 +126,9 @@ else
     export PYLMM_COMMAND="$GN2_PROFILE/bin/pylmm_redis"
     export GEMMA_COMMAND="$GN2_PROFILE/bin/gemma"
     export GEMMA_WRAPPER_COMMAND="$GN2_PROFILE/bin/gemma-wrapper"
+    if [ ! -d $PYTHONPATH ] ; then echo "PYTHONPATH not valid "$PYTHONPATH ; exit 1 ; fi
+    if [ ! -d $R_LIBS_SITE ] ; then echo "R_LIBS_SITE not valid "$R_LIBS_SITE ; exit 1 ; fi
+    if [ ! -d $GEM_PATH ] ; then echo "GEM_PATH not valid "$GEM_PATH ; exit 1 ; fi
 fi
 if [ -z $PYTHONPATH ] ; then
     echo "ERROR PYTHONPATH has not been set - use GN2_PROFILE!"
@@ -116,14 +154,50 @@ set|grep guix
 set|grep $GN2_PROFILE
 set|grep TMPDIR
 
-# Now handle command parameter -c
+# Now handle command parameter -c which runs python
 if [ "$1" = '-c' ] ; then
     cd $GN2_BASE_DIR/wqflask
     cmd=${2#wqflask/}
     echo PYTHONPATH=$PYTHONPATH
     echo RUNNING COMMAND $cmd
     python $cmd
-    exit 0
+    exit $?
+fi
+# Now handle command parameter -cli which runs in bash
+if [ "$1" = "-cli" ] ; then
+    echo "HERE"
+    cd $GN2_BASE_DIR/wqflask
+    cmd=$2
+    echo PYTHONPATH=$PYTHONPATH
+    echo RUNNING COMMAND $cmd
+    $cmd
+    exit $?
+fi
+if [ "$1" = '-gunicorn' ] ; then
+    cd $GN2_BASE_DIR/wqflask
+    cmd=$2
+    echo PYTHONPATH=$PYTHONPATH
+    echo RUNNING gunicorn $cmd
+    gunicorn $cmd
+    exit $?
+fi
+if [ "$1" = '-gunicorn-dev' ] ; then
+    cd $GN2_BASE_DIR/wqflask
+    echo PYTHONPATH=$PYTHONPATH
+    if [ -z $SERVER_PORT ]; then echo "ERROR: Provide a SERVER_PORT" ; exit 1 ; fi
+    cmd="--bind 0.0.0.0:$SERVER_PORT --workers=1 --timeout 180 --reload wsgi"
+    echo RUNNING gunicorn $cmd
+    gunicorn $cmd
+    exit $?
+fi
+if [ "$1" = '-gunicorn-prod' ] ; then
+    cd $GN2_BASE_DIR/wqflask
+    echo PYTHONPATH=$PYTHONPATH
+    if [ -z $SERVER_PORT ]; then echo "ERROR: Provide a SERVER_PORT" ; exit 1 ; fi
+    cmd="--bind 0.0.0.0:$SERVER_PORT --workers=32 --max-requests 1000 --timeout 1200 wsgi"
+    echo RUNNING gunicorn $cmd
+    gunicorn $cmd
+    exit $?
 fi
 
 echo "Starting the redis server:"
@@ -132,7 +206,7 @@ dbfilename gn2.rdb
 " | redis-server - &
 
 # Overrides for packages that are not yet public (currently r-auwerx)
-export R_LIBS_SITE=$R_LIBS_SITE:$HOME/.Rlibs/das1i1pm54dj6lbdcsw5w0sdwhccyj1a-r-3.3.2/lib/R/lib
+# export R_LIBS_SITE=$R_LIBS_SITE:$HOME/.Rlibs/das1i1pm54dj6lbdcsw5w0sdwhccyj1a-r-3.3.2/lib/R/lib
 
 # Start the flask server running GN2
 cd $GN2_BASE_DIR/wqflask
diff --git a/etc/VERSION b/etc/VERSION
index b624c74a..ca9e199c 100644
--- a/etc/VERSION
+++ b/etc/VERSION
@@ -1 +1 @@
-2.10rc5
+2.11-rc1
diff --git a/etc/default_settings.py b/etc/default_settings.py
index 59e22f1a..699d21f1 100644
--- a/etc/default_settings.py
+++ b/etc/default_settings.py
@@ -27,7 +27,7 @@ import sys
 GN_VERSION = open("../etc/VERSION","r").read()
 SQL_URI = "mysql://gn2:mysql_password@localhost/db_webqtl_s"
 SQL_ALCHEMY_POOL_RECYCLE = 3600
-GN_SERVER_URL = "http://localhost:8880/"
+GN_SERVER_URL = "http://localhost:8880/" # REST API server
 
 # ---- Flask configuration (see website)
 TRAP_BAD_REQUEST_ERRORS = True
diff --git a/wqflask/__init__.py b/wqflask/__init__.py
index 315b709e..e69de29b 100644
--- a/wqflask/__init__.py
+++ b/wqflask/__init__.py
@@ -1 +0,0 @@
-from wqflask import app
diff --git a/wqflask/run_gunicorn.py b/wqflask/run_gunicorn.py
new file mode 100644
index 00000000..14a2d689
--- /dev/null
+++ b/wqflask/run_gunicorn.py
@@ -0,0 +1,19 @@
+# Run with gunicorn, see ./bin/genenetwork2 for an example
+#
+# Run standalone with
+#
+#   ./bin/genenetwork2 ./etc/default_settings.py -c run_gunicorn.py
+
+# from flask import Flask
+# application = Flask(__name__)
+
+print "Starting up Gunicorn process"
+
+from wqflask import app
+
+@app.route("/gunicorn")
+def hello():
+    return "<h1 style='color:blue'>Hello There!</h1>"
+
+if __name__ == "__main__":
+    app.run(host='0.0.0.0')
diff --git a/wqflask/runserver.py b/wqflask/runserver.py
index 50f134db..a0c76e51 100644
--- a/wqflask/runserver.py
+++ b/wqflask/runserver.py
@@ -1,5 +1,7 @@
 # Starts the webserver with the ./bin/genenetwork2 command
 #
+# This uses Werkzeug WSGI, see ./run_gunicorn.py for the alternative
+#
 # Please note, running with host set externally below combined with
 # debug mode is a security risk unless you have a firewall setup, e.g.
 #
diff --git a/wqflask/wqflask/marker_regression/marker_regression.py b/wqflask/wqflask/marker_regression/marker_regression.py
index bcb14451..087b95b4 100644
--- a/wqflask/wqflask/marker_regression/marker_regression.py
+++ b/wqflask/wqflask/marker_regression/marker_regression.py
@@ -79,6 +79,16 @@ class MarkerRegression(object):
                     self.samples.append(sample)
                     self.vals.append(value)
 
+        #ZS: Check if genotypes exist in the DB in order to create links for markers
+        if "geno_db_exists" in start_vars:
+            self.geno_db_exists = start_vars['geno_db_exists']
+        else:
+          try:
+            geno_dataset = data_set.create_dataset(self.dataset.group.name + "Geno")
+            self.geno_db_exists = "True"
+          except:
+            self.geno_db_exists = "False"
+
         self.mapping_method = start_vars['method']
         if "results_path" in start_vars:
             self.mapping_results_path = start_vars['results_path']
diff --git a/wqflask/wqflask/marker_regression/marker_regression_gn1.py b/wqflask/wqflask/marker_regression/marker_regression_gn1.py
index 93bd9d42..211cf187 100644
--- a/wqflask/wqflask/marker_regression/marker_regression_gn1.py
+++ b/wqflask/wqflask/marker_regression/marker_regression_gn1.py
@@ -174,6 +174,8 @@ class MarkerRegression(object):
         if 'genofile_string' in start_vars:
             self.genofile_string = start_vars['genofile_string']
 
+        self.geno_db_exists = start_vars['geno_db_exists']
+
         #Needing for form submission when doing single chr mapping or remapping after changing options
         self.samples = start_vars['samples']
         self.vals = start_vars['vals']
@@ -576,7 +578,7 @@ class MarkerRegression(object):
         self.gifmap = gifmap.__str__()
 
         self.filename= webqtlUtil.genRandStr("Itvl_")
-        intCanvas.save(os.path.join(webqtlConfig.GENERATED_IMAGE_DIR, self.filename), format='jpeg')
+        intCanvas.save(os.path.join(webqtlConfig.GENERATED_IMAGE_DIR, self.filename), format='png')
         intImg=HT.Image('/image/'+self.filename+'.png', border=0, usemap='#WebQTLImageMap')
 
         #Scales plot differently for high resolution
@@ -616,7 +618,7 @@ class MarkerRegression(object):
         else:
             showLocusForm = intImg
 
-        if self.permChecked and self.nperm > 0 and not self.multipleInterval and 0 < self.nperm:
+        if (self.permChecked and self.nperm > 0) and not (self.multipleInterval and 0 < self.nperm):
             self.perm_filename = self.drawPermutationHistogram()
             #perm_text_file = self.permutationTextFile()
 
@@ -1200,8 +1202,10 @@ class MarkerRegression(object):
         if self.controlLocus and self.doControl != "false":
             string2 = 'Using %s as control' % self.controlLocus
         else:
-            if self.mapping_method == "gemma":
+            if self.mapping_method == "gemma" or self.mapping_method == "gemma_bimbam":
                 string2 = 'Using GEMMA mapping method with no control for other QTLs.'
+            elif self.mapping_method == "rqtl_plink" or self.mapping_method == "rqtl_geno":
+                string2 = 'Using R/qtl mapping method with no control for other QTLs.'
             elif self.mapping_method == "plink":
                 string2 = 'Using PLINK mapping method with no control for other QTLs.'
             else:
@@ -1963,6 +1967,8 @@ class MarkerRegression(object):
 
             if self.permChecked and self.nperm > 0 and not self.multipleInterval:
                 LRS_LOD_Max = max(self.significant, LRS_LOD_Max)
+            else:
+                LRS_LOD_Max = 1.15*LRS_LOD_Max
 
             #genotype trait will give infinite LRS
             LRS_LOD_Max = min(LRS_LOD_Max, webqtlConfig.MAXLRS)
@@ -2164,10 +2170,7 @@ class MarkerRegression(object):
                 #    Yc = yZero - qtlresult['lrs_value']*LRSHeightThresh/LRS_LOD_Max
 
                 if self.manhattan_plot == True:
-                    if previous_chr_as_int % 2 == 1:
-                        point_color = pid.grey
-                    else:
-                        point_color = pid.black
+                    point_color = pid.black
                     canvas.drawString("5", Xc-canvas.stringWidth("5",font=symbolFont)/2+1,Yc+2,color=point_color, font=symbolFont)
                 else:
                     LRSCoordXY.append((Xc, Yc))
diff --git a/wqflask/wqflask/static/new/javascript/dataset_menu_structure.json b/wqflask/wqflask/static/new/javascript/dataset_menu_structure.json
index 8de85a86..b7ebb9ed 100644
--- a/wqflask/wqflask/static/new/javascript/dataset_menu_structure.json
+++ b/wqflask/wqflask/static/new/javascript/dataset_menu_structure.json
@@ -2974,6 +2974,20 @@
                ]
             ]
          },
+         "BXD-Harvested": {
+            "Liver mRNA": [
+               [
+                  "843",
+                  "UTHSC-BXD-Harv_Liv-0118",
+                  "UTHSC BXD Harvested Liver RNA-Seq (Jan18) Log2 **"
+               ],
+               [
+                  "842",
+                  "UTHSC-BXD-Liv-0917",
+                  "UTHSC BXD Liver Affy Clariom S GeneLevel Main (Sep17) RMA **"
+               ]
+            ]
+         },
          "BXD300": {
             "Genotypes": [
                [
@@ -3864,6 +3878,10 @@
             "BXD Bone"
          ],
          [
+            "BXD-Harvested",
+            "BXD NIA Longevity Study"
+         ],
+         [
             "BXD300",
             "BXD300"
          ],
@@ -5007,6 +5025,12 @@
                "Phenotypes"
             ]
          ],
+         "BXD-Harvested": [
+            [
+               "Liver mRNA",
+               "Liver mRNA"
+            ]
+         ],
          "BXD300": [
             [
                "Phenotypes",
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 2f1d836a..4d98f5d8 100644
--- a/wqflask/wqflask/static/new/javascript/show_trait_mapping_tools.js
+++ b/wqflask/wqflask/static/new/javascript/show_trait_mapping_tools.js
@@ -245,6 +245,7 @@
       //$("#static_progress_bar_container").modal();
       url = "/loading";
       $('input[name=method]').val("gemma_bimbam");
+      $('input[name=num_perm]').val(0);
       $('input[name=genofile]').val($('#genofile_gemma').val());
       $('input[name=maf]').val($('input[name=maf_gemma]').val());
       form_data = $('#trait_data_form').serialize();
diff --git a/wqflask/wqflask/templates/loading.html b/wqflask/wqflask/templates/loading.html
index cede0e86..46136ddb 100644
--- a/wqflask/wqflask/templates/loading.html
+++ b/wqflask/wqflask/templates/loading.html
@@ -1,20 +1,20 @@
 <title>Loading Mapping Results</title>
 <link REL="stylesheet" TYPE="text/css" href="/static/packages/bootstrap/css/bootstrap.css" />
-<link REL="stylesheet" TYPE="text/css" href="/static/packages/bootstrap/css/non-responsive.css" />
-<link REL="stylesheet" TYPE="text/css" href="/static/packages/bootstrap/css/docs.css" />
-<link rel="stylesheet" type="text/css" href="/static/packages/colorbox/example4/colorbox.css"  />
-<link rel="stylesheet" type="text/css" href="/static/new/css/main.css"  />
 <form method="post" action="/marker_regression" name="loading_form" id="loading_form" class="form-horizontal">
   {% for key, value in start_vars.iteritems() %}
   <input type="hidden" name="{{ key }}" value="{{ value }}">
   {% endfor %}
   <div class="container">
-    <div class="row">
-      <div style="margin-left: 46%; margin-right: 50%; min-height: 100vh; display: flex; align-items: center;">
-        <h1>Loading&nbsp;Mapping&nbsp;Results...</h1>
+    <div>
+      <div style="min-height: 80vh; display: flex; align-items: center;">
+        <div class="center-block" style="margin-left: 38%; margin-right: 38%; position: absolute; height:50px; width:24%; top:40%;">
+          <h1>Loading&nbsp;Mapping&nbsp;Results...</h1>
+        </div>
       </div>
-      <div class="progress center-block" style="margin-left: 25%; margin-right: 25%; position: absolute; height:50px; width:50%; top:50%;">
-        <div class="progress-bar progress-bar-striped active" role="progressbar" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100" style="width:100%;"></div>
+      <div style="min-height: 80vh; display: flex; align-items: center;">
+        <div class="progress center-block" style="margin-left: 25%; margin-right: 25%; position: absolute; height:50px; width:50%; top:50%;">
+          <div class="progress-bar progress-bar-striped active" role="progressbar" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100" style="width:100%;"></div>
+        </div>
       </div>
     </div>
   </div>
diff --git a/wqflask/wqflask/templates/marker_regression_gn1.html b/wqflask/wqflask/templates/marker_regression_gn1.html
index d13c68cd..08a934a6 100644
--- a/wqflask/wqflask/templates/marker_regression_gn1.html
+++ b/wqflask/wqflask/templates/marker_regression_gn1.html
@@ -15,6 +15,7 @@
         <input type="hidden" name="trait_id" value="{{ this_trait.name }}">
         <input type="hidden" name="dataset" value="{{ dataset.name }}">
         <input type="hidden" name="genofile" value="{{ genofile_string }}">
+        <input type="hidden" name="geno_db_exists" value="{{ geno_db_exists }}">
         <input type="hidden" name="results_path" value="{{ mapping_results_path }}">
         <input type="hidden" name="method" value="{{ mapping_method }}">
         {% for sample in samples %}
@@ -154,7 +155,7 @@
             <div class="tab-pane active" id="gn1_map">
               <div class="qtlcharts">
                   {{ gifmap|safe }}
-                  <img src="/generated/{{ filename }}.jpeg" usemap="#WebQTLImageMap">
+                  <img src="/generated/{{ filename }}.png" usemap="#WebQTLImageMap">
                   {% if additiveChecked|upper == "ON" %}
                   <br>
                   <span style="white-space: nowrap;">A positive additive coefficient (green line) indicates that {{ dataset.group.parlist[1] }} alleles increase trait values. In contrast, a negative additive coefficient (orange line) indicates that {{ dataset.group.parlist[0] }} alleles increase trait values.</span>
@@ -180,10 +181,10 @@
 
         </form>
         {% if selectedChr == -1 %}
-        <div style="width:{% if 'additive' in trimmed_markers[0] %}45%{% else %}35%{% endif %};">
-          <h2>Results</h2>
-          <div id="table_container">
-          <table id="qtl_results" class="table table-hover table-striped nowrap">
+        <div class="container" style="padding-left: 30px; width:{% if 'additive' in trimmed_markers[0] %}45%{% else %}35%{% endif %};">
+          <h2>Mapping Statistics</h2>
+          <div id="table_container" style="border-style: solid; border-width: 1px; border-color: black;">
+          <table id="trait_table" class="table table-hover table-striped nowrap">
             <thead>
               <tr>
                 <th></th>
@@ -194,7 +195,7 @@
                 {% if plotScale != "physic" %}
                 <th>cM</th>
                 {% else %}
-                <th>Mb</th>
+                <th align="right">Mb</th>
                 {% endif %}
                 {% if 'additive' in trimmed_markers[0] %}
                 <th>Add Eff</th>
@@ -209,11 +210,11 @@
               <tr>
                 <td align="center" style="padding-right: 0px;">
                   <input type="checkbox" name="selectCheck"
-                         class="checkbox edit_sample_checkbox"
-                         value="{{ marker.name }}" checked="checked">
+                         class="checkbox trait_checkbox"
+                         value="{{ marker.name }}">
                 </td>
                 <td align="right">{{ loop.index }}</td>
-                <td>{{ marker.name }}</td>
+                <td>{% if geno_db_exists == "True" %}<a href="/show_trait?trait_id={{ marker.name }}&dataset={{ dataset.group.name }}Geno">{{ marker.name }}</a>{% else %}{{ marker.name }}{% endif %}</td>
                 {% if LRS_LOD == "LOD" or LRS_LOD == "-log(p)" %}
                 {% if 'lod_score' in marker %}
                 <td align="right">{{ '%0.2f' | format(marker.lod_score|float) }}</td>
@@ -294,6 +295,7 @@
     </script>
     {% endif %}
 
+    <script language="javascript" type="text/javascript" src="/static/new/javascript/search_results.js"></script>
     {% if mapping_method != "gemma" and mapping_method != "plink" %}
     <script language="javascript" type="text/javascript" src="/static/new/javascript/panelutil.js"></script>
     <script language="javascript" type="text/javascript" src="/static/new/javascript/chr_lod_chart.js"></script> 
@@ -304,7 +306,7 @@
     <script type="text/javascript" charset="utf-8">
         $(document).ready( function () {
             console.time("Creating table");
-            $('#qtl_results').DataTable( {
+            $('#trait_table').DataTable( {
                 {% if mapping_method != "reaper" %}
                 "columns": [
                     { "type": "natural", "width": "5%" },
diff --git a/wqflask/wqflask/templates/show_trait.html b/wqflask/wqflask/templates/show_trait.html
index a291baf3..dd4325e7 100644
--- a/wqflask/wqflask/templates/show_trait.html
+++ b/wqflask/wqflask/templates/show_trait.html
@@ -28,7 +28,9 @@
 -->
     <div class="container">
         <h2>Trait Data and Analysis for <b>{{ this_trait.name }}</b></h2>
+        {% if this_trait.dataset.type != 'Publish' %}
         <h3>{{ this_trait.description_fmt }}</h3>
+        {% endif %}
     </div>
 
     <form method="post" action="/corr_compute" target="_blank" name="trait_page" id="trait_data_form"
diff --git a/wqflask/wqflask/templates/show_trait_details.html b/wqflask/wqflask/templates/show_trait_details.html
index 2a62733e..1e6d41c2 100644
--- a/wqflask/wqflask/templates/show_trait_details.html
+++ b/wqflask/wqflask/templates/show_trait_details.html
@@ -8,6 +8,22 @@
         <td>Tissue</td>
         <td>{{ this_trait.dataset.tissue }}</td>
     </tr>
+    <tr>
+        <td>Phenotype</td>
+        <td><div style="width:40%;">{{ this_trait.description_fmt }}</div></td>
+    </tr>
+    <tr>
+        <td>Authors</td>
+        <td><div style="width:40%;">{{ this_trait.authors }}</div></td>
+    </tr>
+    <tr>
+        <td>Title</td>
+        <td><div style="width:40%;">{{ this_trait.title }}</div></td>
+    </tr>
+    <tr>
+        <td>Journal</td>
+        <td>{{ this_trait.journal }} (<a href="http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=PubMed&list_uids={{ this_trait.pubmed_id }}&dop=Abstract" title="PubMed">{{ this_trait.year }}</a>)</td>
+    </tr>
     {% endif %}
     {% if this_trait.dataset.type == 'ProbeSet' %}
     {% if this_trait.symbol != None %}
@@ -50,22 +66,29 @@
         </td>
     </tr>
     {% endif %}
+    {% if this_trait.pubmed_id or this_trait.geneid or this_trait.omim or this_trait.symbol %}
+    {% if this_trait.dataset.type != 'Publish' %}
     <tr>
         <td>Resource Links</td>
         <td>
-            {% if this_trait.geneid != None %}
+            {% if this_trait.pubmed_id %}
+            <a href="http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=PubMed&list_uids={{ this_trait.pubmed_id }}&dop=Abstract" title="PubMed">
+                PubMed
+            </a>
+            {% endif %}
+            {% if this_trait.geneid %}
             <a href="http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?db=gene&cmd=Retrieve&dopt=Graphics&list_uids={{ this_trait.geneid }}" title="Info from NCBI Entrez Gene">
                 NCBI
             </a>
             &nbsp;&nbsp;
             {% endif %}
-            {% if this_trait.omim != None %}
+            {% if this_trait.omim %}
             <a href="http://www.ncbi.nlm.nih.gov/omim/{{ this_trait.omim }}" title="Summary from On Mendelion Inheritance in Man">
                 OMIM
             </a>
             &nbsp;&nbsp;
             {% endif %}
-            {% if this_trait.symbol != None %}
+            {% if this_trait.symbol %}
             <a href="http://www.genotation.org/Getd2g.pl?gene_list={{ this_trait.symbol }}" title="Related descriptive, genomic, clinical, functional and drug-therapy information">
                 Genotation
             </a>
@@ -77,6 +100,8 @@
         {% endif %}
         </td>
     </tr>
+    {% endif %}
+    {% endif %}
 </table>
 
 <div style="margin-bottom:15px;" class="btn-toolbar">
diff --git a/wqflask/wqflask/templates/show_trait_mapping_tools.html b/wqflask/wqflask/templates/show_trait_mapping_tools.html
index 77f78415..dcec2b9e 100644
--- a/wqflask/wqflask/templates/show_trait_mapping_tools.html
+++ b/wqflask/wqflask/templates/show_trait_mapping_tools.html
@@ -6,16 +6,16 @@
             <ul class="nav nav-pills">
                 {% if dataset.group.mapping_id == "1" %}
                 <li class="active">
-                    <a href="#interval_mapping" data-toggle="tab">Interval Mapping</a>
+                    <a href="#gemma" data-toggle="tab">GEMMA</a>
                 </li>
                 <li>
-                    <a href="#pylmm" data-toggle="tab">pyLMM</a>
+                    <a href="#interval_mapping" data-toggle="tab">Interval Mapping</a>
                 </li>
                 <li>
                     <a href="#rqtl_geno" data-toggle="tab">R/qtl</a>
                 </li>
                 <li>
-                    <a href="#gemma" data-toggle="tab">GEMMA</a>
+                    <a href="#pylmm" data-toggle="tab">pyLMM</a>
                 </li>
                 {% endif %}
                 {% for mapping_method in dataset.group.mapping_names %}
@@ -37,7 +37,60 @@
             <div class="tab-content">
                 {# if use_pylmm_rqtl and not use_plink_gemma and dataset.group.species != "human" #}
                 {% if dataset.group.mapping_id == "1" %}
-                <div class="tab-pane active" id="interval_mapping">
+                <div class="tab-pane active" id="gemma">
+                    <div style="padding-top: 10px;" class="form-horizontal">
+                        {% if genofiles and genofiles|length>0 %}
+                        <div class="mapping_method_fields form-group">
+                            <label for="genofiles" class="col-xs-3 control-label">Genotypes</label>
+                            <div style="margin-left: 20px;" class="col-xs-8 controls">
+                                <select id="genofile_gemma" class="form-control">
+                                    {% for item in genofiles %}
+                                    <option value="{{item['location']}}:{{item['title']}}">{{item['title']}}</option>
+                                    {% endfor %}
+                                </select>
+                            </div>
+                        </div>
+                        {% endif %}
+                        <div class="mapping_method_fields form-group">
+                            <label for="maf_gemma" class="col-xs-5 control-label">Minor allele threshold</label>
+                            <div style="margin-left: 20px;" class="col-xs-3 controls">
+                                <input name="maf_gemma" value="0.01" type="text" class="form-control">
+                            </div>
+                        </div>
+                        <div class="mapping_method_fields form-group">
+                            <label class="col-xs-4 control-label">Use LOCO</label>
+                            <div style="margin-left: 20px;" class="col-xs-4 controls">
+                                <label class="radio-inline">
+                                    <input type="radio" name="use_loco" value="True">
+                                    Yes
+                                </label>
+                                <label class="radio-inline">
+                                    <input type="radio" name="use_loco" value="False" checked="">
+                                    No
+                               </label>
+                            </div>
+                        </div>
+                    </div>
+                    <div style="padding-top: 5px; padding-bottom: 5px; padding-left: 20px;" class="form-horizontal">
+                        <div class="mapping_method_fields form-group">
+                            <button type="button" id="select_covariates" class="btn btn-default">
+                                Select Covariates
+                            </button>
+                            <button type="button" id="remove_covariates" class="btn btn-default">
+                                Remove Covariates
+                            </button>
+                        </div>
+                    </div>
+
+                    <div class="form-group">
+                        <div class="col-xs-4 controls">
+                            <button id="gemma_bimbam_compute" class="btn submit_special btn-success" data-url="/marker_regression" title="Compute Marker Regression">
+                                Compute
+                            </button>
+                        </div>
+                    </div>
+                </div>
+                <div class="tab-pane" id="interval_mapping">
                     <div style="margin-top: 20px" class="form-horizontal">
                         {% if genofiles and genofiles|length>0 %}
                         <div class="mapping_method_fields form-group">
@@ -131,62 +184,6 @@
                         <!--<div id="alert_placeholder"></div>-->
                     </div>
                 </div>
-                <div class="tab-pane" id="pylmm">
-                    <div style="margin-top: 20px" class="form-horizontal">
-                        {% if genofiles and genofiles|length>0 %}
-                        <div class="mapping_method_fields form-group">
-                            <label for="genofiles" class="col-xs-3 control-label">Genotypes</label>
-                            <div style="margin-left: 20px;" class="col-xs-8 controls">
-                                <select id="genofile_pylmm" class="form-control">
-                                    {% for item in genofiles %}
-                                    <option value="{{item['location']}}:{{item['title']}}">{{item['title']}}</option>
-                                    {% endfor %}
-                                </select>
-                            </div>
-                        </div>
-                        {% endif %}
-<!--
-                        <div class="mapping_method_fields form-group">
-                            <label for="control_for" class="col-xs-3 control-label">Control&nbsp;for</label>
-                            <div style="margin-left: 20px;" class="col-xs-4 controls">
-                                {% if dataset.type == 'ProbeSet' and this_trait.locus_chr != "" %}
-                                <input name="control_pylmm" value="{{ nearest_marker }}" type="text" />
-                                {% else %}
-                                <input name="control_pylmm" value="" type="text" />
-                                {% endif %}
-                                <label class="radio-inline">
-                                    <input type="radio" name="do_control_pylmm" value="true">
-                                    Yes
-                                </label>
-                                <label class="radio-inline">
-                                    <input type="radio" name="do_control_pylmm" value="false" checked="">
-                                    No
-                                </label>
-                            </div>
-                        </div>
-                        <div class="mapping_method_fields form-group">
-                            <label style="text-align:left;" class="col-xs-12 control-label">Manhattan Plot</label>
-                            <div class="col-xs-12 controls">
-                                <label class="radio-inline">
-                                    <input type="radio" name="manhattan_plot_pylmm" value="True">
-                                    Yes
-                                </label>
-                                <label class="radio-inline">
-                                    <input type="radio" name="manhattan_plot_pylmm" value="False" checked="">
-                                    No
-                               </label>
-                            </div>
-                        </div>
--->
-                        <div class="form-group">
-                            <div style="padding-left:15px;" class="controls">
-                                <button id="pylmm_compute" class="btn submit_special btn-success" title="Compute Marker Regression">
-                                    <i class="icon-ok-circle icon-white"></i> Compute
-                                </button>
-                            </div>
-                        </div>
-                    </div>
-                </div>
                 <div class="tab-pane" id="rqtl_geno">
 
                     <div style="margin-top: 20px" class="form-horizontal">
@@ -294,13 +291,13 @@
                         </div>
                     </div>
                 </div>
-                <div class="tab-pane" id="gemma">
-                    <div style="padding-top: 10px;" class="form-horizontal">
+                <div class="tab-pane" id="pylmm">
+                    <div style="margin-top: 20px" class="form-horizontal">
                         {% if genofiles and genofiles|length>0 %}
                         <div class="mapping_method_fields form-group">
                             <label for="genofiles" class="col-xs-3 control-label">Genotypes</label>
                             <div style="margin-left: 20px;" class="col-xs-8 controls">
-                                <select id="genofile_gemma" class="form-control">
+                                <select id="genofile_pylmm" class="form-control">
                                     {% for item in genofiles %}
                                     <option value="{{item['location']}}:{{item['title']}}">{{item['title']}}</option>
                                     {% endfor %}
@@ -308,42 +305,45 @@
                             </div>
                         </div>
                         {% endif %}
+<!--
                         <div class="mapping_method_fields form-group">
-                            <label for="maf_gemma" class="col-xs-5 control-label">Minor allele threshold</label>
-                            <div style="margin-left: 20px;" class="col-xs-3 controls">
-                                <input name="maf_gemma" value="0.01" type="text" class="form-control">
+                            <label for="control_for" class="col-xs-3 control-label">Control&nbsp;for</label>
+                            <div style="margin-left: 20px;" class="col-xs-4 controls">
+                                {% if dataset.type == 'ProbeSet' and this_trait.locus_chr != "" %}
+                                <input name="control_pylmm" value="{{ nearest_marker }}" type="text" />
+                                {% else %}
+                                <input name="control_pylmm" value="" type="text" />
+                                {% endif %}
+                                <label class="radio-inline">
+                                    <input type="radio" name="do_control_pylmm" value="true">
+                                    Yes
+                                </label>
+                                <label class="radio-inline">
+                                    <input type="radio" name="do_control_pylmm" value="false" checked="">
+                                    No
+                                </label>
                             </div>
                         </div>
                         <div class="mapping_method_fields form-group">
-                            <label class="col-xs-4 control-label">Use LOCO</label>
-                            <div style="margin-left: 20px;" class="col-xs-4 controls">
+                            <label style="text-align:left;" class="col-xs-12 control-label">Manhattan Plot</label>
+                            <div class="col-xs-12 controls">
                                 <label class="radio-inline">
-                                    <input type="radio" name="use_loco" value="True">
+                                    <input type="radio" name="manhattan_plot_pylmm" value="True">
                                     Yes
                                 </label>
                                 <label class="radio-inline">
-                                    <input type="radio" name="use_loco" value="False" checked="">
+                                    <input type="radio" name="manhattan_plot_pylmm" value="False" checked="">
                                     No
                                </label>
                             </div>
                         </div>
-                    </div>
-                    <div style="padding-top: 5px; padding-bottom: 5px; padding-left: 20px;" class="form-horizontal">
-                        <div class="mapping_method_fields form-group">
-                            <button type="button" id="select_covariates" class="btn btn-default">
-                                Select Covariates
-                            </button>
-                            <button type="button" id="remove_covariates" class="btn btn-default">
-                                Remove Covariates
-                            </button>
-                        </div>
-                    </div>
-
-                    <div class="form-group">
-                        <div class="col-xs-4 controls">
-                            <button id="gemma_bimbam_compute" class="btn submit_special btn-success" data-url="/marker_regression" title="Compute Marker Regression">
-                                Compute
-                            </button>
+-->
+                        <div class="form-group">
+                            <div style="padding-left:15px;" class="controls">
+                                <button id="pylmm_compute" class="btn submit_special btn-success" title="Compute Marker Regression">
+                                    <i class="icon-ok-circle icon-white"></i> Compute
+                                </button>
+                            </div>
                         </div>
                     </div>
                 </div>
diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py
index 68e779a1..4e81c29c 100644
--- a/wqflask/wqflask/views.py
+++ b/wqflask/wqflask/views.py
@@ -557,6 +557,7 @@ def marker_regression_page():
     wanted = (
         'trait_id',
         'dataset',
+        'geno_db_exists',
         'method',
         'mapping_results_path',
         'trimmed_markers',
@@ -765,7 +766,7 @@ def corr_scatter_plot_page():
 def submit_bnw():
     logger.error(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'})
 
 # Todo: Can we simplify this? -Sam
 def sharing_info_page():
diff --git a/wqflask/wsgi.py b/wqflask/wsgi.py
new file mode 100644
index 00000000..be9c7b37
--- /dev/null
+++ b/wqflask/wsgi.py
@@ -0,0 +1,4 @@
+from run_gunicorn import app as application # expect application as a name
+
+if __name__ == "__main__":
+    application.run()