Exemple #1
0
 def test_can_get_string_from_pdb(self, mock_string, mock_dict):
     pdb = Pdb()
     pdb_dict = Mock()
     mock_string.return_value = "filecontents"
     mock_dict.return_value = pdb_dict
     s = pdb.to_file_string()
     mock_dict.assert_called_with(pdb)
     mock_string.assert_called_with(pdb_dict)
     self.assertEqual(s, "filecontents")
Exemple #2
0
def protonate_pdb(pdb: Pdb) -> Pdb:
    """Hydrogenate a first model of PDB

    1. Passes generic molecules to protonate_ligand,  ligands which already contain hydrogens are skipped
    2. Take H in protonated ligand block and add to existing pdb
    3. Pass pdb to protonate_protein

    Args:
        pdb: The pdb to hydrogenate

    Returns:
        A pdb with hydrogens added
    """
    # Protonate whole pdb
    unprotonated_block = pdb.to_file_string()
    protonated_block = protonate_protein(unprotonated_block)
    protonated_pdb = pdb_dict_to_pdb(
        pdb_string_to_pdb_dict(protonated_block[0]))
    fill_serial_numbers(protonated_pdb)
    return protonated_pdb