about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--misc/notes.txt2
-rw-r--r--wqflask/wqflask/do_search.py140
-rw-r--r--wqflask/wqflask/search_results.py306
-rw-r--r--wqflask/wqflask/templates/base.html13
-rw-r--r--wqflask/wqflask/templates/index_page.html8
-rw-r--r--wqflask/wqflask/templates/search_result_page.html27
-rw-r--r--wqflask/wqflask/templates/show_trait.html32
7 files changed, 281 insertions, 247 deletions
diff --git a/misc/notes.txt b/misc/notes.txt
index e7b94087..b3678a04 100644
--- a/misc/notes.txt
+++ b/misc/notes.txt
@@ -41,7 +41,7 @@ Go to /tmp and tail -f flask_gn_log
 Coffeescript Stuff:
 
 coffee -c (filename)
-coffee -c -w (to watch for changes and recompile)
+coffee -c -w . (to watch for changes and recompile in current directory; the "." is for current directory)
 coffee --help (for information about setting options)
 
 ===========================================
diff --git a/wqflask/wqflask/do_search.py b/wqflask/wqflask/do_search.py
index cfa73334..19c6fa74 100644
--- a/wqflask/wqflask/do_search.py
+++ b/wqflask/wqflask/do_search.py
@@ -7,31 +7,35 @@ from pprint import pformat as pf
 
 
 class DoSearch(object):
+    """Parent class containing parameters/functions used for all searches"""
+    
     def __init__(self, search_term, dataset, cursor, db_conn):
         self.search_term = search_term
         self.dataset = dataset
         self.db_conn = db_conn
         self.cursor = cursor
-        
+
     def execute(self, query):
+        """Executes query and returns results"""
         query = self.normalize_spaces(query)
-        print("query is:", pf(query))
+        print("in do_search query is:", pf(query))
         self.cursor.execute(query)
         results = self.cursor.fetchall()
         return results
-    
+
     def escape(self, stringy):
         """Shorter name than self.db_conn.escape_string"""
         return self.db_conn.escape_string(str(stringy))
-    
+
     def normalize_spaces(self, stringy):
-        """Strips out newlines  extra spaces and replaces them with just spaces"""
+        """Strips out newlines extra spaces and replaces them with just spaces"""
         step_one = " ".join(stringy.split())
         return step_one
 
-        
-        
+
 class ProbeSetSearch(DoSearch):
+    """A search within an mRNA expression dataset"""
+    
     base_query = """SELECT ProbeSet.Name as TNAME,
                 0 as thistable,
                 ProbeSetXRef.Mean as TMEAN,
@@ -42,9 +46,11 @@ class ProbeSetSearch(DoSearch):
                 ProbeSet.Symbol as TSYMBOL,
                 ProbeSet.name_num as TNAME_NUM
                 FROM ProbeSetXRef, ProbeSet """
-    
+
     def run(self):
+        """Generates and runs a simple search of an mRNA expression dataset"""
         
+        print("Running ProbeSetSearch")
         query = (self.base_query +
                 """WHERE (MATCH (ProbeSet.Name,
                     ProbeSet.description,
@@ -57,18 +63,22 @@ class ProbeSetSearch(DoSearch):
                     and ProbeSet.Id = ProbeSetXRef.ProbeSetId
                     and ProbeSetXRef.ProbeSetFreezeId = %s  
                             """ % (self.escape(self.search_term),
-                            self.escape(dataset.id)))
-        
+                            self.escape(self.dataset.id)))
+
+        print("final query is:", pf(query))
+
         return self.execute(query)
 
 
 class PhenotypeSearch(DoSearch):
+    """A search within a phenotype dataset"""
+    
     base_query = """SELECT PublishXRef.Id,
                 PublishFreeze.createtime as thistable,
                 Publication.PubMed_ID as Publication_PubMed_ID,
                 Phenotype.Post_publication_description as Phenotype_Name
                 FROM Phenotype, PublishFreeze, Publication, PublishXRef """
-                
+
     search_fields = ('Phenotype.Post_publication_description',
                     'Phenotype.Pre_publication_description',
                     'Phenotype.Pre_publication_abbreviation',
@@ -78,65 +88,108 @@ class PhenotypeSearch(DoSearch):
                     'Publication.Abstract',
                     'Publication.Title',
                     'Publication.Authors',
-                    'PublishXRef.Id')           
-                
-    def run(self):
+                    'PublishXRef.Id')
+    
+    def get_where_clause(self):
+        """Generate clause for WHERE portion of query"""
+
         #Todo: Zach will figure out exactly what both these lines mean
         #and comment here
         if "'" not in self.search_term:
             search_term = "[[:<:]]" + self.search_term + "[[:>:]]"
 
+        # This adds a clause to the query that matches the search term
+        # against each field in the search_fields tuple
         where_clause = []
         for field in self.search_fields:
             where_clause.append('''%s REGEXP "%s"''' % (field, search_term))
-            
         where_clause = "(%s)" % ' OR '.join(where_clause)
         
+        return where_clause
+
+    def run(self):
+        """Generates and runs a simple search of a phenotype dataset"""
+
         #Get group information for dataset
         self.dataset.get_group()
-        
-        print("before query where clause is:", where_clause)
-        
+
         query = (self.base_query +
                 """WHERE %s and
                     PublishXRef.InbredSetId = %s and
                     PublishXRef.PhenotypeId = Phenotype.Id and
                     PublishXRef.PublicationId = Publication.Id and
                     PublishFreeze.Id = %s""" % (
-                        where_clause,
+                        self.get_where_clause(),
                         self.escape(self.dataset.group_id),
                         self.escape(self.dataset.id)))
 
+        return self.execute(query)
 
 
+class GenotypeSearch(DoSearch):
+    """A search within a genotype dataset"""
+
+    base_query = """SELECT Geno.Name,
+                GenoFreeze.createtime as thistable,
+                Geno.Name as Geno_Name,
+                Geno.Source2 as Geno_Source2,
+                Geno.chr_num as Geno_chr_num,
+                Geno.Mb as Geno_Mb
+                FROM GenoXRef, GenoFreeze, Geno """
+
+    search_fields = ('Name', 'Chr')
+
+    def get_where_clause(self):
+        """Generate clause for WHERE portion of query"""
+
+        # This adds a clause to the query that matches the search term
+        # against each field in search_fields (above)
+        where_clause = []
+        for field in self.search_fields:
+            where_clause.append('''%s REGEXP "%s"''' % ("%s.%s" % (self.dataset.type, field),
+                                                                self.search_term))
+        where_clause = "(%s)" % ' OR '.join(where_clause)
+
+        return where_clause
+
+    def run(self):
+        """Generates and runs a simple search of a genotype dataset"""
+        #Todo: Zach will figure out exactly what both these lines mean
+        #and comment here
+        if "'" not in self.search_term:
+            search_term = "[[:<:]]" + self.search_term + "[[:>:]]"
+
+        query = (self.base_query +
+                """WHERE %s and
+                    Geno.Id = GenoXRef.GenoId and
+                    GenoXRef.GenoFreezeId = GenoFreeze.Id and
+                    GenoFreeze.Id = %s"""% (
+                        self.get_where_clause(),
+                        self.escape(self.dataset.id)))
+
         return self.execute(query)
 
-       
-class GenotypeSearch(DoSearch):
-    def __init__(self):
-       pass
-    
 class GoSearch(ProbeSetSearch):
-    """searches for synapse-associated genes listed in the Gene Ontology."""
-    
+    """Searches for synapse-associated genes listed in the Gene Ontology."""
+
     def run(self):
         field = 'GOterm.acc'
         go_id = 'GO:' + ('0000000'+self.search_term)[-7:]
-        
+
         statements = ("""%s.symbol=GOgene_product.symbol and
            GOassociation.gene_product_id=GOgene_product.id and
            GOterm.id=GOassociation.term_id""" % (
             self.db_conn.escape_string(self.dataset.type)))
-            
+
         clause_item = " %s = '%s' and %s " % (field, go_id, statements)
-        
+
+        # 
         gene_ontology_from_table = """ , db_GeneOntology.term as GOterm,
             db_GeneOntology.association as GOassociation,
             db_GeneOntology.gene_product as GOgene_product """
-        
+
         gene_ontology_from_table = self.normalize_spaces(gene_ontology_from_table)
-        #gene_ontology_from_table = " ".join(gene_ontology_from_table.splitlines())
-        
+
         query = (self.base_query + 
             """%s
                 WHERE %s 
@@ -145,36 +198,37 @@ class GoSearch(ProbeSetSearch):
                             """ % (self.db_conn.escape_string(gene_ontology_from_table),
                                     clause_item,
                                     self.db_conn.escape_string(str(self.dataset.id))))
-        
+
         return self.execute(query)
-        
 
 
 if __name__ == "__main__":
-    
+    ### Usually this will be used as a library, but call it from the command line for testing
+    ### And it runs the code below
+
     import MySQLdb
     import sys
     sys.path.append("/home/zas1024/gene/wqflask")
     print("Path is:", sys.path)
-    
-    
+
+
     from base import webqtlConfig
     from base.webqtlDataset import webqtlDataset
     from base.templatePage import templatePage
     from utility import webqtlUtil
     from dbFunction import webqtlDatabaseFunction
-    
+
     db_conn = MySQLdb.Connect(db=webqtlConfig.DB_NAME,
                               host=webqtlConfig.MYSQL_SERVER,
                               user=webqtlConfig.DB_USER,
                               passwd=webqtlConfig.DB_PASSWD)
     cursor = db_conn.cursor()
-    
+
     dataset_name = "HC_M2_0606_P"
     dataset = webqtlDataset(dataset_name, cursor)
-    
-    #results = ProbeSetSearch("salt", dataset, cursor, db_conn).run()
+
+    results = ProbeSetSearch("salt", dataset, cursor, db_conn).run()
     #results = PhenotypeSearch("brain", dataset, cursor, db_conn).run()
-    
-    results = GoSearch("0045202", dataset, cursor, db_conn).run()
+    #results = GenotypeSearch("rs13475699", dataset, cursor, db_conn).run()
+    #results = GoSearch("0045202", dataset, cursor, db_conn).run()
     print("results are:", pf(results))
\ No newline at end of file
diff --git a/wqflask/wqflask/search_results.py b/wqflask/wqflask/search_results.py
index 02d2bef2..51204ddf 100644
--- a/wqflask/wqflask/search_results.py
+++ b/wqflask/wqflask/search_results.py
@@ -33,14 +33,12 @@ from base.webqtlDataset import webqtlDataset
 from base.webqtlTrait import webqtlTrait
 from base.templatePage import templatePage
 from wqflask import parser
+from wqflask import do_search
 from utility import webqtlUtil
 from dbFunction import webqtlDatabaseFunction
 
 from utility import formatting
 
-import sys
-
-
 #from base.JinjaPage import JinjaEnv, JinjaPage
 
 
@@ -194,7 +192,7 @@ class SearchResultPage(templatePage):
             self.search_fields = ['Name','Chr']
 
 
-        self.do_search()
+        self.search()
         self.gen_search_result()
 
         ###########################################
@@ -635,167 +633,167 @@ class SearchResultPage(templatePage):
             return 0
 
 
-    def do_search(self):
+    def search(self):
         print("fd.search_terms:", self.fd['search_terms'])
         self.search_terms = parser.parse(self.fd['search_terms'])
         print("After parsing:", self.search_terms)
-        
-        
-        #print("ORkeyword is:", pf(self.ORkeyword))
-        #self.ANDkeyword2 = parser.parse(self.ANDkeyword)
-        #self.ORkeyword2 = parser.parse(self.ORkeyword)
-        #print("ORkeyword2 is:", pf(parser.parse(self.ORkeyword)))
-
-        #self.ANDkeyword2 = re.sub(self._1mPattern, '', self.ANDkeyword)
-        #self.ANDkeyword2 = re.sub(self._2mPattern, '', self.ANDkeyword2)
-        #self.ANDkeyword2 = re.sub(self._3mPattern, '', self.ANDkeyword2)
-        #self.ANDkeyword2 = re.sub(self._5mPattern, '', self.ANDkeyword2)
-        ###remove remain parethesis, could be input with  syntax error
-        #self.ANDkeyword2 = re.sub(re.compile('\s*\([\s\S]*\)'), '', self.ANDkeyword2)
-        #self.ANDkeyword2 = self.encregexp(self.ANDkeyword2)
-
-        #self.ORkeyword2 = re.sub(self._1mPattern, '', self.ORkeyword)
-        #self.ORkeyword2 = re.sub(self._2mPattern, '', self.ORkeyword2)
-        #self.ORkeyword2 = re.sub(self._3mPattern, '', self.ORkeyword2)
-        #self.ORkeyword2 = re.sub(self._5mPattern, '', self.ORkeyword2)
-        ###remove remain parethesis, could be input with  syntax error
-        #self.ORkeyword2 = re.sub(re.compile('\s*\([\s\S]*\)'), '', self.ORkeyword2)
-        #self.ORkeyword2 = self.encregexp(self.ORkeyword2)
                 
         self.results = []
-        for item in self.search_terms:
-            search_term = item['search_term']
-        #    self.nkeywords += 1
-        #    #ZS: If there are both AND and OR keywords, just use the OR keywords
-        #    if k >=len(self.ORkeyword2):
-        #        query = self.ANDQuery
-        #        DescriptionText = self.ANDDescriptionText
-        #        clausejoin = ' OR '
-        #        fulltext = ANDFulltext
-        #    else:
-        #        query = self.ORQuery
-        #        DescriptionText = self.ORDescriptionText
-        #        clausejoin = ' OR '
-        #        fulltext = ORFulltext
-
-            print("item is:", pf(search_term))
-            
-            
-#            clause_item = (
-#""" MATCH (ProbeSet.Name,
+        for a_search in self.search_terms:
+            print("[kodak] item is:", pf(a_search))
+            search_term = None
+            search_type = None
+            if "search_term" in a_search:
+                search_term = a_search['search_term']
+            elif key in a_search:
+                search_type = a_search['key']
+                
+                
+            if search_term:
+                if self.dataset.type == "ProbeSet":
+                    search_ob = "ProbeSetSearch"
+                elif self.dataset.type == "Publish":
+                    search_ob = "PhenotypeSearch"
+                elif self.dataset.type == "Geno":
+                    search_ob = "GenotypeSearch"
+                else:
+                    SearchTermNeedsToBeDefined # Cause an error on purpose
+                search_class = getattr(do_search, search_ob)
+                results = search_class(search_term,
+                                        self.dataset,
+                                        self.cursor,
+                                        self.db_conn).run()
+                
+            print("in the search results are:", results)
+#            
+#            
+##            clause_item = (
+##""" MATCH (ProbeSet.Name,
+##        ProbeSet.description,
+##        ProbeSet.symbol,
+##        alias,
+##        GenbankId,
+##        UniGeneId,
+##        Probe_Target_Description)
+##        AGAINST ('%s' IN BOOLEAN MODE) """ % self.db_conn.escape_string(search_term))
+#            if self.dataset.type == "ProbeSet":
+#                
+#                query = (
+#"""SELECT distinct 0,
+#    ProbeSet.Name as TNAME,
+#    0 as thistable,
+#    ProbeSetXRef.Mean as TMEAN,
+#    ProbeSetXRef.LRS as TLRS,
+#    ProbeSetXRef.PVALUE as TPVALUE,
+#    ProbeSet.Chr_num as TCHR_NUM,
+#    ProbeSet.Mb as TMB,
+#    ProbeSet.Symbol as TSYMBOL,
+#    ProbeSet.name_num as TNAME_NUM
+#    FROM ProbeSetXRef, ProbeSet
+#    WHERE (MATCH (ProbeSet.Name,
 #        ProbeSet.description,
 #        ProbeSet.symbol,
 #        alias,
 #        GenbankId,
 #        UniGeneId,
 #        Probe_Target_Description)
-#        AGAINST ('%s' IN BOOLEAN MODE) """ % self.db_conn.escape_string(search_term))
-            if self.dataset.type == "ProbeSet":
-                
-                query = (
-"""SELECT distinct 0, ProbeSet.Name as TNAME, 0 as thistable,
-    ProbeSetXRef.Mean as TMEAN,
-    ProbeSetXRef.LRS as TLRS,
-    ProbeSetXRef.PVALUE as TPVALUE,
-    ProbeSet.Chr_num as TCHR_NUM,
-    ProbeSet.Mb as TMB,
-    ProbeSet.Symbol as TSYMBOL,
-    ProbeSet.name_num as TNAME_NUM
-    FROM ProbeSetXRef, ProbeSet
-    WHERE (MATCH (ProbeSet.Name,
-        ProbeSet.description,
-        ProbeSet.symbol,
-        alias,
-        GenbankId,
-        UniGeneId,
-        Probe_Target_Description)
-        AGAINST ('%s' IN BOOLEAN MODE)) 
-        and ProbeSet.Id = ProbeSetXRef.ProbeSetId
-        and ProbeSetXRef.ProbeSetFreezeId = %s  
-                """ % (self.db_conn.escape_string(search_term),
-                self.db_conn.escape_string(str(self.dataset.id))))
-                
-            elif self.dataset.type == "Publish":
-                include_geno = ""
-                if search_term.find("Geno.name") >= 0:
-                    include_geno = " Geno, "
-                    
-                query = (
-"""SELECT 0, PublishXRef.Id, PublishFreeze.createtime as thistable,
-    Publication.PubMed_ID as Publication_PubMed_ID,
-    Phenotype.Post_publication_description as Phenotype_Name
-    FROM %s PublishFreeze, Publication, PublishXRef, Phenotype
-    WHERE (MATCH (ProbeSet.Name,
-        ProbeSet.description,
-        ProbeSet.symbol,
-        alias,
-        GenbankId,
-        UniGeneId,
-        Probe_Target_Description)
-        AGAINST ('%s' IN BOOLEAN MODE)) and
-        PublishXRef.InbredSetId = %s and
-        PublishXRef.PhenotypeId = Phenotype.Id and
-        PublishXRef.PublicationId = Publication.Id and
-        PublishFreeze.Id = %s
-                """ % (include_geno,
-                       self.db_conn.escape_string(search_term),
-                       self.db_conn.escape_string(str(self.dataset.group_id)),
-                       self.db_conn.escape_string(str(self.dataset.id))))
-
-            elif self.dataset.type == "Geno":
-                query = (
-"""SELECT 0, Geno.Name, GenoFreeze.createtime as thistable,
-    Geno.Name as Geno_Name,
-    Geno.Source2 as Geno_Source2,
-    Geno.chr_num as Geno_chr_num,
-    Geno.Mb as Geno_Mb
-    FROM GenoXRef, GenoFreeze, Geno
-    WHERE (MATCH (ProbeSet.Name,
-        ProbeSet.description,
-        ProbeSet.symbol,
-        alias,
-        GenbankId,
-        UniGeneId,
-        Probe_Target_Description)
-        AGAINST ('%s' IN BOOLEAN MODE)) and
-        and Geno.Id = GenoXRef.GenoId and
-        GenoXRef.GenoFreezeId = GenoFreeze.Id and
-        GenoFreeze.Id = %d
-                """% (self.db_conn.escape_string(search_term),
-                      self.db_conn.escape_string(str(self.dataset.id))))
-
-
-            self.cursor.execute(query)
-            self.results.append(self.cursor.fetchall())
-
-            print("self.results is:", pf(self.results))
-
-
-
-
-            #if self.dataset.type == "ProbeSet" and search_term.find('.') < 0 and search_term.find('\'') < 0:
-            #    full_text.append(search_term)
-            #else:
-            #    if self.matchwhole and search_term.find("'") < 0:
-            #        search_term = "[[:<:]]"+ search_term+"[[:>:]]"
-            #    clause2 = []
-            #    for field in self.search_fields:
-            #        if self.dataset.type == "Publish":
-            #            clause2.append("%s REGEXP \"%s\"" % (field,search_term))
-            #        else:
-            #            clause2.append("%s REGEXP \"%s\"" % ("%s.%s" % (self.dataset.type,field),search_term))
-            #    clause_item = "(%s)" % string.join(clause2, clausejoin)
-            #    query.append(" (%s) " % clause_item)
-        #if ANDFulltext:
-        #    clauseItem = """ MATCH (ProbeSet.Name,ProbeSet.description,ProbeSet.symbol,
-        #    alias,GenbankId, UniGeneId, Probe_Target_Description)
-        #    AGAINST ('+%s' IN BOOLEAN MODE) """ % string.join(ANDFulltext, " +")
-        #    self.ANDQuery.append(" (%s) " % clauseItem)
-        #if ORFulltext:
-        #clauseItem = """ MATCH (ProbeSet.Name,ProbeSet.description,ProbeSet.symbol,alias,
-        #GenbankId, UniGeneId, Probe_Target_Description) AGAINST ('%s' IN BOOLEAN MODE)
-        #""" % string.join(full_text, " ")
-        #self.query.append(" (%s) " % clauseItem)
+#        AGAINST ('%s' IN BOOLEAN MODE)) 
+#        and ProbeSet.Id = ProbeSetXRef.ProbeSetId
+#        and ProbeSetXRef.ProbeSetFreezeId = %s  
+#                """ % (self.db_conn.escape_string(search_term),
+#                self.db_conn.escape_string(str(self.dataset.id))))
+#                
+#            elif self.dataset.type == "Publish":
+#                include_geno = ""
+#                if search_term.find("Geno.name") >= 0:
+#                    include_geno = " Geno, "
+#                    
+#                if self.matchwhole and item.find("'") < 0:
+#                    item = "[[:<:]]"+ item+"[[:>:]]"
+#                clause2 = []
+#                for field in self.searchField:
+#                    if self.dbType == "Publish":
+#                        clause2.append("%s REGEXP \"%s\"" % (field,item))
+#                    else:
+#                        clause2.append("%s REGEXP \"%s\"" % ("%s.%s" % (self.dbType,field),item))                    
+#                    
+#                    
+#                query = (
+#"""SELECT 0, PublishXRef.Id, PublishFreeze.createtime as thistable,
+#    Publication.PubMed_ID as Publication_PubMed_ID,
+#    Phenotype.Post_publication_description as Phenotype_Name
+#    FROM %s PublishFreeze, Publication, PublishXRef, Phenotype
+#    WHERE (MATCH (ProbeSet.Name,
+#        ProbeSet.description,
+#        ProbeSet.symbol,
+#        alias,
+#        GenbankId,
+#        UniGeneId,
+#        Probe_Target_Description)
+#        AGAINST ('%s' IN BOOLEAN MODE)) and
+#        PublishXRef.InbredSetId = %s and
+#        PublishXRef.PhenotypeId = Phenotype.Id and
+#        PublishXRef.PublicationId = Publication.Id and
+#        PublishFreeze.Id = %s
+#                """ % (include_geno,
+#                       self.db_conn.escape_string(search_term),
+#                       self.db_conn.escape_string(str(self.dataset.group_id)),
+#                       self.db_conn.escape_string(str(self.dataset.id))))
+#
+#            elif self.dataset.type == "Geno":
+#                query = (
+#"""SELECT 0, Geno.Name, GenoFreeze.createtime as thistable,
+#    Geno.Name as Geno_Name,
+#    Geno.Source2 as Geno_Source2,
+#    Geno.chr_num as Geno_chr_num,
+#    Geno.Mb as Geno_Mb
+#    FROM GenoXRef, GenoFreeze, Geno
+#    WHERE (MATCH (ProbeSet.Name,
+#        ProbeSet.description,
+#        ProbeSet.symbol,
+#        alias,
+#        GenbankId,
+#        UniGeneId,
+#        Probe_Target_Description)
+#        AGAINST ('%s' IN BOOLEAN MODE)) and
+#        and Geno.Id = GenoXRef.GenoId and
+#        GenoXRef.GenoFreezeId = GenoFreeze.Id and
+#        GenoFreeze.Id = %d
+#                """% (self.db_conn.escape_string(search_term),
+#                      self.db_conn.escape_string(str(self.dataset.id))))
+#
+#
+#            self.cursor.execute(query)
+#            self.results.append(self.cursor.fetchall())
+#
+#            print("self.results is:", pf(self.results))
+#
+#
+#
+#
+#            #if self.dataset.type == "ProbeSet" and search_term.find('.') < 0 and search_term.find('\'') < 0:
+#            #    full_text.append(search_term)
+#            #else:
+#            #    if self.matchwhole and search_term.find("'") < 0:
+#            #        search_term = "[[:<:]]"+ search_term+"[[:>:]]"
+#            #    clause2 = []
+#            #    for field in self.search_fields:
+#            #        if self.dataset.type == "Publish":
+#            #            clause2.append("%s REGEXP \"%s\"" % (field,search_term))
+#            #        else:
+#            #            clause2.append("%s REGEXP \"%s\"" % ("%s.%s" % (self.dataset.type,field),search_term))
+#            #    clause_item = "(%s)" % string.join(clause2, clausejoin)
+#            #    query.append(" (%s) " % clause_item)
+#        #if ANDFulltext:
+#        #    clauseItem = """ MATCH (ProbeSet.Name,ProbeSet.description,ProbeSet.symbol,
+#        #    alias,GenbankId, UniGeneId, Probe_Target_Description)
+#        #    AGAINST ('+%s' IN BOOLEAN MODE) """ % string.join(ANDFulltext, " +")
+#        #    self.ANDQuery.append(" (%s) " % clauseItem)
+#        #if ORFulltext:
+#        #clauseItem = """ MATCH (ProbeSet.Name,ProbeSet.description,ProbeSet.symbol,alias,
+#        #GenbankId, UniGeneId, Probe_Target_Description) AGAINST ('%s' IN BOOLEAN MODE)
+#        #""" % string.join(full_text, " ")
+#        #self.query.append(" (%s) " % clauseItem)
 
 
     def encregexp(self,str):
diff --git a/wqflask/wqflask/templates/base.html b/wqflask/wqflask/templates/base.html
index 385512e3..b54d3424 100644
--- a/wqflask/wqflask/templates/base.html
+++ b/wqflask/wqflask/templates/base.html
@@ -1,7 +1,7 @@
 <!DOCTYPE HTML>
 <html lang="en">
 <html xmlns="http://www.w3.org/1999/xhtml">
-    
+
 <head>
     <meta charset="utf-8">
     <title>GeneNetwork</title>
@@ -67,9 +67,9 @@
         </div>
       </div>
     </div>
-    
+
     {% block content %}{% endblock %}
-    
+
             <!-- Footer
     ================================================== -->
     <footer class="footer">
@@ -146,11 +146,10 @@
               }
             })
     </script>
-    <!--<SCRIPT SRC="/javascript/webqtl.js"></SCRIPT>-->
-    <!--<script src="/static/new/javascript/dataset_menu_structure.json"></script>-->
-    <!--<script src="/static/new/javascript/dataset_select_items.js"></script>-->
     <script src="/static/new/js_external/jquery.cookie.js"></script>
     <script type="text/javascript" src="/static/new/js_external/json2.js"></script>
-    <script src="/static/new/javascript/dataset_select_menu.js"></script>
+    <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.12/jquery-ui.min.js" type="text/javascript"></script>
+    {% block js %}
+    {% endblock %}
 </body>
 </html>
diff --git a/wqflask/wqflask/templates/index_page.html b/wqflask/wqflask/templates/index_page.html
index 2d7ba44c..a113bc15 100644
--- a/wqflask/wqflask/templates/index_page.html
+++ b/wqflask/wqflask/templates/index_page.html
@@ -1,6 +1,6 @@
 {% extends "base.html" %}
 {% block title %}GeneNetwork{% endblock %}
-{% block content %} 
+{% block content %}
 <!-- Start of body -->
 
 
@@ -275,4 +275,8 @@
         </div>
     </div>
 
-{%endblock%}
\ No newline at end of file
+{%endblock%}
+
+{% block js %}
+    <script src="/static/new/javascript/dataset_select_menu.js"></script>
+{% endblock %}
diff --git a/wqflask/wqflask/templates/search_result_page.html b/wqflask/wqflask/templates/search_result_page.html
index abf2dba7..65182e1f 100644
--- a/wqflask/wqflask/templates/search_result_page.html
+++ b/wqflask/wqflask/templates/search_result_page.html
@@ -15,9 +15,9 @@
         <div class="page-header">
             <h1>Your Search</h1>
         </div>
-        
+
         <p>We searched <a href="/dbdoc/{{dataset.fullname}}">{{ dataset.fullname }}</a><//>
-        
+
         <p>To find all records that match:</p>
         <ul>
             {% if search_terms %}
@@ -28,10 +28,10 @@
             </li>
             {% endif %}
         </ul>
-        
+
         <p>To study a record, click on its ID below.<br />
         Check records below and click Add button to add to selection.</p>
-        
+
         <div class="bs-docs-example">
             <table class="table table-hover">
                 <thead>
@@ -40,7 +40,7 @@
                         <th>{{header}}</th>
                     {% endfor %}
                 </thead>
-                
+
                 <tbody>
                     {% for this_trait in trait_list %}
                     <TR id="{{ this_trait }}">
@@ -56,12 +56,7 @@
                                 {{ this_trait.name.upper() }}
                             </a>
                         </TD>
-                        <TD>
-                            <A HREF=
-                                "http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?db=gene&cmd=Retrieve&dopt=Graphics&list_uids={{this_trait.geneid}}" TARGET="_blank">
-                                {{ this_trait.symbol }}
-                            </A>
-                        </TD>
+                        <TD>{{ this_trait.symbol }}</TD>
                         <TD>{{ this_trait.description_display }}</TD>
                         <TD>{{ this_trait.trait_location_repr }}</TD>
                         <TD>{{ this_trait.mean }}</TD>
@@ -70,20 +65,20 @@
                     </TR>
                 {% endfor %}
                 </tbody>
-                
+
             </table>
-            
+
             <br />
-            
+
             <button class="btn"><i class="icon-ok"></i> Select</button>
             <button class="btn"><i class="icon-remove"></i> Deselect</button>
             <button class="btn"><i class="icon-resize-vertical"></i> Invert</button>
             <button class="btn"><i class="icon-plus-sign"></i> Add</button>
             <button class="btn btn-primary pull-right"><i class="icon-download icon-white"></i> Download Table</button>
         </div>
-        
+
     </div>
-    
+
 <!-- End of body -->
 
 {% endblock %}
diff --git a/wqflask/wqflask/templates/show_trait.html b/wqflask/wqflask/templates/show_trait.html
index d7b81562..79f6e78e 100644
--- a/wqflask/wqflask/templates/show_trait.html
+++ b/wqflask/wqflask/templates/show_trait.html
@@ -106,14 +106,6 @@
                     <br>
                     <input type="button" name="Default_Name" class="btn update" value=" Update Figures "><br>
                     <br>
-                    <script language="Javascript" type="text/javascript">
-    <!--
-
-                    //$(function() { $("#stats_tabs0").tabs(); $("#stats_tabs1").tabs(); $("#stats_tabs2").tabs();});
-
-                    //
-                    -->
-                    </script>
 
                     <table cellpadding="0" cellspacing="0" border="0" class="display" id="stats_dyn"></table>
 
@@ -669,13 +661,7 @@
 
                     <p class="sectionheader" id="title4" style="border-radius: 5px;">&nbsp;&nbsp;Mapping Tools</p>
 
-                    <p id="sectionbody4"></p><script language="Javascript" type="text/javascript">
-    <!--
-
-                    //$(function() { $("#mapping_tabs").tabs(); });
-
-                    //-->
-                    </script>
+                    <p id="sectionbody4"></p>
 
                     <table class="target2" cellpadding="0" cellspacing="0" width="100%">
                       <tr>
@@ -1055,7 +1041,7 @@
 
                     <p class="sectionheader" id="title5" style="border-radius: 5px;">&nbsp;&nbsp;Review and Edit Data</p>
 
-                    <table id="stats_table" class="one-column-emphasis" />
+                    <table id="stats_table" class="table table-striped table-bordered" />
 
                     <p id="sectionbody5"></p>
 
@@ -1230,6 +1216,12 @@
           </td>
         </tr>
     </div>
+
+    <!-- End of body -->
+
+{% endblock %}
+
+{% block js %}
     <script>
         js_data = {{ js_data | safe }}
     </script>
@@ -1240,13 +1232,5 @@
 
     <script type="text/javascript" src="/static/new/javascript/stats.js"></script>
     <script type="text/javascript" src="/static/new/javascript/show_trait.js"></script>
-    <script type="text/javascript" src="/static/new/js_external/json2.js"></script>
     <script type="text/javascript" src="/static/new/javascript/validation.js"></script>
-
-
-    <!-- End of body -->
-
-
-
-
 {% endblock %}