aboutsummaryrefslogtreecommitdiff
path: root/wqflask/maintenance
diff options
context:
space:
mode:
authorroot2014-02-19 15:07:02 -0600
committerroot2014-02-19 15:07:02 -0600
commit65abf86206da02c682ca0ca3edcdf26519958cfd (patch)
tree113d4c2752a20723c3c13bb199b7730c754b5566 /wqflask/maintenance
parentb91219e4180173a96dd7535e40db8d788a60db77 (diff)
downloadgenenetwork2-65abf86206da02c682ca0ca3edcdf26519958cfd.tar.gz
Committer: root <root@alexandria.uthsc.edu>
On branch master
Diffstat (limited to 'wqflask/maintenance')
-rw-r--r--wqflask/maintenance/dataset/load_phenotypes.py39
-rw-r--r--wqflask/maintenance/dataset/utilities.py24
2 files changed, 61 insertions, 2 deletions
diff --git a/wqflask/maintenance/dataset/load_phenotypes.py b/wqflask/maintenance/dataset/load_phenotypes.py
index e5a85b32..6e7f049b 100644
--- a/wqflask/maintenance/dataset/load_phenotypes.py
+++ b/wqflask/maintenance/dataset/load_phenotypes.py
@@ -9,8 +9,9 @@ def main(argv):
print "config:"
for item in config.items('config'):
print "\t%s" % (str(item))
- #
+ # var
inbredsetid = config.get('config', 'inbredsetid')
+ cursor = utilities.get_cursor()
print "inbredsetid: %s" % inbredsetid
# datafile
datafile = open(config.get('config', 'datafile'), 'r')
@@ -22,7 +23,41 @@ def main(argv):
phenotypemeta = csv.reader(metafile, delimiter='\t', quotechar='"')
phenotypemeta_head = phenotypemeta.next()
print "phenotypemeta head:\n\t%s" % phenotypemeta_head
- #
+ # load
+ for metarow in phenotypemeta:
+ #
+ datarow_value = phenotypedata.next()
+ datarow_se = phenotypedata.next()
+ datarow_n = phenotypedata.next()
+ # Phenotype
+ sql = """
+ INSERT INTO Phenotype
+ SET
+ Phenotype.`Pre_publication_description`=%s,
+ Phenotype.`Post_publication_description`=%s,
+ Phenotype.`Original_description`=%s,
+ Phenotype.`Pre_publication_abbreviation`=%s,
+ Phenotype.`Post_publication_abbreviation`=%s,
+ Phenotype.`Lab_code`=%s,
+ Phenotype.`Submitter`=%s,
+ Phenotype.`Owner`=%s,
+ Phenotype.`Authorized_Users`=%s,
+ Phenotype.`Units`=%s
+ """
+ cursor.execute(sql, (
+ metarow[1],
+ metarow[2],
+ metarow[3],
+ metarow[4],
+ metarow[5],
+ metarow[6],
+ metarow[7],
+ metarow[8],
+ metarow[9],
+ metarow[18]
+ ))
+ re = cursor.rowcount
+ print "INSERT INTO Phenotype: %d record" % re
if __name__ == "__main__":
print "command line arguments:\n\t%s" % sys.argv
diff --git a/wqflask/maintenance/dataset/utilities.py b/wqflask/maintenance/dataset/utilities.py
index 63a3e84d..e542cb43 100644
--- a/wqflask/maintenance/dataset/utilities.py
+++ b/wqflask/maintenance/dataset/utilities.py
@@ -41,6 +41,30 @@ def overlap(dic1, dic2):
values2.append(value2)
return keys, values1, values2
+def to_db_string_null(s):
+ if s:
+ s = s.strip()
+ if len(s) == 0:
+ return None
+ elif s == 'x':
+ return None
+ else:
+ return s
+ else:
+ return None
+
+def to_db_string_empty(s):
+ if s:
+ s = s.strip()
+ if len(s) == 0:
+ return ''
+ elif s == 'x':
+ return ''
+ else:
+ return s
+ else:
+ return ''
+
def get_config(configfile):
config = ConfigParser.ConfigParser()
config.read(configfile)