def test_rotation(coords, num_atoms):
    batch_size = num_atoms.size(0)
    R = getRandomRotation(batch_size)
    rotate = CoordsRotate()
    rotated = rotate(coords, R, num_atoms)

    print(rotated)
Beispiel #2
0
	def setUp(self):
		print(self.msg, self.device, self.dtype)
		self.translate = CoordsTranslate()
		self.rotate = CoordsRotate()
		self.getCenter = Coords2Center()
		self.coords = torch.randn(self.batch_size, self.max_num_atoms*3, dtype=self.dtype, device=self.device)
		self.num_atoms = torch.zeros(self.batch_size, dtype=torch.int, device=self.device).random_(int(self.max_num_atoms/2), self.max_num_atoms)
def test_random_rotation(num_rotations):
	batch_size = num_rotations
	R = getRandomRotation(batch_size)
		
	num_atoms = torch.ones(R.size(0), dtype=torch.int)
	coords = torch.zeros(R.size(0),3, dtype=torch.double)
	coords[:,0]=1.0
	coords[:,1]=0.0
	coords[:,2]=0.0

	rotate = CoordsRotate()
	rotated = rotate(coords, R, num_atoms)
	
	return rotated
def test_rotation(angle_inc = 0.1):
	u = []
	for alpha in np.arange(0.0, 1.0, angle_inc):
		for beta in np.arange(0.0, 1.0, angle_inc):
			for gamma in np.arange(0.0, 1.0, angle_inc):
				u.append([alpha, beta, gamma])

	u = np.array(u)
	u = torch.from_numpy(u)
	u = u.to(dtype=torch.double)

	R = getRotation(u)
	rotate = CoordsRotate()
	
	num_atoms = torch.ones(u.size(0), dtype=torch.int)
	coords = torch.zeros(u.size(0),3, dtype=torch.double)
	coords[:,0]=1.0
	coords[:,1]=0.0
	coords[:,2]=0.0

	rotated = rotate(coords, R, num_atoms)
	return rotated
Beispiel #5
0
 def setUp(self):
     print(self.msg, self.device, self.dtype)
     self.a2c = Angles2Coords()
     self.translate = CoordsTranslate()
     self.rotate = CoordsRotate()
     self.rmsd = Coords2RMSD()
if __name__=='__main__':
	
	box_size = 80
	resolution = 1.25

	sequence = ['GGAGRRRGGWG']
	angles = torch.zeros(len(sequence), 7, len(sequence[0]), dtype=torch.double)
	angles[0,0,:] = -1.047
	angles[0,1,:] = -0.698
	angles[0,2:,:] = 110.4*np.pi/180.0
	a2c = Angles2Coords()
	c2cc = Coords2CenteredCoords(rotate=False, translate=False, box_size=box_size, resolution=resolution)
	c2tc = Coords2TypedCoords()
	tc2v = TypedCoords2Volume(box_size=box_size, resolution=resolution)
	rotate = CoordsRotate()
	translate = CoordsTranslate()
	R = getRandomRotation( len(sequence) )
	volume_rotate = VolumeRotation(mode='bilinear')

	
	#Generating protein and initial volume
	protein, res_names, atom_names, num_atoms = a2c(angles, sequence)
	protein = c2cc(protein, num_atoms)
	coords, num_atoms_of_type, offsets = c2tc(protein, res_names, atom_names, num_atoms)
	volume = tc2v(coords.cuda(), num_atoms_of_type.cuda(), offsets.cuda())

	#Rotating protein
	center = torch.zeros(len(sequence), 3, dtype=torch.double, device='cpu').fill_((box_size - 0.5)*resolution/2.0)
	centered_coords = translate(coords, -center, num_atoms)
	rotated_centered_coords = rotate(centered_coords, R, num_atoms)