Beispiel #1
0
def makeInfo(): ### Makes Info object which stores program details, mainly for initial print to screen.
    '''Makes Info object which stores program details, mainly for initial print to screen.'''
    (program, version, last_edit, copyright) = ('ProDigIS', '0.2', 'June 2011', '2011')
    description = 'Protein Digestion In Silico'
    author = 'Dr Richard J. Edwards.'
    comments = ['This program is still in development and has not been published.',rje_zen.Zen().wisdom()]
    return rje.Info(program,version,last_edit,description,author,time.time(),copyright,comments)
Beispiel #2
0
 def readSLiMSearchOcc(self,motifs=[]):   ### Reads SLiMSearch results into data dictionary
     '''Reads SLiMSearch results into data dictionary.'''
     try:### ~ [1] Read ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ###
         if not motifs: self.printLog('#OCC','Cannot process occurrences for No motifs!')
         occfile = '%s.csv' % self.info['ResFile']
         delimit = rje.delimitFromExt(filename=occfile)
         data = rje.dataDict(self,occfile,mainkeys=['Motif','Seq','Start_Pos','End_Pos'],datakeys=string.split('Seq,Desc,Start_Pos,End_Pos,Cons,HomNum,GlobID,LocID,Hyd,SA',','))
         self.dict['Occ'] = {}
         ### ~ [2] Process ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ###
         (mx,ox,otot) = (0,0.0,len(data))
         for occ in data:
             self.progLog('\r#OCC','Processing occurrences (%d motifs): %.2f%%' % (mx,ox/otot)); ox += 100.0
             #x#self.deBug('%s vs MinHom %d' % (data[occ],self.stat['MinHom']))
             if string.atoi(data[occ]['HomNum']) < self.stat['MinHom']: continue
             (motif,seq,start,end) = string.split(occ,delimit)
             if motif not in motifs: continue
             try:
                 gene = rje.matchExp('gene:(\S+)\]',data[occ]['Desc'])[0]
                 self.deBug('%s:%s' % (gene,self.ensGO(gene)))
                 if not self.ensGO(gene): continue
             except: continue
             if motif[-3:] == 'rev': (motif,type) = (motif[:-4],'Rev')
             elif motif[-5:] == 'scram': (motif,type) = (motif[:-6],'Scr')
             else: type = 'ELM'
             if motif not in self.dict['Occ']: self.dict['Occ'][motif] = {}; mx += 1
             if type not in self.dict['Occ'][motif]: self.dict['Occ'][motif][type] = {}
             if gene not in self.dict['Occ'][motif][type]: self.dict['Occ'][motif][type][gene] = []
             self.dict['Occ'][motif][type][gene].append(data[occ])
         self.printLog('\r#OCC','Processed %s occurrences: %d motifs with GO-links' % (rje.integerString(otot),mx))
     except: self.log.errorLog(rje_zen.Zen().wisdom())
Beispiel #3
0
def makeInfo():     ### Makes Info object
    '''Makes rje.Info object for program.'''
    (program, version, last_edit, copyright) = ('RJE_TM', '1.2', 'August 2007', '2007')
    description = 'Transmembrane and SignalP Module'
    author = 'Dr Richard J. Edwards.'
    comments = ['This program is under development and may contain bugs!',rje_zen.Zen().wisdom()]
    return rje.Info(program,version,last_edit,description,author,time.time(),copyright,comments)
Beispiel #4
0
def runMain():
    ### ~ [1] ~ Basic Setup of Program  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ###
    try:
        (info, out, mainlog, cmd_list) = setupProgram()
    except SystemExit:
        return
    except:
        print 'Unexpected error during program setup:', sys.exc_info()[0]
        return

    ### ~ [2] ~ Rest of Functionality... ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ###
    try:  #NewClass(mainlog,cmd_list).run()
        print rje_zen.Zen().wisdom(
        ), '\n\n *** No standalone functionality! *** \n\n'

    ### ~ [3] ~ End ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ###
    except SystemExit:
        return  # Fork exit etc.
    except KeyboardInterrupt:
        mainlog.errorLog('User terminated.')
    except:
        mainlog.errorLog('Fatal error in main %s run.' % info.program)
    mainlog.printLog(
        '#LOG',
        '%s V:%s End: %s\n' % (info.program, info.version,
                               time.asctime(time.localtime(time.time()))))
Beispiel #5
0
def makeInfo(): ### Makes Info object which stores program details, mainly for initial print to screen.
    '''Makes Info object which stores program details, mainly for initial print to screen.'''
    (program, version, last_edit, copyright) = ('RJE_SSDS', '0.0', 'December 2009', '2009')
    description = 'SSDS Batch Wrapper'
    author = 'Dr Richard J. Edwards.'
    comments = ['This program is still in development and has not been published.',rje_zen.Zen().wisdom()]
    return rje.Info(program,version,last_edit,description,author,time.time(),copyright,comments)
Beispiel #6
0
 def makePPIDatasets(self):  ### Generate PPI datasets from pairwise data
     '''Generate PPI datasets from pairwise data.'''
     try:  ### ~ [1] Setup ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ###
         rje.mkDir(self, 'YeastPPI/')
         seqdict = self.dict['SeqDict']
         ### ~ [2] Parse data ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ###
         (hx, htot, fx) = (0.0, len(self.dict['PPI']), 0)
         for hub in rje.sortKeys(self.dict['PPI']):
             self.progLog(
                 '\r#FAS', 'Generating %s PPI fasta files: %.2f' %
                 (rje.integerString(fx), hx / htot))
             hx += 100.0
             if len(self.dict['PPI'][hub]) < 3: continue
             seqs = []
             for spoke in self.dict['PPI'][hub]:
                 if spoke not in seqdict: continue
                 seqs.append(seqdict[spoke])
             if len(seqs) < 3: continue
             self.obj['SeqList'].saveFasta(seqs,
                                           rje.makePath('YeastPPI/%s.fas' %
                                                        hub,
                                                        wholepath=True),
                                           log=False)
             fx += 1
         self.printLog(
             '\r#FAS',
             'Generation of %s PPI fasta files from %s hubs complete.' %
             (rje.integerString(fx), rje.integerString(htot)))
     except:
         self.errorLog(rje_zen.Zen().wisdom())
         raise  # Delete this if method error not terrible
Beispiel #7
0
    def run(self):  ### Main run method
        '''Main run method.'''
        try:  ### ~ [1] ~ Setup ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ###
            self.setup()
            ### ~ [2] ~ Add main run code here ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ###
            sx = 0.0
            stot = len(self.list['TrueMarks'])
            for m in self.list['TrueMarks']:
                self.progLog('\r#MARK',
                             'Marking students %.2f%%' % (sx / stot))
                sx += 100.0
                self.list['Marking'].append(
                    int(random.gauss(m, self.stat['Accuracy']) + 0.5))
                self.list['Marking'][-1] = min(
                    100.0, max(self.list['Marking'][-1], 0.0))
                self.list['Rounded'].append(
                    self._roundMark(self.list['Marking'][-1]))
                self.list['MarkErr'].append(
                    rje.modulus(self.list['Marking'][-1] - float(m)))
                self.list['RoundErr'].append(
                    rje.modulus(self.list['Rounded'][-1] - float(m)))
            self.printLog('\r#MARK', 'Marking students %.2f%%' % (sx / stot))
            ### ~ [3] ~ Report ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ###
            realerr = rje.meansd(self.list['MarkErr'])
            rounderr = rje.meansd(self.list['RoundErr'])
            self.printLog(
                '#EXAM',
                'Model=%s; Accuracy=%.1f; RealErr=%.2f +/- %.2f (Max %d); RoundErr=%.2f +/- %.2f  (Max %d)'
                % (self.info['Generate'], self.stat['Accuracy'], realerr[0],
                   realerr[1], max(self.list['MarkErr']), rounderr[0],
                   rounderr[1], max(self.list['RoundErr'])))

        except:
            self.errorLog(rje_zen.Zen().wisdom())
            raise  # Delete this if method error not terrible
Beispiel #8
0
def makeInfo(): ### Makes Info object which stores program details, mainly for initial print to screen.
    '''Makes Info object which stores program details, mainly for initial print to screen.'''
    (program, version, last_edit, copyright) = ('SeqMapper', '2.0', 'February 2013', '2006')
    description = 'Sequence Mapping Program'
    author = 'Dr Richard J. Edwards.'
    comments = ['This program is still in development and has not been published.',rje_zen.Zen().wisdom()]
    return rje.Info(program,version,last_edit,description,author,time.time(),copyright,comments)
Beispiel #9
0
def makeInfo():     ### Makes Info object
    '''Makes rje.Info object for program.'''
    (program, version, last_edit, copy_right) = ('RJE_QSUB', '1.9.2', 'May 2018', '2006')
    description = 'QSub Generating module'
    author = 'Dr Richard J. Edwards.'
    comments = [rje_zen.Zen().wisdom()]
    return rje.Info(program,version,last_edit,description,author,time.time(),copy_right,comments)
Beispiel #10
0
def makeInfo(): ### Makes Info object which stores program details, mainly for initial print to screen.
    '''Makes Info object which stores program details, mainly for initial print to screen.'''
    (program, version, last_edit, cyear) = ('RJE_HTML', '0.3.0', 'April 2018', '2010')
    description = 'RJE HTML Module'
    author = 'Dr Richard J. Edwards.'
    comments = ['This program is still in development and has not been published.',rje_zen.Zen().wisdom()]
    return rje.Info(program,version,last_edit,description,author,time.time(),cyear,comments)
Beispiel #11
0
def makeInfo():     ### Makes Info object
    '''Makes rje.Info object for program.'''
    (program, version, last_edit, copyright) = ('RJE_SLiMFunGo', '0.0', 'June 2008', '2008')
    description = 'SLiM Functional GO classification module'
    author = 'Dr Richard J. Edwards.'
    comments = ['This program is still in development and has not been published.',rje_zen.Zen().wisdom()]
    return rje.Info(program,version,last_edit,description,author,time.time(),copyright,comments)
Beispiel #12
0
def makeInfo(): ### Makes Info object which stores program details, mainly for initial print to screen.
    '''Makes Info object which stores program details, mainly for initial print to screen.'''
    (program, version, last_edit, copyright) = ('PICSI', '1.2', 'March 2014', '2010')
    description = 'Proteomics Identification from Cross-Species Inference'
    author = 'Dr Richard J. Edwards.'
    comments = ['This program is still in development and has not been published.',rje_zen.Zen().wisdom()]
    return rje.Info(program,version,last_edit,description,author,time.time(),copyright,comments)
Beispiel #13
0
def makeInfo():     ### Makes Info object
    '''Makes rje.Info object for program.'''
    (program, version, last_edit, copyright) = ('RJE_GO', '1.2', 'May 2010', '2008')
    description = 'Gene Ontology Parsing/Manipulation Module'
    author = 'Dr Richard J. Edwards.'
    comments = ['This program is still in development and has not been published.',rje_zen.Zen().wisdom()]
    return rje.Info(program,version,last_edit,description,author,time.time(),copyright,comments)
Beispiel #14
0
def makeInfo(): ### Makes Info object which stores program details, mainly for initial print to screen.
    '''Makes Info object which stores program details, mainly for initial print to screen.'''
    (program, version, last_edit, copyyear) = ('rje_samtools', '0.2.0', 'December 2015', '2013')
    description = 'RJE SAMtools parser and processor'
    author = 'Dr Richard J. Edwards.'
    comments = ['This program is still in development and has not been published.',rje_zen.Zen().wisdom()]
    return rje.Info(program,version,last_edit,description,author,time.time(),copyyear,comments)
Beispiel #15
0
 def loadAlias(self, sourcefile):  ### Loads Alias data
     '''
     Loads Alias data.
     >> sourcefile:str = Source filename
     '''
     try:  ### ~ [1] Load Data ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ###
         if sourcefile.lower() in ['', 'none']: return
         if not os.path.exists(sourcefile):
             return self.log.errorLog('Alias file "%s" not found' %
                                      (sourcefile),
                                      printerror=False)
         data = rje.dataDict(self,
                             sourcefile,
                             datakeys=['Aliases'],
                             lists=True)
         ### ~ [2] Parse out Data ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ###
         (hx, htot) = (0.0, len(data))
         for id in data:
             self.log.printLog('\r#ALIAS',
                               'Processing %s: %.1f%%' %
                               (sourcefile, hx / htot),
                               newline=False,
                               log=False)
             hx += 100.0
             ## ~ [2a] Update self.dict ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ##
             for alist in data[id]['Aliases']:
                 for alias in string.split(alist, ','):
                     self.addAlias(id, alias)
             if id in self.dict['Aliases']: self.dict['Aliases'][id].sort()
         self.log.printLog(
             '\r#ALIAS', 'Processed %s: %s IDs with aliases' %
             (sourcefile, rje.integerString(len(self.dict['Aliases']))))
     except:
         self.log.errorLog(rje_zen.Zen().wisdom())
Beispiel #16
0
def makeInfo(): ### Makes Info object which stores program details, mainly for initial print to screen.
    '''Makes Info object which stores program details, mainly for initial print to screen.'''
    (program, version, last_edit, copyright) = ('SLiMGOER', '0.1', 'September 2008', '2008')
    description = 'Short Linear Motif GO Enrichment of RLC'
    author = 'Dr Richard J. Edwards.'
    comments = ['This program is still in development and has not been published.',rje_zen.Zen().wisdom()]
    return rje.Info(program,version,last_edit,description,author,time.time(),copyright,comments)
Beispiel #17
0
 def grouping(self):  ### Calculates grouping vector
     '''Calculates grouping vector.'''
     try:### ~ [1] Setup ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ###
         methodlist = ['triplets','codons','casechange','case','disorder']
         method = self.info['SeqGroup'].lower()
         if method not in methodlist:
             self.errorLog('SeqGroup method "%s" not recognised!' % method,printerror=False)
             self.errorLog('Check seqgroup=%s' % string.join(methodlist,'/'),printerror=False)
             raise ValueError
         ### ~ [2] Calculate ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ###
         if method == 'triplets': self.list['SeqGroup'] = self.triplets()
         elif method == 'codons': self.list['SeqGroup'] = self.codons()
         elif method == 'casechange': self.list['SeqGroup'] = self.caseChange()
         elif method == 'case': self.list['SeqGroup'] = self.case()
         elif method == 'disorder':
             if self.opt['QryGaps']: self.list['SeqGroup'] = self.qry().gappedDisorder()
             else: self.list['SeqGroup'] = self.qry().gappedDisorder(gap=None)
             for i in range(self.qry().seqLen()):
                 if self.list['SeqGroup'][i]:
                     if self.list['SeqGroup'][i] > self.qry().obj['Disorder'].stat['IUCut']: self.list['SeqGroup'][i] = 'Dis'
                     else: self.list['SeqGroup'][i] = 'Ord'
         elif os.path.exists(method):
             self.list['SeqGroup'] = rje.listFromCommand(method,checkfile=True)
             self.printLog('#GRP','Vector of %s group values read from %s' % (len(self.list['SeqGroup']),method))
     except: self.errorLog(rje_zen.Zen().wisdom()); raise   
Beispiel #18
0
def makeInfo(): ### Makes Info object which stores program details, mainly for initial print to screen.
    '''Makes Info object which stores program details, mainly for initial print to screen.'''
    (program, version, last_edit, copyright) = ('SCAP', '0.0', 'January 2009', '2009')
    description = 'Sequence Composition Assessment of Peptides'
    author = 'Dr Richard J. Edwards.'
    comments = ['This program is still in development and has not been published.',rje_zen.Zen().wisdom()]
    return rje.Info(program,version,last_edit,description,author,time.time(),copyright,comments)
Beispiel #19
0
 def posPercID(self,gaps=True,xval=0.0,default=1.0,comp=None):  ### Returns a list of absolute pecentage conservation across each position
     '''
     Returns a list of absolute pecentage conservation across each position.
     >> gaps:bool [True] = Whether to include gapped sequences in calculation [True]
     >> xval:num [0.0] = The value (0-1) to give undefined residues matching defined residues
     >> default:num [1.0] = Value to return if no homologues for position
     >> comp:Sequence object = sequence for pairwise comparison
     '''
     try:### ~ [1] Setup ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ###
         qry = self.qry()
         if comp: compseq = [comp]
         else: compseq = self.seqs()[0:]; compseq.remove(qry)
         poslist = [default] * qry.seqLen()    # List of percentage ID values
         xval = min(1.0,max(0.0,xval))
         ### ~ [2] Calculate ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ###
         for r in range(qry.seqLen()):
             q = qry.info['Sequence'].upper()[r]
             i = 0.0; n = 0
             for seq in compseq:
                 s = seq.info['Sequence'].upper()[r]
                 if s == q: i += 1; n += 1
                 elif 'X' in [s,q]: i += xval; n += 1
                 elif s == '-' and not gaps: continue
                 else: n += 1
             if n: poslist[r] = i / n
         return poslist
     except: self.errorLog(rje_zen.Zen().wisdom()); raise
Beispiel #20
0
 def loadXRef(self):  ### Load Identifier XRef Data
     '''Load Identifier XRef Data.'''
     try:  ### ~ [1] Setup ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ###
         if rje.exists('%s.xref.tdt' %
                       self.info['Basefile']) and not self.opt['Force']:
             return self.db().addTable('%s.xref.tdt' %
                                       self.info['Basefile'],
                                       mainkeys=['#'],
                                       datakeys='All',
                                       name='XRef')
         if not rje.checkForFile(self.info['XRef']): return False
         changehead = {
             'Ensembl Gene ID': 'EnsG',
             'Ensembl Protein ID': 'EnsP',
             'Associated Gene Name': 'Gene',
             'Associated Gene DB': 'GeneDB',
             'UniProt/SwissProt ID': 'UniprotID',
             'UniProt/SwissProt Accession': 'UniProt',
             'SGD Gene': 'SGD'
         }
         ### ~ [2] Load data ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ###
         xref = self.db().addTable(self.info['XRef'],
                                   mainkeys='All',
                                   datakeys='All',
                                   name='XRef')
         for field in changehead:
             if field in xref.fields():
                 xref.renameField(field, changehead[field])
         xref.saveToFile('%s.xref.tdt' % self.info['Basefile'])
         return xref
     except:
         self.errorLog(rje_zen.Zen().wisdom())
         raise  # Delete this if method error not terrible
Beispiel #21
0
def makeInfo(): ### Makes Info object which stores program details, mainly for initial print to screen.
    '''Makes Info object which stores program details, mainly for initial print to screen.'''
    (program, version, last_edit, copyright) = ('RJE_PRICE', '0.0', 'August 2009', '2009')
    description = 'Experimental Price Equation Tool'
    author = 'Dr Richard J. Edwards & Dr Joel D. Parker.'
    comments = ['This program is still in development and has not been published.',rje_zen.Zen().wisdom()]
    return rje.Info(program,version,last_edit,description,author,time.time(),copyright,comments)
Beispiel #22
0
 def run(self, gtext=''):  ### Main run method
     '''Main run method.'''
     try:  ### ~ [1] ~ Setup ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ###
         self.setup(gtext)
         ### ~ [2] ~ Add main run code here ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ###
         html = self.glossaryHTML()
         hobj = self.obj['HTML']
         date = string.split(time.asctime(time.localtime(time.time())))
         date = '%s %s %s' % (date[2], date[1], date[-1])
         hobj.info['Copyright'] += '. Generated by rje_glossary.py'
         title = '%s' % self.getStr('Name')
         tabber = self.getStr('HTMLStyle').lower() == 'tab'
         frontpage = True
         html = '%s\n\n%s\n\n%s' % (hobj.htmlHead(
             title, tabber, frontpage), html, hobj.htmlTail(tabber))
         if not gtext:  # Replace with CGI option
             rje.backup(self, self.getStr('OutFile'), appendable=False)
             open(self.getStr('OutFile'), 'w').write(html)
             self.printLog(
                 '#HTML',
                 '%s HTML output to %s' % (title, self.getStr('OutFile')))
         return html
     except:
         self.errorLog(rje_zen.Zen().wisdom())
         raise  # Delete this if method error not terrible
Beispiel #23
0
 def run(self):  ### Main run method
     '''Main run method.'''
     try:  ### ~ [0] Setup ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ###
         if self.opt['MakeFlySeq']: self.makeFlySeq()
         if self.opt['Codons']: self.codons()
     except:
         self.log.errorLog(rje_zen.Zen().wisdom())
Beispiel #24
0
 def run(self):  ### Main run method
     '''Main run method.'''
     try:  ### ~ [1] ~ Setup ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ###
         if not self.setup(): return
         ### ~ [2] ~ Add main run code here ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ###
         tables = self.db().tables()[0:]
         ## ~ [2a] ~ Calculate Differences ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ##
         for table1 in tables:
             for table2 in tables[tables.index(table1) + 1:]:
                 self.difference(table1, table2)
         ## ~ [2b] ~ Calculate Averages & Generate HTML ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ##
         for table in self.db().tables()[0:]:
             self.average(table)
         ## ~ [2c] ~ Output HTML ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ##
         if self.getBool('TopHTML'):
             html = rje_html.HTML(self.log, self.cmd_list)
             hfile = '%s.html' % self.basefile()
             rje.backup(self, hfile)
             open(hfile, 'w').write(
                 html.htmlHead(title=self.basefile(), tabber=False) +
                 self.getStr('TopHTML') + html.htmlTail(False))
         return
     except:
         self.errorLog(rje_zen.Zen().wisdom())
         raise  # Delete this if method error not terrible
Beispiel #25
0
 def report(self):  ### Run qstat to get job list then showstart on each job
     '''Run qstat to get job list then showstart on each job .'''
     try:  ### ~ [1] ~ Setup ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ###
         qidlist = []
         qidjob = {}
         ### ~ [2] ~ Read in List of IDs ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ###
         for qline in os.popen('qstat'):
             try:
                 (qid, job) = rje.matchExp('^(\d+)\.\S+\s+(\S+)', qline)
                 qidlist.append(qid)
                 qidjob[qid] = job
             except:
                 continue
         ### ~ [3] ~ Report ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ###
         self.printLog('#QSTAT', '%d jobs in queue.' % len(qidlist))
         for qid in qidlist:
             self.printLog('#JOB',
                           '%s = %s' % (qid, qidjob[qid]),
                           timeout=False)
             for qline in os.popen('showstart %s' % qid):
                 if rje.chomp(qline):
                     self.printLog('#INFO', qline, timeout=False)
         self.printLog('#ZEN', rje_zen.Zen().wisdom())
     except:
         self.errorLog('QSub.report problem')
Beispiel #26
0
def makeInfo(): ### Makes Info object which stores program details, mainly for initial print to screen.
    '''Makes Info object which stores program details, mainly for initial print to screen.'''
    (program, version, last_edit, copyright) = ('RJE_CODONS', '0.1', 'August 2011', '2011')
    description = 'RJE Codon Usage module'
    author = 'Dr Richard J. Edwards.'
    comments = ['This program is still in development and has not been published.',rje_zen.Zen().wisdom()]
    return rje.Info(program,version,last_edit,description,author,time.time(),copyright,comments)
Beispiel #27
0
 def makeGOFile(self):   ### Maps GO to sequences and outputs table for R analysis
     '''Maps GO to sequences and outputs table for R analysis.'''
     try:### ~ [1] ~ Setup ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ###
         outfile = '%s.goer.tdt' % self.info['ResFile']
         headers = ['GOID','Motif','Type','Gene','Cons','HomNum','GlobID','LocID','Hyd','SA']
         rje.delimitedFileOutput(self,outfile,headers,rje_backup=True)
         ### ~ [2] ~ Work through dictionary and output data ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ###
         (mx,mtot) = (-100.0,len(self.dict['Occ']))
         for motif in rje.sortKeys(self.dict['Occ']):
             mx += 100.0; self.progLog('\r#OUT','Generating %s output: %.1f%% (%s|CheckSeq)         ' % (outfile,(mx/mtot),motif))
             ## ~ [2a] ~ Check MinOcc in terms of sequences ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ##
             for type in rje.sortKeys(self.dict['Occ'][motif]):
                 if len(self.dict['Occ'][motif][type]) < self.stat['MinOcc']: self.dict['Occ'][motif].pop(type)
             if 'ELM' not in self.dict['Occ'][motif] or len(self.dict['Occ'][motif]) < 2: continue
             for type in self.dict['Occ'][motif]:
                 ## ~ [2b] ~ Map GO terms and check MinOcc ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ##
                 self.progLog('\r#OUT','Generating %s output: %.1f%% (%s|Check%s) ' % (outfile,(mx/mtot),motif,type)); 
                 godict = {}     # Temp dictionary of {GOID:[Seqs]}
                 for gene in self.dict['Occ'][motif][type]:
                     for go in self.ensGO(gene):
                         if go not in godict: godict[go] = [gene]
                         else: godict[go].append(gene)
                 self.progLog('\r#OUT','Generating %s output: %.1f%% (%s|OccGO%s) ' % (outfile,(mx/mtot),motif,type)); 
                 for go in rje.sortKeys(godict):
                     if len(godict[go]) < self.stat['MinOcc']: godict.pop(go)
                 ## ~ [2c] ~ Output remaining GO terms occurrences ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ##
                 self.progLog('\r#OUT','Generating %s output: %.1f%% (%s|Output%s)' % (outfile,(mx/mtot),motif,type)); 
                 for go in rje.sortKeys(godict):
                     for gene in godict[go]:
                         for occdict in self.dict['Occ'][motif][type][gene]:
                             datadict = rje.combineDict({'GOID':'GO:%s' % go,'Motif':motif,'Type':type,'Gene':gene},occdict)
                             rje.delimitedFileOutput(self,outfile,headers,datadict=datadict)
             self.printLog('#OUT','Output for %s %s complete.' % (motif,rje.sortKeys(self.dict['Occ'][motif])),screen=False)
         self.printLog('\r#OUT','Generating %s output complete!         ' % (outfile))
     except: self.log.errorLog(rje_zen.Zen().wisdom())
Beispiel #28
0
def makeInfo(): ### Makes Info object which stores program details, mainly for initial print to screen.
    '''Makes Info object which stores program details, mainly for initial print to screen.'''
    (program, version, last_edit, copyright) = ('RJE_MASCOT', '1.2', 'February 2013', '2012')
    description = 'Module for loading, manipulating and saving MASCOT data for BUDAPEST and PICSI'
    author = 'Dr Richard J. Edwards.'
    comments = ['This program is still in development and has not been published.',rje_zen.Zen().wisdom()]
    return rje.Info(program,version,last_edit,description,author,time.time(),copyright,comments)
Beispiel #29
0
def makeInfo():     ### Makes Info object
    '''Makes rje.Info object for program.'''
    (program, version, last_edit, copyyear) = ('RJE_XGMML', '1.0', 'June 2014', '2007')
    description = 'RJE XGMLL Module'
    author = 'Dr Richard J. Edwards.'
    comments = [rje_zen.Zen().wisdom()]
    return rje.Info(program,version,last_edit,description,author,time.time(),copyyear,comments)
Beispiel #30
0
 def run(self):  ### Main run method
     '''Main run method.'''
     try:### ~ [1] ~ Setup ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ###
         self.setup()
         ### ~ [2] ~ Add main run code here ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ###
         return
     except:
         self.errorLog(rje_zen.Zen().wisdom())
         raise   # Delete this if method error not terrible