utils module
- utils.atomlistToChannels(atomNames, hashing='Element_Hashing', device='cpu')[source]
function to get channels from atom names (obtained parsing the pdb files with the parsePDB function)
- Parameters
atomNames (list) – atom names obtained parsing the pdb files with the parsePDB function
hashing ("TPL_Hashing" or "Element_Hashing" or dict) –
define which atoms are grouped together. You can use two default hashings or build your own hashing:
TPL_Hashing: uses the hashing of torch protein library (https://github.com/lupoglaz/TorchProteinLibrary) Element_Hashing: groups atoms in accordnce with the element only: C -> 0, N -> 1, O ->2, P ->3, S- >4, H ->5, everything else ->6
Alternatively, if you are not happy with the default hashings, you can build a dictionary of dictionaries that defines the channel of every atom type in the pdb. the first dictionary has the residue tag (three letters amino acid code) as key (3 letters compound name for hetero atoms, as written in the PDB file) every residue key is associated to a dictionary, which the atom tags (as written in the PDB files) as keys and the channel (int) as value
for example, you can define the channels just based on the atom element as following: { ‘CYS’: {‘N’: 1, ‘O’: 2, ‘C’: 0, ‘SG’: 3, ‘CB’: 0, ‘CA’: 0}, # channels for cysteine atoms ‘GLY’: {‘N’: 1, ‘O’: 2, ‘C’: 0, ‘CA’: 0}, # channels for glycine atom … ‘GOL’: {‘O1’:2,’O2’:2,’O3’:2,’C1’:0,’C2’:0,’C3’:0}, # channels for glycerol atom … }
The default encoding is the one that assigns a different channel to each element
other encodings can be found in sources/hashings.py
device (torch.device) – The device on which the model should run. E.g. torch.device(“cuda”) or torch.device(“cpu:0”)
- Returns
coords (torch.Tensor) – coordinates of the atoms in the pdb file(s). Shape ( batch, numberOfAtoms, 3)
channels (torch.tensor) – the channel of every atom. Shape (batch,numberOfAtoms)
- utils.atomlistToRadius(atomList, hashing='FoldX_radius', device='cpu')[source]
function to get radius from atom names (obtained parsing the pdb files with the parsePDB function)
- Parameters
atomNames (list) – atom names obtained parsing the pdb files with the parsePDB function
hashing (FoldX_radius or dict) –
“FoldX_radius” provides the radius used by the FoldX force field
Alternatively, if you are not happy with the foldX radius, you can build a dictionary of dictionaries that defines the radius of every atom type in the pdb. The first dictionary has the residue tag (three letters amino acid code) as key (3 letters compound name for hetero atoms, as written in the PDB file) every residue key is associated to a dictionary, which the atom tags (as written in the PDB files) as keys and the radius (float) as value
for example, you can define the radius as following: { ‘CYS’: {‘N’: 1.45, ‘O’: 1.37, ‘C’: 1.7, ‘SG’: 1.7, ‘CB’: 1.7, ‘CA’: 1.7}, # radius for cysteine atoms ‘GLY’: {‘N’: 1.45, ‘O’: 1.37, ‘C’: 1.7, ‘CA’: 1.7}, # radius for glycine atoms … ‘GOL’: {‘O1’:1.37,’O2’:1.37,’O3’:1.37,’C1’:1.7,’C2’:1.7,’C3’:1.7}, # radius for glycerol atoms … }
The default radius are the ones defined in FoldX
Radius default dictionary can be found in sources/hashings.py
device (torch.device) – The device on which the model should run. E.g. torch.device(“cuda”) or torch.device(“cpu:0”)
- Returns
coords (torch.Tensor) – coordinates of the atoms in the pdb file(s). Shape ( batch, numberOfAtoms, 3)
radius (torch.tensor) – The radius of every atom. Shape (batch,numberOfAtoms)
- utils.parsePDB(PDBFile, keep_only_chains=None, keep_hetatm=True, bb_only=False)[source]
function to parse pdb files. It can be used to parse a single file or all the pdb files in a folder. In case a folder is given, the coordinates are gonna be padded
- Parameters
PDBFile (str) – path of the PDB file or of the folder containing multiple PDB files
bb_only (bool) – if True ignores all the atoms but backbone N, C and CA
keep_only_chains (str or None) – ignores all the chain but the one given. If None it keeps all chains
keep_hetatm (bool) – if False it ignores heteroatoms
- Returns
coords (torch.Tensor) – coordinates of the atoms in the pdb file(s). Shape ( batch, numberOfAtoms, 3)
atomNames (list) – a list of the atom identifier. It encodes atom type, residue type, residue position and chain
- utils.parseSDF(SDFFile)[source]
function to parse pdb files. It can be used to parse a single file or all the pdb files in a folder. In case a folder is given, the coordinates are gonna be padded
- Parameters
SDFFile (str) – path of the PDB file or of the folder containing multiple PDB files
- Returns
coords (torch.Tensor) – coordinates of the atoms in the pdb file(s). Shape ( batch, numberOfAtoms, 3)
atomNames (list) – a list of the atom identifier. It encodes atom type, residue type, residue position and chain