Example #1
0
    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)
Example #2
0
    def structure(self):
        """Get the structure from the Cif file.

        :returns: The first structure in the cif file.
        """

        pdb = self.data.getName()
        residues = self.__residues__(pdb)
        return Structure(list(residues), pdb=pdb)
    def coordinates(self, pdb, residue):
        """Compute a string of the coordinates in CIF format (the atom_site
        block) for the given residue. Exclude the header and trailing lines
        that are part of the atom_site entries, because these entries are meant 
        to be concatenated together for the coordinate server later.

        Parameters
        ----------
        pdb : str
            The PDB id to use.

        residue : fr3d.data.Component
            The residue to convert.

        Returns
        -------
        coordinates : str
            A string that represents CIF-formatted data for the given residue.
        """

        structure = Structure([residue], pdb=pdb)
        sio = StringIO()
        writer = CifAtom(sio, unit_ids=False, protect_lists_of_lists=True)
        writer(structure)
        raw = sio.getvalue()
        coords = []
        for line in raw.split('\n'):
            # Exclude header/comment lines that start with: 1) "data_",
            # 2) "loop_",  3) "_", or 4) "#".
            if not line or \
                    line.startswith('data_') or \
                    line.startswith('loop_') or \
                    line[0] in set('_#'):
                continue
            coords.append(line)
        return '\n'.join(coords)
Example #4
0
 def setUp(self):
     self.structure = Structure([nts.nt77_9, nts.nt78_9, nts.nt79_9,
                                 nts.nt80_9], pdb="1S72")
Example #5
0
 def test_empty_structure_is_false(self):
     val = Structure([])
     self.assertFalse(bool(val))
Example #6
0
 def test_selecting_a_subset_updates_unit_id(self):
     val = Structure([], pdb='1S72').select(model=1).unit_id()
     self.assertEquals('1S72|1', val)
Example #7
0
 def test_has_a_unit_id(self):
     val = Structure([], pdb='1S72').unit_id()
     self.assertEquals('1S72', val)
Example #8
0
 def test_no_residues_is_0_length(self):
     val = Structure([])
     self.assertEquals(0, len(val))
Example #9
0
 def test_length_is_number_of_residues(self):
     val = Structure([1])
     self.assertEquals(1, len(val))
Example #10
0
 def test_non_empty_structure_is_true(self):
     val = Structure([1])
     self.assertTrue(bool(val))