예제 #1
0
파일: __init__.py 프로젝트: barettog1/ProDy
from numpy import array, invert, ones, tile

from prody import Ensemble, PDBEnsemble, LOGGER
from prody.tests.datafiles import parseDatafile, DATA_FILES

LOGGER.verbosity = 'none'

ATOL = 1e-5
RTOL = 0

ATOMS = parseDatafile('multi_model_truncated', subset='ca')
ALLATOMS = parseDatafile('multi_model_truncated')
DCD = parseDatafile('dcd')
COORDS = ATOMS.getCoords()
COORDSETS = ATOMS.getCoordsets()
ENSEMBLE = Ensemble(ATOMS)
CONF = ENSEMBLE[0]
DATA = DATA_FILES['multi_model_truncated']
ENSEMBLE_RMSD = DATA['rmsd_ca']
ENSEMBLE_SUPERPOSE = DATA['rmsd_ca_aligned']

ENSEMBLEW = Ensemble(ATOMS)
ENSEMBLEW.setWeights(ones(len(ATOMS), dtype=float))
CONFW = ENSEMBLEW[0]

PDBENSEMBLE = PDBEnsemble('PDBEnsemble')
PDBENSEMBLE.setCoords(COORDS)
WEIGHTS = []
for i, xyz in enumerate(ATOMS.iterCoordsets()):
    weights = ones((len(ATOMS), 1), dtype=float)
    if i > 0:
예제 #2
0
    def testMSF(self):

        dcd = DCDFile(pathDatafile('dcd'))
        ens = parseDatafile('dcd')
        ens.superpose()
        assert_array_almost_equal(calcMSF(dcd), calcMSF(ens), 4)
예제 #3
0
    def testMSFfloat(self):

        dcd = DCDFile(pathDatafile('dcd'), astype=float)
        ens = parseDatafile('dcd', astype=float)
        ens.superpose()
        assert_array_almost_equal(calcMSF(dcd), calcMSF(ens), 10)
예제 #4
0
from numpy.testing import assert_array_equal

from numpy import concatenate

from prody.dynamics import calcGNM, calcANM
from prody.dynamics import extendModel, extendMode, extendVector

from prody.tests import unittest
from prody.tests.datafiles import parseDatafile

from prody import _PY3K

if not _PY3K:
    range = xrange

ATOMS = parseDatafile('1ubi').protein.copy()
ANM, NODES = calcANM(ATOMS)
GNM = calcGNM(ATOMS)[0]

EXT1D = concatenate([[i] * len(res)
                     for i, res in enumerate(ATOMS.iterResidues())])

EXT3D = concatenate([list(range(i*3, (i+1)*3)) * len(res)
                     for i, res in enumerate(ATOMS.iterResidues())])


class TestExtending(unittest.TestCase):

    def testModel3d(self):

        ext = extendModel(ANM, NODES, ATOMS)[0]
예제 #5
0
from prody.tests import unittest
from prody.tests.datafiles import parseDatafile, pathDatafile

from prody.trajectory import DCDFile
from prody.measure import calcDistance, buildDistMatrix
from prody.measure import calcAngle, calcPsi, calcPhi
from prody.measure import calcCenter
from prody.measure import calcMSF
from prody import LOGGER
LOGGER.verbosity = None

ATOL = 1e-5
RTOL = 0


UBI = parseDatafile('1ubi')
UBI_NTER = UBI['A', 1]
UBI_GLY10 = UBI['A', 10]
UBI_CTER = UBI['A', 76]

class TestDihedrals(unittest.TestCase):

    """Test functions that calculate dihedral angles."""

    def testCalcPsi(self):

        assert_approx_equal(14.386, calcPsi(UBI_GLY10), 2)

    def testCalcPhi(self):

        assert_approx_equal(87.723, calcPhi(UBI_GLY10), 2)
예제 #6
0
"""This module contains unit tests for :mod:`.frame` module."""

from code import interact
from prody.tests import TestCase

from numpy import array
from numpy.testing import assert_allclose

from prody.trajectory import Trajectory
from prody.tests.datafiles import parseDatafile, pathDatafile

DCD = Trajectory(pathDatafile('dcd'))
PDB = parseDatafile('multi_model_truncated', model=1)
RMSD_ALL = array([0.0, 1.380, 1.745])
RMSD_CARBON = array([0.0, 0.964, 1.148])


class TestSuperpose(TestCase):

    def setUp(self):

        DCD.setCoords(PDB.getCoords())
        DCD.reset()

    def testAll(self):

        rmsd = []
        for frame in DCD:
            frame.superpose()
            rmsd.append(frame.getRMSD())
        assert_allclose(rmsd, RMSD_ALL, atol=0.001)
예제 #7
0
from numpy.testing import assert_array_equal

from numpy import concatenate

from prody.dynamics import calcGNM, calcANM
from prody.dynamics import extendModel, extendMode, extendVector

from prody.tests import unittest
from prody.tests.datafiles import parseDatafile

from prody import _PY3K

if not _PY3K:
    range = xrange

ATOMS = parseDatafile('1ubi').protein.copy()
ANM, NODES = calcANM(ATOMS)
GNM = calcGNM(ATOMS)[0]

EXT1D = concatenate([[i] * len(res)
                     for i, res in enumerate(ATOMS.iterResidues())])

EXT3D = concatenate([
    list(range(i * 3, (i + 1) * 3)) * len(res)
    for i, res in enumerate(ATOMS.iterResidues())
])


class TestExtending(unittest.TestCase):
    def testModel3d(self):
예제 #8
0
from numpy import array, concatenate, unique
from numpy.testing import assert_array_equal, assert_equal

from prody.tests import unittest
from prody.tests.datafiles import parseDatafile, pathDatafile

from prody.measure import Contacts, findNeighbors, iterNeighbors
from prody.measure import buildDistMatrix, calcDistance

UBI = parseDatafile('1ubi')
UBI_XYZ = UBI._getCoords()
UBI_MIN = UBI_XYZ.min(0)
UBI_MAX = UBI_XYZ.max(0)
UBI_UC = UBI_MAX - UBI_MIN
N0P = [-1, 0, 1]
UBI_EDGES = UBI_MIN + UBI_UC * array([(i, j, k) for i in N0P for j in N0P
                                      for k in N0P])
UBI_RADIUS = 20

UBI_CONTACTS = Contacts(UBI_XYZ)
UBI_CONTACTS_PBC = Contacts(UBI_XYZ, UBI_UC)


class TestContacts(unittest.TestCase):
    """Test functions that calculate dihedral angles."""
    def testPBCvsNONE(self):

        wout_pbc = unique(concatenate([UBI_CONTACTS(UBI_RADIUS, UBI_EDGES)]))
        with_pbc = UBI_CONTACTS_PBC(UBI_RADIUS, UBI_MIN)
        assert_array_equal(wout_pbc, with_pbc)
예제 #9
0
"""This module contains unit tests for :mod:`prody.measure.transform` module.
"""

from numpy import zeros, ones, eye, all
from numpy.testing import assert_equal

from prody.tests import unittest
from prody.tests.datafiles import parseDatafile

from prody.measure import moveAtoms, wrapAtoms

UBI = parseDatafile('1ubi')


class TestMoveAtoms(unittest.TestCase):

    def testToArgument(self):

        atoms = UBI.ca

        coords = UBI.getCoords()
        center = atoms._getCoords().mean(0)
        moveAtoms(atoms, to=zeros(3), ag=True)
        assert_equal(UBI._getCoords(), coords - center)

    def testByArgument(self):

        atoms = UBI
        offset = ones(3) * 10.
        coords = atoms.getCoords()
        moveAtoms(atoms, by=offset)
예제 #10
0
from numpy import array, invert, ones, tile

from prody import Ensemble, PDBEnsemble, LOGGER
from prody.tests.datafiles import parseDatafile, DATA_FILES

LOGGER.verbosity = 'none'

ATOL = 1e-5
RTOL = 0

ATOMS = parseDatafile('multi_model_truncated', subset='ca')
ALLATOMS = parseDatafile('multi_model_truncated')
DCD = parseDatafile('dcd')
COORDS = ATOMS.getCoords()
COORDSETS = ATOMS.getCoordsets()
ENSEMBLE = Ensemble(ATOMS)
CONF = ENSEMBLE[0]
DATA = DATA_FILES['multi_model_truncated']
ENSEMBLE_RMSD = DATA['rmsd_ca']
ENSEMBLE_SUPERPOSE = DATA['rmsd_ca_aligned']

ENSEMBLEW = Ensemble(ATOMS)
ENSEMBLEW.setWeights(ones(len(ATOMS), dtype=float))
CONFW = ENSEMBLEW[0]

PDBENSEMBLE = PDBEnsemble('PDBEnsemble')
PDBENSEMBLE.setCoords(COORDS)
WEIGHTS = []
for i, xyz in enumerate(ATOMS.iterCoordsets()):
    weights = ones((len(ATOMS), 1), dtype=float)
    if i > 0:
예제 #11
0
"""This module contains unit tests for :mod:`.frame` module."""

from code import interact
from prody.tests import TestCase

from numpy import array
from numpy.testing import assert_allclose

from prody.trajectory import Trajectory
from prody.tests.datafiles import parseDatafile, pathDatafile

DCD = Trajectory(pathDatafile('dcd'))
PDB = parseDatafile('multi_model_truncated', model=1)
RMSD_ALL = array([0.0, 1.380, 1.745])
RMSD_CARBON = array([0.0, 0.964, 1.148])


class TestSuperpose(TestCase):
    def setUp(self):

        DCD.setCoords(PDB.getCoords())
        DCD.reset()

    def testAll(self):

        rmsd = []
        for frame in DCD:
            frame.superpose()
            rmsd.append(frame.getRMSD())
        assert_allclose(rmsd, RMSD_ALL, atol=0.001)
예제 #12
0
from numpy import array, concatenate, unique
from numpy.testing import assert_array_equal, assert_equal

from prody.tests import unittest
from prody.tests.datafiles import parseDatafile, pathDatafile

from prody.measure import Contacts, findNeighbors, iterNeighbors
from prody.measure import buildDistMatrix, calcDistance


UBI = parseDatafile("1ubi")
UBI_XYZ = UBI._getCoords()
UBI_MIN = UBI_XYZ.min(0)
UBI_MAX = UBI_XYZ.max(0)
UBI_UC = UBI_MAX - UBI_MIN
N0P = [-1, 0, 1]
UBI_EDGES = UBI_MIN + UBI_UC * array([(i, j, k) for i in N0P for j in N0P for k in N0P])
UBI_RADIUS = 20

UBI_CONTACTS = Contacts(UBI_XYZ)
UBI_CONTACTS_PBC = Contacts(UBI_XYZ, UBI_UC)


class TestContacts(unittest.TestCase):

    """Test functions that calculate dihedral angles."""

    def testPBCvsNONE(self):

        wout_pbc = unique(concatenate([UBI_CONTACTS(UBI_RADIUS, UBI_EDGES)]))
        with_pbc = UBI_CONTACTS_PBC(UBI_RADIUS, UBI_MIN)