about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLei Yan2014-01-24 22:54:10 -0600
committerLei Yan2014-01-24 22:54:10 -0600
commiteb223dde7b6d543a6c2f0a6a2bdde19722db2452 (patch)
tree7b872bdcdbafce09bef9cc5143e36af22ef1e0b9
parent3e4c187e00b7eaafca2d3c215777cdc3b4101a33 (diff)
downloadgenenetwork2-eb223dde7b6d543a6c2f0a6a2bdde19722db2452.tar.gz
On branch master
-rw-r--r--wqflask/maintenance/dataset/phenotypes/phenotypes.py52
1 files changed, 52 insertions, 0 deletions
diff --git a/wqflask/maintenance/dataset/phenotypes/phenotypes.py b/wqflask/maintenance/dataset/phenotypes/phenotypes.py
new file mode 100644
index 00000000..bd5dcaa6
--- /dev/null
+++ b/wqflask/maintenance/dataset/phenotypes/phenotypes.py
@@ -0,0 +1,52 @@
+# Author:               Lei Yan
+
+# import
+import sys
+import os
+import re
+import MySQLdb
+
+def fetch():
+    # parameters
+    inbredsetid = 1
+    # 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()
+    # get strain list
+    strains = []
+    sql = """
+        SELECT Strain.`Name`
+        FROM StrainXRef, Strain
+        WHERE StrainXRef.`StrainId`=Strain.`Id`
+        AND StrainXRef.`InbredSetId`=%s
+        ORDER BY StrainXRef.`OrderId`
+        """
+    cursor.execute(sql, (inbredsetid))
+    results = cursor.fetchall()
+    for row in results:
+        strain = row[0]
+        strain = strain.lower()
+        strains.append(strain)
+    print "get %d strains: %s" % (len(strains), strains)
+    #
+    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
+        """
+    cursor.execute(sql, (inbredsetid))
+    results = cursor.fetchall()
+    print "get %d phenotypes" % len(results)
+    for row in results:
+        print row
+        break
+    
+# main
+if __name__ == "__main__":
+    fetch()
+    print "exit successfully"