예제 #1
0
파일: d1d2plot.py 프로젝트: VuisterLab/cing
def plotDihedralD1D2():
    dihedralName1 = 'Cb4N'
    dihedralName2 = 'Cb4C'
    graphicsFormat = "png"


    entryId = "1brv" # Small much studied PDB NMR entry
#        entryId = "1hy8" # small, single model, very low scoring entry

    pdbDirectory = os.path.join(cingDirTestsData, "pdb", entryId)
    pdbFileName = "pdb" + entryId + ".ent"
    pdbFilePath = os.path.join(pdbDirectory, pdbFileName)

    # does it matter to import it just now?
    project = Project(entryId)
    project.removeFromDisk()
    project = Project.open(entryId, status='new')
    project.initPDB(pdbFile=pdbFilePath, convention=IUPAC)

#        ssType = 'E'
#        resType = 'GLY'
#        for ssType in histRamaBySsAndResType.keys():
#            ssTypeForFileName = ssType.replace(' ', '_')
    titleStr = 'd1d2 all 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.histd1BySs0.keys() # TODO: check this histd1BySs0 attribute. UNTESTED.
    ssTypeList.sort() # in place sort to: space, H, S
    for ssType in ssTypeList:
        hist = getDeepByKeys(hPlot.histd1BySs0, ssType)
        if hist != None:
            nTdebug('appending [%s]' % ssType)
            histList.append(hist)
    if histList:
        plot.dihedralComboPlot(histList)
#            fn = os.path.join('bySsAndResType', ( ssTypeForFileName+"_"+resType+"."+graphicsFormat))
#            fn = os.path.join('byResType', ( resType+"."+graphicsFormat))


    fpGood = open(project.name + '.testCb2Good.out', 'w')
    fpBad = open(project.name + '.testCb2Bad.out', 'w')

    mCount = project.molecule.modelCount

    for res in project.molecule.A.allResidues():
        triplet = NTlist()
        for i in [-1, 0, 1]:
            triplet.append(res.sibling(i))
        if None in triplet:
            nTdebug('Skipping ' % res)

        else:
            ca_atms = triplet.zap('CA')
            cb_atms = triplet.zap('CB')

            nTdebug("%s %s %s %s" % (res, triplet, ca_atms, cb_atms))

            if None in cb_atms: # skip Gly for now
                nTdebug('Skipping %s' % res)
            else:
                d1 = Dihedral(res, 'Cb4N', range=[0.0, 360.0])
                d1.atoms = [cb_atms[0], ca_atms[0], ca_atms[1], cb_atms[1]]
                d1.calculateValues()
                res['Cb4N'] = d1 # append dihedral to residue

                d2 = Dihedral(res, 'Cb4C', range=[0.0, 360.0])
                d2.atoms = [cb_atms[1], ca_atms[1], ca_atms[2], cb_atms[2]]
                d2.calculateValues()
                res['Cb4C'] = d2 # append dihedral to residue

                bb = getDeepByKeys(res, WHATIF_STR, BBCCHK_STR, VALUE_LIST_STR, 0) # check first one.
                if bb == None:
                    nTdebug('Skipping without BB %s' % res)
                    continue

                if d1.cv < 0.03 and d2.cv < 0.03: # Only include structured residues
                    for i in range(mCount): # Consider each model individually
    #                    bb = res.Whatif.bbNormality.valueList[i]
                        bb = getDeepByKeys(res, WHATIF_STR, BBCCHK_STR, VALUE_LIST_STR, i)
                        if bb == None:
                            nTdebug('Skipping without BB %s' % res)
                            continue
                        angles = NTlist() # store phi, psi, chi1, chi2
                        for angle in ['PHI', 'PSI', 'CHI1', 'CHI2']:
                            if res.has_key(angle):
                                angles.append(res[angle][i])
                            else:
                                angles.append(0.0)
                        #end for
                        if bb < 20.0: # Arbitrary 20 bb occurences as cuttoff for now
                            fprintf(fpBad,  '%4d   %7.2f  %7.2f  %7.2f  %s  %s %s\n', 
                                    res.resNum, d1[i], d2[i], bb, angles.format("%7.2f  "), res, res.dssp.consensus)
                        else:
                            fprintf(fpGood, '%4d   %7.2f  %7.2f  %7.2f  %s  %s %s\n', 
                                    res.resNum, d1[i], d2[i], bb, angles.format("%7.2f  "), res, res.dssp.consensus)
                #end if
            #end if
        #end if
    #end for
    fpBad.close()
    fpGood.close()

    fn = "allRestype_d1d2." + graphicsFormat
    ps.hardcopy(fn, graphicsFormat)
예제 #2
0
def plotDihedralD1D2():
    dihedralName1 = 'Cb4N'
    dihedralName2 = 'Cb4C'
    graphicsFormat = "png"

    entryId = "1brv"  # Small much studied PDB NMR entry
    #        entryId = "1hy8" # small, single model, very low scoring entry

    pdbDirectory = os.path.join(cingDirTestsData, "pdb", entryId)
    pdbFileName = "pdb" + entryId + ".ent"
    pdbFilePath = os.path.join(pdbDirectory, pdbFileName)

    # does it matter to import it just now?
    project = Project(entryId)
    project.removeFromDisk()
    project = Project.open(entryId, status='new')
    project.initPDB(pdbFile=pdbFilePath, convention=IUPAC)

    #        ssType = 'E'
    #        resType = 'GLY'
    #        for ssType in histRamaBySsAndResType.keys():
    #            ssTypeForFileName = ssType.replace(' ', '_')
    titleStr = 'd1d2 all 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.histd1BySs0.keys(
    )  # TODO: check this histd1BySs0 attribute. UNTESTED.
    ssTypeList.sort()  # in place sort to: space, H, S
    for ssType in ssTypeList:
        hist = getDeepByKeys(hPlot.histd1BySs0, ssType)
        if hist != None:
            nTdebug('appending [%s]' % ssType)
            histList.append(hist)
    if histList:
        plot.dihedralComboPlot(histList)
#            fn = os.path.join('bySsAndResType', ( ssTypeForFileName+"_"+resType+"."+graphicsFormat))
#            fn = os.path.join('byResType', ( resType+"."+graphicsFormat))

    fpGood = open(project.name + '.testCb2Good.out', 'w')
    fpBad = open(project.name + '.testCb2Bad.out', 'w')

    mCount = project.molecule.modelCount

    for res in project.molecule.A.allResidues():
        triplet = NTlist()
        for i in [-1, 0, 1]:
            triplet.append(res.sibling(i))
        if None in triplet:
            nTdebug('Skipping ' % res)

        else:
            ca_atms = triplet.zap('CA')
            cb_atms = triplet.zap('CB')

            nTdebug("%s %s %s %s" % (res, triplet, ca_atms, cb_atms))

            if None in cb_atms:  # skip Gly for now
                nTdebug('Skipping %s' % res)
            else:
                d1 = Dihedral(res, 'Cb4N', range=[0.0, 360.0])
                d1.atoms = [cb_atms[0], ca_atms[0], ca_atms[1], cb_atms[1]]
                d1.calculateValues()
                res['Cb4N'] = d1  # append dihedral to residue

                d2 = Dihedral(res, 'Cb4C', range=[0.0, 360.0])
                d2.atoms = [cb_atms[1], ca_atms[1], ca_atms[2], cb_atms[2]]
                d2.calculateValues()
                res['Cb4C'] = d2  # append dihedral to residue

                bb = getDeepByKeys(res, WHATIF_STR, BBCCHK_STR, VALUE_LIST_STR,
                                   0)  # check first one.
                if bb == None:
                    nTdebug('Skipping without BB %s' % res)
                    continue

                if d1.cv < 0.03 and d2.cv < 0.03:  # Only include structured residues
                    for i in range(mCount):  # Consider each model individually
                        #                    bb = res.Whatif.bbNormality.valueList[i]
                        bb = getDeepByKeys(res, WHATIF_STR, BBCCHK_STR,
                                           VALUE_LIST_STR, i)
                        if bb == None:
                            nTdebug('Skipping without BB %s' % res)
                            continue
                        angles = NTlist()  # store phi, psi, chi1, chi2
                        for angle in ['PHI', 'PSI', 'CHI1', 'CHI2']:
                            if res.has_key(angle):
                                angles.append(res[angle][i])
                            else:
                                angles.append(0.0)
                        #end for
                        if bb < 20.0:  # Arbitrary 20 bb occurences as cuttoff for now
                            fprintf(fpBad,
                                    '%4d   %7.2f  %7.2f  %7.2f  %s  %s %s\n',
                                    res.resNum, d1[i], d2[i], bb,
                                    angles.format("%7.2f  "), res,
                                    res.dssp.consensus)
                        else:
                            fprintf(fpGood,
                                    '%4d   %7.2f  %7.2f  %7.2f  %s  %s %s\n',
                                    res.resNum, d1[i], d2[i], bb,
                                    angles.format("%7.2f  "), res,
                                    res.dssp.consensus)
                #end if
            #end if
        #end if
    #end for
    fpBad.close()
    fpGood.close()

    fn = "allRestype_d1d2." + graphicsFormat
    ps.hardcopy(fn, graphicsFormat)
예제 #3
0
파일: analyzeCb2.py 프로젝트: jakesyl/cing
    triplet = NTlist()
    for i in [-1,0,1]:
        triplet.append( res.sibling(i) )
    if None in triplet:
        print 'Skipping ', res

    else:
        CA_atms = triplet.zap('CA')
        CB_atms = triplet.zap('CB')

#        print res, triplet, CA_atms, CB_atms

        if None in CB_atms: # skip Gly for now
            print 'Skipping ', res
        else:
            d1 = Dihedral( res, 'Cb4N', range=[0.0,360.0] )
            d1.atoms = [CB_atms[0], CA_atms[0], CA_atms[1], CB_atms[1]]
            d1.calculateValues()
            res['Cb4N'] = d1 # append dihedral to residue

            d2 = Dihedral( res, 'Cb4C', range=[0.0,360.0] )
            d2.atoms = [CB_atms[1], CA_atms[1], CA_atms[2], CB_atms[2]]
            d2.calculateValues()
            res['Cb4C'] = d2 # append dihedral to residue

            bb = getDeepByKeys( res, WHATIF_STR, BBCCHK_STR, VALUE_LIST_STR, 0) # check first one.
            if bb ==  None:
                print 'Skipping without BB', res
                continue

            if d1.cv < 0.03 and d2.cv < 0.03: # Only include structured residues