diff options
author | Lei Yan | 2014-01-24 22:54:10 -0600 |
---|---|---|
committer | Lei Yan | 2014-01-24 22:54:10 -0600 |
commit | eb223dde7b6d543a6c2f0a6a2bdde19722db2452 (patch) | |
tree | 7b872bdcdbafce09bef9cc5143e36af22ef1e0b9 /wqflask/maintenance/dataset | |
parent | 3e4c187e00b7eaafca2d3c215777cdc3b4101a33 (diff) | |
download | genenetwork2-eb223dde7b6d543a6c2f0a6a2bdde19722db2452.tar.gz |
On branch master
Diffstat (limited to 'wqflask/maintenance/dataset')
-rw-r--r-- | wqflask/maintenance/dataset/phenotypes/phenotypes.py | 52 |
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" |