Ejemplo n.º 1
0
    def testPeirceTest5(self):
        values = [61.1080599488, 34.876110084, 63.0380528016, -37.3907919689, 55.7742201359, 158.950985878, 152.580838711, 159.962185469, 
                  39.5242231825, 167.478815798, -45.1721895276, 150.966989049, 38.7181950131, 54.4126758063, 62.9191496902, -41.4928983793,
                  46.5057394648, -36.3803547969, -48.513237809, 61.4695459467]
                
        result = peirceTest.peirceTest( values )
        self.failUnless(result)
        v,obj = result
#        print 'number of outliers at size: '+repr(n)+ ' =',len(obj)
        self.assertTrue(len(v) == 10)
        self.assertTrue(len(obj) == 10)
Ejemplo n.º 2
0
    def testPeirceTest4(self):
        values = []
        n = 2  # Default value 200. Tested up to 10,000 once before.
        for i in range(n):
            values.append(i)

        result = peirceTest.peirceTest(values)
        self.failUnless(result)
        v, obj = result
        #        print 'number of outliers at size: '+repr(n)+ ' =',len(obj)
        self.assertTrue(len(v) == n)
        self.assertTrue(len(obj) == 0)
Ejemplo n.º 3
0
    def testPeirceTest4(self):
        values = []    
        n = 2   # Default value 200. Tested up to 10,000 once before.
        for i in range(n):
            values.append(i)        
                
        result = peirceTest.peirceTest( values )
        self.failUnless(result)
        v,obj = result
#        print 'number of outliers at size: '+repr(n)+ ' =',len(obj)
        self.assertTrue(len(v) == n)
        self.assertTrue(len(obj) == 0)
Ejemplo n.º 4
0
    def testPeirceTest1(self):        
        values = [101.2, 90.0, 99.0, 102.0, 103.0, 100.2, 89.0, 98.1, 101.5, 102.0]
        vOld,_oOld = peirceTest.peirceTestOld( values )
#        print 'v=',vOld
#        print vOld.av, vOld.sd
#        print 'o=',_oOld
#        
        v,_o = peirceTest.peirceTest( values )
#        print 'v=',v
#        print v.av, v.sd
#        print 'o=',_o
    
        self.assertTrue( vOld == v )
Ejemplo n.º 5
0
    def testPeirceTest1(self):
        values = [
            101.2, 90.0, 99.0, 102.0, 103.0, 100.2, 89.0, 98.1, 101.5, 102.0
        ]
        vOld, _oOld = peirceTest.peirceTestOld(values)
        #        print 'v=',vOld
        #        print vOld.av, vOld.sd
        #        print 'o=',_oOld
        #
        v, _o = peirceTest.peirceTest(values)
        #        print 'v=',v
        #        print v.av, v.sd
        #        print 'o=',_o

        self.assertTrue(vOld == v)
Ejemplo n.º 6
0
    def testPeirceTest5(self):
        values = [
            61.1080599488, 34.876110084, 63.0380528016, -37.3907919689,
            55.7742201359, 158.950985878, 152.580838711, 159.962185469,
            39.5242231825, 167.478815798, -45.1721895276, 150.966989049,
            38.7181950131, 54.4126758063, 62.9191496902, -41.4928983793,
            46.5057394648, -36.3803547969, -48.513237809, 61.4695459467
        ]

        result = peirceTest.peirceTest(values)
        self.failUnless(result)
        v, obj = result
        #        print 'number of outliers at size: '+repr(n)+ ' =',len(obj)
        self.assertTrue(len(v) == 10)
        self.assertTrue(len(obj) == 10)
Ejemplo n.º 7
0
    def testPeirceTest3(self):
        #Note the difference between array sizes 17 and 18. 
        #No outliers identified at 18 but 7 outliers made the cutoff at size 17
        values = []    
        n = 200   # Default value 200. Tested up to 10,000 once before.
        m = 10    # Only tested with default value 10.
        for i in range(0,n):
            values.append(1)        
#        nTdebug("n=", len(values))
        for i in range(0,m):
            values[i] = 2
                
        while n > 3:
            values = values[:n]        
            _v,obj = peirceTest.peirceTest( values )
#            print 'number of outliers at size: '+repr(n)+ ' =',len(obj)
            self.assertTrue(len(obj)<=m)
            n -= 1
Ejemplo n.º 8
0
    def testPeirceTest3(self):
        #Note the difference between array sizes 17 and 18.
        #No outliers identified at 18 but 7 outliers made the cutoff at size 17
        values = []
        n = 200  # Default value 200. Tested up to 10,000 once before.
        m = 10  # Only tested with default value 10.
        for i in range(0, n):
            values.append(1)


#        nTdebug("n=", len(values))
        for i in range(0, m):
            values[i] = 2

        while n > 3:
            values = values[:n]
            _v, obj = peirceTest.peirceTest(values)
            #            print 'number of outliers at size: '+repr(n)+ ' =',len(obj)
            self.assertTrue(len(obj) <= m)
            n -= 1
Ejemplo n.º 9
0
    def testPeirceTest2(self):
        # A stable array just longer than the reference data used in the test.
        values = []
        for i in range(0, 1000):
            values.append(1)
#        nTdebug("n=",len(values))
        for i in range(0, 10):
            values[i] = 2
        # Will only note first 9 outliers
        vOld, oOld = peirceTest.peirceTestOld(values)
        #        print 'v=',vOld
        #        print vOld.av, vOld.sd
        #        print 'obj=',oOld
        #
        v, obj = peirceTest.peirceTest(values)
        #        print 'v=',v
        #        print v.av, v.sd
        #        print 'obj=',obj

        self.assertFalse(vOld == v)
        self.assertFalse(oOld == obj)
Ejemplo n.º 10
0
    def testPeirceTest2(self):
        # A stable array just longer than the reference data used in the test.
        values = []        
        for i in range(0,1000):
            values.append(1)        
#        nTdebug("n=",len(values))
        for i in range(0,10):
            values[i] = 2        
        # Will only note first 9 outliers
        vOld,oOld = peirceTest.peirceTestOld( values )
#        print 'v=',vOld
#        print vOld.av, vOld.sd
#        print 'obj=',oOld
#        
        v,obj = peirceTest.peirceTest( values )
#        print 'v=',v
#        print v.av, v.sd
#        print 'obj=',obj
    
        self.assertFalse( vOld == v )
        self.assertFalse( oOld == obj )
Ejemplo n.º 11
0
def plotTestHistoDihedral():
    nTdebug("Starting plotTestHistoDihedral")
    ps = NTplotSet()  # closes any previous plots
    ps.hardcopySize = (600, 369)

    graphicsFormat = "png"
    residueName = "ASN1"
    dihedralName = "CHI1"
    dihedralNameLatex = "$\chi 1$"

    project = Project('plotTestHistoDihedral')
    plotparams = project.plotParameters.getdefault(dihedralName,
                                                   'dihedralDefault')
    binsize = int(plotparams.ticksize /
                  12)  # 60 over 12 results in 5 degrees. as an int
    bins = (plotparams.max - plotparams.min) / binsize  # int

    angleList = NTlist(50, 60, 51, 53, 52, 54, 62, 90, 93)
    angleList.cAverage()
    goodAndOutliers = peirceTest(angleList)
    if not goodAndOutliers:
        nTerror("No goodAndOutliers in plotTestHistoDihedral")
        return True
    angleList.good, angleList.outliers = goodAndOutliers

    angleList.limit(plotparams.min,
                    plotparams.max)  # Actually not plotted angle anymore.?
    angleList.cAverage(plotparams.min, plotparams.max)
    angleList.good.limit(plotparams.min, plotparams.max, byItem=1)
    angleList.good.cAverage(plotparams.min, plotparams.max, byItem=1)
    angleList.outliers.limit(plotparams.min, plotparams.max, byItem=1)
    angleList.outliers.cAverage(plotparams.min, plotparams.max, byItem=1)

    for i, angleL in enumerate([angleList, angleList.good,
                                angleList.outliers]):
        nTdebug("angleL %d: %s" % (i, str(angleL)))
        nTdebug("      cav: %s" % angleL.cav)
    # end for
    xTicks = range(int(plotparams.min), int(plotparams.max + 1),
                   plotparams.ticksize)
    #        nTdebug("xTicks: " + repr(xTicks))
    #        figWidth  = 600
    #        figHeight = None # Golden which turns out to be 369
    #            figHeight = figWidth * golden_mean
    plot = NTplot(title=residueName,
                  xRange=(plotparams.min, plotparams.max),
                  xTicks=xTicks,
                  xLabel=dihedralNameLatex,
                  yLabel='Occurrence')
    ps.addPlot(plot)

    if not angleList.__dict__.has_key('good'):
        nTerror("angleList.__dict__.has_key('good')")
        return True

    plot.histogram(angleList.good.zap(1),
                   plotparams.min,
                   plotparams.max,
                   bins,
                   attributes=boxAttributes(fillColor=plotparams.color))

    if angleList.__dict__.has_key('outliers'):
        plot.histogram(angleList.outliers.zap(1),
                       plotparams.min,
                       plotparams.max,
                       bins,
                       attributes=boxAttributes(fillColor=plotparams.outlier),
                       valueIndexPairList=angleList.outliers)

#    aAv  = angleList.cav
    aAv = angleList.good.cav

    width = 4.0
    lower, upper = 45, 55
    alpha = 0.3

    ylim = plot.get_ylim()
    ylimMax = 5  # Just assume.
    if ylim is not None:
        ylimMax = ylim[1]
    # note plotparams.lower is a color!
    bounds = NTlist(lower, upper)
    bounds.limit(plotparams.min, plotparams.max)
    if bounds[0] < bounds[1]:  # single box
        point = (bounds[0], 0)  # lower left corner of only box.
        sizes = (bounds[1] - bounds[0], ylimMax)
        #            nTdebug("point: " + repr(point))
        #            nTdebug("sizes: " + repr(sizes))
        plot.box(point, sizes,
                 boxAttributes(fillColor=plotparams.lower, alpha=alpha))
    else:  # two boxes
        # right box
        point = (bounds[0], 0)  # lower left corner of first box.
        sizes = (plotparams.max - bounds[0], ylimMax)
        #            nTdebug("point: " + repr(point))
        #            nTdebug("sizes: " + repr(sizes))
        plot.box(point, sizes,
                 boxAttributes(fillColor=plotparams.lower, alpha=alpha))
        point = (plotparams.min, 0)  # lower left corner of second box.
        sizes = (bounds[1] - plotparams.min, ylimMax)
        #            nTdebug("point: " + repr(point))
        #            nTdebug("sizes: " + repr(sizes))
        plot.box(point, sizes,
                 boxAttributes(fillColor=plotparams.lower, alpha=alpha))

#        plot.line( (lower, 0), (lower, ylimMax),
#                   lineAttributes(color=plotparams.lower, width=width) )
#        plot.line( (upper, 0), (upper, ylimMax),
#                   lineAttributes(color=plotparams.upper, width=width) )
#
# Always plot the cav line
# pylint: disable=E1102
    plot.line((aAv, 0), (aAv, ylimMax),
              lineAttributes(color=plotparams.average, width=width))
    #                   dashdotline() )
    fnBase = "testPlotHistoDihedral"
    if True:
        fn = fnBase + '.png'
    else:
        i = 0
        fn = None
        while not fn or os.path.exists(fn):
            i += 1
            fn = fnBase + '_' + str(i) + '.png'
    ps.hardcopy(fn, graphicsFormat)
Ejemplo n.º 12
0
def plotTestHistoDihedral():
    nTdebug("Starting plotTestHistoDihedral")
    ps = NTplotSet() # closes any previous plots
    ps.hardcopySize = (600,369)

    graphicsFormat = "png"
    residueName = "ASN1"
    dihedralName= "CHI1"
    dihedralNameLatex= "$\chi 1$"

    project     = Project('plotTestHistoDihedral')
    plotparams  = project.plotParameters.getdefault(dihedralName,'dihedralDefault')
    binsize     = int(plotparams.ticksize / 12 ) # 60 over 12 results in 5 degrees. as an int
    bins        = (plotparams.max - plotparams.min)/binsize # int

    angleList = NTlist( 50,60, 51, 53, 52, 54, 62, 90, 93 )
    angleList.cAverage()
    goodAndOutliers = peirceTest( angleList )
    if not goodAndOutliers:
        nTerror("No goodAndOutliers in plotTestHistoDihedral")
        return True
    angleList.good, angleList.outliers = goodAndOutliers


    angleList.limit(          plotparams.min, plotparams.max ) # Actually not plotted angle anymore.?
    angleList.cAverage(       plotparams.min, plotparams.max )
    angleList.good.limit(     plotparams.min, plotparams.max, byItem=1 )
    angleList.good.cAverage(  plotparams.min, plotparams.max, byItem=1 )
    angleList.outliers.limit( plotparams.min, plotparams.max, byItem=1 )
    angleList.outliers.cAverage(  plotparams.min, plotparams.max, byItem=1 )

    for i,angleL in enumerate( [angleList, angleList.good, angleList.outliers] ):
        nTdebug("angleL %d: %s" % (i, str(angleL)))
        nTdebug("      cav: %s" % angleL.cav)
    # end for
    xTicks = range(int(plotparams.min), int(plotparams.max+1), plotparams.ticksize)
#        nTdebug("xTicks: " + repr(xTicks))
#        figWidth  = 600
#        figHeight = None # Golden which turns out to be 369
#            figHeight = figWidth * golden_mean
    plot = NTplot(title  = residueName,
                  xRange = (plotparams.min, plotparams.max),
                  xTicks = xTicks,
                  xLabel = dihedralNameLatex,
                  yLabel = 'Occurrence'
                )
    ps.addPlot(plot)

    if not angleList.__dict__.has_key('good'):
        nTerror("angleList.__dict__.has_key('good')")
        return True

    plot.histogram( angleList.good.zap(1),
                    plotparams.min, plotparams.max, bins,
                    attributes = boxAttributes( fillColor=plotparams.color )
                  )

    if angleList.__dict__.has_key('outliers'):
        plot.histogram( angleList.outliers.zap(1),
                    plotparams.min, plotparams.max, bins,
                    attributes = boxAttributes( fillColor=plotparams.outlier),
                    valueIndexPairList=angleList.outliers
                  )

#    aAv  = angleList.cav
    aAv  = angleList.good.cav
    
    width = 4.0
    lower, upper = 45, 55
    alpha = 0.3

    ylim = plot.get_ylim()
    ylimMax = 5 # Just assume.
    if ylim is not None:
        ylimMax = ylim[1]
    # note plotparams.lower is a color!
    bounds = NTlist(lower, upper)
    bounds.limit(plotparams.min, plotparams.max)
    if bounds[0] < bounds[1]: # single box
        point = (bounds[0], 0) # lower left corner of only box.
        sizes = (bounds[1]-bounds[0],ylimMax)
#            nTdebug("point: " + repr(point))
#            nTdebug("sizes: " + repr(sizes))
        plot.box(point, sizes, boxAttributes(fillColor=plotparams.lower, alpha=alpha))
    else: # two boxes
        # right box
        point = (bounds[0], 0) # lower left corner of first box.
        sizes = (plotparams.max-bounds[0],ylimMax)
#            nTdebug("point: " + repr(point))
#            nTdebug("sizes: " + repr(sizes))
        plot.box(point, sizes, boxAttributes(fillColor=plotparams.lower, alpha=alpha))
        point = (plotparams.min, 0) # lower left corner of second box.
        sizes = (bounds[1]-plotparams.min,ylimMax)
#            nTdebug("point: " + repr(point))
#            nTdebug("sizes: " + repr(sizes))
        plot.box(point, sizes, boxAttributes(fillColor=plotparams.lower, alpha=alpha))



#        plot.line( (lower, 0), (lower, ylimMax),
#                   lineAttributes(color=plotparams.lower, width=width) )
#        plot.line( (upper, 0), (upper, ylimMax),
#                   lineAttributes(color=plotparams.upper, width=width) )
#
    # Always plot the cav line
    # pylint: disable=E1102    
    plot.line( (aAv, 0), (aAv, ylimMax), lineAttributes(color=plotparams.average, width=width) )
#                   dashdotline() )
    fnBase = "testPlotHistoDihedral"
    if True:
        fn = fnBase + '.png'
    else:
        i=0
        fn = None
        while not fn or os.path.exists(fn):
            i += 1
            fn = fnBase + '_' + str(i) + '.png'
    ps.hardcopy(fn, graphicsFormat)