ppiref.utils.misc

Miscellaneous utility functions.

ppiref.utils.misc.download_from_zenodo(file: str, project_url: str = 'https://zenodo.org/records/14845086/files/', destination_folder: Path | str = None) None

Download a file from Zenodo and extract its contents.

Parameters:
  • file (str) – Name of the file to download and unpack. For example, 'ppi_6A.zip' to download all the 6A-interfaces (based on the 6 Angstrom cutoff).

  • project_url (str, optional) – URL of the Zenodo project.

  • destination_folder (Union[Path, str], optional) – Path to the destination folder. If None, the folder will be created in the ppiref.definitions.PPIREF_DATA_DIR directory. Defaults to None.

ppiref.utils.misc.get_partition(lst: list, beg: float, end: float)

Get [beg, end) partition of the list lst.

ppiref.utils.misc.list_to_chunks(lst: list, n: int)

Cut list lst into n chunks.

ppiref.utils.misc.random_id(length: int = 20) str

Generate a random ID of a given length.

ppiref.utils.pdb

Utilities for working with PDB files.

ppiref.utils.pdb.download_pdb(pdb_id: str, dir: Path | str | None = '.', path: Path | None = None) None

Download a .pdb file by its ID from the RCSB PDB database.

ppiref.utils.pdb.get_first_model(pdb_path: Path, out_path: Path | None = None) None

Extract first model from a .pdb file as a Biopandas data frame.

ppiref.utils.pdb.get_n_models(pdb_path: Path) int

Get number of models in a .pdb file.

ppiref.utils.ppi

Utilities for working with and analyzing PPI files.

class ppiref.utils.ppi.PPI(ppi: Path | str)

Bases: object

This class represents a protein-protein interaction (PPI) defined by its path and provides methods for visualizing and analyzing it.

Parameters:

ppi (Union[Path, str]) – Either full path or PPI id to get from PPIRef.

is_dummy() bool

Check if the PPI is a dummy file that does not contain any PPIs.

n_residues() int

Get the number of residues in the PPI.

visualize(**kwargs)

Visualize the PPI in PyMOL.

ppiref.utils.ppi.sort_partners(ppi_id)

Sort partners in the ppi_id.

ppiref.utils.ppipath

PPIPath class and related functions for PPI file paths.

class ppiref.utils.ppipath.PPIPath(*args, **kwargs)

Bases: PosixPath

Path to a protein-protein interaction (PPI) file.

https://stackoverflow.com/q/61689391

classmethod construct(pref: str | Path, name: str, partners: str, nested: bool = True) PPIPath

Construct a PPI path from the components.

contains(other: Path | str) bool

Check if one PPI path contains another based on sets of partners.

is_dummy() bool

Check if the PPI file is a dummy file that does not contain any PPIs.

is_equivalent_to(other: Path | str) bool

Check if two PPI paths are equivalent, up to partners order.

partners() list[str]

Get the list of partners from the path ([‘A’, ‘B’]).

pdb_id() str

Get PDB ID from the path (1abc).

ppi_id() str

Get PPI ID from the path (1abc_A_B).

with_sorted_partners() Path

Get a path with partners sorted alphabetically.

ppiref.utils.ppipath.path_to_partners(path: Path | str) list

Get the list of partners from the path ([‘A’, ‘B’]).

ppiref.utils.ppipath.path_to_pdb_id(path: Path | str) str

Get PDB ID from the path (1abc).

ppiref.utils.ppipath.path_to_ppi_id(path: Path | str) str

Get PPI ID from the path (1abc_A_B).

ppiref.utils.ppipath.pdb_id_to_nested_suffix(pdb_id: str) str

Get a nested suffix for a PDB ID (1abc -> ab/1abc.pdb).

ppiref.utils.ppipath.ppi_id_to_nested_suffix(ppi_id: str) str

Get a nested suffix for a PPI ID (1abc_A_B -> ab/1abc_A_B.pdb).

ppiref.utils.residue

Utility functions for working with protein residue.

class ppiref.utils.residue.Residue(chain_id, residue_number, insertion)

Bases: tuple

Create new instance of Residue(chain_id, residue_number, insertion)

chain_id

Alias for field number 0

insertion

Alias for field number 2

residue_number

Alias for field number 1

Utilities for PPIRef.