Beispiel #1
0
def ligands(pdb: Pdb, ligand_expo: Dict[str, Mol]) -> List[Ligand]:
    """Ligands of a pdb

    Args:
        pdb: The pdb
        ligand_expo: Dictionary with molecules of ligand expo

    Raises:
        NoLigands: When PDB has no ligands

    Returns:
        List of ligands, ordered by name
    """
    model = pdb.model()
    ligs = {}
    for amol in model.molecules(generic=True):
        amol_id = amol.molecule_id()
        lig_id = pdb.code().lower() + '_' + amol.name(
        ) + '_1_' + amol_id[0] + '_' + amol_id[1:]
        try:
            lig = ligand_expo[lig_id]
            plig = protonate_molecule(lig)
            ligs[lig_id] = Ligand(amol, plig)
        except KeyError:
            logger.warning(
                'Unable to find {0} in ligand expo db, skipping'.format(
                    lig_id))
            pass

    if not ligs:
        raise NoLigands()
    return sorted(ligs.values(), key=lambda l: l.name())
Beispiel #2
0
def ligands(pdb: Pdb, ligand_expo: Dict[str, Mol]) -> List[Ligand]:
    """Ligands of a pdb

    Args:
        pdb: The pdb
        ligand_expo: Dictionary with molecules of ligand expo

    Raises:
        NoLigands: When PDB has no ligands

    Returns:
        List of ligands, ordered by name
    """
    model = pdb.model()
    ligs = {}
    for amol in model.molecules(generic=True):
        amol_id = amol.molecule_id()
        # Workaround for atomium 0.8 as to handle molecules with resID 0
        # NOTE: was fixed in 0.11.1, but other changes break kripo
        if amol_id[1:]=="":
             amol._id = amol_id + '0'
             amol_id = amol.molecule_id()
        
        lig_id = pdb.code().lower() + '_' + amol.name() + '_1_' + amol_id[0] + '_' + amol_id[1:]
        try:
            lig = ligand_expo[lig_id]
            plig = protonate_molecule(lig)
            ligs[lig_id] = Ligand(amol, plig)
        except KeyError:
            logger.warning('Unable to find {0} in ligand expo db, skipping'.format(lig_id))
            pass

    if not ligs:
        raise NoLigands()
    return sorted(ligs.values(), key=lambda l: l.name())
Beispiel #3
0
 def test_code_must_be_valid(self):
     pdb = Pdb()
     with self.assertRaises(ValueError):
         pdb.code = "1xxxx"
     with self.assertRaises(ValueError):
         pdb.code = "1xx"
Beispiel #4
0
 def test_code_must_be_str(self):
     pdb = Pdb()
     with self.assertRaises(TypeError):
         pdb.code = 100
Beispiel #5
0
 def test_can_update_code(self):
     pdb = Pdb()
     pdb._code = "1xxx"
     pdb.code = "2yyy"
     self.assertEqual(pdb._code, "2yyy")
Beispiel #6
0
def test_code(pdb_3heg: Pdb):
    assert pdb_3heg.code() == '3HEG'