コード例 #1
0
    def test_Whatif(self):
        #entryId = "1ai0" # Most complex molecular system in any PDB NMR entry
#        entryId = "2hgh" # Small much studied PDB NMR entry; 48 models
#        entryId = "1bus" # Small much studied PDB NMR entry:  5 models of 57 AA.: 285 residues.
        entryId = "1brv" # DEFAULT is not to do more than 2 models because it takes quite a while.
#        entryId = "1brv_cs_pk_2mdl"

#        entryId = "1tgq_1model"
#        pdbConvention = IUPAC
        parseOnly = False # normal is False
        showValues = True
        ranges='cv'
#        ranges='172-177'
#        ranges='6-13,29-45'


        cingDirTmpTest = os.path.join( cingDirTmp, getCallerName() )
        mkdirs( cingDirTmpTest )
        self.failIf(os.chdir(cingDirTmpTest), msg =
            "Failed to change to test directory for files: " + cingDirTmpTest)
        project = Project( entryId )
        if not parseOnly:
            project.removeFromDisk()
            project = Project.open( entryId, status='new' )
            inputArchiveDir = os.path.join(cingDirTestsData, "ccpn")

            ccpnFile = os.path.join(inputArchiveDir, entryId + ".tgz")
            if not os.path.exists(ccpnFile):
                ccpnFile = os.path.join(inputArchiveDir, entryId + ".tar.gz")
                if not os.path.exists(ccpnFile):
                    self.fail("Neither %s or the .tgz exist" % ccpnFile)

            self.assertTrue(project.initCcpn(ccpnFolder = ccpnFile, modelCount=2))
            self.assertFalse(runWhatif(project, ranges=ranges, parseOnly=False))
        else:
            project = Project.open( entryId, status='old' )
#        print project.cingPaths.format()

        project.save()
        if showValues:
            for res in project.molecule.allResidues():
                nTdebug(repr(res))
                whatifResDict = res.getDeepByKeys(WHATIF_STR)
                if not whatifResDict:
                    continue
#                checkIDList = whatifResDict.keys()
                checkIDList = 'RAMCHK'.split()
                for checkID in checkIDList:
                    valueList = whatifResDict.getDeepByKeys(checkID,VALUE_LIST_STR)
                    qualList  = whatifResDict.getDeepByKeys(checkID,QUAL_LIST_STR)
                    nTdebug("%10s valueList: %-80s qualList: %-80s" % ( checkID, valueList, qualList))
        # Do not leave the old CCPN directory laying around since it might get added to by another test.
        if os.path.exists(entryId):
            self.assertFalse(shutil.rmtree(entryId))
コード例 #2
0
    def testMoleculePlot(self):

        actuallyRunWhatif = False
        showValues = False

        modelNum = 1 # Only used when simulating data
        #entryId = "1ai0" # Most complex molecular system in any PDB NMR entry
#        entryId = "2hgh" # Small much studied PDB NMR entry; 48 models
        entryId = "1bus" # Small much studied PDB NMR entry:  5 models of 57 AA.: 285 residues.
#        entryId = "2hgh_1model"
#        entryId = "1brv_1model"

#        ranges = None
        ranges = 'cv'
        if entryId.startswith("2hgh"):
            # Compile a NTlist instance with residue objects.
            ranges = "2-54,111-136,145-193"
            ranges = None
                # 1 and 55 are 5' and 3' terminii which are a little looser.
                # 12, and 34 are bases that are not basepaired.
                # 191-193 are bound ZN ions.
        elif entryId.startswith("1brv"):
            # Truncate from Val171-Glu189 to:
            ranges = "175-188"
#            ranges = None
        elif entryId.startswith("1bus"):
            ranges = "6-13,29-45"

        project = Project.open(entryId, status='new')
        cyanaFile = os.path.join(cingDirTestsData, "cyana", entryId + ".cyana.tgz")
        self.assertTrue(project.initCyana(cyanaFolder = cyanaFile))

#        project.validate(parseOnly=False, htmlOnly=True, doProcheck=False, doWhatif=False, doWattos=False, doTalos=False) # needed?

        self.assertFalse( project.molecule.setRanges(ranges) )
        from cing.PluginCode.dssp import runDssp # Triggers checks. @UnusedImport # pylint: disable=W0612,W0404

        project.runDssp()
        if actuallyRunWhatif:
            from cing.PluginCode.Whatif import runWhatif # Triggers checks. # pylint: disable=W0612,W0404
            self.assertFalse(runWhatif(project))
        else:
            rangeList = project.molecule.getFixedRangeList(
                max_length_range=ResPlot.MAX_WIDTH_IN_RESIDUES)
            _resNumb = 0
            for resList in rangeList:
                for res in resList:
                    _resNumb += 1

        #            nTdebug(repr(res))

        #            if random() < 0.2: # Skip a 10%
        #                continue

                    whatifResDict = res.setdefault(WHATIF_STR, NTdict())
                    procheckResDict = res.setdefault(PROCHECK_STR, NTdict())
        #            if not whatifResDict: # empty dict
        #                continue

                    angList = NTlist()
                    bndList = NTlist()
                    quaList = NTlist()
                    ramList = NTlist()
                    c12List = NTlist()
                    rotList = NTlist()
                    bbcList = NTlist()
                    accList = NTlist()

                    for _modelID in range(modelNum):
                        if not actuallyRunWhatif:
                            angList.append(random()*10 - 0) # Simulate abs max of Z-scores.
                            bndList.append(random()*5 + 1)  # offset by 1 but still want to start from zero?
                            quaList.append(random()*100 + 1)
                            ramList.append(random()*5 + 1)
                            c12List.append(random()*5 + 1)
                            rotList.append(random()*5 + 1)
                            bbcList.append(random()*5 + 1)
                            accList.append(random()*4 - 2)

                    if not actuallyRunWhatif:
                        self.assertFalse (whatifResDict.setDeepByKeys(angList, ANGCHK_STR, VALUE_LIST_STR))
                        self.assertFalse (whatifResDict.setDeepByKeys(bndList, BNDCHK_STR, VALUE_LIST_STR))
                        self.assertFalse (whatifResDict.setDeepByKeys(quaList, QUACHK_STR, VALUE_LIST_STR))
                        self.assertFalse (whatifResDict.setDeepByKeys(ramList, RAMCHK_STR, VALUE_LIST_STR))
                        self.assertFalse (whatifResDict.setDeepByKeys(c12List, C12CHK_STR, VALUE_LIST_STR))
                        self.assertFalse (whatifResDict.setDeepByKeys(rotList, ROTCHK_STR, VALUE_LIST_STR))
                        self.assertFalse (whatifResDict.setDeepByKeys(bbcList, BBCCHK_STR, VALUE_LIST_STR))
                        self.assertFalse (whatifResDict.setDeepByKeys(accList, INOCHK_STR, VALUE_LIST_STR))

                    for d in [whatifResDict, procheckResDict]:
                        checkIDList = d.keys()
                        for checkID in checkIDList:
                            if d == whatifResDict:
                                valueList = d.getDeepByKeys(checkID, VALUE_LIST_STR)
                            else:
                                valueList = d.getDeepByKeys(checkID)
                            if showValues:
                                nTdebug("%10s valueList: %-80s" % (checkID, valueList))
        #end if actuallyRunWhatif:

        # The following object will be responsible for creating a (png/pdf) file with
        # possibly multiple pages
        # Level 1: row
        # Level 2: against main or alternative y-axis
        # Level 3: plot parameters dictionary (extendable).
        keyLoLoL = []

        plotAttributesRowMain = NTdict()
        plotAttributesRowAlte = NTdict()
        plotAttributesRowMain[ KEY_LIST_STR] = [ PHI_STR, CV_STR ]
        plotAttributesRowMain[ KEY_LIST2_STR] = [ PSI_STR, CV_STR ]
        plotAttributesRowAlte[ KEY_LIST_STR] = [ 'cv_backbone' ]
        plotAttributesRowMain[ YLABEL_STR] = 'cv phi/psi'
        plotAttributesRowAlte[ YLABEL_STR] = 'cv backbone'
        plotAttributesRowMain[ USE_ZERO_FOR_MIN_VALUE_STR] = True
#        plotAttributesRowMain[ USE_MAX_VALUE_STR] = 0.2
        keyLoLoL.append([ [plotAttributesRowMain], [plotAttributesRowAlte] ])

        plotAttributesRowMain = NTdict()
        plotAttributesRowMain[ KEY_LIST_STR] = [ CHK_STR, RAMACHANDRAN_CHK_STR, VALUE_STR ]
        plotAttributesRowMain[ YLABEL_STR] = 'Z phi/psi'
        keyLoLoL.append([ [plotAttributesRowMain]])

        plotAttributesRowMain = NTdict()
        plotAttributesRowAlte = NTdict()
        plotAttributesRowMain[ KEY_LIST_STR] = [ CHI1_STR, CV_STR ]
        plotAttributesRowMain[ KEY_LIST2_STR] = [ CHI2_STR, CV_STR ]
        plotAttributesRowAlte[ KEY_LIST_STR] = [ 'cv_sidechain' ]
        plotAttributesRowMain[ YLABEL_STR] = 'cv chi1/2'
        plotAttributesRowAlte[ YLABEL_STR] = 'cv sidechain'
        plotAttributesRowMain[ USE_ZERO_FOR_MIN_VALUE_STR] = True
#        plotAttributesRowMain[ USE_MAX_VALUE_STR]   = 1.0
        keyLoLoL.append([ [plotAttributesRowMain], [plotAttributesRowAlte] ])

        plotAttributesRowMain = NTdict()
        plotAttributesRowAlte = NTdict()
        plotAttributesRowMain[ KEY_LIST_STR] = [ RMSD_STR, BACKBONE_AVERAGE_STR, VALUE_STR ]
        plotAttributesRowAlte[ KEY_LIST_STR] = [ RMSD_STR, HEAVY_ATOM_AVERAGE_STR, VALUE_STR ]
        plotAttributesRowMain[ YLABEL_STR] = BACKBONE_AVERAGE_STR
        plotAttributesRowAlte[ YLABEL_STR] = HEAVY_ATOM_AVERAGE_STR
        plotAttributesRowMain[ USE_ZERO_FOR_MIN_VALUE_STR] = True
        keyLoLoL.append([ [plotAttributesRowMain], [plotAttributesRowAlte] ])

        plotAttributesRowMain = NTdict()
        plotAttributesRowAlte = NTdict()
        plotAttributesRowMain[ KEY_LIST_STR] = [ WHATIF_STR, C12CHK_STR, VALUE_LIST_STR ]
        plotAttributesRowAlte[ KEY_LIST_STR] = [ WHATIF_STR, ROTCHK_STR, VALUE_LIST_STR ]
        plotAttributesRowAlte[ KEY_LIST2_STR] = [ WHATIF_STR, RAMCHK_STR, VALUE_LIST_STR ]
        plotAttributesRowMain[ YLABEL_STR] = C12CHK_STR
        plotAttributesRowAlte[ YLABEL_STR] = ROTCHK_STR
        plotAttributesRowMain[ USE_ZERO_FOR_MIN_VALUE_STR] = True
#        plotAttributesRowMain[ USE_MAX_VALUE_STR] = 10.0
        keyLoLoL.append([ [plotAttributesRowMain], [plotAttributesRowAlte] ])

        plotAttributesRowMain = NTdict()
        plotAttributesRowMain[ KEY_LIST_STR] = [ QSHIFT_STR, ALL_ATOMS_STR]
        plotAttributesRowMain[ KEY_LIST2_STR] = [ QSHIFT_STR, BACKBONE_STR]
        plotAttributesRowMain[ KEY_LIST3_STR] = [ QSHIFT_STR, HEAVY_ATOMS_STR]
        plotAttributesRowMain[ KEY_LIST4_STR] = [ QSHIFT_STR, PROTONS_STR]
        plotAttributesRowMain[ YLABEL_STR] = 'QCS all/bb/hvy/prt'
        plotAttributesRowMain[ USE_ZERO_FOR_MIN_VALUE_STR] = True
#        plotAttributesRowMain[ USE_VERBOSE_Y_LOCATOR_STR ] = True
        plotAttributesRowMain[ USE_MAX_VALUE_STR] = 0.5
        keyLoLoL.append([ [plotAttributesRowMain] ])


#BACKBONE_STR = 'backbone'
#HEAVY_ATOMS_STR = 'heavyAtoms'
#PROTONS_STR = 'protons'

        nTdebug("Instantiating moleculePlotSet")
        moleculePlotSet = MoleculePlotSet(project=project, keyLoLoL=keyLoLoL)
        pdfPath = '%s/test_NTMoleculePlot.pdf' % self.cingDirTmpTest
        moleculePlotSet.renderMoleculePlotSet(pdfPath, createPngCopyToo=True)
コード例 #3
0
    def testResPlot(self):

        actuallyRunProcheck = False
        actuallyRunWhatif   = False
        showValues          = False
        modelNum            = 1 # Only used when simulating data
        #entryId = "1ai0" # Most complex molecular system in any PDB NMR entry
#        entryId = "2hgh" # Small much studied PDB NMR entry; 48 models
#        entryId = "1bus" # Small much studied PDB NMR entry:  5 models of 57 AA.: 285 residues.
        entryId = "1brv"

        ranges = None
        if entryId.startswith("2hgh"):
            # Compile a NTlist instance with residue objects.
            ranges = "2-54,111-136,145-193"
                # 1 and 55 are 5' and 3' terminii which are a little looser.
                # 12, and 34 are bases that are not basepaired.
                # 191-193 are bound ZN ions.
        elif entryId.startswith("1brv"):
            # Truncate from Val171-Glu189 to:
            ranges = "176-188"

        project = Project( entryId )
        project.removeFromDisk()
        project = Project.open( entryId, status='new' )
        cyanaFolder = os.path.join(cingDirTestsData,"cyana", entryId+".cyana.tgz")
        nTdebug("Reading files from: " + cyanaFolder)
        project.initCyana( cyanaFolder )
        project.runDssp()

        rangeList = project.molecule.getFixedRangeList(
            max_length_range = ResPlot.MAX_WIDTH_IN_RESIDUES, ranges=ranges )

        if actuallyRunProcheck:
            self.failIf(project.procheck(createPlots=False, runAqua=False) is None)
        if actuallyRunWhatif:
            self.assertFalse(runWhatif(project))

        pointsANGCHK = [] # list per res in rangeList of lists
        pointsBNDCHK = []
        pointsQUACHK = []
        pointsRAMCHK = []
        pointsC12CHK = []
        pointsBBCCHK = []
        resNumb = 0
        for resList in rangeList:
            for res in resList:
                resNumb += 1

    #            nTdebug(repr(res))

    #            if random() < 0.2: # Skip a 10%
    #                continue

                whatifResDict = res.setdefault(WHATIF_STR, NTdict())
                procheckResDict = res.setdefault(PROCHECK_STR, NTdict())
    #            if not whatifResDict: # empty dict
    #                continue

                angList = NTlist()
                bndList = NTlist()

                quaList = NTlist()
                ramList = NTlist()
                c12List = NTlist()
                bbcList = NTlist()

                accList = NTlist()
                sstList = NTlist()
                sstListPossibilities='SH' # secondary structure elements.

                for _modelID in range(modelNum):
                    if not actuallyRunWhatif:
                        angList.append(random()*10-0) # Simulate abs max of Z-scores.
                        bndList.append(random()*5+1)  # offset by 1 but still want to start from zero?

                        quaList.append(random()*5+1)
                        ramList.append(random()*5+1)
                        c12List.append(random()*5+1)
                        bbcList.append(random()*5+1)

                        accList.append(random()*4-2)
                    if not actuallyRunProcheck:
                        sstList.append( sstListPossibilities[ int(random()*2)])  # Simulate secondary structure

                if not actuallyRunWhatif:
                    self.assertFalse (   whatifResDict.setDeepByKeys(angList,  ANGCHK_STR,VALUE_LIST_STR) )
                    self.assertFalse (   whatifResDict.setDeepByKeys(bndList,  BNDCHK_STR,VALUE_LIST_STR) )

                    self.assertFalse (   whatifResDict.setDeepByKeys(quaList,  QUACHK_STR,VALUE_LIST_STR) )
                    self.assertFalse (   whatifResDict.setDeepByKeys(ramList,  RAMCHK_STR,VALUE_LIST_STR) )
                    self.assertFalse (   whatifResDict.setDeepByKeys(c12List,  C12CHK_STR,VALUE_LIST_STR) )
                    self.assertFalse (   whatifResDict.setDeepByKeys(bbcList,  BBCCHK_STR,VALUE_LIST_STR) )

                    self.assertFalse (   whatifResDict.setDeepByKeys(accList,  INOCHK_STR,VALUE_LIST_STR) )

                if not actuallyRunProcheck:
                    self.assertFalse ( procheckResDict.setDeepByKeys(sstList,  SECSTRUCT_STR) )

                for d in [whatifResDict, procheckResDict]:
                    checkIDList = d.keys()
                    for checkID in checkIDList:
                        if d==whatifResDict:
                            valueList = d.getDeepByKeys(checkID,VALUE_LIST_STR)
                        else:
                            valueList = d.getDeepByKeys(checkID)

                        if checkID == ANGCHK_STR:
                            zScore = valueList.average()[0]
                            pointsANGCHK.append( (resNumb-.5, zScore) )
                        elif checkID == BNDCHK_STR:
                            zScore = valueList.average()[0]
                            pointsBNDCHK.append( (resNumb-.5, zScore) )
                        elif checkID == QUACHK_STR:
                            zScore = valueList.average()[0]
                            pointsQUACHK.append( (resNumb-.5, zScore) )
                        elif checkID == RAMCHK_STR:
                            zScore = valueList.average()[0]
                            pointsRAMCHK.append( (resNumb-.5, zScore) )
                        elif checkID == C12CHK_STR:
                            zScore = valueList.average()[0]
                            pointsC12CHK.append( (resNumb-.5, zScore) )
                        elif checkID == BBCCHK_STR:
                            zScore = valueList.average()[0]
                            pointsBBCCHK.append( (resNumb-.5, zScore) )
#                            nTdebug("pointsBBCCHK: %s", pointsBBCCHK)

                        if showValues:
                            nTdebug("%10s valueList: %-80s" % ( checkID, valueList))
        fileNameList =[]
        ps = None
        r = 0
        for resList in rangeList:
            r += 1
#            nTdebug("resList: %s" % resList)
            ps = NTplotSet() # closes any previous plots
            ps.hardcopySize = (600,600)
            nrows = 2
            ntPlotList = []
            for i in range(nrows):
                ntPlotList.append( ps.createSubplot(nrows,1,i+1,useResPlot=True,molecule=project.molecule,resList=resList) )


            ps.subplotsAdjust(hspace  = .1) # no height spacing between plots.
            ps.subplotsAdjust(top     = 0.9) # Accommodate icons and res types.
            ps.subplotsAdjust(left    = 0.15) # Accommodate extra Y axis label.

            attr = fontVerticalAttributes()
            attr.fontColor  = 'blue'
            # Left of actual yLabel.
            labelAxesExtraList = [
              'Backbone',
              'Quality',
              'Angle',
              '',
              '' ]
            labelAxesList = [
              'Ramachandr. Z',
              'Chi 1/2. Z',
              'Bond max Z',
              'Restraint RMSD',
              '' ]
            for i in range(nrows):
                position = (-0.12, 0.5)
                ntPlotList[i].labelAxes( position, labelAxesExtraList[i], attributes=attr)
                ntPlotList[i].yLabel = labelAxesList[i]
                if i != nrows-1:
                    ntPlotList[i].xLabel = None



            plusPoint   = pointAttributes( type='plus',   size=1.5, color='black' )
            circlePoint = pointAttributes( type='circle', size=1.5, color='blue')
            plusPoint.lineColor   = 'black'
            circlePoint.lineColor = 'blue'
            length = ntPlotList[0].MAX_WIDTH_IN_RESIDUES
            start = (r-1)*length

#            pointsBBCCHK = removeNulls(pointsBBCCHK)
            # buildin max is overridden by matplotlib
#            end   = NTmin(start + ntPlot1.MAX_WIDTH_IN_RESIDUES,len(pointsANGCHK))
            pointsANGCHKOffset = convertPointsToPlotRange(pointsANGCHK, xOffset=-start, yOffset=0, start=0, length=length)
            pointsBNDCHKOffset = convertPointsToPlotRange(pointsBNDCHK, xOffset=-start, yOffset=0, start=0, length=length)
            pointsQUACHKOffset = convertPointsToPlotRange(pointsQUACHK, xOffset=-start, yOffset=0, start=0, length=length)
            pointsRAMCHKOffset = convertPointsToPlotRange(pointsRAMCHK, xOffset=-start, yOffset=0, start=0, length=length)
            pointsC12CHKOffset = convertPointsToPlotRange(pointsC12CHK, xOffset=-start, yOffset=0, start=0, length=length)
            pointsBBCCHKOffset = convertPointsToPlotRange(pointsBBCCHK, xOffset=-start, yOffset=0, start=0, length=length)

            pointsOffsetList = [pointsRAMCHKOffset,
                                pointsQUACHKOffset,
                                pointsANGCHKOffset ]
            pointsOffsetList2 = [pointsBBCCHKOffset,
                                 pointsC12CHKOffset,
                                 pointsBNDCHKOffset ]
#            nTdebug("pointsRAMCHKOffset: %s" % pointsRAMCHKOffset)
#            nTdebug("start:end: %s %s" % (start,end))
            for i in range(nrows):
                if i >= len( pointsOffsetList ):
                    continue
                ntPlotList[i].lines(pointsOffsetList[i],  plusPoint)
                ntPlotList[i].lines(pointsOffsetList2[i], circlePoint)
                ntPlotList[i].autoScaleY( pointsOffsetList[i]+pointsOffsetList2[i] )
                if i == 2: # by chance
                    ntPlotList[i].setYrange((.0, ntPlotList[i].yRange[1]))

            ySpaceAxisResTypes = .02 + (nrows-1) * .01
            ntPlotList[0].drawResTypes(ySpaceAxis=ySpaceAxisResTypes) # Weirdly can only be called after yRange is set.

            for i in range(nrows):
                showLabels = False
                if i == nrows-1:
                    showLabels = True
                # also sets the grid lines for major. Do last as it won't rescale with plot yet.
                ntPlotList[i].drawResNumbers( showLabels=showLabels)

            # Draw secondary structure elements and accessibility
            # Set x range and major ticker.
            # The major ticker determines the grid layout.
            # leave space for res types but get it right on top.
#            .18 at nrows = 4
            # Needs to be done before re-scaling the y axis from [0,1] ???????
            ySpaceAxisResIcons = .06 + (nrows-1) * .04
            ntPlotList[0].iconBoxYheight = 0.16 * nrows / 3. # .16 at nrows=3
            ntPlotList[0].drawResIcons( ySpaceAxis=ySpaceAxisResIcons )

            # Set the grid and major tickers
            fileNameList.append( 'residuePlotSet%03d.pdf' % r)
            ps.hardcopy(fileNameList[r-1])
        # end for resList in rangeList:
        self.assertFalse( joinPdfPages( fileNameList, 'residuePlotSetAll.pdf' ))
        for fileName in fileNameList:
            os.unlink( fileName )
コード例 #4
0
    def testMoleculePlot(self):

        actuallyRunWhatif = False
        showValues = False

        modelNum = 1  # Only used when simulating data
        #entryId = "1ai0" # Most complex molecular system in any PDB NMR entry
        #        entryId = "2hgh" # Small much studied PDB NMR entry; 48 models
        entryId = "1bus"  # Small much studied PDB NMR entry:  5 models of 57 AA.: 285 residues.
        #        entryId = "2hgh_1model"
        #        entryId = "1brv_1model"

        #        ranges = None
        ranges = 'cv'
        if entryId.startswith("2hgh"):
            # Compile a NTlist instance with residue objects.
            ranges = "2-54,111-136,145-193"
            ranges = None
            # 1 and 55 are 5' and 3' terminii which are a little looser.
            # 12, and 34 are bases that are not basepaired.
            # 191-193 are bound ZN ions.
        elif entryId.startswith("1brv"):
            # Truncate from Val171-Glu189 to:
            ranges = "175-188"


#            ranges = None
        elif entryId.startswith("1bus"):
            ranges = "6-13,29-45"

        project = Project.open(entryId, status='new')
        cyanaFile = os.path.join(cingDirTestsData, "cyana",
                                 entryId + ".cyana.tgz")
        self.assertTrue(project.initCyana(cyanaFolder=cyanaFile))

        #        project.validate(parseOnly=False, htmlOnly=True, doProcheck=False, doWhatif=False, doWattos=False, doTalos=False) # needed?

        self.assertFalse(project.molecule.setRanges(ranges))
        from cing.PluginCode.dssp import runDssp  # Triggers checks. @UnusedImport # pylint: disable=W0612,W0404

        project.runDssp()
        if actuallyRunWhatif:
            from cing.PluginCode.Whatif import runWhatif  # Triggers checks. # pylint: disable=W0612,W0404
            self.assertFalse(runWhatif(project))
        else:
            rangeList = project.molecule.getFixedRangeList(
                max_length_range=ResPlot.MAX_WIDTH_IN_RESIDUES)
            _resNumb = 0
            for resList in rangeList:
                for res in resList:
                    _resNumb += 1

                    #            nTdebug(repr(res))

                    #            if random() < 0.2: # Skip a 10%
                    #                continue

                    whatifResDict = res.setdefault(WHATIF_STR, NTdict())
                    procheckResDict = res.setdefault(PROCHECK_STR, NTdict())
                    #            if not whatifResDict: # empty dict
                    #                continue

                    angList = NTlist()
                    bndList = NTlist()
                    quaList = NTlist()
                    ramList = NTlist()
                    c12List = NTlist()
                    rotList = NTlist()
                    bbcList = NTlist()
                    accList = NTlist()

                    for _modelID in range(modelNum):
                        if not actuallyRunWhatif:
                            angList.append(random() * 10 -
                                           0)  # Simulate abs max of Z-scores.
                            bndList.append(
                                random() * 5 + 1
                            )  # offset by 1 but still want to start from zero?
                            quaList.append(random() * 100 + 1)
                            ramList.append(random() * 5 + 1)
                            c12List.append(random() * 5 + 1)
                            rotList.append(random() * 5 + 1)
                            bbcList.append(random() * 5 + 1)
                            accList.append(random() * 4 - 2)

                    if not actuallyRunWhatif:
                        self.assertFalse(
                            whatifResDict.setDeepByKeys(
                                angList, ANGCHK_STR, VALUE_LIST_STR))
                        self.assertFalse(
                            whatifResDict.setDeepByKeys(
                                bndList, BNDCHK_STR, VALUE_LIST_STR))
                        self.assertFalse(
                            whatifResDict.setDeepByKeys(
                                quaList, QUACHK_STR, VALUE_LIST_STR))
                        self.assertFalse(
                            whatifResDict.setDeepByKeys(
                                ramList, RAMCHK_STR, VALUE_LIST_STR))
                        self.assertFalse(
                            whatifResDict.setDeepByKeys(
                                c12List, C12CHK_STR, VALUE_LIST_STR))
                        self.assertFalse(
                            whatifResDict.setDeepByKeys(
                                rotList, ROTCHK_STR, VALUE_LIST_STR))
                        self.assertFalse(
                            whatifResDict.setDeepByKeys(
                                bbcList, BBCCHK_STR, VALUE_LIST_STR))
                        self.assertFalse(
                            whatifResDict.setDeepByKeys(
                                accList, INOCHK_STR, VALUE_LIST_STR))

                    for d in [whatifResDict, procheckResDict]:
                        checkIDList = d.keys()
                        for checkID in checkIDList:
                            if d == whatifResDict:
                                valueList = d.getDeepByKeys(
                                    checkID, VALUE_LIST_STR)
                            else:
                                valueList = d.getDeepByKeys(checkID)
                            if showValues:
                                nTdebug("%10s valueList: %-80s" %
                                        (checkID, valueList))
        #end if actuallyRunWhatif:

        # The following object will be responsible for creating a (png/pdf) file with
        # possibly multiple pages
        # Level 1: row
        # Level 2: against main or alternative y-axis
        # Level 3: plot parameters dictionary (extendable).
        keyLoLoL = []

        plotAttributesRowMain = NTdict()
        plotAttributesRowAlte = NTdict()
        plotAttributesRowMain[KEY_LIST_STR] = [PHI_STR, CV_STR]
        plotAttributesRowMain[KEY_LIST2_STR] = [PSI_STR, CV_STR]
        plotAttributesRowAlte[KEY_LIST_STR] = ['cv_backbone']
        plotAttributesRowMain[YLABEL_STR] = 'cv phi/psi'
        plotAttributesRowAlte[YLABEL_STR] = 'cv backbone'
        plotAttributesRowMain[USE_ZERO_FOR_MIN_VALUE_STR] = True
        #        plotAttributesRowMain[ USE_MAX_VALUE_STR] = 0.2
        keyLoLoL.append([[plotAttributesRowMain], [plotAttributesRowAlte]])

        plotAttributesRowMain = NTdict()
        plotAttributesRowMain[KEY_LIST_STR] = [
            CHK_STR, RAMACHANDRAN_CHK_STR, VALUE_STR
        ]
        plotAttributesRowMain[YLABEL_STR] = 'Z phi/psi'
        keyLoLoL.append([[plotAttributesRowMain]])

        plotAttributesRowMain = NTdict()
        plotAttributesRowAlte = NTdict()
        plotAttributesRowMain[KEY_LIST_STR] = [CHI1_STR, CV_STR]
        plotAttributesRowMain[KEY_LIST2_STR] = [CHI2_STR, CV_STR]
        plotAttributesRowAlte[KEY_LIST_STR] = ['cv_sidechain']
        plotAttributesRowMain[YLABEL_STR] = 'cv chi1/2'
        plotAttributesRowAlte[YLABEL_STR] = 'cv sidechain'
        plotAttributesRowMain[USE_ZERO_FOR_MIN_VALUE_STR] = True
        #        plotAttributesRowMain[ USE_MAX_VALUE_STR]   = 1.0
        keyLoLoL.append([[plotAttributesRowMain], [plotAttributesRowAlte]])

        plotAttributesRowMain = NTdict()
        plotAttributesRowAlte = NTdict()
        plotAttributesRowMain[KEY_LIST_STR] = [
            RMSD_STR, BACKBONE_AVERAGE_STR, VALUE_STR
        ]
        plotAttributesRowAlte[KEY_LIST_STR] = [
            RMSD_STR, HEAVY_ATOM_AVERAGE_STR, VALUE_STR
        ]
        plotAttributesRowMain[YLABEL_STR] = BACKBONE_AVERAGE_STR
        plotAttributesRowAlte[YLABEL_STR] = HEAVY_ATOM_AVERAGE_STR
        plotAttributesRowMain[USE_ZERO_FOR_MIN_VALUE_STR] = True
        keyLoLoL.append([[plotAttributesRowMain], [plotAttributesRowAlte]])

        plotAttributesRowMain = NTdict()
        plotAttributesRowAlte = NTdict()
        plotAttributesRowMain[KEY_LIST_STR] = [
            WHATIF_STR, C12CHK_STR, VALUE_LIST_STR
        ]
        plotAttributesRowAlte[KEY_LIST_STR] = [
            WHATIF_STR, ROTCHK_STR, VALUE_LIST_STR
        ]
        plotAttributesRowAlte[KEY_LIST2_STR] = [
            WHATIF_STR, RAMCHK_STR, VALUE_LIST_STR
        ]
        plotAttributesRowMain[YLABEL_STR] = C12CHK_STR
        plotAttributesRowAlte[YLABEL_STR] = ROTCHK_STR
        plotAttributesRowMain[USE_ZERO_FOR_MIN_VALUE_STR] = True
        #        plotAttributesRowMain[ USE_MAX_VALUE_STR] = 10.0
        keyLoLoL.append([[plotAttributesRowMain], [plotAttributesRowAlte]])

        plotAttributesRowMain = NTdict()
        plotAttributesRowMain[KEY_LIST_STR] = [QSHIFT_STR, ALL_ATOMS_STR]
        plotAttributesRowMain[KEY_LIST2_STR] = [QSHIFT_STR, BACKBONE_STR]
        plotAttributesRowMain[KEY_LIST3_STR] = [QSHIFT_STR, HEAVY_ATOMS_STR]
        plotAttributesRowMain[KEY_LIST4_STR] = [QSHIFT_STR, PROTONS_STR]
        plotAttributesRowMain[YLABEL_STR] = 'QCS all/bb/hvy/prt'
        plotAttributesRowMain[USE_ZERO_FOR_MIN_VALUE_STR] = True
        #        plotAttributesRowMain[ USE_VERBOSE_Y_LOCATOR_STR ] = True
        plotAttributesRowMain[USE_MAX_VALUE_STR] = 0.5
        keyLoLoL.append([[plotAttributesRowMain]])

        #BACKBONE_STR = 'backbone'
        #HEAVY_ATOMS_STR = 'heavyAtoms'
        #PROTONS_STR = 'protons'

        nTdebug("Instantiating moleculePlotSet")
        moleculePlotSet = MoleculePlotSet(project=project, keyLoLoL=keyLoLoL)
        pdfPath = '%s/test_NTMoleculePlot.pdf' % self.cingDirTmpTest
        moleculePlotSet.renderMoleculePlotSet(pdfPath, createPngCopyToo=True)