コード例 #1
0
    def test_with_no_ligands(self):

        self.assertEqual(
            mmcif_header.get_ligand_resnum(structure="test",
                                           ligand_resnames=[]), None)
        self.assertEqual(
            mmcif_header.get_ligand_resnum(structure="test",
                                           ligand_resnames=None), None)
コード例 #2
0
    def test_with_chain_model_selection(self):

        input_ligand_resnames = ["LIGAND"]

        residue_1 = mock.Mock()
        residue_2 = mock.Mock()

        residue_1.resname = "LIGAND"
        residue_2.resname = "NOT_LIGAND"

        residue_1.id = ("", 1, "")
        residue_2.id = ("", 2, "")

        residues = [residue_1, residue_2]

        structure = mock.Mock()
        structure.return_value = structure
        structure.return_value.get_residues.return_value = residues

        input_structure = {0: {'A': structure}}

        output = mmcif_header.get_ligand_resnum(
            structure=input_structure,
            ligand_resnames=input_ligand_resnames,
            protein_chain='A',
            protein_model=0)

        self.assertEqual(output, [["LIGAND", 1]])
コード例 #3
0
def update_ligands(Protein, chain_model_selection = False):
    """
    If you have a HPC_Drug.structures.protein.Protein instance with some self._ligands
    but the files they referr to are obsolete, and maybe the resnums are obsolete too,
    if the Protein.pdb_file is a file containing (the protein and) the new ligand coordinates and resnums
    this is the function you want to use

    returns a HPC_Drug.structures.protein.Protein instance with updated self._ligands

    Protein :: HPC_Drug.structures.protein.Protein instance

    chain_model_selection :: bool, default False, if True checks only Protein.chain and Protein.model from the PDB file
    """

    ligand_resnames = []

    old_Protein = copy.deepcopy(Protein)

    for lig in Protein.get_ligand_list():

        ligand_resnames.append(lig.resname)

    Protein.update_structure(struct_type = "biopython")

    if chain_model_selection:
        protein_chain = Protein.chain
        protein_model = Protein.model

    else:
        protein_chain = protein_model = None

    Protein = get_ligands.get_ligands(Protein = Protein,
                        ligand_resnames_resnums = mmcif_header.get_ligand_resnum(structure = Protein.structure,
                                                                                ligand_resnames = ligand_resnames,
                                                                                protein_chain = protein_chain,
                                                                                protein_model = protein_model))

    #in order not to loose the info about itp, gro, etc... files
    for i in range(len(old_Protein.get_ligand_list())):

        old_Protein.get_ligand_list()[i].resnum = Protein.get_ligand_list()[i].resnum

        old_Protein.get_ligand_list()[i].pdb_file = Protein.get_ligand_list()[i].pdb_file

        if old_Protein.get_ligand_list()[i].resname.upper() != Protein.get_ligand_list()[i].resname.upper():

            raise ValueError("Something went wrong during the ligand update")

    return old_Protein
コード例 #4
0
    def test_with_wrong_structure_type(self):

        with self.assertRaises(TypeError):

            mmcif_header.get_ligand_resnum(structure="test_wrong",
                                           ligand_resnames=["aa", "bb"])