Skip to main content

Python bindings around the TM-align code for structural alignment of proteins

Project description

TM-Tools

Python bindings for the TM-align algorithm and code developed by Zhang et al for protein structure comparison.

Installation

You can install the released version of the package directly from PyPI by running

    pip install tmtools

Pre-built wheels are available for Linux, macOS, and Windows, for Python 3.6 and up.

To build the package from scratch, e.g. because you want to contribute to it, clone this repository, and then from the root of the repository, run

    pip install -e . -v

This requires a C++ compiler to be installed with support for C++ 14.

Usage

The function tmtools.tm_align takes two NumPy arrays with coordinates for the residues (with shape (N, 3)) and two sequences of peptide codes, performs the alignment, and returns the optimal rotation matrix and translation, along with the TM score:

>>> import numpy as np
>>> from tmtools import tm_align
>>>
>>> coords1 = np.array(
...     [[1.2, 3.4, 1.5],
...      [4.0, 2.8, 3.7],
...      [1.2, 4.2, 4.3],
...      [0.0, 1.0, 2.0]])
>>> coords2 = np.array(
...     [[2.3, 7.4, 1.5],
...      [4.0, 2.9, -1.7],
...      [1.2, 4.2, 4.3]])
>>>
>>> seq1 = "AYLP"
>>> seq2 = "ARN"
>>>
>>> res = tm_align(coords1, coords2, seq1, seq2)
>>> res.t
array([ 2.94676159,  5.55265245, -1.75151383])
>>> res.u
array([[ 0.40393231,  0.04161396, -0.91384187],
       [-0.59535733,  0.77040999, -0.22807475],
       [ 0.69454181,  0.63618922,  0.33596866]])
>>> res.tm_norm_chain1
0.3105833326322145
>>> res.tm_norm_chain2
0.414111110176286

If you already have some PDB files, you can use the functions from tmalign.io to retrieve the coordinate and sequence data. These functions rely on BioPython, which is not installed by default to keep dependencies lightweight. To use them, you have to install BioPython first (pip install biopython). Then run:

>>> from tmtools.io import get_structure, get_residue_data
>>> from tmtools.testing import get_pdb_path
>>> s = get_structure(get_pdb_path("2gtl"))
>>> s
<Structure id=2gtl>
>>> chain = next(s.get_chains())
>>> coords, seq = get_residue_data(chain)
>>> seq
'DCCSYEDRREIRHIWDDVWSSSFTDRRVAIVRAVFDDLFKHYPTSKALFERVKIDEPESGEFKSHLVRVANGLKLLINLLDDTLVLQSHLGHLADQHIQRKGVTKEYFRGIGEAFARVLPQVLSCFNVDAWNRCFHRLVARIAKDLP'
>>> coords.shape
(147, 3)

Credits

This package arose out of a personal desire to better understand both the TM-score algorithm and the pybind11 library to interface with C++ code. At this point in time it contains no original research code.

If you use the package for research, you should cite the original TM-score papers:

  • Y. Zhang, J. Skolnick, Scoring function for automated assessment of protein structure template quality, Proteins, 57: 702-710 (2004).
  • J. Xu, Y. Zhang, How significant is a protein structure similarity with TM-score=0.5? Bioinformatics, 26, 889-895 (2010).

License

The original TM-align software (version 20210224, released under the MIT license) is bundled with this repository (src/extern/TMalign.cpp). Some small tweaks had to be made to compile the code on macOS and to embed it as a library. This modifications are also released under the MIT license.

The rest of the codebase is released under the GPL v3 license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tmtools-0.0.3.tar.gz (1.5 MB view hashes)

Uploaded Source

Built Distributions

tmtools-0.0.3-cp311-cp311-win_amd64.whl (1.5 MB view hashes)

Uploaded CPython 3.11 Windows x86-64

tmtools-0.0.3-cp311-cp311-win32.whl (1.5 MB view hashes)

Uploaded CPython 3.11 Windows x86

tmtools-0.0.3-cp311-cp311-musllinux_1_1_x86_64.whl (2.1 MB view hashes)

Uploaded CPython 3.11 musllinux: musl 1.1+ x86-64

tmtools-0.0.3-cp311-cp311-musllinux_1_1_i686.whl (2.2 MB view hashes)

Uploaded CPython 3.11 musllinux: musl 1.1+ i686

tmtools-0.0.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.6 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

tmtools-0.0.3-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl (1.6 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ i686

tmtools-0.0.3-cp311-cp311-macosx_11_0_arm64.whl (1.6 MB view hashes)

Uploaded CPython 3.11 macOS 11.0+ ARM64

tmtools-0.0.3-cp311-cp311-macosx_10_9_x86_64.whl (1.6 MB view hashes)

Uploaded CPython 3.11 macOS 10.9+ x86-64

tmtools-0.0.3-cp310-cp310-win_amd64.whl (1.5 MB view hashes)

Uploaded CPython 3.10 Windows x86-64

tmtools-0.0.3-cp310-cp310-win32.whl (1.5 MB view hashes)

Uploaded CPython 3.10 Windows x86

tmtools-0.0.3-cp310-cp310-musllinux_1_1_x86_64.whl (2.1 MB view hashes)

Uploaded CPython 3.10 musllinux: musl 1.1+ x86-64

tmtools-0.0.3-cp310-cp310-musllinux_1_1_i686.whl (2.2 MB view hashes)

Uploaded CPython 3.10 musllinux: musl 1.1+ i686

tmtools-0.0.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.6 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

tmtools-0.0.3-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl (1.6 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ i686

tmtools-0.0.3-cp310-cp310-macosx_11_0_arm64.whl (1.6 MB view hashes)

Uploaded CPython 3.10 macOS 11.0+ ARM64

tmtools-0.0.3-cp310-cp310-macosx_10_9_x86_64.whl (1.6 MB view hashes)

Uploaded CPython 3.10 macOS 10.9+ x86-64

tmtools-0.0.3-cp39-cp39-win_amd64.whl (1.5 MB view hashes)

Uploaded CPython 3.9 Windows x86-64

tmtools-0.0.3-cp39-cp39-win32.whl (1.5 MB view hashes)

Uploaded CPython 3.9 Windows x86

tmtools-0.0.3-cp39-cp39-musllinux_1_1_x86_64.whl (2.1 MB view hashes)

Uploaded CPython 3.9 musllinux: musl 1.1+ x86-64

tmtools-0.0.3-cp39-cp39-musllinux_1_1_i686.whl (2.2 MB view hashes)

Uploaded CPython 3.9 musllinux: musl 1.1+ i686

tmtools-0.0.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.6 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

tmtools-0.0.3-cp39-cp39-manylinux_2_17_i686.manylinux2014_i686.whl (1.6 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ i686

tmtools-0.0.3-cp39-cp39-macosx_11_0_arm64.whl (1.6 MB view hashes)

Uploaded CPython 3.9 macOS 11.0+ ARM64

tmtools-0.0.3-cp39-cp39-macosx_10_9_x86_64.whl (1.6 MB view hashes)

Uploaded CPython 3.9 macOS 10.9+ x86-64

tmtools-0.0.3-cp38-cp38-win_amd64.whl (1.5 MB view hashes)

Uploaded CPython 3.8 Windows x86-64

tmtools-0.0.3-cp38-cp38-win32.whl (1.5 MB view hashes)

Uploaded CPython 3.8 Windows x86

tmtools-0.0.3-cp38-cp38-musllinux_1_1_x86_64.whl (2.1 MB view hashes)

Uploaded CPython 3.8 musllinux: musl 1.1+ x86-64

tmtools-0.0.3-cp38-cp38-musllinux_1_1_i686.whl (2.2 MB view hashes)

Uploaded CPython 3.8 musllinux: musl 1.1+ i686

tmtools-0.0.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.6 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

tmtools-0.0.3-cp38-cp38-manylinux_2_17_i686.manylinux2014_i686.whl (1.6 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ i686

tmtools-0.0.3-cp38-cp38-macosx_11_0_arm64.whl (1.6 MB view hashes)

Uploaded CPython 3.8 macOS 11.0+ ARM64

tmtools-0.0.3-cp38-cp38-macosx_10_9_x86_64.whl (1.6 MB view hashes)

Uploaded CPython 3.8 macOS 10.9+ x86-64

tmtools-0.0.3-cp37-cp37m-win_amd64.whl (1.5 MB view hashes)

Uploaded CPython 3.7m Windows x86-64

tmtools-0.0.3-cp37-cp37m-win32.whl (1.5 MB view hashes)

Uploaded CPython 3.7m Windows x86

tmtools-0.0.3-cp37-cp37m-musllinux_1_1_x86_64.whl (2.1 MB view hashes)

Uploaded CPython 3.7m musllinux: musl 1.1+ x86-64

tmtools-0.0.3-cp37-cp37m-musllinux_1_1_i686.whl (2.2 MB view hashes)

Uploaded CPython 3.7m musllinux: musl 1.1+ i686

tmtools-0.0.3-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.6 MB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64

tmtools-0.0.3-cp37-cp37m-manylinux_2_17_i686.manylinux2014_i686.whl (1.6 MB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ i686

tmtools-0.0.3-cp37-cp37m-macosx_10_9_x86_64.whl (1.6 MB view hashes)

Uploaded CPython 3.7m macOS 10.9+ x86-64

tmtools-0.0.3-cp36-cp36m-win_amd64.whl (1.5 MB view hashes)

Uploaded CPython 3.6m Windows x86-64

tmtools-0.0.3-cp36-cp36m-win32.whl (1.5 MB view hashes)

Uploaded CPython 3.6m Windows x86

tmtools-0.0.3-cp36-cp36m-musllinux_1_1_x86_64.whl (2.1 MB view hashes)

Uploaded CPython 3.6m musllinux: musl 1.1+ x86-64

tmtools-0.0.3-cp36-cp36m-musllinux_1_1_i686.whl (2.2 MB view hashes)

Uploaded CPython 3.6m musllinux: musl 1.1+ i686

tmtools-0.0.3-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.6 MB view hashes)

Uploaded CPython 3.6m manylinux: glibc 2.17+ x86-64

tmtools-0.0.3-cp36-cp36m-manylinux_2_17_i686.manylinux2014_i686.whl (1.6 MB view hashes)

Uploaded CPython 3.6m manylinux: glibc 2.17+ i686

tmtools-0.0.3-cp36-cp36m-macosx_10_9_x86_64.whl (1.6 MB view hashes)

Uploaded CPython 3.6m macOS 10.9+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page