Beispiel #1
0
def plotDihedralD1D2byResType():
    showDataPoints = False
    dihedralName1 = 'Cb4N'
    dihedralName2 = 'Cb4C'
    #    graphicsFormat = "png"

    outputDir = os.path.join(cingDirTmp, 'd1d2')
    if not os.path.exists(outputDir):
        os.mkdir(outputDir)
#        outputDir = cingDirTmp
    os.chdir(outputDir)

    #        ssType = 'E'
    #        resType = 'GLY'
    #        for ssType in histRamaBySsAndResType.keys():
    #            ssTypeForFileName = ssType.replace(' ', '_')
    ssTypeFixed = 'H'
    resTypeListSkip = [
        'CSB', 'GLUH', 'HISE', 'HISH', 'MSE', '', '', '', '', ''
    ]
    for resType in hPlot.histd1BySs0AndResTypes[ssTypeFixed].keys(
    ):  # TODO: check UNTESTED code for attribute histd1BySs0AndResTypes
        #            if resType != 'ARG': # for testing enable filtering.
        #                continue
        if resType in resTypeListSkip:
            continue
        titleStr = 'd1d2 ' + resType
        nTmessage("plotting: %s" % titleStr)
        #            hist = histd1d2BySsAndResType[ssType][resType]

        ps = NTplotSet()  # closes any previous plots
        ps.hardcopySize = (500, 500)

        #                residueName = resType + ""
        x = NTlist(-45, -80, 125)  # outside the range.
        y = NTlist(-65, -63, -125)

        # important to switch to temp space before starting to generate files for the project.
        project = Project('testPlotHistoDihedrald1d2')
        plotparams1 = project.plotParameters.getdefault(
            dihedralName1, 'dihedralDefault')
        plotparams2 = project.plotParameters.getdefault(
            dihedralName2, 'dihedralDefault')

        x.limit(plotparams1.min, plotparams1.max)
        y.limit(plotparams2.min, plotparams2.max)

        plot = NTplot(title=titleStr,
                      xRange=(plotparams1.min, plotparams1.max),
                      xTicks=range(int(plotparams1.min),
                                   int(plotparams1.max + 1),
                                   plotparams1.ticksize),
                      xLabel=dihedralName1,
                      yRange=(plotparams2.min, plotparams2.max),
                      yTicks=range(int(plotparams2.min),
                                   int(plotparams2.max + 1),
                                   plotparams2.ticksize),
                      yLabel=dihedralName2)
        ps.addPlot(plot)

        # Plot a density background
        histList = []
        ssTypeList = hPlot.histd1BySs0AndResTypes.keys(
        )  # TODO: test this untested histd1BySs0AndResTypes parameter
        ssTypeList.sort()  # in place sort to: space, H, S
        for ssType in ssTypeList:
            hist = getDeepByKeys(hPlot.histd1BySs0AndResTypes, ssType, resType)
            if hist != None:
                nTdebug('appending [%s]' % ssType)
                histList.append(hist)
        if histList:
            plot.dihedralComboPlot(histList)
        if showDataPoints:
            myPoint = plusPoint.copy()
            myPoint.pointColor = 'green'
            myPoint.pointSize = 6.0
            myPoint.pointEdgeWidth = 1.0
            myPoint.fill = False
            if resType == 'GLY':
                myPoint.pointType = 'triangle'
            if resType == 'PRO':
                myPoint.pointType = 'square'
            plot.points(zip(x, y), attributes=myPoint)


#            fn = os.path.join('bySsAndResType', ( ssTypeForFileName+"_"+resType+"."+graphicsFormat))
#            fn = os.path.join('byResType', ( resType+"."+graphicsFormat))
#        fn = resType + "_d1d2." + graphicsFormat
#        ps.hardcopy(fn, graphicsFormat)
        plot.show()
Beispiel #2
0
def plotDihedralD1D2byResType():
    showDataPoints = False
    dihedralName1 = 'Cb4N'
    dihedralName2 = 'Cb4C'
#    graphicsFormat = "png"

    outputDir = os.path.join(cingDirTmp, 'd1d2')
    if not os.path.exists(outputDir):
        os.mkdir(outputDir)
#        outputDir = cingDirTmp
    os.chdir(outputDir)

#        ssType = 'E'
#        resType = 'GLY'
#        for ssType in histRamaBySsAndResType.keys():
#            ssTypeForFileName = ssType.replace(' ', '_')
    ssTypeFixed = 'H'
    resTypeListSkip = ['CSB', 'GLUH', 'HISE', 'HISH', 'MSE', '', '', '', '', '']
    for resType in hPlot.histd1BySs0AndResTypes[ssTypeFixed].keys(): # TODO: check UNTESTED code for attribute histd1BySs0AndResTypes
#            if resType != 'ARG': # for testing enable filtering.
#                continue
        if resType in resTypeListSkip:
            continue
        titleStr = 'd1d2 ' + resType
        nTmessage("plotting: %s" % titleStr)
#            hist = histd1d2BySsAndResType[ssType][resType]

        ps = NTplotSet() # closes any previous plots
        ps.hardcopySize = (500, 500)

#                residueName = resType + ""
        x = NTlist(-45, -80, 125) # outside the range.
        y = NTlist(-65, -63, -125)

        # important to switch to temp space before starting to generate files for the project.
        project = Project('testPlotHistoDihedrald1d2')
        plotparams1 = project.plotParameters.getdefault(dihedralName1, 'dihedralDefault')
        plotparams2 = project.plotParameters.getdefault(dihedralName2, 'dihedralDefault')

        x.limit(plotparams1.min, plotparams1.max)
        y.limit(plotparams2.min, plotparams2.max)

        plot = NTplot(title=titleStr,
          xRange=(plotparams1.min, plotparams1.max),
          xTicks=range(int(plotparams1.min), int(plotparams1.max + 1), plotparams1.ticksize),
          xLabel=dihedralName1,
          yRange=(plotparams2.min, plotparams2.max),
          yTicks=range(int(plotparams2.min), int(plotparams2.max + 1), plotparams2.ticksize),
          yLabel=dihedralName2)
        ps.addPlot(plot)

        # Plot a density background
        histList = []
        ssTypeList = hPlot.histd1BySs0AndResTypes.keys() # TODO: test this untested histd1BySs0AndResTypes parameter
        ssTypeList.sort() # in place sort to: space, H, S
        for ssType in ssTypeList:
            hist = getDeepByKeys(hPlot.histd1BySs0AndResTypes, ssType, resType)
            if hist != None:
                nTdebug('appending [%s]' % ssType)
                histList.append(hist)
        if histList:
            plot.dihedralComboPlot(histList)
        if showDataPoints:
            myPoint = plusPoint.copy()
            myPoint.pointColor = 'green'
            myPoint.pointSize = 6.0
            myPoint.pointEdgeWidth = 1.0
            myPoint.fill = False
            if resType == 'GLY':
                myPoint.pointType = 'triangle'
            if resType == 'PRO':
                myPoint.pointType = 'square'
            plot.points(zip(x, y), attributes=myPoint)
#            fn = os.path.join('bySsAndResType', ( ssTypeForFileName+"_"+resType+"."+graphicsFormat))
#            fn = os.path.join('byResType', ( resType+"."+graphicsFormat))
#        fn = resType + "_d1d2." + graphicsFormat
#        ps.hardcopy(fn, graphicsFormat)
        plot.show()