Beispiel #1
0
def main():
    print >> sys.stderr, "Print the result to screen"
    if len(sys.argv) > 4:
        print >> sys.stderr, 'Using python %s repId locusHasIsoform \
            [annofile]' % sys.argv[0]
        sys.exit(0)
    #----------------------------------------------------
    allIsoformId = readIsoformId(sys.argv[2])
    repIsoformId = readIsoformId(sys.argv[1])
    hasAnno = 0
    if len(sys.argv) == 4:
        hasAnno = 1
        annodict = {}
        readAnno(sys.argv[3], annodict)

    repKL = repIsoformId.keys()
    repKL.sort()
    print "WithRep\tNoRep\tAnno\tGene Ontology\tInterpro"
    for repK in repKL:
        if repK not in allIsoformId:
            continue
        repVL = repIsoformId[repK]
        lenRepVL = len(repVL)
        allVL = allIsoformId[repK]
        lenAllVL = len(allVL)
        #----------diff-------------------------
        if lenRepVL < lenAllVL:
            repVL.sort()
            allVL.sort()
            #------output-----------------------
            for allV in allVL:
                locus = repK + allV
                print >> sys.stderr, locus
                if hasAnno:
                    if locus in annodict:
                        anno = annodict[locus]
                        anno = anno.replace(r'\\', '\t')
                    if allV in repVL:
                        print "%s\t*\t%s" % (locus, anno)
                    else:
                        print "*\t%s\t%s" % (locus, anno)
                else:
                    if allV in repVL:
                        print "%s\t*" % locus
                    else:
                        print "*\t%s" % locus
Beispiel #2
0
def main():
    print >>sys.stderr, "Print the result to screen"
    if len(sys.argv) > 4:
        print >>sys.stderr, 'Using python %s repId locusHasIsoform \
            [annofile]' % sys.argv[0]
        sys.exit(0)
    #----------------------------------------------------
    allIsoformId = readIsoformId(sys.argv[2])
    repIsoformId = readIsoformId(sys.argv[1])
    hasAnno = 0
    if len(sys.argv) == 4:
        hasAnno = 1
        annodict = {}
        readAnno(sys.argv[3], annodict)

    repKL = repIsoformId.keys()
    repKL.sort()
    print "WithRep\tNoRep\tAnno\tGene Ontology\tInterpro"
    for repK in repKL:
        if repK not in allIsoformId:
            continue
        repVL = repIsoformId[repK]
        lenRepVL = len(repVL)
        allVL = allIsoformId[repK]
        lenAllVL = len(allVL)
        #----------diff-------------------------
        if lenRepVL < lenAllVL:
            repVL.sort()
            allVL.sort()
            #------output-----------------------
            for allV in allVL:
                locus = repK+allV
                print >>sys.stderr, locus
                if hasAnno:
                    if locus in annodict:
                        anno = annodict[locus]
                        anno = anno.replace(r'\\', '\t')
                    if allV in repVL:
                        print "%s\t*\t%s" % (locus, anno)
                    else:
                        print "*\t%s\t%s" % (locus, anno)
                else:
                    if allV in repVL:
                        print "%s\t*" % locus
                    else:
                        print "*\t%s" % locus
Beispiel #3
0
def main():
    print >> sys.stderr, "Paste the mother sequene and related\
 repetition together"

    print >> sys.stderr, "Print the result to screen"
    if len(sys.argv) < 3:
        print >> sys.stderr, 'Using python %s forc repResult \
[anno] [locus] ' % sys.argv[0]
        sys.exit(0)

    seqDict = {}
    readseq(sys.argv[1], seqDict)
    #--------------------------------------------
    isAnno = 0
    if sys.argv[3]:
        isAnno = 1
        annoDict = {}
        readAnno(sys.argv[3], annoDict)
    #--------------------------------------------
    isLoc = 0
    if sys.argv[4]:
        isLoc = 1
        locL = [locus.strip() for locus in open(sys.argv[4])]
    #--------------------------------------------
    for line in open(sys.argv[2]):
        if line[0] == '>':
            output = 1
            locus = line[1:].strip()
            if isLoc and \
                (locus not in locL) and \
                (locus[:-2] not in locL):
                output = 0
                continue
            #------------------------------------
            print '>', locus
            if isAnno and locus in annoDict:
                print annoDict[locus]
            if locus in seqDict:
                print seqDict[locus]
        else:
            if output:
                print line,
Beispiel #4
0
def main():
    print >>sys.stderr, "Paste the mother sequene and related\
 repetition together"
    print >>sys.stderr, "Print the result to screen"
    if len(sys.argv) < 3:
        print >>sys.stderr, 'Using python %s forc repResult \
[anno] [locus] ' % sys.argv[0]
        sys.exit(0)
    
    seqDict = {}
    readseq(sys.argv[1], seqDict)
    #--------------------------------------------
    isAnno = 0
    if sys.argv[3]:
        isAnno = 1
        annoDict = {}
        readAnno(sys.argv[3], annoDict)
    #--------------------------------------------
    isLoc = 0
    if sys.argv[4]:
        isLoc = 1
        locL = [locus.strip() for locus in open(sys.argv[4])]
    #--------------------------------------------
    for line in open(sys.argv[2]):
        if line[0] == '>':
            output = 1
            locus = line[1:].strip()
            if isLoc and \
                (locus not in locL) and \
                (locus[:-2] not in locL):
                output = 0
                continue
            #------------------------------------
            print '>', locus
            if isAnno and locus in annoDict:
                print annoDict[locus]
            if locus in seqDict:
                print seqDict[locus]
        else:
            if output:
                print line,
Beispiel #5
0
def main():
    (options, args) = cmdpara(sys.argv)
    if options.sort:
        print 'sort'
        sys.exit(1)
    else:
        print 'no sort'
        sys.exit(1)
    print >> sys.stderr, "*******Print the result to screen.*******"

    #-------------------macro-------------------------------------
    isRep = 0
    isLoc = 0
    #-------------------------------------------------------------
    if options.seqfile != None:
        seqdict = {}
        ctIO.readseq(options.seqfile, seqdict)
    if options.seqrepfile != None:
        seqdict = {}
        repdict = {}
        ctIO.readseqrep(options.seqrepfile, seqdict, repdict)
        isRep = 1
    if options.repfile != None:
        repdict = {}
        ctIO.readRep(options.repfile, repdict)
        isRep = 1
    if options.locusfile != None:
        locusList = [line.strip() for line in open(options.locusfile)]
        isLoc = 1
    if not isLoc:
        locusList = repdict.keys() if isRep else seqdict.keys()
        locusList.sort()
    if isRep or isLoc:
        annodict = {}
        ctIO.readAnno(options.anno, annodict, 1, locusList)
        interproDict = {}
        ctIO.readInterpro(options.interpro, interproDict, locusList)

    #print locusList
    #print repdict.keys()
    #print repdict
    #print isRep
    #sys.exit(1)
    #----------------------------------------------------------------
    latexHead()
    latexExplain()
    #---------------------------------------------------------------
    for id in locusList:
        if id not in seqdict:
            print >> sys.stderr, "Unknown locus %s" % id
        else:
            hasInterpro = 0
            seq = list(seqdict[id])
            #-------------get newDict--------------------------------
            newDict = {}
            if id in interproDict:
                hasInterpro = 1
                domainDespList = []
                domainPosL = interproDict[id].keys()
                getnewDictDomain(interproDict[id], domainDespList, newDict)
            #------------------------------------------------
            if isRep:
                repDespList = []
                repdictSonL = repdict[id]
                num = len(repdictSonL)
                if not hasInterpro:
                    domainPosL = []
                getnewDictRep(repdictSonL, domainPosL, repDespList, newDict)
                getnewDictRepDesp(id, num, repDespList)
            #----------------get newDict---------------------------
            modifySeq(seq, newDict)
            #---------------------------------------------------------
            shortAnno = ''
            annos = annodict[id].replace('_', r'\_')
            annos = annos.replace('%', r'\%')
            annos = annos.replace('~', r'\~')
            annos = annos.replace('&', r'\&')
            firstBr = annos.find('[')
            if firstBr != -1:
                shortAnno = annos[:firstBr]
            print ''.join((r'\section{', id, ' ', shortAnno, '}'))
            annos = r'\tair{' + id[:-2] + '} ' + annos
            print r'\anno{', annos, '}'

            print r'''
\noindent\begin{minipage}{\textwidth}
\noindent\rule{\textwidth}{2pt}
\DNA!'''
            #--without annotation
            seq = ''.join(seq)
            print seq

            print r'''!
\end{minipage}            
'''
            #------------------------------------------------
            print
            print '.' * 100
            print
            #---------------Rep------------------------------
            if isRep:
                for repSeq in repDespList:
                    print repSeq
                    print
            #-------------Domain desp----------------------
            if hasInterpro:
                print '.' * 100
                print
                for domainDesp in domainDespList:
                    print domainDesp
                    print
            print r'\clearpage'
            print
        #----------------End of else ---one locus-------------
    #----------------END of for ---all locus------------------
    latexTail()
Beispiel #6
0
def main():
    (options, args) = cmdpara(sys.argv)
    print >> sys.stderr, "*******Print the result to screen.*******"

    # -------------------macro-------------------------------------
    isRep = 0
    isLoc = 0
    # -------------------------------------------------------------
    if options.seqfile != None:
        seqdict = {}
        ctIO.readseq(options.seqfile, seqdict)
    if options.seqrepfile != None:
        seqdict = {}
        repdict = {}
        ctIO.readseqrep(options.seqrepfile, seqdict, repdict)
        isRep = 1
    if options.repfile != None:
        repdict = {}
        ctIO.readRep(options.repfile, repdict)
        isRep = 1
    if options.locusfile != None:
        locusList = [line.strip() for line in open(options.locusfile)]
        isLoc = 1
    if not isLoc:
        locusList = repdict.keys() if isRep else seqdict.keys()
    if isRep or isLoc:
        annodict = {}
        ctIO.readAnno(options.anno, annodict, 1, locusList)
        interproDict = {}
        ctIO.readInterpro(options.interpro, interproDict, locusList)

    # print locusList
    # print repdict.keys()
    # print repdict
    # print isRep
    # sys.exit(1)
    # ----------------------------------------------------------------
    latexHead()
    latexExplain()
    # ---------------------------------------------------------------
    for id in locusList:
        if id not in seqdict:
            print >> sys.stderr, "Unknown locus %s" % id
        else:
            hasInterpro = 0
            seq = list(seqdict[id])
            # -------------get newDict--------------------------------
            newDict = {}
            if id in interproDict:
                hasInterpro = 1
                domainDespList = []
                domainPosL = interproDict[id].keys()
                getnewDictDomain(interproDict[id], domainDespList, newDict)
            # ------------------------------------------------
            if isRep:
                repDespList = []
                repdictSonL = repdict[id]
                num = len(repdictSonL)
                if not hasInterpro:
                    domainPosL = []
                getnewDictRep(repdictSonL, domainPosL, repDespList, newDict)
                getnewDictRepDesp(id, num, repDespList)
            # ----------------get newDict---------------------------
            modifySeq(seq, newDict)
            # ---------------------------------------------------------
            print "".join((r"\section{", id, "}"))
            annos = annodict[id].replace("_", r"\_")
            annos = annos.replace("%", r"\%")
            annos = annos.replace("~", r"\~")
            annos = annos.replace("&", r"\&")
            annos = r"\tair{" + id[:-2] + "} " + annos
            print r"\anno{", annos, "}"

            print r"""
\noindent\begin{minipage}{\textwidth}
\noindent\rule{\textwidth}{2pt}
\DNA!"""
            # --without annotation
            seq = "".join(seq)
            print seq

            print r"""!
\end{minipage}            
"""
            # ------------------------------------------------
            print
            print "." * 100
            print
            # ---------------Rep------------------------------
            if isRep:
                for repSeq in repDespList:
                    print repSeq
                    print
            # -------------Domain desp----------------------
            if hasInterpro:
                print "." * 100
                print
                for domainDesp in domainDespList:
                    print domainDesp
                    print
            print r"\clearpage"
            print
        # ----------------End of else ---one locus-------------
    # ----------------END of for ---all locus------------------
    latexTail()
Beispiel #7
0
def main():
    (options, args) = cmdpara(sys.argv)
    if options.sort:
        print 'sort'
        sys.exit(1)
    else:
        print 'no sort'
        sys.exit(1)
    print >>sys.stderr, "*******Print the result to screen.*******"

    #-------------------macro-------------------------------------
    isRep = 0
    isLoc = 0
    #-------------------------------------------------------------
    if options.seqfile != None:
        seqdict = {}
        ctIO.readseq(options.seqfile, seqdict)
    if options.seqrepfile != None:
        seqdict = {}
        repdict = {}
        ctIO.readseqrep(options.seqrepfile, seqdict, repdict)
        isRep = 1
    if options.repfile != None:
        repdict = {}
        ctIO.readRep(options.repfile, repdict)
        isRep = 1
    if options.locusfile != None:
        locusList = [line.strip() for line in open(options.locusfile)]
        isLoc = 1
    if not isLoc:
        locusList = repdict.keys() if isRep else seqdict.keys()
        locusList.sort()
    if isRep or isLoc:
        annodict = {}
        ctIO.readAnno(options.anno, annodict, 1, locusList)
        interproDict = {}
        ctIO.readInterpro(options.interpro, interproDict, locusList)

    #print locusList
    #print repdict.keys()
    #print repdict
    #print isRep
    #sys.exit(1)
    #----------------------------------------------------------------
    latexHead()
    latexExplain()
    #---------------------------------------------------------------
    for id in locusList:
        if id not in seqdict:
            print >>sys.stderr, "Unknown locus %s" % id
        else:
            hasInterpro = 0
            seq = list(seqdict[id])
            #-------------get newDict--------------------------------
            newDict = {}
            if id in interproDict:
                hasInterpro = 1
                domainDespList = []
                domainPosL = interproDict[id].keys()
                getnewDictDomain(interproDict[id], domainDespList,
                    newDict)
            #------------------------------------------------
            if isRep:
                repDespList = []
                repdictSonL = repdict[id]
                num = len(repdictSonL)
                if not hasInterpro:
                    domainPosL = []
                getnewDictRep(repdictSonL, domainPosL, repDespList, newDict)
                getnewDictRepDesp(id, num, repDespList)
            #----------------get newDict---------------------------           
            modifySeq(seq, newDict)
            #---------------------------------------------------------
            shortAnno = ''
            annos = annodict[id].replace('_', r'\_')
            annos = annos.replace('%', r'\%')
            annos = annos.replace('~', r'\~')
            annos = annos.replace('&', r'\&')
            firstBr = annos.find('[')
            if firstBr != -1:
                shortAnno = annos[:firstBr]
            print ''.join((r'\section{', id, ' ', shortAnno, '}' ))
            annos = r'\tair{' + id[:-2] + '} ' + annos
            print r'\anno{', annos, '}'

            print r'''
\noindent\begin{minipage}{\textwidth}
\noindent\rule{\textwidth}{2pt}
\DNA!'''
            #--without annotation
            seq = ''.join(seq)
            print seq

            print r'''!
\end{minipage}            
'''
            #------------------------------------------------
            print
            print '.' * 100
            print
            #---------------Rep------------------------------
            if isRep:
                for repSeq in repDespList:
                    print repSeq
                    print
            #-------------Domain desp----------------------
            if hasInterpro:
                print '.' * 100
                print
                for domainDesp in domainDespList:
                    print domainDesp
                    print
            print r'\clearpage'
            print
        #----------------End of else ---one locus-------------
    #----------------END of for ---all locus------------------
    latexTail()