Skip to content

Utils

Utility functions for structure module.

check_ligand(pdb, reference)

Compare the ligand in the PDB file with the ligand in the reference file.

PARAMETER DESCRIPTION
pdb

str or file-like Path to the PDB file or file-like object.

reference

str or file-like Path to the csv file or file-like object.

RETURNS DESCRIPTION
bool

True if the ligand is the same in the two PDB files, False otherwise.

chery_pick_ligand(pdb, ligand, remove_water=True, water_selection=None)

Cherry pick a ligand from a PDB file.

PARAMETER DESCRIPTION
pdb

str or file-like Path to the PDB file or file-like object.

ligand

str The ligand to cherry pick.

remove_water

bool Remove crystallographic waters from the protein structures. Default is True.

water_selection

str The selection of water molecules to keep. Default is "none".

RETURNS DESCRIPTION
Literal['Protein', 'Ligand']

Universe object containing the protein.

Literal['Protein', 'Ligand']

Universe object containing the ligand.

find_resolution(pdb_id, rcsb_data=None)

Find the resolution of a PDB file using the RCSB API.

PARAMETER DESCRIPTION
pdb_id

str The PDB ID to find the resolution for.

rcsb_data

dict or None The data for the PDB ID from the RCSB API. If None, the data will be fetched.

RETURNS DESCRIPTION
float

The resolution of the PDB file.

get_entity_ids(pdb_id, rcsb_data=None)

Get the entity IDs for a given PDB ID using the RCSB API.

PARAMETER DESCRIPTION
pdb_id

str The PDB ID to retrieve the entity IDs for.

rcsb_data

dict or None The data for the PDB ID from the RCSB API. If None, the data will be fetched.

RETURNS DESCRIPTION
dict[str, list[str]]

The entity IDs for the given PDB ID as a dictionary. The keys are the entity type and the values are the entity numbers.

dict[str, list[str]]

The data for the PDB ID from the RCSB API. If None, the data will be fetched.

get_ligand_names(pdb)

Get the names of the ligands in a PDB file.

PARAMETER DESCRIPTION
pdb

str or file-like Path to the PDB file or file-like object.

RETURNS DESCRIPTION
list

The names of the ligands in the PDB file.

get_nonpolymer_names(pdb_id, rcsb_data=None)

Get the names of the non-polymer entities in a PDB file.

PARAMETER DESCRIPTION
pdb_id

str The PDB ID to retrieve the non-polymer entity names for.

rcsb_data

dict or None The data for the PDB ID from the RCSB API. If None, the data will be fetched.

RETURNS DESCRIPTION
list

The names of the non-polymer entities in the PDB file.

get_rcsb_data(pdb_id)

Get entry data for a given PDB ID using the RCSB API.

PARAMETER DESCRIPTION
pdb_id

The PDB ID to retrieve the entry data for.

TYPE: str

RETURNS DESCRIPTION

The entry data for the given PDB ID.

get_smiles(ligand_resname)

Get the SMILES string of a ligand from a PDB file.

PARAMETER DESCRIPTION
ligand_resname

str or file-like The residue name of the ligand.

RETURNS DESCRIPTION
dict[str, str]

The SMILES string of the ligand.

has_covalent_bonds(pdb, rcsb_data=None)

Check if the PDB file has covalent bonds or not.

PARAMETER DESCRIPTION
pdb

str the PDB id needed to be checked.

rcsb_data

dict or None The data for the PDB ID from the RCSB API. If None, the data will be fetched.

RETURNS DESCRIPTION
bool

True if the PDB file has covalent bonds, False otherwise.

has_ligands(pdb, rcsb_data=None)

Check if the PDB file has ligands or not.

PARAMETER DESCRIPTION
pdb

str the PDB id needed to be checked.

rcsb_data

dict or None The data for the PDB ID from the RCSB API. If None, the data will be fetched.

RETURNS DESCRIPTION
bool

True if the PDB file has ligands which can be ions/additatives, False otherwise.

is_xray_structure(pdb)

Check if the PDB file was generated from X-ray diffraction data.

Arg

pdb : Path to the PDB file. or file-like object. or just pdb id

RETURNS DESCRIPTION
bool

True if the PDB was generated from X-ray data, False otherwise.

map_genid_to_pdb(gene_ids)

Map a list of gene IDs to PDB IDs using the UniProt ID Mapping API.

PARAMETER DESCRIPTION
gene_ids

list of str The list of gene IDs to map.

RETURNS DESCRIPTION
list[dict]

The mapping of each gene ID to the PDB ID and other attributes.

pdb_has_mutation(pdb_id, rcsb_data=None)

Check if a PDB file has mutations or not

PARAMETER DESCRIPTION
pdb

str Path to the PDB file.

rcsb_data

dict or None The data for the PDB ID from the RCSB API. If None, the data will be fetched.

RETURNS DESCRIPTION
bool

True if the PDB file has mutations, False otherwise.

separate_protein_ligand(pdb, remove_water=True, keep_het_chain=None, water_selection=None, hetatm='valid_ligand', context=ProteinContext.default())

Separate protein and ligand from a PDB file.

PARAMETER DESCRIPTION
pdb

str or file-like Path to the PDB file or file-like object.

remove_water

bool Remove crystallographic waters from the protein structures. Default is True.

keep_het_chain

str or list Chain(s) to keep their HETATM in the protein structure. Default is None. If None, all HETATM will be kept.

water_selection

str The selection of water molecules to keep if remove_water is False. Default is "none"

hetatm

str The selection of hetatoms to keep in the protein structure. Default is "valid_ligand".

context

ProteinContext or None or str or dict ProteinContext object or path to ProteinContext YAML file. Default is ProteinContext.

Returns: a tuple of: - mda Universe object containing the protein. - mda Universe object containing the ligand.

validate_ligands(pdb, impurities=ProteinContext.default().impurities)

Validate the ligands from pdb id using the impurities list.

PARAMETER DESCRIPTION
pdb

str The PDB ID to validate.

impurities

list or None or ProteinContext List of impurities to check against. Default is impurities from the ProteinContext.

RETURNS DESCRIPTION
bool

True if the ligands are valid, False otherwise.

validate_pdb(pdb_id)

Validate a PDB file using the RCSB API.

PARAMETER DESCRIPTION
pdb_id

str The PDB ID to validate.

RETURNS DESCRIPTION
bool

True if the PDB file is valid (i.e has ligand, no covalent bond and no mutation), False otherwise.