Created
March 1, 2023 03:26
-
-
Save NicholasClark/8d1f514c2bfcbae5a94f8a0d0741b228 to your computer and use it in GitHub Desktop.
A couple of simple helper functions for running TM-align with tmtools
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from tmtools import tm_align | |
from tmtools.io import get_structure, get_residue_data | |
### Helper function to load data from PDB file | |
# Input is the filename of a PDB file | |
# Output is an object with the sequence and coordinates of the structure | |
##### Note: This works well for PDB files from AlphaFold, but you may have to modify for PDBs from the Protein Data Bank because I believe they can have multiple "chains" | |
def get_pdb_data_from_file(file): | |
s1 = get_structure(file) | |
chain1 = next(s1.get_chains()) | |
coords1, seq1 = get_residue_data(chain1) | |
return((coords1, seq1)) | |
### Helper function to run TM-align for a given pair of kinases | |
# Inputs are two objects created using the "get_pdb_data_from_file" function above | |
# Outputs are a translation vector "t", rotation matrix "u", and two TM-scores: one normalized by the length of the first protein and the other normalized by the length of the second protein. | |
def tm_align_objects(obj1, obj2): | |
coords1, seq1 = obj1 | |
coords2, seq2 = obj2 | |
res = tm_align(coords1, coords2, seq1, seq2) | |
return(res.t, res.u, res.tm_norm_chain1, res.tm_norm_chain2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, how to get PDB of Aligned Structures?