Module deeporigin.src.utilities.prepare_protein
Functions
def prepare(protein_path: str,
protein_pdb_id: str = '',
protein_extension: str = 'pdb',
metal_resnames: List[str] = None,
cofactor_resnames: List[str] = None,
model_loops: bool = False)-
Expand source code
def prepare( protein_path: str, protein_pdb_id: str = "", protein_extension: str = "pdb", metal_resnames: List[str] = None, cofactor_resnames: List[str] = None, model_loops: bool = False ): """ Prepare a protein structure for docking by processing its PDB file. This function sends the protein structure to a server for preparation, which may include cleaning the structure, adding missing atoms, and handling metal ions and cofactors. Args: protein_path (str): Path to the protein structure file protein_pdb_id (str, optional): PDB ID of the protein. Defaults to "". protein_extension (str, optional): File extension of the protein structure. Defaults to "pdb". metal_resnames (List[str], optional): List of metal residue names to preserve. Defaults to None. cofactor_resnames (List[str], optional): List of cofactor residue names to preserve. Defaults to None. model_loops (bool, optional): Whether to model missing loops. Defaults to False. Returns: dict: A dictionary containing: - prepared_protein_content (str): The prepared protein structure in PDB format - raw_protein_path (str): Path to the original protein file - protein_extension (str): File extension of the protein structure - protein_pdb_id (str): PDB ID of the protein Raises: May raise exceptions related to file operations or HTTP requests. """ client = Client() with open(protein_path, "r") as e: data = e.read() metal_resnames = ",".join(metal_resnames) if metal_resnames else "" cofactor_resnames = ",".join(cofactor_resnames) if cofactor_resnames else "" payload = { "content": data, "pdb_id": protein_pdb_id, "extension": protein_extension, "metals": metal_resnames, "cofactors": cofactor_resnames, "model_loops": model_loops, } response = client.post_request( logger=DEFAULT_LOGGER, endpoint="docking/prepare", data=payload, ) pdb_content = "" if response.status_code == 200: data = response.json() DEFAULT_LOGGER.log_info(data["msg"]) pdb_content = data["pdb_content"] else: msg = data.get("msg", "") if not msg: msg = "Failed to prepare" DEFAULT_LOGGER.log_error(msg) return { "prepared_protein_content": pdb_content, "raw_protein_path": protein_path, "protein_extension": protein_extension, "protein_pdb_id": protein_pdb_id, }
Prepare a protein structure for docking by processing its PDB file.
This function sends the protein structure to a server for preparation, which may include cleaning the structure, adding missing atoms, and handling metal ions and cofactors.
Args
protein_path
:str
- Path to the protein structure file
protein_pdb_id
:str
, optional- PDB ID of the protein. Defaults to "".
protein_extension
:str
, optional- File extension of the protein structure. Defaults to "pdb".
metal_resnames
:List[str]
, optional- List of metal residue names to preserve. Defaults to None.
cofactor_resnames
:List[str]
, optional- List of cofactor residue names to preserve. Defaults to None.
model_loops
:bool
, optional- Whether to model missing loops. Defaults to False.
Returns
dict
- A dictionary containing: - prepared_protein_content (str): The prepared protein structure in PDB format - raw_protein_path (str): Path to the original protein file - protein_extension (str): File extension of the protein structure - protein_pdb_id (str): PDB ID of the protein
Raises
May raise exceptions related to file operations or HTTP requests.