Exemple #1
0
    def test_lognormal(self):
        """Statistics.lognormal test"""
        import random
        import Biskit.gnuplot as gnuplot
        import Biskit.hist as H

        cr = []
        for i in range( 10000 ):
            ## Some random values drawn from the same lognormal distribution 

            alpha = 1.5
            beta = .7
            x = 10.

            R = [ random.lognormvariate( alpha, beta ) for j in range( 10 ) ]

            cr += [ logConfidence( x, R )[0] ]


        ca = logArea( x, alpha, beta )

        if self.local:
            gnuplot.plot( H.density( N.array(cr) - ca, 100 ) )

            globals().update( locals() )

        self.assertAlmostEqual( ca,  0.86877651432955771, 7)
def plot( delta_scores_1, delta_rms_1, delta_scores_2, delta_rms_2,
          feps ):
    """
    """
    p = B.FramedPlot()
    p.xlabel = r"Interface rmsd to bound relative to free"
    p.ylabel = r"Docking performance relative to free"
    
    points_1 = B.Points( delta_rms_1, delta_scores_1, type='circle',
                         symbolsize=1)
    points_1.label = 'MD'
    
    points_2 = B.Points( delta_rms_2, delta_scores_2, type='diamond',
                         symbolsize=1)
    points_2.label = 'PCR-MD'

    a = concatenate( (delta_rms_1, delta_rms_2) )
    h = density( a, 20 )
    scale = max( h[:,1] ) / max( a )
    histogram = B.Curve( h[:,0], h[:,1] * scale )
    histogram.label = "distribution"
    
    p.add( points_1 )
    p.add( points_2 )
    p.add( histogram )
    p.add( B.PlotKey( 0.73, 0.95, [ points_1, points_2, histogram ] ) )

    p.show()
    p.write_eps( feps )
Exemple #3
0
    def test_lognormal(self):
        """Statistics.lognormal test"""
        import random
        import Biskit.gnuplot as gnuplot
        import Biskit.hist as H

        cr = []
        for i in range(10000):
            ## Some random values drawn from the same lognormal distribution

            alpha = 1.5
            beta = .7
            x = 10.

            R = [random.lognormvariate(alpha, beta) for j in range(10)]

            cr += [logConfidence(x, R)[0]]

        ca = logArea(x, alpha, beta)

        if self.local:
            gnuplot.plot(H.density(N.array(cr) - ca, 100))

            globals().update(locals())

        self.assertAlmostEqual(ca, 0.86877651432955771, 7)
Exemple #4
0
def plot( delta_scores_1, delta_rms_1, delta_scores_2, delta_rms_2,
          feps ):
    """
    """
    p = B.FramedPlot()
    p.xlabel = r"Interface rmsd to bound relative to free"
    p.ylabel = r"Docking performance relative to free"
    
    points_1 = B.Points( delta_rms_1, delta_scores_1, type='circle',
                         symbolsize=1)
    points_1.label = 'MD'
    
    points_2 = B.Points( delta_rms_2, delta_scores_2, type='diamond',
                         symbolsize=1)
    points_2.label = 'PCR-MD'

    a = concatenate( (delta_rms_1, delta_rms_2) )
    h = density( a, 20 )
    scale = max( h[:,1] ) / max( a )
    histogram = B.Curve( h[:,0], h[:,1] * scale )
    histogram.label = "distribution"
    
    p.add( points_1 )
    p.add( points_2 )
    p.add( histogram )
    p.add( B.PlotKey( 0.73, 0.95, [ points_1, points_2, histogram ] ) )

    p.show()
    p.write_eps( feps )
    def plotHistogram( self, *name, **arg ):
        """
        @param bins: number of bins (10)
        @type  bins: int
        @param ynormalize: normalize histograms to area 1.0 (False)
        @type  ynormalize: bool
        @param xnormalize: adapt bin range to min and max of all profiles (True)
        @type  xnormalize: bool
        @param xrange: min and max of bin range (None)
        @type  xrange: (float, float)
        @param steps: draw histogram steps (True)
        @type  steps: bool
        """
        if not biggles:
            raise ImportError, 'module biggles could not be imported'

        plot = biggles.FramedArray( len(name),1 )

        if not 'size' in arg:
            arg['size'] = 1
        
        bins = arg.get('bins', 10)
        hist = arg.get('ynormalize', False)
        steps= arg.get('steps', 1)
        histrange= arg.get('xrange', None)
        autorange= arg.get('xnormalize', histrange is None)
        
        xkey = arg.get('xkey', None)
        if xkey:
            plot.xlabel = xkey

        if autorange:
            v = []
            for keys in name:
                if not type(keys) is tuple:
                    keys = ( keys, )
                for key in keys:
                    v += list(self[key])
            histrange = ( min( v ), max( v ) )
            
        for i, keys in enumerate(name):
            
            if not type(keys) is tuple:
                keys = ( keys, )
                
            for j, key in enumerate(keys):

                h = density( self[key], nBins=bins, steps=steps, hist=hist,
                             range=histrange )
                x = h[:,0]
                y = h[:,1]
                
                colors = [0] + T.colorSpectrum( len(keys) , '00FF00', 'FF00FF')

                plot[i,0].add( biggles.Curve( x, y, color=colors[j], **arg ) )
    
                plot[i,0].add( biggles.PlotLabel( 0.7, 0.95-j*0.1, key,
                                                  color=colors[j] ) )

        return plot
Exemple #6
0
    def plotContactDensity(self, step=1, cutoff=4.5):
        """
        Example. plot histogramm of contact density. Somehing wrong??

        @raise ComplexTrajError: if gnuplot program is not installed
        """
        if not gnuplot.installed:
            raise ComplexTrajError, 'gnuplot program is not installed'
        r = self.averageContacts(step, cutoff)
        r = N0.ravel(r)
        r = N0.compress(r, r)
        gnuplot.plot(hist.density(r, 10))
Exemple #7
0
    def __init__(self, p=None, values=None, bins=20):
        """
        @param p: discrete distribution, array (2 x len(data) ) with
                  start of bin and witdh of bin (default: None)
        @type  p: array
        @param values: list of samples  (default: None)
        @type  values: [float]
        @param bins: number of bins  (default: 20)
        @type  bins: int
        """
        if p is None and values is None:
            raise ValueError, 'Either a discrete distribution or ' + \
                  'a list of samples must be specified'

        if values is not None:

            p = H.density(values, bins, steps=0)

        self.store(p)

        self.verbose = 0
Exemple #8
0
    def __init__(self, p = None, values = None, bins = 20):
        """
        @param p: discrete distribution, array (2 x len(data) ) with
                  start of bin and witdh of bin (default: None)
        @type  p: array
        @param values: list of samples  (default: None)
        @type  values: [float]
        @param bins: number of bins  (default: 20)
        @type  bins: int
        """
        if p is None and values is None:
            raise ValueError, 'Either a discrete distribution or ' + \
                  'a list of samples must be specified'

        if values is not None:

            p = H.density(values, bins, steps = 0)

        self.store(p)

        self.verbose = 0