[Swift-commit] r3009 - SwiftApps/SIDGrid/scripts

noreply at svn.ci.uchicago.edu noreply at svn.ci.uchicago.edu
Tue Jul 14 21:45:16 CDT 2009


Author: skenny
Date: 2009-07-14 21:45:16 -0500 (Tue, 14 Jul 2009)
New Revision: 3009

Modified:
   SwiftApps/SIDGrid/scripts/Mediator.py
Log:
single vox flag

Modified: SwiftApps/SIDGrid/scripts/Mediator.py
===================================================================
--- SwiftApps/SIDGrid/scripts/Mediator.py	2009-07-15 02:04:25 UTC (rev 3008)
+++ SwiftApps/SIDGrid/scripts/Mediator.py	2009-07-15 02:45:16 UTC (rev 3009)
@@ -20,15 +20,17 @@
         self.r_swift_args = ""
         self.r_script = ""
         self.r_infile = ""
-        self.begin_vox = ""
-        self.end_vox = ""
+        self.begin_vox = "1"
+        self.end_vox = "2"
+        self.vox = -1
         self.subject = ""
-        self.batchstep = ""
+        self.batchstep = "1"
         self.helpmsg = ""
         self.outprefix = "defaultoutname"
         self.all_queries = []
         self.qout_r_args = []
         self.g_db = None
+        self.voxfile = "false"
 
     #..........................................................................    
 
@@ -111,7 +113,11 @@
             elif o == "--batchstep":
                 self.batchstep = argstr[i+1]
             elif o == "--outprefix":
-                self.outprefix = argstr[i+1]                                
+                self.outprefix = argstr[i+1]
+            elif o == "--vox_file":
+                self.voxfile = argstr[i+1]
+            elif o == "--vox":
+                self.vox = argstr[i+1]
             elif (o.find("--")>-1):
                 print "o is this "+o
                 print "and i is this "+str(i)
@@ -124,7 +130,7 @@
     def gethelp(self,option):
         helpmsg = """
         Unknown Option: """+option+"""
-        usage:  --user, --conf, --db, --host, --query, --r_swift_args, --r_script, --r_infile, --outprefix, --begin_vox, --end_vox, --batchstep
+        usage:  --user, --conf, --db, --host, --query, --r_swift_args, --r_script, --r_infile, --outprefix, --begin_vox, --end_vox, --batchstep, --vox
         """
         return helpmsg
         
@@ -149,21 +155,42 @@
     #.....................................................................
 
     def gen_queries(self):
-        bgn = int(self.begin_vox)
-        end = int(self.end_vox)
-        stp = int(self.batchstep)
-        for i in range(bgn,end,stp):
-            beginbatch = i
-            endbatch = i+stp-1
-            tmp = self.query.replace("BEGIN_BATCH",str(beginbatch))
-            tmp2= tmp.replace("END_BATCH",str(endbatch))
-            tmp3= tmp2.replace("SUBJECT", self.subject)
-            self.all_queries.append(tmp3)
-            self.qout_r_args.append(str(beginbatch)+"_"+str(endbatch))
+        if(self.vox > -1):
+            tmp = self.query.replace("VOX",str(self.vox))
+            tmp2 = tmp.replace("SUBJECT", self.subject)
+            self.all_queries.append(tmp2)
+            self.qout_r_args.append(str(self.vox))
+        else:
+            bgn = int(self.begin_vox)
+            end = int(self.end_vox)
+            stp = int(self.batchstep)
+            for i in range(bgn,end,stp):
+                beginbatch = i
+                endbatch = i+stp-1
+                tmp = self.query.replace("BEGIN_BATCH",str(beginbatch))
+                tmp2= tmp.replace("END_BATCH",str(endbatch))
+                tmp3= tmp2.replace("SUBJECT", self.subject)
+                self.all_queries.append(tmp3)
+                self.qout_r_args.append(str(beginbatch)+"_"+str(endbatch))
         pass
 
     #.......................................................................
 
+    def gen_queries_noncontig(self):
+        allqueries = []
+        query = self.query
+        qcount = 0
+        voxfname = self.voxfile
+        voxfile = open ( voxfname, "r" )
+        for line in voxfile.readlines ():
+            tmp = query.replace("VOX_BATCH", "("+line.strip()+");")
+            self.all_queries.append(tmp)
+            self.qout_r_args.append(str(qcount)+"_")
+            qcount = qcount + 1 
+        voxfile.close()
+
+    #.......................................................................
+
     def run_query(self, query):
         print "RUNNING QUERY: "+query
         self.passwd = self.load('PASSWORD')
@@ -208,7 +235,10 @@
 
 med = Mediator ()
 med.get_opts(sys.argv)
-med.gen_queries()
+if med.voxfile == "false":
+    med.gen_queries()
+else:
+    med.gen_queries_noncontig()
 n=0
 for q in med.all_queries:
     med.run_query(q)




More information about the Swift-commit mailing list