Пример #1
0
 def testPdbWriteAltlocOptions(self):
     """ Test PDB file writing with different altloc options """
     pdbfile = read_PDB(self.pdb)
     self._check4lzt(pdbfile)
     output = StringIO()
     pdbfile.write_pdb(output, renumber=False, altlocs='all')
     output.seek(0)
     pdbfile2 = read_PDB(output)
     self._check4lzt(pdbfile2, check_meta=False)
     self._compareInputOutputPDBs(pdbfile, pdbfile2)
     # Check that 'first' option works
     output = reset_stringio(output)
     pdbfile.write_pdb(output, renumber=False, altlocs='first')
     output.seek(0)
     pdbfile3 = read_PDB(output)
     self._check4lzt(pdbfile3, check_meta=False, has_altloc=False)
     self._compareInputOutputPDBs(pdbfile, pdbfile3, altloc_option='first')
     # Check that the 'occupancy' option works
     output = reset_stringio(output)
     write_PDB(pdbfile, output, renumber=False, altlocs='occupancy')
     output.seek(0)
     pdbfile4 = read_PDB(output)
     self._check4lzt(pdbfile4, check_meta=False, has_altloc=False)
     self._compareInputOutputPDBs(pdbfile, pdbfile4, altloc_option='occupancy')
     # Double-check 'first' vs. 'occupancy'. Residue 85 (SER) has a conformer
     # A that has an occupancy of 0.37 and conformer B with occupancy 0.63
     self.assertEqual(pdbfile3.residues[84][4].xx, -4.162)
     self.assertEqual(pdbfile4.residues[84][4].xx, -4.157)
Пример #2
0
 def testPdbWriteXtal(self):
     """ Test PDB file writing from a Xtal structure """
     pdbfile = read_PDB(self.pdb)
     self._check4lzt(pdbfile)
     output = StringIO()
     pdbfile.write_pdb(output, renumber=False)
     output.seek(0)
     pdbfile2 = read_PDB(output)
     self._check4lzt(pdbfile2, check_meta=False)
     self._compareInputOutputPDBs(pdbfile, pdbfile2)
     output = reset_stringio(output)
     write_PDB(pdbfile, output)
     output.seek(0)
     pdbfile3 = read_PDB(output)
     self._check4lzt(pdbfile3, check_meta=False)
     self._compareInputOutputPDBs(pdbfile, pdbfile3, True)
     # Now check that renumbering is done correctly. 4lzt skips residues 130
     # through 200
     for res1, res2 in zip(pdbfile.residues, pdbfile3.residues):
         if res1.idx < 129:
             self.assertEqual(res1.number, res2.number)
         elif res1.idx < 135:
             self.assertEqual(res1.number, res2.number + 71)
         else:
             # Some residue numbers are skipped in the water numbering
             self.assertGreaterEqual(res1.number, res2.number + 71 + 794)
Пример #3
0
 def testPdbWriteModels(self):
     """ Test PDB file writing from NMR structure with models """
     pdbfile = read_PDB(self.models)
     self.assertEqual(pdbfile.get_coordinates('all').shape, (20, 451, 3))
     self.assertEqual(len(pdbfile.atoms), 451)
     output = StringIO()
     write_PDB(pdbfile, output)
     output.seek(0)
     pdbfile2 = read_PDB(output)
     self.assertEqual(len(pdbfile2.atoms), 451)
     self.assertEqual(pdbfile2.get_coordinates('all').shape, (20, 451, 3))
     self._compareInputOutputPDBs(pdbfile, pdbfile2)
Пример #4
0
        continue

    new_b = list()

    neighbor_list = pdb[matrix_idx[1][np.where(matrix_idx[0] == idx_1)]].atoms

    for atom_2 in neighbor_list:

        if atom_2.bfactor == 0.0:

            continue

        atom2_name = atom_2.name

        if (atom2_name.startswith("H") \
        or atom2_name.startswith("h")) \
        and atom2_name != "HG":

            continue

        new_b.append(atom_2.occupancy + atom_2.bfactor)

    norm_pdb[idx_1].bfactor /= np.array(new_b).mean()

    std_pdb[idx_1].bfactor = (std_pdb[idx_1].bfactor -
                              np.array(new_b).mean()) / np.array(new_b).std()

pmd.write_PDB(norm_pdb, name + "_norm.pdb")

pmd.write_PDB(std_pdb, name + "_std.pdb")