about summary refs log tree commit diff
path: root/wqflask
diff options
context:
space:
mode:
authorLei Yan2014-02-03 12:48:37 -0600
committerLei Yan2014-02-03 12:48:37 -0600
commit818797d2fd7e425da47cf12ddab6001e3234c2e5 (patch)
tree0e62f3f1cacbafa6a75528d2a39eb6acd46b0b2e /wqflask
parentb462fae9df948dbf35232a764d61fbf10c930e82 (diff)
downloadgenenetwork2-818797d2fd7e425da47cf12ddab6001e3234c2e5.tar.gz
On branch master
Diffstat (limited to 'wqflask')
-rw-r--r--wqflask/maintenance/dataset/phenotypes.py27
-rw-r--r--wqflask/maintenance/dataset/utilities.py (renamed from wqflask/maintenance/dataset/db.py)0
2 files changed, 13 insertions, 14 deletions
diff --git a/wqflask/maintenance/dataset/phenotypes.py b/wqflask/maintenance/dataset/phenotypes.py
index 821e5687..ae1e82cc 100644
--- a/wqflask/maintenance/dataset/phenotypes.py
+++ b/wqflask/maintenance/dataset/phenotypes.py
@@ -6,6 +6,8 @@ import os
 import re
 import MySQLdb
 
+import utilities
+
 def fetch():
     # parameters
     inbredsetid = 1
@@ -13,12 +15,7 @@ def fetch():
     #
     phenotypesfile.write("id\tOriginal_description\tPre_publication_description\tPost_publication_description\t")
     # open db
-    host = 'localhost'
-    user = 'webqtl'
-    passwd = 'webqtl'
-    db = 'db_webqtl'
-    con = MySQLdb.Connect(db=db, user=user, passwd=passwd, host=host)
-    cursor = con.cursor()
+    cursor = utilities.get_cursor()
     # get strain list
     strains = []
     sql = """
@@ -40,20 +37,22 @@ def fetch():
     phenotypesfile.flush()
     # phenotypes
     sql = """
-        SELECT PublishXRef.`Id`, Phenotype.`Original_description`, Phenotype.`Pre_publication_description`, Phenotype.`Post_publication_description`
-        FROM (PublishXRef, Phenotype)
-        WHERE PublishXRef.`PhenotypeId`=Phenotype.`Id`
-        AND PublishXRef.`InbredSetId`=%s
+        SELECT PublishXRef.`Id`, Publication.`Authors`, Phenotype.`Original_description`, Phenotype.`Pre_publication_description`, Phenotype.`Post_publication_description`
+        FROM (PublishXRef, Phenotype, Publication)
+        WHERE PublishXRef.`InbredSetId`=%s
+        AND PublishXRef.`PhenotypeId`=Phenotype.`Id`
+        AND PublishXRef.`PublicationId`=Publication.`Id`
         """
     cursor.execute(sql, (inbredsetid))
     results = cursor.fetchall()
     print "get %d phenotypes" % (len(results))
     for phenotyperow in results:
         publishxrefid = phenotyperow[0]
-        original_description = clearspaces(phenotyperow[1])
-        pre_publication_description = clearspaces(phenotyperow[2])
-        post_publication_description = clearspaces(phenotyperow[3])
-        phenotypesfile.write("%s\t%s\t%s\t%s\t" % (publishxrefid, original_description, pre_publication_description, post_publication_description))
+        authors = clearspaces(phenotyperow[1])
+        original_description = clearspaces(phenotyperow[2])
+        pre_publication_description = clearspaces(phenotyperow[3])
+        post_publication_description = clearspaces(phenotyperow[4])
+        phenotypesfile.write("%s\t%s\t%s\t%s\t" % (publishxrefid, authors, original_description, pre_publication_description, post_publication_description))
         sql = """
             SELECT Strain.Name, PublishData.value
             FROM (PublishXRef, PublishData, Strain)
diff --git a/wqflask/maintenance/dataset/db.py b/wqflask/maintenance/dataset/utilities.py
index 453ee707..453ee707 100644
--- a/wqflask/maintenance/dataset/db.py
+++ b/wqflask/maintenance/dataset/utilities.py