def setup(self): ### Main class setup method. '''Main class setup method.''' try:### ~ [1] ~ Setup Program ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ### self.obj['Prog'] = None prog = self.getStrLC('Name') if prog in mod: i = self.obj['ProgInfo'] = mod[prog].makeInfo() self.printLog('#PROG','%s V%s: %s' % (i.program,i.version,i.description)) progcmd = rje.getCmdList([],info=i) + self.cmd_list + ['newlog=F'] out = rje.Out(cmd_list=progcmd) out.printIntro(i) #self.debug(prog); self.debug(progcmd) if self.getBool('Help'): progcmd = mod[prog].cmdHelp(i,out,['help']+progcmd) self.printLog('#CMD','Full %s CmdList: %s' % (i.program,rje.argString(rje.tidyArgs(progcmd,nopath=self.getStrLC('Rest') and not self.dev(),purgelist=purgelist))),screen=False) #self.debug(prog); self.debug(progcmd) ## ~ [1a] ~ Make self.obj['Prog'] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ## if prog in ['seqlist','rje_seqlist']: self.obj['Prog'] = rje_seqlist.SeqList(self.log,progcmd) elif prog in ['uniprot','rje_uniprot']: self.obj['Prog'] = rje_uniprot.UniProt(self.log,progcmd) elif prog in ['taxonomy','rje_taxonomy']: self.obj['Prog'] = rje_taxonomy.Taxonomy(self.log,progcmd) elif prog in ['tree','rje_tree']: self.obj['Prog'] = rje_tree.Tree(self.log,progcmd) elif prog in ['xref','rje_xref']: self.obj['Prog'] = rje_xref.XRef(self.log,progcmd) elif prog in ['seq','rje_seq']: self.obj['Prog'] = rje_seq.SeqList(self.log,progcmd) elif prog in ['mitab','rje_mitab']: self.obj['Prog'] = rje_mitab.MITAB(self.log,progcmd) elif prog in ['dbase','database']: self.obj['Prog'] = rje_dbase.DatabaseController(self.log,progcmd) elif prog in ['pydocs']: self.obj['Prog'] = rje_pydocs.PyDoc(self.log,progcmd) elif prog in ['ensembl','rje_ensembl']: self.obj['Prog'] = rje_ensembl.EnsEMBL(self.log,progcmd) elif prog in ['genbank','rje_genbank']: self.obj['Prog'] = rje_genbank.GenBank(self.log,progcmd) elif prog in ['extatic']: self.obj['Prog'] = extatic.ExTATIC(self.log,progcmd) elif prog in ['revert']: self.obj['Prog'] = revert.REVERT(self.log,progcmd) elif prog in ['fiesta']: self.obj['Prog'] = fiesta.FIESTA(self.log,progcmd) elif prog in ['gablam']: self.obj['Prog'] = gablam.GABLAM(self.log,progcmd) elif prog in ['gopher']: self.obj['Prog'] = gopher.Gopher(self.log,progcmd) elif prog in ['haqesac']: self.obj['Prog'] = haqesac.HAQESAC(self.log,progcmd) elif prog in ['multihaq']: self.obj['Prog'] = multihaq.MultiHAQ(self.log,progcmd) elif prog in ['pingu']: self.obj['Prog'] = pingu.PINGU(self.log,progcmd) elif prog in ['pacbio']: self.obj['Prog'] = rje_pacbio.PacBio(self.log,progcmd) elif prog in ['rje_zen','zen']: self.obj['Prog'] = rje_zen.Zen(self.log,progcmd) ### ~ [2] ~ Failure to recognise program ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ### if not self.obj['Prog']: self.printLog('#ERR','Program "%s" not recognised.' % self.getStr('Name')) if self.i() < 0: return False if rje.yesNo('Show SeqSuite help with program options?'): extracmd = cmdHelp(cmd_list=['help'])[1:] if extracmd: self.cmd_list += extracmd self._cmdList() if prog != self.getStrLC('Name'): return self.setup() self.setStr({'Name':rje.choice('Give program name (Blank or CTRL+C to quit)')}) if self.getStrLC('Name'): return self.setup() else: return False return self.obj['Prog'] # Setup successful except KeyboardInterrupt: return False except SystemExit: raise except: self.errorLog('Problem during %s setup.' % self.prog()); return False # Setup failed
def setup(self,rest=False): ### Main class setup method. '''Main class setup method.''' try:### ~ [1] ~ Setup Program ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ### self.obj['Prog'] = None prog = self.getStrLC('Name') if prog in mod: i = self.obj['ProgInfo'] = mod[prog].makeInfo() self.printLog('#PROG','%s V%s: %s' % (i.program,i.version,i.description)) progcmd = rje.getCmdList([],info=i) + self.cmd_list + ['newlog=F'] out = rje.Out(cmd_list=progcmd) out.printIntro(i) if self.getBool('Help'): progcmd = mod[prog].cmdHelp(i,out,['help']+progcmd) purgelist = seqsuite.purgelist self.printLog('#CMD','Full %s CmdList: %s' % (i.program,rje.argString(rje.tidyArgs(progcmd,nopath=self.getStrLC('Rest') and not self.dev(),purgelist=purgelist))),screen=False) #self.debug(prog) ## ~ [1a] ~ Make self.obj['Prog'] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ## if prog in ['slimcore','rje_slimcore','core']: self.obj['Prog'] = rje_slimcore.SLiMCore(self.log,progcmd) elif prog in ['rlc','iuscore']: self.obj['Prog'] = rje_slimcore.SLiMCore(self.log,progcmd+['prog=%s' % prog]) elif prog in ['slimlist','rje_slimlist']: self.obj['Prog'] = rje_slimlist.SLiMList(self.log,progcmd) elif prog in ['slimfinder']: self.obj['Prog'] = slimfinder.SLiMFinder(self.log,progcmd) elif prog in ['qslimfinder']: self.obj['Prog'] = qslimfinder.QSLiMFinder(self.log,progcmd) elif prog in ['slimprob']: self.obj['Prog'] = slimprob.SLiMProb(self.log,progcmd) elif prog in ['slimmaker']: self.obj['Prog'] = slimmaker.SLiMMaker(self.log,progcmd) elif prog in ['slimfarmer','farm']: self.obj['Prog'] = slimfarmer.SLiMFarmer(self.log,progcmd) elif prog in ['slimbench']: self.obj['Prog'] = slimbench.SLiMBench(self.log,progcmd) elif prog in ['comparimotif']: self.obj['Prog'] = comparimotif.CompariMotif(self.log,progcmd) elif prog in ['peptcluster']: self.obj['Prog'] = peptcluster.PeptCluster(self.log,progcmd) elif prog in ['peptalign']: self.obj['Prog'] = peptcluster.PeptCluster(self.log,['peptalign=T']+progcmd+['peptdis=None']) self.obj['Prog'].dict['Output']['help'] = mod[prog].__doc__ elif prog in seqsuite.mod: seqsuiteobj = seqsuite.SeqSuite(self.log,self.cmd_list) self.obj['Prog'] = seqsuiteobj.setup() self.obj['ProgInfo'] = seqsuiteobj.obj['ProgInfo'] self.obj['Prog'].dict['Output']['help'] = seqsuite.mod[prog].__doc__ ### ~ [2] ~ Failure to recognise program ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ### if not self.obj['Prog']: if self.getStrLC('Name') != 'help': if not rest: self.printLog('#ERR','Program "%s" not recognised.' % self.getStr('Name')) if self.i() < 0 or rest: return False #!# Try SeqSuite? #!# if self.getStrLC('Name') == 'help' or rje.yesNo('Show SLiMSuite help with program options?'): extracmd = cmdHelp(cmd_list=['help'])[1:] if extracmd: self.cmd_list += extracmd self._cmdList() if prog != self.getStrLC('Name'): return self.setup() self.setStr({'Name':rje.choice('Give program name (Blank or CTRL+C to quit)')}) if self.getStrLC('Name'): return self.setup() else: return False return self.obj['Prog'] # Setup successful except KeyboardInterrupt: return False except SystemExit: raise except: self.errorLog('Problem during %s setup.' % self.prog()); return False # Setup failed
def setup(self): ### Main class setup method. '''Main class setup method.''' try: ### ~ [1] ~ Setup Program ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ### self.obj['Prog'] = None prog = self.getStrLC('Name') if prog in mod: i = self.obj['ProgInfo'] = mod[prog].makeInfo() self.printLog( '#PROG', '%s V%s: %s' % (i.program, i.version, i.description)) progcmd = rje.getCmdList( [], info=i) + self.cmd_list + ['newlog=F'] out = rje.Out(cmd_list=progcmd) out.printIntro(i) if self.getBool('Help'): progcmd = mod[prog].cmdHelp(i, out, ['help'] + progcmd) purgelist = seqsuite.purgelist self.printLog('#CMD', 'Full %s CmdList: %s' % (i.program, rje.argString( rje.tidyArgs(progcmd, nopath=self.getStrLC('Rest') and not self.dev(), purgelist=purgelist))), screen=False) #self.debug(prog) ## ~ [1a] ~ Make self.obj['Prog'] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ## if prog in ['slimcore', 'rje_slimcore']: self.obj['Prog'] = rje_slimcore.SLiMCore(self.log, progcmd) elif prog in ['rlc', 'disorder']: self.obj['Prog'] = rje_slimcore.SLiMCore( self.log, progcmd + ['prog=%s' % prog]) elif prog in ['slimlist', 'rje_slimlist']: self.obj['Prog'] = rje_slimlist.SLiMList(self.log, progcmd) elif prog in ['slimfinder']: self.obj['Prog'] = slimfinder.SLiMFinder(self.log, progcmd) elif prog in ['qslimfinder']: self.obj['Prog'] = qslimfinder.QSLiMFinder( self.log, progcmd) elif prog in ['slimprob']: self.obj['Prog'] = slimprob.SLiMProb(self.log, progcmd) elif prog in ['slimmaker']: self.obj['Prog'] = slimmaker.SLiMMaker(self.log, progcmd) elif prog in ['slimfarmer', 'farm']: self.obj['Prog'] = slimfarmer.SLiMFarmer(self.log, progcmd) elif prog in ['slimbench']: self.obj['Prog'] = slimbench.SLiMBench(self.log, progcmd) elif prog in ['comparimotif']: self.obj['Prog'] = comparimotif.CompariMotif( self.log, progcmd) elif prog in ['peptcluster']: self.obj['Prog'] = peptcluster.PeptCluster( self.log, progcmd) elif prog in ['peptalign']: self.obj['Prog'] = peptcluster.PeptCluster( self.log, ['peptalign=T'] + progcmd) self.obj['Prog'].dict['Output']['help'] = mod[prog].__doc__ elif prog in seqsuite.mod: seqsuiteobj = seqsuite.SeqSuite(self.log, self.cmd_list) self.obj['Prog'] = seqsuiteobj.setup() self.obj['ProgInfo'] = seqsuiteobj.obj['ProgInfo'] self.obj['Prog'].dict['Output']['help'] = seqsuite.mod[ prog].__doc__ ### ~ [2] ~ Failure to recognise program ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ### if not self.obj['Prog']: self.printLog( '#ERR', 'Program "%s" not recognised.' % self.getStr('Name')) if self.i() < 0: return False #!# Try SeqSuite? #!# if rje.yesNo('Show SLiMSuite help with program options?'): extracmd = cmdHelp(cmd_list=['help'])[1:] if extracmd: self.cmd_list += extracmd self._cmdList() if prog != self.getStrLC('Name'): return self.setup() self.setStr({ 'Name': rje.choice('Give program name (Blank or CTRL+C to quit)') }) if self.getStrLC('Name'): return self.setup() else: return False return self.obj['Prog'] # Setup successful except KeyboardInterrupt: return False except SystemExit: raise except: self.errorLog('Problem during %s setup.' % self.prog()) return False # Setup failed
def gff3(self,locdb,sumdb,exmodel,filename=''): ### Converts local and summary tables into GFF table. ''' Converts local and summary tables into GFF table. :param locdb: Local hits database Table :param sumdb: Hit summary database Table :param exmodel: Exonerate model :param filename: Save to filename, if given. :return: GFF database Table ''' try:### ~ [0] Setup ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ### if not exmodel: exmodel = 'dna2dna' lochits = {} # Dictionary of {hitsumkey:[local entries]} for hkey in sumdb.dataKeys(): lochits[hkey] = [] for lkey in locdb.dataKeys(): entry = locdb.data(lkey) hkey = (entry['Qry'],entry['Rank'],entry['Hit']) if hkey in lochits: lochits[hkey].append(entry) else: self.warnLog('Local hit (%s) without summary (%s)' % (lkey,hkey)) gffdb = self.db().copyTable(locdb,'%sgff' % locdb.name()[:3]) gffdb.addField('type',evalue='similarity') #!# Add cds and gene types gffdb.addField('attributes',evalue='') #!# Add cds and gene types e2gfields = [('Hit','seqid'), ('HitStart','start'), ('HitEnd','end'), ('Phase','phase'), ('Score','score'), ('HitStrand','strand')] gfields = string.split('seqid source type start end score strand phase attributes') # ID is unique # Name is not unique # Parent links exons or cds to gene geneid = {} for hkey in sumdb.dataKeys(): entry = sumdb.data(hkey) entry['Phase'] = '.' entry['AlnID'] = entry['Rank'] geneid[hkey] = '%s-%d' % (entry['Qry'],entry['Rank']) entry['attributes'] = 'ID=%s;Name=%s;' % (geneid[hkey],geneid[hkey]) if 'QryDesc' in sumdb.fields(): entry['attributes'] += 'Note=Similar to %s;' % (entry['QryDesc']) if exmodel in ['est2genome','protein2genome']: entry['type'] = 'gene' else: entry['type'] = 'similarity' gffdb.addEntry(entry) for lkey in locdb.dataKeys(): entry = gffdb.data(lkey) hkey = (entry['Qry'],entry['Rank'],entry['Hit']) if exmodel in ['est2genome','protein2genome']: entry['type'] = 'CDS' entry['attributes'] = 'ID=%s:%s;Parent=%s;Name=%s-%s;' % (geneid[hkey],entry['type'],geneid[hkey],geneid[hkey],entry['AlnID']) gffdb.addField('source',evalue='rje_apollo:exonerate:%s' % exmodel) qrytype = 'Qry' for entry in gffdb.entries(): if entry['HitStart'] > entry['HitEnd']: [entry['HitStart'], entry['HitEnd']] = [entry['HitEnd'],entry['HitStart']] entry['attributes'] += 'qstart=%s;' % min(entry['%sStart' % qrytype],entry['%sEnd' % qrytype]) entry['attributes'] += 'qend=%s;' % max(entry['%sStart' % qrytype],entry['%sEnd' % qrytype]) if 'QryLen' in entry and entry['QryLen']: field = 'QryLen' entry['attributes'] += 'qrylen=%s;' % (entry[field]) entry['attributes'] += 'identity=%s;' % (entry['Identity']) entry['attributes'] += 'score=%s;' % (entry['Score']) entry['attributes'] = entry['attributes'][:-1] for (ef,gf) in e2gfields: if ef in gffdb.fields(): gffdb.renameField(ef,gf) else: gffdb.addField(gf,evalue='.') gffdb.newKey(['seqid','start','AlnID','end','type','source','attributes']) gffdb.keepFields(gfields+['AlnID']) ### ~ [2] Output GFF File ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ### if filename: gcomments = ['##gff-version 3','#Generated by %s' % self.log.runDetails()] if not self.getStrLC('Rest'): gcomments.append('#Full Command List: %s' % rje.argString(rje.tidyArgs(self.log.cmd_list))) gffdb.saveToFile(filename,delimit='\t',backup=True,append=False,savefields=gfields,log=True,headers=False,comments=gcomments) return gffdb except: self.errorLog('%s.gff3 error' % self.prog()); raise
def setup(self): ### Main class setup method. '''Main class setup method.''' try: ### ~ [1] ~ Setup Program ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ### self.obj['Prog'] = None prog = self.getStrLC('Name') if prog in mod: i = self.obj['ProgInfo'] = mod[prog].makeInfo() self.printLog( '#PROG', '%s V%s: %s' % (i.program, i.version, i.description)) progcmd = rje.getCmdList( [], info=i) + self.cmd_list + ['newlog=F'] out = rje.Out(cmd_list=progcmd) out.printIntro(i) #self.debug(prog); self.debug(progcmd) if self.getBool('Help'): progcmd = mod[prog].cmdHelp(i, out, ['help'] + progcmd) self.printLog('#CMD', 'Full %s CmdList: %s' % (i.program, rje.argString( rje.tidyArgs(progcmd, nopath=self.getStrLC('Rest') and not self.dev(), purgelist=purgelist))), screen=False) #self.debug(prog); self.debug(progcmd) ## ~ [1a] ~ Make self.obj['Prog'] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ## if prog in ['seqlist', 'rje_seqlist']: self.obj['Prog'] = rje_seqlist.SeqList(self.log, progcmd) elif prog in ['uniprot', 'rje_uniprot']: self.obj['Prog'] = rje_uniprot.UniProt(self.log, progcmd) elif prog in ['taxonomy', 'rje_taxonomy']: self.obj['Prog'] = rje_taxonomy.Taxonomy(self.log, progcmd) elif prog in ['tree', 'rje_tree']: self.obj['Prog'] = rje_tree.Tree(self.log, progcmd) elif prog in ['xref', 'rje_xref']: self.obj['Prog'] = rje_xref.XRef(self.log, progcmd) elif prog in ['seq', 'rje_seq']: self.obj['Prog'] = rje_seq.SeqList(self.log, progcmd) elif prog in ['mitab', 'rje_mitab']: self.obj['Prog'] = rje_mitab.MITAB(self.log, progcmd) elif prog in ['dbase', 'database']: self.obj['Prog'] = rje_dbase.DatabaseController( self.log, progcmd) elif prog in ['pydocs']: self.obj['Prog'] = rje_pydocs.PyDoc(self.log, progcmd) elif prog in ['ensembl', 'rje_ensembl']: self.obj['Prog'] = rje_ensembl.EnsEMBL(self.log, progcmd) elif prog in ['genbank', 'rje_genbank']: self.obj['Prog'] = rje_genbank.GenBank(self.log, progcmd) elif prog in ['extatic']: self.obj['Prog'] = extatic.ExTATIC(self.log, progcmd) elif prog in ['revert']: self.obj['Prog'] = revert.REVERT(self.log, progcmd) elif prog in ['fiesta']: self.obj['Prog'] = fiesta.FIESTA(self.log, progcmd) elif prog in ['gablam']: self.obj['Prog'] = gablam.GABLAM(self.log, progcmd) elif prog in ['gopher']: self.obj['Prog'] = gopher.Gopher(self.log, progcmd) elif prog in ['haqesac']: self.obj['Prog'] = haqesac.HAQESAC(self.log, progcmd) elif prog in ['multihaq']: self.obj['Prog'] = multihaq.MultiHAQ(self.log, progcmd) elif prog in ['pingu']: self.obj['Prog'] = pingu.PINGU(self.log, progcmd) elif prog in ['pacbio']: self.obj['Prog'] = rje_pacbio.PacBio(self.log, progcmd) elif prog in ['rje_zen', 'zen']: self.obj['Prog'] = rje_zen.Zen(self.log, progcmd) ### ~ [2] ~ Failure to recognise program ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ### if not self.obj['Prog']: self.printLog( '#ERR', 'Program "%s" not recognised.' % self.getStr('Name')) if self.i() < 0: return False if rje.yesNo('Show SeqSuite help with program options?'): extracmd = cmdHelp(cmd_list=['help'])[1:] if extracmd: self.cmd_list += extracmd self._cmdList() if prog != self.getStrLC('Name'): return self.setup() self.setStr({ 'Name': rje.choice('Give program name (Blank or CTRL+C to quit)') }) if self.getStrLC('Name'): return self.setup() else: return False return self.obj['Prog'] # Setup successful except KeyboardInterrupt: return False except SystemExit: raise except: self.errorLog('Problem during %s setup.' % self.prog()) return False # Setup failed