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): 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 __residues__(self, pdb): key = op.attrgetter( 'pdb', 'model', 'chain', 'component_id', 'component_number', 'insertion_code', 'symmetry', ) mapping = it.groupby(sorted(self.__atoms__(pdb), key=key), key) for comp_id, all_atoms in mapping: for atoms in self.__group_alt_atoms__(list(all_atoms)): first = atoms[0] type = self._chem.get(first.component_id, {}) type = type.get('type', None) alt_id = first.alt_id if alt_id == '.': alt_id = None yield Component( atoms, pdb=first.pdb, model=first.model, type=type, alt_id=alt_id, chain=first.chain, symmetry=first.symmetry, sequence=first.component_id, number=first.component_number, index=first.component_index, insertion_code=first.insertion_code, polymeric=first.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 __residues__(self, pdb): mapping = it.groupby( sorted(self.__atoms__(pdb), key=lambda a: a.component_unit_id()), lambda a: a.component_unit_id()) for comp_id, atoms in mapping: atoms = list(atoms) first = atoms[0] type = self._chem.get(first.component_id, {}) type = type.get('type', None) alt_id = first.alt_id if alt_id == '.': alt_id = None yield Component(atoms, pdb=first.pdb, model=first.model, type=type, alt_id=alt_id, chain=first.chain, symmetry=first.symmetry, sequence=first.component_id, number=first.component_number, index=first.component_index, insertion_code=first.insertion_code, polymeric=first.polymeric)
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): 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 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.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', 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 test_gives_none_for_unknown_unit(self): val = self.loader.type(Component([], sequence='GTP')) ans = None self.assertEqual(ans, val)
def test_can_determine_is_rna(self): component = Component([], sequence='A') self.assertEquals('rna', units.component_type(component))
nt10_0 = Component([ Atom(type='N', name='N1', x=19.679762, y=146.510834, z=106.455235), Atom(type='C', name='C2', x=19.459715, y=146.692932, z=107.816836), Atom(type='O', name='O2', x=19.354777, y=147.785831, z=108.333165), Atom(type='N', name='N3', x=19.375964, y=145.491465, z=108.503069), Atom(type='C', name='C4', x=19.482438, y=144.177244, z=108.006327), Atom(type='O', name='O4', x=19.384232, y=143.219519, z=108.751357), Atom(type='C', name='C6', x=19.800699, y=145.278872, z=105.856545), Atom(type='C', name='C5', x=19.712414, y=144.129302, z=106.564466), Atom(type='H', name='H5', x=19.808116, y=143.162711, z=106.089600), Atom(type='H', name='H1', x=19.747568, y=147.360820, z=105.915883), Atom(type='H', name='H3', x=19.215883, y=145.577268, z=109.499783), Atom(type='H', name='H6', x=19.970458, y=145.295294, z=104.785373), Atom(type='C', name='C1*', x=19.841000, y=147.761000, z=105.646000), Atom(type='C', name='C2*', x=20.264000, y=147.625000, z=104.181000), Atom(type='O', name='O2*', x=21.328000, y=148.530000, z=104.003000), Atom(type='C', name='C3*', x=18.978000, y=148.021000, z=103.445000), Atom(type='O', name='O3*', x=19.159000, y=148.571000, z=102.125000), Atom(type='C', name='C4*', x=18.405000, y=149.086000, z=104.371000), Atom(type='O', name='O4*', x=18.630000, y=148.501000, z=105.679000), Atom(type='C', name='C5*', x=16.942000, y=149.450000, z=104.201000), Atom(type='O', name='O5*', x=16.030000, y=148.355000, z=104.290000), Atom(type='P', name='P', x=19.695000, y=146.523000, z=106.436000), Atom(type='O', name='O1P', x=19.695000, y=146.523000, z=106.436000), Atom(type='O', name='O2P', x=19.695000, y=146.523000, z=106.436000) ], type='rna', pdb='1S72', sequence='U', chain='0', number='10')
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_determine_is_water(self): component = Component([], sequence='hoh') self.assertEquals('water', units.component_type(component))
def test_gives_none_otherwise(self): component = Component([], sequence='gtp') self.assertEquals(None, units.component_type(component))
def test_knows_if_unit_is_water(self): val = self.loader.type(Component([], sequence='HOH')) ans = 'water' self.assertEqual(ans, val)
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), Atom(type='O', name='O3*', x=39.435000, y=61.360000, z=125.157000), Atom(type='C', name='C4*', x=41.611000, y=61.984000, z=125.929000), Atom(type='O', name='O4*', x=42.402000, y=62.056000, z=124.698000), Atom(type='C', name='C5*', x=42.487000, y=61.728000, z=127.126000), Atom(type='O', name='O5*', x=43.480000, y=62.734000, z=127.249000), Atom(type='P', name='P', x=45.014000, y=62.337000, z=127.402000), Atom(type='O', name='O1P', x=45.546000, y=62.055000, z=126.041000), Atom(type='O', name='O2P', x=45.658000, y=63.379000, z=128.241000) ], type='rna', pdb='1S72', sequence='A', chain='9', number='77')
def test_knows_if_unit_is_aa(self): val = self.loader.type(Component([], sequence='GLU')) ans = 'aa' self.assertEqual(ans, val)