moleculekit.align module#
- moleculekit.align.molTMalign(mol: Molecule, ref: Molecule, molsel: str | ndarray = 'protein', refsel: str | ndarray = 'protein', return_alignments: bool = True, frames: list | range | ndarray | None = None, matchingframes: bool = False)#
Calculates the TMscore between two protein Molecules
- Parameters:
mol (
Moleculeobject) – A Molecule containing a single or multiple framesref (
Moleculeobject) – A reference Molecule containing a single frame. Will automatically keep only ref.frame.molsel (str or np.ndarray) – Atoms of mol to use, as an atom selection string, a boolean mask, or an integer index array (see
Molecule.atomselect).refsel (str or np.ndarray) – Atoms of ref to use, as an atom selection string, a boolean mask, or an integer index array (see
Molecule.atomselect).return_alignments (bool) – If True it will return the aligned structures of mol and the transformation matrices used to produce them
frames (list) – A list of frames of mol to align to ref. If None it will align all frames.
matchingframes (bool) – If set to True it will align the selected frames of this molecule to the corresponding frames of the refmol. This requires both molecules to have the same number of frames.
- Returns:
tmscore (numpy.ndarray) – TM score (if normalized by length of ref) for each frame in mol
rmsd (numpy.ndarray) – RMSD only OF COMMON RESIDUES for all frames. This is not the same as a full protein RMSD!!!
nali (numpy.ndarray) – Number of aligned residues for each frame in mol
alignments (list of Molecules) – Each frame of mol aligned to ref
transformation (list of numpy.ndarray) – Contains the transformation for each frame of mol to align to ref. The first element is the rotation and the second is the translation. Look at examples on how to manually produce the aligned structure.
Examples
>>> tmscore, rmsd, nali, alignments, transformation = molTMalign(mol, ref)
To manually generate the aligned structure for the first frame, first rotate, then translate >>> mol.rotateBy(transformation[0][0]) >>> mol.moveBy(transformation[0][1])
- moleculekit.align.molTMscore(mol: Molecule, ref: Molecule, molsel: str | ndarray = 'protein', refsel: str | ndarray = 'protein')#
Calculates the TMscore between two protein Molecules
This is a thin wrapper around
molTMalign()that does not return the aligned structures or transformation matrices (i.e. it callsmolTMalignwithreturn_alignments=False).- Parameters:
mol (
Moleculeobject) – A Molecule containing a single or multiple framesref (
Moleculeobject) – A reference Molecule containing a single frame. Will automatically keep only ref.frame.molsel (str or np.ndarray) – Atoms of mol to use, as an atom selection string, a boolean mask, or an integer index array (see
Molecule.atomselect).refsel (str or np.ndarray) – Atoms of ref to use, as an atom selection string, a boolean mask, or an integer index array (see
Molecule.atomselect).
- Returns:
tmscore (numpy.ndarray) – TM score (normalized by length of ref) for each frame in mol
rmsd (numpy.ndarray) – RMSD only OF COMMON RESIDUES for all frames. This is not the same as a full protein RMSD!!!
nali (numpy.ndarray) – Number of aligned residues for each frame in mol
Examples
>>> tmscore, rmsd, nali = molTMscore(mol, ref)