Ejemplo n.º 1
0
def setupProgram(): ### Basic Setup of Program
    '''
    Basic setup of Program:
    - Reads sys.argv and augments if appropriate
    - Makes Info, Out and Log objects
    - Returns [info,out,log,cmd_list]
    '''
    try:
        ### Initial Command Setup & Info ###
        info = makeInfo()
        cmd_list = rje.getCmdList(sys.argv[1:],info=info)      ### Load defaults from program.ini
        ### Out object ###
        out = rje.Out(cmd_list=cmd_list)
        out.verbose(2,2,cmd_list,1)
        out.printIntro(info)
        ### Additional commands ###
        cmd_list = cmdHelp(info,out,cmd_list)
        ### Log ###
        log = rje.setLog(info=info,out=out,cmd_list=cmd_list)
        return [info,out,log,cmd_list]
    except SystemExit: sys.exit()
    except KeyboardInterrupt: sys.exit()
    except:
        print 'Problem during initial setup.'
        raise
Ejemplo n.º 2
0
def setupProgram():  ### Basic Setup of Program
    '''
    Basic setup of Program:
    - Reads sys.argv and augments if appropriate
    - Makes Info, Out and Log objects
    - Returns [info,out,log,cmd_list]
    '''
    ### <0> ### Objects setup
    try:
        ## <a> ## Initial Command Setup & Info
        cmd_list = sys.argv[1:]
        info = makeInfo()
        cmd_list = rje.getCmdList(
            cmd_list, info=info)  ### Load defaults from program.ini
        ## <b> ## Out object
        out = rje.Out(cmd_list=cmd_list)
        out.verbose(0, 2, cmd_list, 1)
        out.printIntro(info)
        ## <c> ## Additional commands
        cmd_list = cmdHelp(info, out, cmd_list)
        ## <d> ## Log
        log = rje.setLog(info=info, out=out, cmd_list=cmd_list)
        return [info, out, log, cmd_list]
    except SystemExit:
        sys.exit()
    except:
        print "Problem during initial setup."
        raise
Ejemplo n.º 3
0
def setupProgram():  ### Basic Setup of Program
    '''
    Basic setup of Program:
    - Reads sys.argv and augments if appropriate
    - Makes Info, Out and Log objects
    - Returns [info,out,log,cmd_list]
    '''
    try:
        ### Initial Command Setup & Info ###
        info = makeInfo()
        cmd_list = rje.getCmdList(
            sys.argv[1:], info=info)  ### Load defaults from program.ini
        ### Out object ###
        out = rje.Out(cmd_list=cmd_list)
        out.verbose(2, 2, cmd_list, 1)
        out.printIntro(info)
        ### Additional commands ###
        cmd_list = cmdHelp(info, out, cmd_list)
        ### Log ###
        log = rje.setLog(info=info, out=out, cmd_list=cmd_list)
        return [info, out, log, cmd_list]
    except SystemExit:
        sys.exit()
    except KeyboardInterrupt:
        sys.exit()
    except:
        print 'Problem during initial setup.'
        raise
Ejemplo n.º 4
0
def setupProgram():  ### Basic Setup of Program when called from commandline.
    '''
    Basic Setup of Program when called from commandline:
    - Reads sys.argv and augments if appropriate
    - Makes Info, Out and Log objects
    - Returns [info,out,log,cmd_list]
    '''
    try:  ### ~ [1] ~ Initial Command Setup & Info ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ###
        info = makeInfo()  # Sets up Info object with program details
        cmd_list = rje.getCmdList(
            sys.argv[1:],
            info=info)  # Reads arguments and load defaults from program.ini
        out = rje.Out(cmd_list=cmd_list
                      )  # Sets up Out object for controlling output to screen
        out.verbose(2, 2, cmd_list,
                    1)  # Prints full commandlist if verbosity >= 2
        out.printIntro(
            info)  # Prints intro text using details from Info object
        cmd_list = cmdHelp(
            info, out,
            cmd_list)  # Shows commands (help) and/or adds commands from user
        log = rje.setLog(
            info, out,
            cmd_list)  # Sets up Log object for controlling log file output
        return (info, out, log, cmd_list)  # Returns objects for use in program
    except SystemExit:
        sys.exit()
    except KeyboardInterrupt:
        sys.exit()
    except:
        print 'Problem during initial setup.'
        raise
Ejemplo n.º 5
0
def setupProgram():  ### Basic Setup of Program
    """
    Basic setup of Program:
    - Reads sys.argv and augments if appropriate
    - Makes Info, Out and Log objects
    - Returns [info,out,log,cmd_list]
    """
    ### <0> ### Objects setup
    try:
        ## <a> ## Initial Command Setup & Info
        cmd_list = sys.argv[1:]
        info = makeInfo()
        cmd_list = rje.getCmdList(cmd_list, info=info)  ### Load defaults from program.ini
        ## <b> ## Out object
        out = rje.Out(cmd_list=cmd_list)
        out.verbose(0, 2, cmd_list, 1)
        out.printIntro(info)
        ## <c> ## Additional commands
        cmd_list = cmdHelp(info, out, cmd_list)
        ## <d> ## Log
        log = rje.setLog(info=info, out=out, cmd_list=cmd_list)
        return [info, out, log, cmd_list]
    except SystemExit:
        sys.exit()
    except KeyboardInterrupt:
        sys.exit()
    except:
        print "Problem during initial setup."
        raise
Ejemplo n.º 6
0
 def batchRun(self,returnobj=False):     ### Execute batch mode runs
     '''Execute batch mode runs.'''
     try:### ~ [0] Setup ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ###
         barg = self.getStrLC('BatchArg')
         if not barg: raise ValueError('Cannot use batchrun=FILELIST if batcharg=None.')
         batchfiles = self.list['BatchRun'][0:]
         self.list['BatchRun'] = []  # Avoid recursive running!
         blog = self.getStr('BatchLog')
         if not blog.startswith('.'): blog = '.%s' % blog
         if not blog.endswith('.log'): blog = '%s.log' % blog
         rawcmd = self.cmd_list[0:]
         rawlog = self.log
         batchobj = []
         ### ~ [1] Batch Run ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ###
         bx = 0
         for bfile in batchfiles:
             bx += 1
             self.printLog('#BATCH','Batch running %s of %s: %s=%s' % (rje.iStr(bx),rje.iLen(batchfiles),barg,bfile))
             ## Setup parameters
             bbase = rje.baseFile(bfile,strip_path=True)
             bcmd = ['%s=%s' % (barg,bfile)]
             if self.getBool('BatchBase'):
                 if blog == '.log': bcmd += ['basefile=%s' % bbase]
                 else: bcmd += ['basefile=%s%s' % (bbase,rje.baseFile(blog))]
             elif self.getStrLC('BatchLog'): bcmd += ['log=%s%s' % (bbase,blog)]
             else: bcmd += ['newlog=F']
             #self.debug(bcmd)
             ## Setup Seqsuite object
             self.cmd_list = rawcmd + bcmd
             self.log = rje.setLog(self.log.obj['Info'],self,self.cmd_list)                 # Sets up Log object for controlling log file output
             ## Run
             batchobj.append(self.run())
             ## Finish and Tidy
             self.log = rawlog
             runobj =  batchobj[-1]
             if runobj:
                 if not returnobj: batchobj[-1] = True
                 info = runobj.log.obj['Info']
                 self.printLog('#RUN','%s V%s run finished.' % (info.program,info.version))
             else: self.warnLog('Batch run failed (%s=%s).' % (barg,bfile))
         ### ~ [2] Finish and Return ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ###
         failx = batchobj.count(False)
         self.printLog('#BATCH','%s batch runs complete: %s failed.' % (rje.iLen(batchfiles),rje.iStr(failx)))
         self.list['BatchRun'] = batchfiles
         return batchobj
     except: self.errorLog('%s.batchRun error' % self); return False
Ejemplo n.º 7
0
def setupProgram(): ### Basic Setup of Program when called from commandline.
    '''
    Basic Setup of Program when called from commandline:
    - Reads sys.argv and augments if appropriate
    - Makes Info, Out and Log objects
    - Returns [info,out,log,cmd_list]
    '''
    try:### ~ [1] ~ Initial Command Setup & Info ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ###
        info = makeInfo()                                   # Sets up Info object with program details
        cmd_list = rje.getCmdList(sys.argv[1:],info=info)   # Reads arguments and load defaults from program.ini
        out = rje.Out(cmd_list=cmd_list)                    # Sets up Out object for controlling output to screen
        out.verbose(2,2,cmd_list,1)                         # Prints full commandlist if verbosity >= 2 
        out.printIntro(info)                                # Prints intro text using details from Info object
        cmd_list = cmdHelp(info,out,cmd_list)               # Shows commands (help) and/or adds commands from user
        log = rje.setLog(info,out,cmd_list)                 # Sets up Log object for controlling log file output
        return (info,out,log,cmd_list)                      # Returns objects for use in program
    except SystemExit: sys.exit()
    except KeyboardInterrupt: sys.exit()
    except: print 'Problem during initial setup.'; raise
Ejemplo n.º 8
0
 def multiHAQ(self,secondrun=False):     ### Executes main HAQESAC runs
     '''Executes main HAQESAC runs.'''
     try:### ~ [0] Setup ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ###
         finalrun = secondrun == self.opt['MultiHAQ']    # Whether this is the manual HAQESAC phase
         qryacc = self.obj['SeqList'].accList()          # Full list of Query accession numbers
         processed = []                                  # List of processed sequence accession numbers
         ### ~ [1] Peform HAQESAC runs ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ###
         for seq in self.seqs():
             ## ~ [1a] Check AutoSkip ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ##
             acc = seq.info['AccNum']
             if finalrun and acc in processed and (self.opt['AutoSkip'] or (self.i() >=0 and rje.yesNo('%s already covered by previous HAQESAC. Skip?' % seq.shortName()))):
                 self.printLog('#SKIP','%s already covered by previous HAQESAC: Skipped' % seq.shortName()); continue
             ## ~ [1b] Check Whether to run (re-runs and low sequence number) ~~~~~~~~~~~~~~~~~~ ##
             logfile = rje.makePath('%s%s.log' % (self.info['HaqDir'],acc),wholepath=True)
             infile = rje.makePath('%s%s.fas' % (self.info['HaqDir'],acc),wholepath=True)
             pkfile = rje.makePath('%s%s.pickle' % (self.info['HaqDir'],acc),wholepath=True)
             pkzfile = rje.makePath('%s%s.pickle.gz' % (self.info['HaqDir'],acc),wholepath=True)
             if not os.path.exists(infile): self.printLog('#SKIP','%s input file %s not found: Skipped' % (seq.shortName(),infile)); continue
             if not finalrun and not self.opt['Force'] and rje.isYounger(pkzfile,infile) == pkzfile:
                 self.printLog('#SKIP','%s run detected: Skipped' % seq.shortName()); continue
             if not finalrun and not self.opt['Force'] and rje.isYounger(pkfile,infile) == pkfile:
                 self.printLog('#SKIP','%s run detected: Skipped' % seq.shortName()); continue
             inseqx = rje_seq.SeqCount(self,infile)
             if inseqx < 2: self.printLog('#SKIP','Only one sequence found in %s: Skipped' % (infile)); continue
             ## ~ [1c] Pause if running in Chaser Mode and no Pickle ~~~~~~~~~~~~~~~~~~~~~~~~~~~ ##
             pickled = os.path.exists(pkfile) or os.path.exists('%s.gz' % pkfile); tm = 0
             while secondrun and self.opt['Chaser'] and not pickled:
                 self.progLog('#WAIT','No %s pickle. Sleeping for %d min.' % (acc,tm))
                 time.sleep(60*tm); tm += 1
                 pickled = os.path.exists(pkfile) or os.path.exists('%s.gz' % pkfile)
                 if not pickled:
                     try: rje.choice('Press <ENTER> to try again, or <CTRL+C> to Quit')
                     except:
                         self.printLog('#PICKLE','No %s pickle.' % (acc,tm))
                         self.printLog('\r#MULTI','Exiting multiHAQ "Chaser" run.'); return
             ## ~ [1d] Run HAQESAC ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ##
             runhaqesac = True
             pngfile = rje.makePath('%s%s.png' % (self.info['HaqDir'],acc),wholepath=True)
             if not self.force() and rje.exists(pngfile):
                 self.printLog('#SKIP','Found evidence of completed run: %s (force=F). Skipping.' % pngfile)
                 runhaqesac = False
             ancfile = rje.makePath('%s%s.anc.fas' % (self.info['HaqDir'],acc),wholepath=True)
             if not self.force() and rje.exists(ancfile):
                 self.printLog('#SKIP','Found evidence of completed run: %s (force=F). Skipping.' % ancfile)
                 runhaqesac = False
             #if not finalrun or self.opt['Force'] or rje.isYounger(logfile,nsfile) != logfile:
             if runhaqesac:
                 haqcmd = ['ini=haqesac.ini','seqin=%s.fas' % acc, 'query=%s' % acc, 'basefile=%s' % acc, 'newlog=F']
                 self.printLog('#HAQ','Running HAQESAC for %s - will have own log etc.' % seq.shortName(),log=False)
                 os.chdir(self.info['HaqDir'])
                 info = haqesac.makeInfo()
                 haqcmd = rje.getCmdList(haqcmd,info=info)
                 out = rje.Out(cmd_list=haqcmd)    # Sets up Out object for controlling output to screen
                 out.printIntro(info)                                # Prints intro text using details from Info object
                 haqlog = rje.setLog(info,out,haqcmd)                 # Sets up Log object for controlling log file output
                 try: haqesac.HAQESAC(log=haqlog, cmd_list=haqcmd).run(setobjects=True)
                 except:
                     os.chdir(self.info['RunPath'])
                     if self.i() >= 0 and rje.yesNo('Problem with %s HAQESAC run. Abort?' % seq.shortName()): raise KeyboardInterrupt
                 os.chdir(self.info['RunPath'])
                 if finalrun: self.printLog('#HAQ','HAQESAC final round run for %s' % seq.shortName())
                 else: self.printLog('#HAQ','HAQESAC first round run for %s' % seq.shortName())
             ## ~ [1e] Update ScreenQry ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ##
             if not self.opt['ScreenQry'] or not finalrun: continue
             qacclist = []
             for qacc in rje_seq.SeqList(self.log,['seqin=%s' % infile,'autoload=T','autofilter=F']).accList():
                 if qacc in qryacc and qacc != acc: qacclist.append(qacc)
                 if qacc in qryacc and qacc not in processed: processed.append(qacc)
             self.printLog('#QRY','%d other queries found in %s: [%s]' % (len(qacclist),infile,string.join(qacclist,'; ')))
             self.printLog('#QRY','%d of %d queries processed' % (len(processed),self.seqNum()))
         ### ~ [2] MultiHAQ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ###
         if not finalrun: self.printLog('#MULTI','Executing second round of multiHAQ'); self.multiHAQ(True)
     except: self.errorLog('Major problem with MultiHAQ.multiHAQ',quitchoice=True)
Ejemplo n.º 9
0
 def multiHAQ(self, secondrun=False):  ### Executes main HAQESAC runs
     '''Executes main HAQESAC runs.'''
     try:  ### ~ [0] Setup ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ###
         finalrun = secondrun == self.opt[
             'MultiHAQ']  # Whether this is the manual HAQESAC phase
         qryacc = self.obj['SeqList'].accList(
         )  # Full list of Query accession numbers
         processed = []  # List of processed sequence accession numbers
         ### ~ [1] Peform HAQESAC runs ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ###
         for seq in self.seqs():
             ## ~ [1a] Check AutoSkip ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ##
             acc = seq.info['AccNum']
             if finalrun and acc in processed and (
                     self.opt['AutoSkip'] or (self.i() >= 0 and rje.yesNo(
                         '%s already covered by previous HAQESAC. Skip?' %
                         seq.shortName()))):
                 self.printLog(
                     '#SKIP',
                     '%s already covered by previous HAQESAC: Skipped' %
                     seq.shortName())
                 continue
             ## ~ [1b] Check Whether to run (re-runs and low sequence number) ~~~~~~~~~~~~~~~~~~ ##
             logfile = rje.makePath('%s%s.log' % (self.info['HaqDir'], acc),
                                    wholepath=True)
             infile = rje.makePath('%s%s.fas' % (self.info['HaqDir'], acc),
                                   wholepath=True)
             pkfile = rje.makePath('%s%s.pickle' %
                                   (self.info['HaqDir'], acc),
                                   wholepath=True)
             pkzfile = rje.makePath('%s%s.pickle.gz' %
                                    (self.info['HaqDir'], acc),
                                    wholepath=True)
             if not os.path.exists(infile):
                 self.printLog(
                     '#SKIP', '%s input file %s not found: Skipped' %
                     (seq.shortName(), infile))
                 continue
             if not finalrun and not self.opt['Force'] and rje.isYounger(
                     pkzfile, infile) == pkzfile:
                 self.printLog('#SKIP',
                               '%s run detected: Skipped' % seq.shortName())
                 continue
             if not finalrun and not self.opt['Force'] and rje.isYounger(
                     pkfile, infile) == pkfile:
                 self.printLog('#SKIP',
                               '%s run detected: Skipped' % seq.shortName())
                 continue
             inseqx = rje_seq.SeqCount(self, infile)
             if inseqx < 2:
                 self.printLog(
                     '#SKIP',
                     'Only one sequence found in %s: Skipped' % (infile))
                 continue
             ## ~ [1c] Pause if running in Chaser Mode and no Pickle ~~~~~~~~~~~~~~~~~~~~~~~~~~~ ##
             pickled = os.path.exists(pkfile) or os.path.exists(
                 '%s.gz' % pkfile)
             tm = 0
             while secondrun and self.opt['Chaser'] and not pickled:
                 self.progLog(
                     '#WAIT',
                     'No %s pickle. Sleeping for %d min.' % (acc, tm))
                 time.sleep(60 * tm)
                 tm += 1
                 pickled = os.path.exists(pkfile) or os.path.exists(
                     '%s.gz' % pkfile)
                 if not pickled:
                     try:
                         rje.choice(
                             'Press <ENTER> to try again, or <CTRL+C> to Quit'
                         )
                     except:
                         self.printLog('#PICKLE',
                                       'No %s pickle.' % (acc, tm))
                         self.printLog('\r#MULTI',
                                       'Exiting multiHAQ "Chaser" run.')
                         return
             ## ~ [1d] Run HAQESAC ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ##
             runhaqesac = True
             pngfile = rje.makePath('%s%s.png' % (self.info['HaqDir'], acc),
                                    wholepath=True)
             if not self.force() and rje.exists(pngfile):
                 self.printLog(
                     '#SKIP',
                     'Found evidence of completed run: %s (force=F). Skipping.'
                     % pngfile)
                 runhaqesac = False
             ancfile = rje.makePath('%s%s.anc.fas' %
                                    (self.info['HaqDir'], acc),
                                    wholepath=True)
             if not self.force() and rje.exists(ancfile):
                 self.printLog(
                     '#SKIP',
                     'Found evidence of completed run: %s (force=F). Skipping.'
                     % ancfile)
                 runhaqesac = False
             #if not finalrun or self.opt['Force'] or rje.isYounger(logfile,nsfile) != logfile:
             if runhaqesac:
                 haqcmd = [
                     'ini=haqesac.ini',
                     'seqin=%s.fas' % acc,
                     'query=%s' % acc,
                     'basefile=%s' % acc, 'newlog=F'
                 ]
                 self.printLog(
                     '#HAQ',
                     'Running HAQESAC for %s - will have own log etc.' %
                     seq.shortName(),
                     log=False)
                 os.chdir(self.info['HaqDir'])
                 info = haqesac.makeInfo()
                 haqcmd = rje.getCmdList(haqcmd, info=info)
                 out = rje.Out(
                     cmd_list=haqcmd
                 )  # Sets up Out object for controlling output to screen
                 out.printIntro(
                     info
                 )  # Prints intro text using details from Info object
                 haqlog = rje.setLog(
                     info, out, haqcmd
                 )  # Sets up Log object for controlling log file output
                 try:
                     haqesac.HAQESAC(log=haqlog,
                                     cmd_list=haqcmd).run(setobjects=True)
                 except:
                     os.chdir(self.info['RunPath'])
                     if self.i() >= 0 and rje.yesNo(
                             'Problem with %s HAQESAC run. Abort?' %
                             seq.shortName()):
                         raise KeyboardInterrupt
                 os.chdir(self.info['RunPath'])
                 if finalrun:
                     self.printLog(
                         '#HAQ',
                         'HAQESAC final round run for %s' % seq.shortName())
                 else:
                     self.printLog(
                         '#HAQ',
                         'HAQESAC first round run for %s' % seq.shortName())
             ## ~ [1e] Update ScreenQry ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ##
             if not self.opt['ScreenQry'] or not finalrun: continue
             qacclist = []
             for qacc in rje_seq.SeqList(
                     self.log,
                 ['seqin=%s' % infile, 'autoload=T', 'autofilter=F'
                  ]).accList():
                 if qacc in qryacc and qacc != acc: qacclist.append(qacc)
                 if qacc in qryacc and qacc not in processed:
                     processed.append(qacc)
             self.printLog(
                 '#QRY', '%d other queries found in %s: [%s]' %
                 (len(qacclist), infile, string.join(qacclist, '; ')))
             self.printLog(
                 '#QRY', '%d of %d queries processed' %
                 (len(processed), self.seqNum()))
         ### ~ [2] MultiHAQ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ###
         if not finalrun:
             self.printLog('#MULTI', 'Executing second round of multiHAQ')
             self.multiHAQ(True)
     except:
         self.errorLog('Major problem with MultiHAQ.multiHAQ',
                       quitchoice=True)
Ejemplo n.º 10
0
 def batchRun(self, returnobj=False):  ### Execute batch mode runs
     '''Execute batch mode runs.'''
     try:  ### ~ [0] Setup ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ###
         barg = self.getStrLC('BatchArg')
         if not barg:
             raise ValueError(
                 'Cannot use batchrun=FILELIST if batcharg=None.')
         batchfiles = self.list['BatchRun'][0:]
         self.list['BatchRun'] = []  # Avoid recursive running!
         blog = self.getStr('BatchLog')
         if not blog.startswith('.'): blog = '.%s' % blog
         if not blog.endswith('.log'): blog = '%s.log' % blog
         rawcmd = self.cmd_list[0:]
         rawlog = self.log
         batchobj = []
         ### ~ [1] Batch Run ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ###
         bx = 0
         for bfile in batchfiles:
             bx += 1
             self.printLog(
                 '#BATCH', 'Batch running %s of %s: %s=%s' %
                 (rje.iStr(bx), rje.iLen(batchfiles), barg, bfile))
             ## Setup parameters
             bbase = rje.baseFile(bfile, strip_path=True)
             bcmd = ['%s=%s' % (barg, bfile)]
             if self.getBool('BatchBase'):
                 if blog == '.log': bcmd += ['basefile=%s' % bbase]
                 else:
                     bcmd += ['basefile=%s%s' % (bbase, rje.baseFile(blog))]
             elif self.getStrLC('BatchLog'):
                 bcmd += ['log=%s%s' % (bbase, blog)]
             else:
                 bcmd += ['newlog=F']
             #self.debug(bcmd)
             ## Setup Seqsuite object
             self.cmd_list = rawcmd + bcmd
             self.log = rje.setLog(
                 self.log.obj['Info'], self, self.cmd_list
             )  # Sets up Log object for controlling log file output
             ## Run
             batchobj.append(self.run())
             ## Finish and Tidy
             self.log = rawlog
             runobj = batchobj[-1]
             if runobj:
                 if not returnobj: batchobj[-1] = True
                 info = runobj.log.obj['Info']
                 self.printLog(
                     '#RUN',
                     '%s V%s run finished.' % (info.program, info.version))
             else:
                 self.warnLog('Batch run failed (%s=%s).' % (barg, bfile))
         ### ~ [2] Finish and Return ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ###
         failx = batchobj.count(False)
         self.printLog(
             '#BATCH', '%s batch runs complete: %s failed.' %
             (rje.iLen(batchfiles), rje.iStr(failx)))
         self.list['BatchRun'] = batchfiles
         return batchobj
     except:
         self.errorLog('%s.batchRun error' % self)
         return False