コード例 #1
0
    def __init__(self,
                 coords=None,
                 radii=None,
                 atnames=None,
                 filename=None,
                 name='msms',
                 maxnat=0):
        """MSMS <- MSMS(coords=None, radii=None, atnames=None, filename=None,
                        name='msms', maxnat=0)

    This class can be instantiated int a number of ways:

    - no arguments:
         m = MSMS()
    - with an array of Nx4 coordinates:
         m = MSMS(coords = c)
    - with an array of Nx3 centers and an array of radii:
         m = MSMS(coords = c, radii = r)
    - by specifying a filename from wich to load the xyzr and possibly names
         m = MSMS(filename)

    additional parameters are:
    name:    string to name that surface
    atnames: array of N atom names
    maxnat:  maximum number of atoms in the molecule. This number needs to be
             larger than largest number of atoms that surface will ever have.
    """
        if filename:
            c, atnames = readxyzr(filename)
            nat = len(c)
            if name: self.surface_name = name
            else: self.surface_name = os.basename(filename)
        else:
            self.surface_name = name
            if coords is not None:
                self.coords = num_array(coords).astype(num_float32)
                assert len(
                    self.coords.shape) == 2, "coordinates array of bad shape"
                if self.coords.shape[1] == 3:
                    self.radii = num_array(radii).astype(num_float32)
                    self.radii.shape = (self.radii.shape[0], 1)
                    c = num_concatenate((self.coords, self.radii), 1)
                else:
                    assert self.coords.shape[
                        1] == 4, "coordinates array of bad shape"
                    c = self.coords
                if not c.flags.contiguous or c.dtype.char != 'f':
                    c = num_array(c).astype(num_float32)
                nat = len(c)
            else:
                c = None
                nat = 0

        msms.MOLSRF.__init__(self,
                             name=name,
                             coord=c,
                             nat=nat,
                             maxat=maxnat,
                             names=atnames)
        self.geometry = None
コード例 #2
0
    def test_relfreq(self):
        "Testing relfreq"

        data = [self.L, self.LF, self.A, self.AF]
        results1 = ([
            0.10000000000000001, 0.10000000000000001, 0.10000000000000001,
            0.10000000000000001, 0.10000000000000001, 0.10000000000000001,
            0.10000000000000001, 0.10000000000000001, 0.10000000000000001,
            0.10000000000000001
        ], -0.045000050000000069, 2.0900001000000001, 0)
        results2 = ([
            0.10000000000000001, 0.10000000000000001, 0.10000000000000001,
            0.10000000000000001, 0.10000000000000001, 0.10000000000000001,
            0.10000000000000001, 0.10000000000000001, 0.10000000000000001,
            0.10000000000000001
        ], -0.045000050000000069, 2.0900001000000001, 0)
        results3 = (num_array(
            [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1,
             0.1]), -0.045000050000000069, 2.0900001000000001, 0)
        results4 = (num_array(
            [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1,
             0.1]), -0.045000050000000069, 2.0900001000000001, 0)

        i = 0
        for d in data:
            self.assertEqual(stats.relfreq(d)[i], results1[i])
            i += 1
コード例 #3
0
    def test_mode(self):
        "Testing mode"
        L1 = [1, 1, 1, 2, 3, 4, 5]
        L2 = [1, 1, 1, 2, 3, 4, 5, 6]

        A1 = num_array(L1)
        A2 = num_array(L2)
        data = [L1, L2, A1, A2]
        for d in data:
            self.assertEqual(stats.mode(d), (3, [1]))
コード例 #4
0
    def test_mode(self):
        "Testing mode"
        L1 = [1,1,1,2,3,4,5 ]
        L2 = [1,1,1,2,3,4,5,6 ]

        A1 = num_array( L1 )
        A2 = num_array( L2 )
        data = [ L1, L2, A1, A2  ]
        for d in data :
            self.assertEqual( stats.mode( d ), (3, [1]) )
コード例 #5
0
ファイル: test_all.py プロジェクト: haavee/RDBE
    def setUp(self):
        "Gets called on each test"
        # generate list data
        self.L  = self.LF = range( 1, 21 )
        self.LF[2] = 3.0
        self.LL = [ self.L ] * 5

        # array data if numpy is installed
        self.A  = self.AF = num_array( self.L )
        self.AA = num_array( self.LL )
        
        self.EQ = self.assertAlmostEqual
コード例 #6
0
 def test_cumfreq(self):
     "Testing cumfreq"
     data = [ self.L, self.LF, self.A, self.AF ]
     results1 = ([2, 4, 6, 8, 10, 12, 14, 16, 18, 20], -0.045000050000000069, 2.0900001000000001, 0 )
     results2 = ([2, 4, 6, 8, 10, 12, 14, 16, 18, 20], -0.045000050000000069, 2.0900001000000001, 0 )
     results3 = (num_array([  2.,   4.,   6.,   8.,  10.,  12.,  14.,  16.,  18.,  20.]), -0.045000050000000069, 2.0900001000000001, 0 )
     results4 = (num_array([  2.,   4.,   6.,   8.,  10.,  12.,  14.,  16.,  18.,  20.]), -0.045000050000000069, 2.0900001000000001, 0 )
     
     i = 0
     for d in data:
         self.assertEqual( stats.cumfreq( d )[i], results1[i] )
         i += 1
コード例 #7
0
 def test_cumfreq(self):
     "Testing cumfreq"
     data = [ self.L, self.LF, self.A, self.AF ]
     results1 = ([2, 4, 6, 8, 10, 12, 14, 16, 18, 20], -0.045000050000000069, 2.0900001000000001, 0 )
     results2 = ([2, 4, 6, 8, 10, 12, 14, 16, 18, 20], -0.045000050000000069, 2.0900001000000001, 0 )
     results3 = (num_array([  2.,   4.,   6.,   8.,  10.,  12.,  14.,  16.,  18.,  20.]), -0.045000050000000069, 2.0900001000000001, 0 )
     results4 = (num_array([  2.,   4.,   6.,   8.,  10.,  12.,  14.,  16.,  18.,  20.]), -0.045000050000000069, 2.0900001000000001, 0 )
     
     i = 0
     for d in data:
         self.assertEqual( stats.cumfreq( d )[i], results1[i] )
         i += 1
コード例 #8
0
 def test_relfreq(self):
     "Testing relfreq"
     
     data = [ self.L, self.LF, self.A, self.AF ]
     results1 = ([0.10000000000000001, 0.10000000000000001, 0.10000000000000001, 0.10000000000000001, 0.10000000000000001, 0.10000000000000001, 0.10000000000000001, 0.10000000000000001, 0.10000000000000001, 0.10000000000000001], -0.045000050000000069, 2.0900001000000001, 0)
     results2 = ([0.10000000000000001, 0.10000000000000001, 0.10000000000000001, 0.10000000000000001, 0.10000000000000001, 0.10000000000000001, 0.10000000000000001, 0.10000000000000001, 0.10000000000000001, 0.10000000000000001], -0.045000050000000069, 2.0900001000000001, 0)
     results3 = (num_array([ 0.1,  0.1,  0.1,  0.1,  0.1,  0.1,  0.1,  0.1,  0.1,  0.1]), -0.045000050000000069, 2.0900001000000001, 0)
     results4 = (num_array([ 0.1,  0.1,  0.1,  0.1,  0.1,  0.1,  0.1,  0.1,  0.1,  0.1]), -0.045000050000000069, 2.0900001000000001, 0)
     
     i = 0
     for d in data:
         self.assertEqual( stats.relfreq( d )[i], results1[i])
         i += 1
コード例 #9
0
 def test_describe(self):
     "Testing describe"
     self.assertEqual(
         stats.describe(self.L),
         (20, (1, 20), 10.5, 5.9160797830996161, 0.0, 1.7939849624060149))
     self.assertEqual(
         stats.describe(self.LF),
         (20, (1, 20), 10.5, 5.9160797830996161, 0.0, 1.7939849624060149))
     self.assertEqual(stats.describe(self.A),
                      (20, (1, 20), 10.5, 5.9160797830996161,
                       num_array(0.0), num_array(1.7939849624060149)))
     self.assertEqual(stats.describe(self.AF),
                      (20, (1, 20), 10.5, 5.9160797830996161,
                       num_array(0.0), num_array(1.7939849624060149)))
コード例 #10
0
    def __init__(self, coords=None, radii=None, atnames=None, filename=None,
                 name='msms', maxnat=0):
        """MSMS <- MSMS(coords=None, radii=None, atnames=None, filename=None,
                        name='msms', maxnat=0)

    This class can be instantiated int a number of ways:

    - no arguments:
         m = MSMS()
    - with an array of Nx4 coordinates:
         m = MSMS(coords = c)
    - with an array of Nx3 centers and an array of radii:
         m = MSMS(coords = c, radii = r)
    - by specifying a filename from wich to load the xyzr and possibly names
         m = MSMS(filename)

    additional parameters are:
    name:    string to name that surface
    atnames: array of N atom names
    maxnat:  maximum number of atoms in the molecule. This number needs to be
             larger than largest number of atoms that surface will ever have.
    """
        if filename:
            c, atnames = readxyzr(filename)
            nat = len(c)
            if name: self.surface_name = name
            else: self.surface_name = os.basename(filename)
        else:
            self.surface_name = name
            if coords is not None:
                self.coords = num_array(coords).astype(num_float32)
                assert len(self.coords.shape)==2, "coordinates array of bad shape"
                if self.coords.shape[1] == 3:
                    self.radii = num_array(radii).astype(num_float32)
                    self.radii.shape = (self.radii.shape[0],1)
                    c = num_concatenate( (self.coords, self.radii), 1 )
                else:
                    assert self.coords.shape[1]==4, "coordinates array of bad shape"
                    c = self.coords
                if not c.flags.contiguous or c.dtype.char!='f':
                    c = num_array(c).astype(num_float32)
                nat = len(c)
            else:
                c=None
                nat=0
                
        msms.MOLSRF.__init__(self, name=name, coord=c, nat=nat,
                             maxat=maxnat, names=atnames)
        self.geometry = None
コード例 #11
0
    def setUp(self):
        "Gets called on each test"
        # generate list data
        self.L = self.LF = range(1, 21)
        self.LF[2] = 3.0
        self.LL = [self.L] * 5

        # array data if numpy is installed
        self.A = self.AF = num_array(self.L)
        self.AA = num_array(self.LL)

        self.M = range(4, 24)
        self.M[10] = 34
        self.B = num_array(self.M)

        self.PB = [0] * 9 + [1] * 11
        self.APB = num_array(self.PB)

        self.EQ = self.assertAlmostEqual
コード例 #12
0
    def setUp(self):
        "Gets called on each test"
        # generate list data
        self.L  = self.LF = range( 1, 21 )
        self.LF[2] = 3.0
        self.LL = [ self.L ] * 5

        # array data if numpy is installed
        self.A  = self.AF = num_array( self.L )
        self.AA = num_array( self.LL )
        
        self.M = range(4,24)
        self.M[10] = 34 
        self.B = num_array(self.M)
        
        self.PB = [0]*9 + [1]*11
        self.APB = num_array(self.PB)
        
        self.EQ = self.assertAlmostEqual
コード例 #13
0
 def test_histogram(self):
     "Testing histogram"
     data = [ self.L, self.A ]
     results1 = ([2, 2, 2, 2, 2, 2, 2, 2, 2, 2], -0.045000050000000069, 2.0900001000000001, 0)
     results2 = (num_array([ 2.,  2.,  2.,  2.,  2.,  2.,  2.,  2.,  2.,  2.]), -0.045000050000000069, 2.0900001000000001, 0)
     
     i = 0
     for d in data:
         self.assertEqual( stats.histogram( d )[i], results1[i] ) 
         i += 1
コード例 #14
0
    def test_medianscore(self):
        "Testing medianscore"

        # data of even lenghts
        data1 = [self.L, self.LF, self.A, self.AF]
        for d in data1:
            self.EQ(stats.medianscore(d), 10.5)

        # data with odd lenghts
        L2 = self.L + [20]
        A2 = num_array(L2)
        data2 = [L2, A2]
        for d in data2:
            self.EQ(stats.medianscore(d), 11)
コード例 #15
0
    def buriedVertices(self, coords, radii=None, component=None):
        """buriedVertices(coords, radii=None, component=None)

    tags all vertices of an SES trianuglated component that are buried by a
set of spheres.
- If radii is None, coords has to be an Mx4 array of floats describing the
centers and radii of the set of spheres used to check if the surface is
burried. Else coords has to be an Mx3 array describing the centers and the
radii have to be provided in the radii array.
- If component is None, this operation is performed on all components.
Components are specified using 0-based integers, 0 being the external one
"""
        if radii is not None:
            radii = num_array(radii, num_float32)
            radii.shape = (-1, 1)
            assert len(radii) == len(coords)
            coords = num_array(coords, num_float32)
            coords = num_concatenate((coords, radii), 1)
        else:
            coords = num_array(coords, num_float32)

        assert len(coords.shape) == 2 and coords.shape[1] == 4

        if component is None:
            self.resetBuriedVertexFlags()
            rs = self.rsr.fst
            i = 0
            while rs.this:
                if rs.ses.this and rs.ses.nbtri > 0:
                    self.findBuriedVertices(rs.ses.this, coords, len(coords))
                    i = i + 1
                rs = rs.nxt
        else:
            self.resetBuriedVertexFlags(component)
            comp = self._getSESComp(component).this
            self.findBuriedVertices(comp, coords, len(coords))