예제 #1
0
def plot(pictureFileName,
         sbjctLen,
         sbjctAcc,
         blHits,
         sizeX=700,
         fontsize=4,
         typePlot='png'):
    """ picture output """
    # blHits: list of split (blast m8 line)
    # blHits = [qry, sbjct, % identity, aln length, mismatches, gap, q. start, q. end, s. start, s. end, e-value, bit score]
    gdPlot = genoGd.genoGD(fontsize=fontsize, sizeX=sizeX, nbQuery=len(blHits))
    gdPlot.plotSeq(seqlen=sbjctLen,
                   start=0,
                   stop=sizeX,
                   header=sbjctAcc,
                   color='red',
                   up=True)
    gdPlot._nbligneP()
    rpt = float(sizeX) / sbjctLen
    nbhit = 0
    for blh in blHits:
        head = True
        # if len(blLine[0])<= 10:
        #    header = blLine[0]
        # else:
        #    header = blLine[0][0:10]+'..'
        header = blh[0][8:18] + '..'
        if int(blh[8]) < int(blh[9]):
            gdPlot.plotHit(int(int(blh[8]) * rpt),
                           int(int(blh[9]) * rpt),
                           header,
                           _blastScoreVsColor(float(blh[10])),
                           delta=2,
                           head=head)
            nbhit += 1
            gdPlot._nbligneP()
        else:
            gdPlot.plotHit(int(int(blh[9]) * rpt),
                           int(int(blh[8]) * rpt),
                           header,
                           _blastScoreVsColorInv(float(blh[10])),
                           delta=2,
                           head=head)
            nbhit += 1
            gdPlot._nbligneP()
        head = False

    gdPlot._nbligneP()
    gdPlot.plotSeq(seqlen=sbjctLen,
                   start=0,
                   stop=sizeX,
                   header=sbjctAcc,
                   color='red',
                   up=False)
    gdPlot.legend()
    gdPlot.legendInv()
    if typePlot == 'png' and nbhit > 0:
        picturefh = open(pictureFileName, "w")
        gdPlot.picture.writePng(picturefh)
        picturefh.close()
예제 #2
0
def plotMergeFewPlus(pictureFileName,
                     sbjctLen,
                     sbjctAcc,
                     blHits,
                     sizeX=700,
                     fontsize=4,
                     typePlot='png'):
    """ picture output """
    # blHits: list of split (blast m8 line)
    # blHits = [qry, sbjct, % identity, aln length, mismatches, gap, q. start, q. end, s. start, s. end, e-value, bit score]
    gdPlot = genoGd.genoGD(fontsize=fontsize,
                           sizeX=sizeX,
                           nbQuery=len(blHits) / 60)
    gdPlot.plotSeq(seqlen=sbjctLen,
                   start=0,
                   stop=sizeX,
                   header=sbjctAcc,
                   color='red',
                   up=True)
    gdPlot._nbligneP()
    gdPlot._nbligneP()
    rpt = float(sizeX) / sbjctLen
    nbhit = 1
    i = 0
    nmax = 0
    while i < len(blHits):
        head = False
        header = ''
        end = int(blHits[i][9])
        gdPlot.plotHit(int(int(blHits[i][8]) * rpt),
                       int(int(blHits[i][9]) * rpt),
                       '',
                       _blastScoreVsColor(float(blHits[i][11])),
                       delta=2,
                       head=False)
        n = 0
        while (i < len(blHits) - 1) and (int(blHits[i + 1][8]) < end):
            gdPlot._nbligneP()
            gdPlot.plotHit(int(int(blHits[i + 1][8]) * rpt),
                           int(int(blHits[i + 1][9]) * rpt),
                           header,
                           _blastScoreVsColor(float(blHits[i + 1][11])),
                           delta=2,
                           head=head)
            i += 1
            n += 1
            if n > nmax:
                nmax = n
        gdPlot.nbligne -= n
        i += 1

    gdPlot.nbligne += nmax
    # gdPlot.plotSeq(seqlen=sbjctLen, start=0, stop=sizeX, header=sbjctAcc, color='red', up = False)
    # gdPlot._nbligneP()
    gdPlot.legendMerge()
    if typePlot == 'png' and nbhit > 0:
        picturefh = open(pictureFileName, "w")
        gdPlot.picture.writePng(picturefh)
        picturefh.close()
예제 #3
0
def plotMerge(pictureFileName,
              sbjctLen,
              sbjctAcc,
              blHits,
              sizeX=700,
              fontsize=4,
              typePlot='png'):
    """ picture output """
    # blHits: list of split (blast m8 line)
    # blHits = [qry, sbjct, % identity, aln length, mismatches, gap, q. start, q. end, s. start, s. end, e-value, bit score]
    gdPlot = genoGd.genoGD(fontsize=fontsize, sizeX=sizeX, nbQuery=1)
    gdPlot.plotSeq(seqlen=sbjctLen,
                   start=0,
                   stop=sizeX,
                   header=sbjctAcc,
                   color='red',
                   up=True)
    gdPlot._nbligneP()
    gdPlot._nbligneP()
    rpt = float(sizeX) / sbjctLen
    #     if sbjctLen > float(sizeX):
    #         rpt = float(sizeX) / sbjctLen
    #     else:
    #         rpt = 1
    nbhit = 1
    for blh in blHits:
        head = False
        header = ''

        if int(blh[11]) < int(blh[12]):
            gdPlot.plotHit(int(int(blh[11]) * rpt),
                           int(int(blh[12]) * rpt),
                           header,
                           'lightred',
                           delta=2,
                           head=head)
        else:
            gdPlot.plotHit(int(int(blh[12]) * rpt),
                           int(int(blh[11]) * rpt),
                           header,
                           'blue',
                           delta=2,
                           head=head)
        head = False

    gdPlot._nbligneP()
    # gdPlot.plotSeq(seqlen=sbjctLen, start=0, stop=sizeX, header=sbjctAcc, color='red', up = False)
    # gdPlot._nbligneP()
    gdPlot.legendMerge()
    if typePlot == 'png' and nbhit > 0:
        picturefh = open(pictureFileName, "w")
        gdPlot.picture.writePng(picturefh)
        picturefh.close()