Пример #1
0
 def setUp(self):
     self.a2c = FullAtomModel.Angles2Coords()
     self.c2tc = FullAtomModel.Coords2TypedCoords()
     self.c2cc = FullAtomModel.CoordsTransform.Coords2CenteredCoords(
         rotate=True, translate=True)
     self.error = 0.0
     self.N = 0
Пример #2
0
 def __init__(self, device='cpu', num_sequences=32, seq_length=350):
     self.module = FullAtomModel.Angles2Coords()
     self.sequences = [
         gen_rand_seq(seq_length) for i in range(num_sequences)
     ]
     # print(self.sequences)
     self.angles = torch.randn(len(self.sequences),
                               7,
                               len(self.sequences[-1]),
                               dtype=torch.double,
                               device='cpu',
                               requires_grad=True)
Пример #3
0
def hook(module, input, output):
    global g_src
    global g_dst
    dst = output.grad_fn.Ut_coordinates_dst
    src = output.grad_fn.c_coords_input

    src = src.resize(int(src.size(1) / 3), 3).cpu().numpy()
    dst = dst.resize(int(dst.size(1) / 3), 3).cpu().numpy()
    g_src.append(src)
    g_dst.append(dst)


if __name__ == '__main__':
    #Reading pdb file
    p2c = FullAtomModel.PDB2CoordsUnordered()
    coords_dst, res_names_dst, atom_names_dst, num_atoms_dst = p2c(
        ["FullAtomModel/f4TQ1_B.pdb"])

    #Making a mask on CA, C, N atoms
    is0C = torch.eq(atom_names_dst[:, :, 0], 67).squeeze()
    is1A = torch.eq(atom_names_dst[:, :, 1], 65).squeeze()
    is20 = torch.eq(atom_names_dst[:, :, 2], 0).squeeze()
    is0N = torch.eq(atom_names_dst[:, :, 0], 78).squeeze()
    is10 = torch.eq(atom_names_dst[:, :, 1], 0).squeeze()
    isCA = is0C * is1A * is20
    isC = is0C * is10
    isN = is0N * is10
    isSelected = torch.ge(isCA + isC + isN, 1)
    num_backbone_atoms = int(isSelected.sum())
Пример #4
0
import torch
from TorchProteinLibrary import ReducedModel, FullAtomModel, RMSD
from torch import optim
import numpy as np
import matplotlib.pylab as plt
import mpl_toolkits.mplot3d.axes3d as p3
from matplotlib import animation
from matplotlib.animation import FuncAnimation

if __name__ == '__main__':
    #Reading pdb file
    p2c = FullAtomModel.PDB2CoordsUnordered()
    coords_dst, chain_names, res_names_dst, res_nums_dst, atom_names_dst, num_atoms_dst = p2c(
        ["FullAtomModel/f4TQ1_B.pdb"])

    #Making a mask on CA, C, N atoms
    is0C = torch.eq(atom_names_dst[:, :, 0], 67).squeeze()
    is1A = torch.eq(atom_names_dst[:, :, 1], 65).squeeze()
    is20 = torch.eq(atom_names_dst[:, :, 2], 0).squeeze()
    is0N = torch.eq(atom_names_dst[:, :, 0], 78).squeeze()
    is10 = torch.eq(atom_names_dst[:, :, 1], 0).squeeze()
    isCA = is0C * is1A * is20
    isC = is0C * is10
    isN = is0N * is10
    isSelected = torch.ge(isCA + isC + isN, 1)
    num_backbone_atoms = int(isSelected.sum())

    #Resizing coordinates array for convenience
    N = int(num_atoms_dst[0].item())
    coords_dst.resize_(1, N, 3)
Пример #5
0
import torch
from TorchProteinLibrary import FullAtomModel
import numpy as np
import matplotlib.pylab as plt
import mpl_toolkits.mplot3d.axes3d as p3

if __name__ == '__main__':
    a2c = FullAtomModel.Angles2Coords()
    sequences = ['GGMLGWAHFGY']

    #Setting conformation to alpha-helix
    angles = torch.zeros(len(sequences),
                         7,
                         len(sequences[-1]),
                         dtype=torch.double,
                         device='cpu')
    angles.data[:, 0, :] = -1.047
    angles.data[:, 1, :] = -0.698
    angles.data[:, 2:, :] = 110.4 * np.pi / 180.0

    #Converting angles to coordinates
    coords, res_names, atom_names, num_atoms = a2c(angles, sequences)

    #Making a mask on CA, C, N atoms
    is0C = torch.eq(atom_names[:, :, 0], 67).squeeze()
    is1A = torch.eq(atom_names[:, :, 1], 65).squeeze()
    is20 = torch.eq(atom_names[:, :, 2], 0).squeeze()
    is0N = torch.eq(atom_names[:, :, 0], 78).squeeze()
    is10 = torch.eq(atom_names[:, :, 1], 0).squeeze()
    isCA = is0C * is1A * is20
    isC = is0C * is10
Пример #6
0
	def setUp(self):
		self.a2c = FullAtomModel.Angles2Coords()
		self.c2tc = FullAtomModel.Coords2TypedCoords()
Пример #7
0
 def setUp(self):
     self.a2c = FullAtomModel.Angles2Coords()
Пример #8
0
import torch
from TorchProteinLibrary import Volume, FullAtomModel
import _Volume
import numpy as np
import matplotlib.pylab as plt
import mpl_toolkits.mplot3d.axes3d as p3

if __name__ == '__main__':
    a2c = FullAtomModel.Angles2Coords()
    translate = FullAtomModel.CoordsTranslate()
    sequences = ['GGMLGWAHFGY']

    #Setting conformation to alpha-helix
    angles = torch.zeros(len(sequences),
                         7,
                         len(sequences[-1]),
                         dtype=torch.double,
                         device='cpu')
    angles.data[:, 0, :] = -1.047
    angles.data[:, 1, :] = -0.698
    angles.data[:, 2:, :] = 110.4 * np.pi / 180.0

    #Converting angles to coordinates
    coords, res_names, atom_names, num_atoms = a2c(angles, sequences)

    #Translating the structure to fit inside the volume
    translation = torch.tensor([[60, 60, 60]],
                               dtype=torch.double,
                               device='cpu')
    coords = translate(coords, translation, num_atoms)