diff options
-rw-r--r-- | wqflask/maintenance/dataset/datastructure.py | 25 | ||||
-rw-r--r-- | wqflask/maintenance/dataset/load_phenotypes.py | 14 |
2 files changed, 30 insertions, 9 deletions
diff --git a/wqflask/maintenance/dataset/datastructure.py b/wqflask/maintenance/dataset/datastructure.py index ce588c78..b2af5777 100644 --- a/wqflask/maintenance/dataset/datastructure.py +++ b/wqflask/maintenance/dataset/datastructure.py @@ -1,7 +1,7 @@ import utilities def get_probesetfreezes(inbredsetid): - cursor = utilities.get_cursor() + cursor, con = utilities.get_cursor() sql = """ SELECT ProbeSetFreeze.`Id`, ProbeSetFreeze.`Name`, ProbeSetFreeze.`FullName` FROM ProbeSetFreeze, ProbeFreeze @@ -12,7 +12,7 @@ def get_probesetfreezes(inbredsetid): return cursor.fetchall() def get_probesetfreeze(probesetfreezeid): - cursor = utilities.get_cursor() + cursor, con = utilities.get_cursor() sql = """ SELECT ProbeSetFreeze.`Id`, ProbeSetFreeze.`Name`, ProbeSetFreeze.`FullName` FROM ProbeSetFreeze @@ -22,7 +22,7 @@ def get_probesetfreeze(probesetfreezeid): return cursor.fetchone() def get_strains(inbredsetid): - cursor = utilities.get_cursor() + cursor, con = utilities.get_cursor() sql = """ SELECT Strain.`Id`, Strain.`Name` FROM StrainXRef, Strain @@ -34,7 +34,7 @@ def get_strains(inbredsetid): return cursor.fetchall() def get_inbredset(probesetfreezeid): - cursor = utilities.get_cursor() + cursor, con = utilities.get_cursor() sql = """ SELECT InbredSet.`Id`, InbredSet.`Name`, InbredSet.`FullName` FROM InbredSet, ProbeFreeze, ProbeSetFreeze @@ -44,9 +44,20 @@ def get_inbredset(probesetfreezeid): """ cursor.execute(sql, (probesetfreezeid)) return cursor.fetchone() + +def get_species(inbredsetid): + cursor, con = utilities.get_cursor() + sql = """ + SELECT Species.`Id`, Species.`Name`, Species.`MenuName`, Species.`FullName` + FROM InbredSet, Species + WHERE InbredSet.`Id`=%s + AND InbredSet.`SpeciesId`=Species.`Id` + """ + cursor.execute(sql, (inbredsetid)) + return cursor.fetchone() def get_nextdataid_phenotype(): - cursor = utilities.get_cursor() + cursor, con = utilities.get_cursor() sql = """ SELECT PublishData.`Id` FROM PublishData @@ -60,7 +71,7 @@ def get_nextdataid_phenotype(): return dataid def insert_strain(speciesid, strainname): - cursor = utilities.get_cursor() + cursor, con = utilities.get_cursor() sql = """ INSERT INTO Strain SET @@ -71,7 +82,7 @@ def insert_strain(speciesid, strainname): cursor.execute(sql, (strainname, strainname, speciesid)) def get_strain(speciesid, strainname): - cursor = utilities.get_cursor() + cursor, con = utilities.get_cursor() sql = """ SELECT Strain.`Id`, Strain.`Name` FROM Strain diff --git a/wqflask/maintenance/dataset/load_phenotypes.py b/wqflask/maintenance/dataset/load_phenotypes.py index 77133d0c..e74f8725 100644 --- a/wqflask/maintenance/dataset/load_phenotypes.py +++ b/wqflask/maintenance/dataset/load_phenotypes.py @@ -2,6 +2,7 @@ import sys import csv import utilities +import datastructure def main(argv): # config @@ -11,14 +12,21 @@ def main(argv): print "\t%s" % (str(item)) # var inbredsetid = config.get('config', 'inbredsetid') - dataid = utilities.get_nextdataid_phenotype() - cursor, con = utilities.get_cursor() print "inbredsetid: %s" % inbredsetid + species = datastructure.get_species(inbredsetid) + speciesid = species[0] + print "speciesid: %s" % speciesid + dataid = datastructure.get_nextdataid_phenotype() + print "next data id: %s" % dataid + cursor, con = utilities.get_cursor() # datafile datafile = open(config.get('config', 'datafile'), 'r') phenotypedata = csv.reader(datafile, delimiter='\t', quotechar='"') phenotypedata_head = phenotypedata.next() print "phenotypedata head:\n\t%s" % phenotypedata_head + strainnames = phenotypedata_head[1:] + strains = datastructure.get_strains_bynames(speciesid, strainnames) + print "%s" % strains # metafile metafile = open(config.get('config', 'metafile'), 'r') phenotypemeta = csv.reader(metafile, delimiter='\t', quotechar='"') @@ -102,6 +110,8 @@ def main(argv): rowcount = cursor.rowcount publicationid = con.insert_id() print "INSERT INTO Publication: %d record: %d" % (rowcount, publicationid) + # data + if __name__ == "__main__": print "command line arguments:\n\t%s" % sys.argv |