def test_read_one(self): reader = Reader().readThisFile('data/amber_mini.pdb') coordinates = reader.read() self.assertEqual(148, reader.numberOfAtoms) self.assertEqual(3, reader.numberOfFrames) numpy.testing.assert_almost_equal(testPdbReader.mini_all_coords, coordinates, 12)
def test_read_multiple_only_CA(self): reader = Reader().readThisFile('data/amber_mini.pdb').andThisOtherFile('data/amber_mini.pdb').gettingOnlyCAs() coordinates = reader.read() self.assertEqual(9, reader.numberOfAtoms) self.assertEqual(6, reader.numberOfFrames) coord_shape = coordinates.shape self.assertEqual(coord_shape[0]*coord_shape[1]*coord_shape[2],9*6*3) numpy.testing.assert_almost_equal(numpy.reshape(self.mini_CA_coords,3*9*3), numpy.reshape(coordinates,6*9*3)[0:9*3*3], 10) numpy.testing.assert_almost_equal(numpy.reshape(self.mini_CA_coords,3*9*3), numpy.reshape(coordinates,6*9*3)[9*3*3:], 10)
def test_read_multiple(self): reader = Reader().readThisFile('data/amber_mini.pdb').andThisOtherFile('data/amber_mini.pdb') coordinates = reader.read() self.assertEqual(148, reader.numberOfAtoms) self.assertEqual(6, reader.numberOfFrames) coord_shape = coordinates.shape self.assertEqual(coord_shape[0]*coord_shape[1]*coord_shape[2],148*6*3) numpy.testing.assert_almost_equal(numpy.reshape(self.mini_all_coords,3*148*3), numpy.reshape(coordinates,148*6*3)[0:148*3*3], 10) numpy.testing.assert_almost_equal(numpy.reshape(self.mini_all_coords,3*148*3), numpy.reshape(coordinates,148*6*3)[148*3*3:], 10)
def test_read_multiple_only_CA(self): reader = Reader().readThisFile('data/amber_mini.pdb').andThisOtherFile( 'data/amber_mini.pdb').gettingOnlyCAs() coordinates = reader.read() self.assertEqual(9, reader.numberOfAtoms) self.assertEqual(6, reader.numberOfFrames) coord_shape = coordinates.shape self.assertEqual(coord_shape[0] * coord_shape[1] * coord_shape[2], 9 * 6 * 3) numpy.testing.assert_almost_equal( numpy.reshape(self.mini_CA_coords, 3 * 9 * 3), numpy.reshape(coordinates, 6 * 9 * 3)[0:9 * 3 * 3], 10) numpy.testing.assert_almost_equal( numpy.reshape(self.mini_CA_coords, 3 * 9 * 3), numpy.reshape(coordinates, 6 * 9 * 3)[9 * 3 * 3:], 10)
def test_read_multiple(self): reader = Reader().readThisFile('data/amber_mini.pdb').andThisOtherFile( 'data/amber_mini.pdb') coordinates = reader.read() self.assertEqual(148, reader.numberOfAtoms) self.assertEqual(6, reader.numberOfFrames) coord_shape = coordinates.shape self.assertEqual(coord_shape[0] * coord_shape[1] * coord_shape[2], 148 * 6 * 3) numpy.testing.assert_almost_equal( numpy.reshape(self.mini_all_coords, 3 * 148 * 3), numpy.reshape(coordinates, 148 * 6 * 3)[0:148 * 3 * 3], 10) numpy.testing.assert_almost_equal( numpy.reshape(self.mini_all_coords, 3 * 148 * 3), numpy.reshape(coordinates, 148 * 6 * 3)[148 * 3 * 3:], 10)
def test_read_one_only_CA(self): reader = Reader().readThisFile('data/amber_mini.pdb').gettingOnlyCAs() coordinates = reader.read() self.assertEqual(9, reader.numberOfAtoms) self.assertEqual(3, reader.numberOfFrames) numpy.testing.assert_almost_equal(self.mini_CA_coords, coordinates, 10)
import os import bz2 from pyRMSD.utils.proteinReading import Reader if __name__ == '__main__': using_cuda = "QCP_CUDA_CALCULATOR" in pyRMSD.RMSDCalculator.availableCalculators() ###################### # BENCHMARKING ###################### print "Loading file..." t1 = time.time() print "\tUncompressing..." open("tmp_amber_long.pdb","w").write(bz2.BZ2File("data/amber_long.pdb.tar.bz2").read()) print "\tLoading..." reader = Reader().readThisFile('tmp_amber_long.pdb').gettingOnlyCAs() coordsets = reader.read() number_of_atoms = reader.numberOfAtoms number_of_conformations = reader.numberOfFrames os.system("rm tmp_amber_long.pdb") print "\tDeleting temporary file" t2 = time.time() print 'Loading took %0.3f s' % (t2-t1) ####################### # CALCULATION ####################### types = pyRMSD.RMSDCalculator.availableCalculators() DEFAULT_PRECISSION = 1e-8 precissions = collections.defaultdict(lambda:DEFAULT_PRECISSION)