ed627ae35c176ae6e43cc4dc2935efd7d6f66a34
steve
  Fri Sep 5 09:26:38 2014 -0700
Changed the way the organism name is retrieved.  Now obtained from dbDb.organism field instead of chopping number from assembly name and obtaining from defaultDb.genome.  This addresses a rare issue where calMil0 and calMil1 have different values for the organism name; refs #13121
diff --git src/utils/qa/copyHgcentral src/utils/qa/copyHgcentral
index 66fd16a..ed4cf31 100755
--- src/utils/qa/copyHgcentral
+++ src/utils/qa/copyHgcentral
@@ -232,40 +232,30 @@
     else:
         if eraseFirst == 1:
             callHgsql("hgcentral", deleteQuery, "genome-centdb")
         callHgsql("hgcentral", loadQueryRr, "genome-centdb")
         if execTable == "dbDb":
             callHgsql("hgcentral", activeZeroQuery, "genome-centdb")
         queryExecuteRr = chopper(callHgsql("hgcentral", execQuery, "genome-centdb"), "strip", "")
     printOutput(execTable, queryExecuteDev, queryExecuteBeta, queryExecuteRr)
     print "***", execTable, "successfully copied from", execOptions.orig, "to", \
           execOptions.dest, "***\n"
     if execOptions.dest == "rr" and execTable == "dbDb":
         print "*** active set to 0 on rr ***\n"
     print
 
 
-def sqlRetrieve(retrieveAssembly, retrieveTable, retrieveField):
-    """Querying defaultDb and genomeClade relies on the genome name rather
-       than the assembly name, so this function is run to obtain the
-       appropriate values to plug into the runQuery function."""
-    assemblyChop = re.sub(r'\d', '', retrieveAssembly)
-    queryRetrieve = callHgsql("hgcentraltest", "select genome from " + retrieveTable + " where " +
-                              retrieveField + " like '" + assemblyChop + "%' limit 1", "hgwdev")
-    return queryRetrieve
-
-
 def main():
     parser = argparse.ArgumentParser(prog='copyHgcentral',
                                      description='Copies items from hgcentraltest -> hgcentralbeta \
                                                   and from hgcentralbeta -> hgcentral',
                                      usage="%(prog)s mode assembly table origin destination \
                                             \n\nType '%(prog)s -h' for more details")
 
     parser.add_argument('mode', action='store', choices=['test','execute'], metavar='mode',
                         help="Must be 'test' or 'execute' (test mode must be run first)")
     parser.add_argument('assembly', action='store',
                         help='The assembly whose data you would like to copy \
                         (e.g., hg19, mm10, etc.)')
     parser.add_argument('table', action='store', metavar='table',
                         choices=['blatServers','dbDb','defaultDb','genomeClade','all'],
                         help="The table whose data you would like to copy (must be 'blatServers', \
@@ -278,36 +268,40 @@
                         help="The server to copy to (must be 'beta' or 'rr')")
     optionList = parser.parse_args()
     if optionList.orig == "dev" and optionList.dest != "beta":
         print "\n *** If the origin is dev, the destination must be beta ***\n\n"
         sys.exit()
     if optionList.orig == "beta" and optionList.dest != "rr":
         print "\n *** If the origin is beta, the destination must be rr ***\n\n"
         sys.exit()
     if optionList.mode == "test":
         print
         if optionList.table in ["blatServers", "all"]:
             runTest(optionList, "blatServers", "db", optionList.assembly, "port")
         if optionList.table in ["dbDb", "all"]:
             runTest(optionList, "dbDb", "name", optionList.assembly, "name")
         if optionList.table in ["defaultDb", "all"]:
-            genome = chopper(sqlRetrieve(optionList.assembly, "defaultDb", "name"), "strip", "")
+            genome = chopper(callHgsql("hgcentraltest", "select organism from dbDb where name='" +
+                              optionList.assembly + "'", "hgwdev"), "strip", "")
             runTest(optionList, "defaultDb", "genome", genome, "genome")
         if optionList.table in ["genomeClade", "all"]:
-            genomeClade = chopper(sqlRetrieve(optionList.assembly, "defaultDb", "name"), "strip", "")
+            genomeClade = chopper(callHgsql("hgcentraltest", "select organism from dbDb where name='" +
+                              optionList.assembly + "'", "hgwdev"), "strip", "")
             runTest(optionList, "genomeClade", "genome", genomeClade, "genome")
     else:
         print
         if optionList.table in ["blatServers", "all"]:
             runExecute(optionList, "blatServers", "db", optionList.assembly, "port")
         if optionList.table in ["dbDb", "all"]:
             runExecute(optionList, "dbDb", "name", optionList.assembly, "name")
         if optionList.table in ["defaultDb", "all"]:
-            genome = chopper(sqlRetrieve(optionList.assembly, "defaultDb", "name"), "strip", "")
+            genome = chopper(callHgsql("hgcentraltest", "select organism from dbDb where name='" +
+                              optionList.assembly + "'", "hgwdev"), "strip", "")
             runExecute(optionList, "defaultDb", "genome", genome, "genome")
         if optionList.table in ["genomeClade", "all"]:
-            genomeClade = chopper(sqlRetrieve(optionList.assembly, "defaultDb", "name"), "strip", "")
+            genomeClade = chopper(callHgsql("hgcentraltest", "select organism from dbDb where name='" +
+                              optionList.assembly + "'", "hgwdev"), "strip", "")
             runExecute(optionList, "genomeClade", "genome", genomeClade, "genome")
 
 
 if __name__ == '__main__':
     main()