class AtomTest(ut.TestCase): def setUp(self): self.atom = Atom(pdb='1GID', model=1, chain='A', component_id='C', component_number=50, name="C1'", symmetry='6_555', x=-1, y=0, z=0) def test_has_item_access(self): self.assertEqual(-1, self.atom.x) def test_computes_a_unit_id(self): val = self.atom.unit_id() ans = "1GID|1|A|C|50|C1'|||6_555" self.assertEqual(val, ans) def test_computes_its_component_id(self): val = self.atom.component_unit_id() ans = "1GID|1|A|C|50||||6_555" self.assertEqual(val, ans) def test_can_get_coordinates(self): val = self.atom.coordinates() ans = np.array([-1, 0, 0]) np.testing.assert_array_equal(val, ans) def test_can_get_distance_between_atoms(self): val = self.atom.distance(Atom(x=1, y=0, z=0)) self.assertEqual(2.0, val)
class AtomTransformationTest(ut.TestCase): def setUp(self): self.atom = Atom(pdb='1GID', model=1, chain='A', component_id='C', component_number=50, name="C1'", symmetry='6_555', x=-1, y=0, z=2, type='Bob', polymeric=True) trans = np.array([[1.0, 0.0, 0.0, 0.0], [0.0, -1.0, 0.0, 97.240], [0.0, 0.0, -1.0, 0.0], [0.0, 0.0, 0.0, 1.0]]) self.trans = self.atom.transform(trans) def test_transform_moves_coordiantes(self): val = [self.trans.x, self.trans.y, self.trans.z] ans = [-1.0, 97.240, -2.0] self.assertEquals(ans, val) def test_transform_preserves_unit_id(self): val = self.trans.unit_id() ans = self.atom.unit_id() self.assertEquals(ans, val) def test_perserves_the_type(self): self.assertEquals('Bob', self.trans.type) def test_perserves_the_polymeric(self): self.assertEquals(True, self.trans.polymeric)
def setUp(self): atoms = [ Atom(name='N9', x=3.0, y=3.0, z=3.0), Atom(name='C4', x=2.0, y=2.0, z=2.0), Atom(name='N3', x=1.0, y=1.0, z=1.0), ] self.residue = Component(atoms, sequence='A')
def setUp(self): self.atoms = [ Atom(name='N9', x=3.0, y=3.0, z=3.0), Atom(name='C4', x=2.0, y=2.0, z=2.0), Atom(name='N3', x=1.0, y=1.0, z=1.0), Atom(name='C3', x=0.0, y=0.0, z=0.0), ] self.component = Component(self.atoms)
def setUp(self): self.atoms = [ Atom(type='C', name='a1', component_number=3, x=1.0, y=0.0, z=0.0), Atom(type='C', name='a2', component_number=2, x=2.0, y=0.0, z=0.0), Atom(type='N', name='b1', component_number=1, x=3.0, y=0.0, z=0.0), Atom(type='N', name='c2', component_number=0, x=0.0, y=1.0, z=0.0) ] self.proxy = AtomProxy(self.atoms)
def setUp(self): atoms = [ Atom(name='N9', x=3.0, y=3.0, z=3.0), Atom(name='C4', x=2.0, y=2.0, z=2.0), Atom(name='N3', x=1.0, y=1.0, z=1.0), ] self.residue = Component(atoms, type='rna', pdb='1GID', model=1, chain='A', sequence='C', number=50, symmetry='6_555')
def setUp(self): self.atom = Atom(pdb='4OQ8', model=1, chain='A', component_id='SER', component_number=27, name='CA', alt_id='A', symmetry='PP')
def setUp(self): self.atom = Atom(pdb='1GID', model=1, chain='A', component_id='C', component_number=50, name="C1'", symmetry='6_555', x=-1, y=0, z=0)
class AlternativeAtomTest(ut.TestCase): def setUp(self): self.atom = Atom(pdb='4OQ8', model=1, chain='A', component_id='SER', component_number=27, name='CA', alt_id='A', symmetry='PP') def test_has_a_unit_id(self): self.assertEquals('4OQ8|1|A|SER|27|CA|A||PP', self.atom.unit_id()) def test_has_a_component_id(self): self.assertEquals('4OQ8|1|A|SER|27||A||PP', self.atom.component_unit_id())
def setUp(self): self.atoms = [ Atom(type='C', name='a1', polymeric='A', component_number=3, x=0.0, y=0.0, z=0.0), Atom(type='C', name='a2', polymeric='B', component_number=2, x=0.0, y=0.0, z=0.0), Atom(type='N', name='b1', polymeric='C', component_number=1, x=0.0, y=0.0, z=0.0), Atom(type='N', name='c2', polymeric='C', component_number=0, x=0.0, y=0.0, z=0.0) ] self.component = Component(self.atoms, type='rna', pdb='1GID', model=1, chain='A', sequence='C', number=50, symmetry='6_555')
def setUp(self): self.atoms = [ Atom(type='C', name='a1', component_number=3, x=1.0, y=0.0, z=0.0, pdb='1S72', model=1, chain='A', component_id='C'), Atom(type='C', name='a2', component_number=2, x=2.0, y=0.0, z=0.0, pdb='1S72', model=1, chain='A', component_id='C'), Atom(type='N', name='b1', component_number=1, x=3.0, y=0.0, z=0.0, pdb='1S72', model=1, chain='A', component_id='C'), Atom(type='N', name='c2', component_number=0, x=0.0, y=1.0, z=0.0, pdb='1S72', model=1, chain='A', component_id='C') ]
def setUp(self): self.atoms = [ Atom(type='C', name='a1', polymeric='A', x=0.0, y=0.0, z=0.0), Atom(type='C', name='a2', polymeric='B', x=0.0, y=0.0, z=0.0), Atom(type='N', name='b1', polymeric='C', x=0.0, y=0.0, z=0.0), Atom(type='N', name='c2', polymeric='C', x=0.0, y=0.0, z=0.0) ] self.component = Component(self.atoms, type='rna', pdb='1GID', model=1, chain='A', sequence='C', symmetry='6_555') self.sub = self.component.select(name=['a1', 'a2'])
def setUp(self): self.atom = Atom(pdb='1GID', model=1, chain='A', component_id='C', component_number=50, name="C1'", symmetry='6_555', x=-1, y=0, z=2, type='Bob', polymeric=True) trans = np.array([[1.0, 0.0, 0.0, 0.0], [0.0, -1.0, 0.0, 97.240], [0.0, 0.0, -1.0, 0.0], [0.0, 0.0, 0.0, 1.0]]) self.trans = self.atom.transform(trans)
def __atom__(self, pdb, atom, symmetry): x, y, z = self.__apply_symmetry__(atom, symmetry) index = atom['label_seq_id'] if index != '.': index = int(index) else: index = None symmetry_name = self.__symmetry_name__(symmetry) ins_code = atom['pdbx_PDB_ins_code'] if ins_code == '?': ins_code = None alt_id = atom['label_alt_id'] if alt_id == '.': alt_id = None return Atom(pdb=pdb, model=int(atom['pdbx_PDB_model_num']), chain=atom['auth_asym_id'], component_id=atom['label_comp_id'], component_number=int(atom['auth_seq_id']), component_index=index, insertion_code=ins_code, alt_id=alt_id, x=x, y=y, z=z, group=atom['group_PDB'], type=atom['type_symbol'], name=atom['label_atom_id'], symmetry=symmetry_name, polymeric=self.is_polymeric_atom(atom))
def test_can_build_problematic_id(self): atom = Atom(pdb='3V27', model=1, chain='A', component_id='G', component_number=94, component_index=1, insertion_code='A', x=None, y=None, z=None, group='ATOM', type='OP1', name='P', symmetry='1_555', polymeric=False) val = atom.component_unit_id() ans = '3V27|1|A|G|94|||A' self.assertEquals(ans, val)
def standard_component(self, seq): atoms = [] for name, coord in defs.RNAbasecoordinates[seq].items(): x, y, z = coord atoms.append(Atom(x=x, y=y, z=z, name=name)) component = Component(atoms, sequence=seq) component.infer_hydrogens() assert_array_almost_equal(component.centers['base'], [0, 0, 0]) return component
def setUp(self): self.component1 = Component([ Atom(name='N9', x=3.0, y=3.0, z=3.0), Atom(name='C4', x=2.0, y=2.0, z=2.0), Atom(name='N3', x=1.0, y=1.0, z=1.0), Atom(name='C3', x=0.0, y=0.0, z=0.0), ]) self.component2 = Component([ Atom(name='N1', x=0.0, y=-1.0, z=0.0), Atom(name='N3', x=-10.0, y=0.0, z=-1.0), Atom(name='C2', x=-2.0, y=0.0, z=-3.0) ])
def test_can_find_new_atom_positions(self): self.atoms.append(Atom(name='s', x=3.0, y=2.0, z=1.0)) val = self.proxy['s'] ans = np.array([3.0, 2.0, 1.0]) np.testing.assert_almost_equal(ans, val)
# -*- coding: utf-8 -*- """ Created on Wed Nov 20 12:50:43 2013 @author: zirbel """ from fr3d.data import Atom from fr3d.data import Component from fr3d.geometry.discrepancy import discrepancy nt77_9 = Component([ Atom(type='N', name='N9', x=43.063866, y=60.593299, z=122.948693), Atom(type='C', name='C4', x=42.888197, y=59.952482, z=121.742655), Atom(type='N', name='N3', x=41.743000, y=59.665137, z=121.107361), Atom(type='N', name='N1', x=43.174443, y=58.683103, z=119.409845), Atom(type='C', name='C6', x=44.294465, y=58.989433, z=120.078177), Atom(type='N', name='N6', x=45.492460, y=58.648576, z=119.551113), Atom(type='C', name='C8', x=44.415702, y=60.651476, z=123.176564), Atom(type='C', name='C5', x=44.188911, y=59.660647, z=121.315765), Atom(type='C', name='C2', x=41.988409, y=59.033005, z=119.954772), Atom(type='N', name='N7', x=45.139547, y=60.098841, z=122.214056), Atom(type='H', name='H2', x=41.115198, y=58.758914, z=119.368203), Atom(type='H', name='H8', x=44.822196, y=61.111613, z=124.067401), Atom(type='H', name='H9', x=42.326540, y=60.946934, z=123.540317), Atom(type='1', name='1H6', x=45.517242, y=58.171343, z=118.666736), Atom(type='2', name='2H6', x=46.340025, y=58.872608, z=120.042414), Atom(type='C', name='C1*', x=41.945000, y=61.063000, z=123.795000), Atom(type='C', name='C2*', x=41.342000, y=59.980000, z=124.691000), Atom(type='O', name='O2*', x=40.486000, y=59.109000, z=123.980000), Atom(type='C', name='C3*', x=40.625000, y=60.844000, z=125.716000),
def setUp(self): self.nt1 = Component(atoms=[ Atom(x=0, y=0, z=1, name='C1'), Atom(x=0, y=0, z=0, name='C2'), Atom(x=1, y=0, z=1, name='N'), ], sequence='A', model=1, chain='A', number=1, polymeric=True) self.nt2 = Component(atoms=[ Atom(x=5, y=5, z=5, name='C1'), Atom(x=5, y=5, z=5, name='C2'), Atom(x=5, y=5, z=5, name='N'), ], sequence='U', model=1, chain='A', number=2, polymeric=True) self.nt3 = Component(atoms=[ Atom(x=-5, y=-5, z=-5, name='C1'), Atom(x=-5, y=-5, z=-5, name='C2'), Atom(x=-5, y=-5, z=-5, name='N'), ], sequence='C', model=1, chain='A', number=3, polymeric=True) self.nt4 = Component(atoms=[ Atom(x=0, y=0, z=3, name='C1'), Atom(x=0, y=0, z=3, name='C2'), Atom(x=0, y=0, z=3, name='N'), ], sequence='U', model=1, chain='A', number=4, polymeric=True) self.nt5 = Component(atoms=[ Atom(x=0, y=0, z=8, name='C1'), Atom(x=0, y=0, z=8, name='C2'), Atom(x=0, y=0, z=3, name='N'), ], sequence='G', model=1, chain='A', number=5, polymeric=True) structure = Structure([self.nt1, self.nt2, self.nt3, self.nt4, self.nt5], pdb='0000', model='1') self.pairs = Pairs(structure)
def setUp(self): some_atoms = [ Atom(insertion_code='?', component_id='G', name='P', symmetry='1_555', component_number='118', chain='B', y=54.015, x=47.242, model='1', z=51.393, pdb='1GID'), Atom(insertion_code='?', component_id='G', name='OP1', symmetry='1_555', component_number='118', chain='B', y=53.619, x=45.943, model='1', z=50.812, pdb='1GID'), Atom(insertion_code='?', component_id='G', name='OP2', symmetry='1_555', component_number='118', chain='B', y=55.016, x=48.096, model='1', z=50.668, pdb='1GID'), Atom(insertion_code='?', component_id='G', name="O5'", symmetry='1_555', component_number='118', chain='B', y=54.52, x=47.009, model='1', z=52.887, pdb='1GID'), Atom(insertion_code='?', component_id='G', name="C5'", symmetry='1_555', component_number='118', chain='B', y=53.848, x=46.12, model='1', z=53.764, pdb='1GID'), Atom(insertion_code='?', component_id='G', name="C4'", symmetry='1_555', component_number='118', chain='B', y=54.529, x=46.123, model='1', z=55.11, pdb='1GID'), Atom(insertion_code='?', component_id='G', name="O4'", symmetry='1_555', component_number='118', chain='B', y=54.338, x=47.426, model='1', z=55.73, pdb='1GID'), Atom(insertion_code='?', component_id='G', name="C3'", symmetry='1_555', component_number='118', chain='B', y=56.037, x=45.94, model='1', z=55.051, pdb='1GID'), Atom(insertion_code='?', component_id='G', name="O3'", symmetry='1_555', component_number='118', chain='B', y=56.374, x=44.553, model='1', z=54.993, pdb='1GID'), Atom(insertion_code='?', component_id='G', name="C2'", symmetry='1_555', component_number='118', chain='B', y=56.495, x=46.647, model='1', z=56.326, pdb='1GID'), Atom(insertion_code='?', component_id='G', name="O2'", symmetry='1_555', component_number='118', chain='B', y=56.349, x=45.878, model='1', z=57.494, pdb='1GID'), Atom(insertion_code='?', component_id='G', name="C1'", symmetry='1_555', component_number='118', chain='B', y=55.528, x=47.827, model='1', z=56.387, pdb='1GID'), Atom(insertion_code='?', component_id='G', name='N9', symmetry='1_555', component_number='118', chain='B', y=56.026, x=49.033, model='1', z=55.738, pdb='1GID'), Atom(insertion_code='?', component_id='G', name='C8', symmetry='1_555', component_number='118', chain='B', y=55.785, x=49.442, model='1', z=54.455, pdb='1GID'), Atom(insertion_code='?', component_id='G', name='N7', symmetry='1_555', component_number='118', chain='B', y=56.371, x=50.566, model='1', z=54.161, pdb='1GID'), Atom(insertion_code='?', component_id='G', name='C5', symmetry='1_555', component_number='118', chain='B', y=57.031, x=50.913, model='1', z=55.323, pdb='1GID'), Atom(insertion_code='?', component_id='G', name='C6', symmetry='1_555', component_number='118', chain='B', y=57.827, x=52.019, model='1', z=55.608, pdb='1GID'), Atom(insertion_code='?', component_id='G', name='O6', symmetry='1_555', component_number='118', chain='B', y=58.131, x=52.969, model='1', z=54.873, pdb='1GID'), Atom(insertion_code='?', component_id='G', name='N1', symmetry='1_555', component_number='118', chain='B', y=58.301, x=51.975, model='1', z=56.907, pdb='1GID'), Atom(insertion_code='?', component_id='G', name='C2', symmetry='1_555', component_number='118', chain='B', y=58.033, x=50.991, model='1', z=57.814, pdb='1GID'), Atom(insertion_code='?', component_id='G', name='N2', symmetry='1_555', component_number='118', chain='B', y=58.557, x=51.138, model='1', z=59.032, pdb='1GID'), Atom(insertion_code='?', component_id='G', name='N3', symmetry='1_555', component_number='118', chain='B', y=57.299, x=49.949, model='1', z=57.556, pdb='1GID'), Atom(insertion_code='?', component_id='G', name='C4', symmetry='1_555', component_number='118', chain='B', y=56.828, x=49.974, model='1', z=56.301, pdb='1GID') ] self.res = Component(some_atoms, type='rna', pdb='1GID', model=1, chain='A', sequence='G', number=50, symmetry='6_555')
def test_can_get_distance_between_atoms(self): val = self.atom.distance(Atom(x=1, y=0, z=0)) self.assertEqual(2.0, val)