tmquick 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- tmquick-1.0.0/LICENSE.md +21 -0
- tmquick-1.0.0/MANIFEST.in +2 -0
- tmquick-1.0.0/PKG-INFO +23 -0
- tmquick-1.0.0/README.md +197 -0
- tmquick-1.0.0/pyproject.toml +40 -0
- tmquick-1.0.0/setup.cfg +4 -0
- tmquick-1.0.0/setup.py +30 -0
- tmquick-1.0.0/tmq/__init__.py +14 -0
- tmquick-1.0.0/tmq/cli.py +250 -0
- tmquick-1.0.0/tmq/commands/__init__.py +2 -0
- tmquick-1.0.0/tmq/commands/average_trajmap_cli.py +36 -0
- tmquick-1.0.0/tmq/commands/csv2shift_cli.py +27 -0
- tmquick-1.0.0/tmq/commands/diff2graph_cli.py +35 -0
- tmquick-1.0.0/tmq/commands/hotspot_cli.py +89 -0
- tmquick-1.0.0/tmq/commands/pdb2csv_cli.py +29 -0
- tmquick-1.0.0/tmq/commands/shift2graph_cli.py +29 -0
- tmquick-1.0.0/tmq/commands/traj2pdb_cli.py +21 -0
- tmquick-1.0.0/tmq/commands/trajmap_cli.py +29 -0
- tmquick-1.0.0/tmq/core/__init__.py +2 -0
- tmquick-1.0.0/tmq/core/average_trajmap.py +35 -0
- tmquick-1.0.0/tmq/core/csv2shift.py +17 -0
- tmquick-1.0.0/tmq/core/diff2graph.py +75 -0
- tmquick-1.0.0/tmq/core/hotspot.py +164 -0
- tmquick-1.0.0/tmq/core/pdb2csv.py +53 -0
- tmquick-1.0.0/tmq/core/shift2graph.py +63 -0
- tmquick-1.0.0/tmq/core/traj2pdb.py +12 -0
- tmquick-1.0.0/tmq/core/trajmap.py +52 -0
- tmquick-1.0.0/tmq/utils/__init__.py +2 -0
- tmquick-1.0.0/tmq/utils/utils.py +233 -0
- tmquick-1.0.0/tmquick.egg-info/PKG-INFO +23 -0
- tmquick-1.0.0/tmquick.egg-info/SOURCES.txt +33 -0
- tmquick-1.0.0/tmquick.egg-info/dependency_links.txt +1 -0
- tmquick-1.0.0/tmquick.egg-info/entry_points.txt +2 -0
- tmquick-1.0.0/tmquick.egg-info/requires.txt +12 -0
- tmquick-1.0.0/tmquick.egg-info/top_level.txt +1 -0
tmquick-1.0.0/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 SHEDOOMTC
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
tmquick-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: tmquick
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: TrajMapQuick: Towards Fast Trajectory Map Analysis and Visualization
|
|
5
|
+
Author: Wande M. Oluyemi (PhD), Adeniyi T. Adewumi (PhD), Shadrach C. Eze, Stephen C. Nnemolisa, @ Research Laboratory for Rational Design of Drugs and Biomaterials (ResLaR Labs), Afe Babalola University, Ado-Ekiti Nigeria
|
|
6
|
+
Project-URL: Homepage, https://github.com/SHEDOOMTC/TrajMapQuick.git
|
|
7
|
+
Project-URL: Documentation, https://github.com/SHEDOOMTC/TrajMapQuick/blob/7997b0076a6c31bd725dba3ccdca4349b43250d4/README.md
|
|
8
|
+
Project-URL: DOI, https://github.com/SHEDOOMTC/TrajMapQuick.git
|
|
9
|
+
Requires-Python: >=3.9
|
|
10
|
+
License-File: LICENSE.md
|
|
11
|
+
Requires-Dist: numpy
|
|
12
|
+
Requires-Dist: pandas
|
|
13
|
+
Requires-Dist: matplotlib
|
|
14
|
+
Requires-Dist: seaborn
|
|
15
|
+
Requires-Dist: tqdm
|
|
16
|
+
Requires-Dist: biopython
|
|
17
|
+
Requires-Dist: scipy
|
|
18
|
+
Requires-Dist: netcdf4
|
|
19
|
+
Requires-Dist: colorama
|
|
20
|
+
Provides-Extra: md
|
|
21
|
+
Requires-Dist: mdtraj; extra == "md"
|
|
22
|
+
Dynamic: license-file
|
|
23
|
+
Dynamic: requires-python
|
tmquick-1.0.0/README.md
ADDED
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="https://github.com/SHEDOOMTC/TrajMapQuick/blob/main/assets/TrajMapQuick.png" alt="TrajMapQuick Logo" />
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
## **Overview**
|
|
6
|
+
**TrajMapQuick 1.0** is a light tool useful for visualization of trajectory maps and residual shifts within select regions of proteins, across several frames. It is built partially on the codes provided in the original work of Matej Kožić and Branimir Bertoša, 2024 : [**"Trajectory maps: molecular dynamics visualization and analysis"**](https://doi.org/10.1093/nargab/lqad114). **TrajMapQuick** extends the work by reconfiguring how the pdb files are parsed to generate the distance matrix, thereby improving speed dramatically. In addition, **TrajMapQuick** provides a CLI where the user can pass arguments for better throughput and batch processing.
|
|
7
|
+
We have also extended the code to allow for automatic detection of regions with high residual fluctuations (named **"Hotspots"**) and generation of the residual shifts of those regions. In addition, a python API has also been provided for python based community. In TrajMapQuick, the user can also choose between the backbone (**backbone**) atoms or the alpha carbon (**CA**) for computing the maps.
|
|
8
|
+
|
|
9
|
+
## **Features**
|
|
10
|
+
- **Trajectory Map Visualization:** Generates a trajectory map of residual fluctuations across the select frames chosen by the user.
|
|
11
|
+
- **Residual shift calculation and visualization:** For a select range of residues (region), residual shifts are computed and visualized across select frames
|
|
12
|
+
- **Difference and Average map visualization** This computes the difference and average of two trajectories, respectively and display the resultant trajectory maps.
|
|
13
|
+
- **Hotspot Detection and Plotting:** This automatically probes and detects regions of high fluctuations and computes the residual shift for each region for downstream processing.
|
|
14
|
+
- **Hotspot Annotation:** An RMSF like plot is also generated with the key hotspots highlight for visual confirmation and inspection.
|
|
15
|
+
|
|
16
|
+
## **Project Structure**
|
|
17
|
+
<pre>
|
|
18
|
+
TrajMapQuick/
|
|
19
|
+
├── README.md # Project overview, installation, usage
|
|
20
|
+
├── requirements.txt # Python dependencies
|
|
21
|
+
├── setup.py # Packaging configuration
|
|
22
|
+
├── environment.yml # Build config
|
|
23
|
+
├── pyproject.toml # Build config
|
|
24
|
+
├── LICENSE # MIT license
|
|
25
|
+
├── Manifest.in
|
|
26
|
+
├── tmq/ # Source codes and CLI wrappers lives here
|
|
27
|
+
│ ├── cli.py/ # Main command line launcher
|
|
28
|
+
│ ├── __init__.py # Main launcher for the python API
|
|
29
|
+
│ ├── core/ # Python package folder
|
|
30
|
+
│ │ ├── __init__.py
|
|
31
|
+
│ │ ├── traj2pdb.py # Converts trajectory to pdb
|
|
32
|
+
│ │ ├── pdb2csv.py # Converts pdb to distance matrix
|
|
33
|
+
│ │ ├── trajmap.py # plots the trajectory map
|
|
34
|
+
│ │ ├── csv2shift.py # Core shift logic for a given loop
|
|
35
|
+
│ │ ├── shift2graph.py # Makes shift plots for a given loop
|
|
36
|
+
│ │ ├── hotspot.py # Automatic detection of regions with peak fluctuations
|
|
37
|
+
│ │ ├── diff2graph.py # Computes and plot difference map for two trajectories
|
|
38
|
+
│ │ └── average_trajmap.py # Computes and plot average map for two trajectories
|
|
39
|
+
│ ├── commands/ # Main wrapper for the CLI
|
|
40
|
+
│ │ ├── __init__.py
|
|
41
|
+
│ │ ├── traj2pdb_cli.py # CLI wrapper
|
|
42
|
+
│ │ ├── pdb2csv_cli.py # CLI wrapper
|
|
43
|
+
│ │ ├── trajmap_cli.py # CLI wrapper
|
|
44
|
+
│ │ ├── csv2shift_cli.py # CLI wrapper
|
|
45
|
+
│ │ ├── shift2graph_cli.py # CLI wrapper
|
|
46
|
+
│ │ ├── hotspot_cli.py # CLI wrapper
|
|
47
|
+
│ │ ├── diff2graph_cli.py # CLI wrapper
|
|
48
|
+
│ │ └── average_trajmap_cli.py# CLI wrapper
|
|
49
|
+
│ └── utils # Holds functions
|
|
50
|
+
│ │ ├── __init__.py
|
|
51
|
+
│ │ └── utils.py # utility functions
|
|
52
|
+
├── docs/ # docstrings for the modules
|
|
53
|
+
├── assets/ # Container for images
|
|
54
|
+
├── Tests/ # Containers for test trajectories and topologies
|
|
55
|
+
└── Conda/ # Backup YAML files
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
</pre>
|
|
59
|
+
|
|
60
|
+
## **Installation**
|
|
61
|
+
```bash
|
|
62
|
+
# Clone the repo
|
|
63
|
+
git clone https://github.com/SHEDOOMTC/TrajMapQuick.git
|
|
64
|
+
cd TrajMapQuick
|
|
65
|
+
|
|
66
|
+
# In conda environment with pip
|
|
67
|
+
conda create -n tmq python=3.10
|
|
68
|
+
conda activate tmq
|
|
69
|
+
conda install -c conda-forge mdtraj
|
|
70
|
+
pip install (-e) .
|
|
71
|
+
|
|
72
|
+
# In conda environment without pip
|
|
73
|
+
conda env create -f environment.yml
|
|
74
|
+
conda activate tmq
|
|
75
|
+
|
|
76
|
+
Use tmq --help to see the arguments
|
|
77
|
+
```
|
|
78
|
+
## **Commands**
|
|
79
|
+
```bash
|
|
80
|
+
#TrajMapQuick uses a two levell subcommand from the global "tmq" command
|
|
81
|
+
tmq shift : Extract matrices, compute residue-residue shifts and make plots: For more, use tmq shift --help
|
|
82
|
+
|
|
83
|
+
tmq hotspot : Detect hotspots in residue shifts and create plots: For more, use tmq hotspot --help
|
|
84
|
+
|
|
85
|
+
tmq diff Computes difference between two matrices and creates the difference map: For more, use tmq diff --help
|
|
86
|
+
|
|
87
|
+
tmq average Computes average of n matrices and creates the average map: For more, use tmq average --help
|
|
88
|
+
|
|
89
|
+
```
|
|
90
|
+
## **Usage (CLI)**
|
|
91
|
+
```bash
|
|
92
|
+
# For tmq shift, arguments are passed into the flags for trajectory, topology etc.
|
|
93
|
+
|
|
94
|
+
tmq shift --traj traj.pdb --top top.parmtop --str 1 --resr 1-300 --resrs 110-125 --cent backbone --plot --out shift_output
|
|
95
|
+
|
|
96
|
+
#for tmq hotspot, arguments are passed similiarly, except that the region of shift is not provided
|
|
97
|
+
|
|
98
|
+
tmq hotspot --traj traj.pdb --top top.parmtop --str 1 --resr 1-300 --cent backbone --out hotspot_output
|
|
99
|
+
```
|
|
100
|
+
## **Usage (Python API)**
|
|
101
|
+
The core modules in the tmq library are clearly demonstrated in the **[Python_API.ipynb](./Notebooks/Python_API.ipynb)** file
|
|
102
|
+
|
|
103
|
+
```python
|
|
104
|
+
#Typical modules are loaded and then used as explained in the jupyter notebook above:
|
|
105
|
+
|
|
106
|
+
from tmq.core.traj2pdb import traj2pdb
|
|
107
|
+
from tmq.core.pdb2csv import pdb2csv
|
|
108
|
+
from tmq.core.trajmap import trajmap
|
|
109
|
+
from tmq.core.csv2shift import shift
|
|
110
|
+
from tmq.core.shift2graph import shift2graph
|
|
111
|
+
from tmq.core.hotspot import detect_shifts
|
|
112
|
+
from tmq.core.hotspot import create_submatrices
|
|
113
|
+
from tmq.core.hotspot import plot_hotspot_regions
|
|
114
|
+
from tmq.core.hotspot import slice_shifts
|
|
115
|
+
from tmq.core.hotspot import plot_slice_regions
|
|
116
|
+
from tmq.core.diff2graph import diff_map
|
|
117
|
+
from tmq.core.average_trajmap import avg_trajmap
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
```python
|
|
121
|
+
# To run the notebook
|
|
122
|
+
cd ./Notebooks/
|
|
123
|
+
jupyter notebook Python_API.ipynb
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## **Requirements**
|
|
127
|
+
- Trajectory processing libraries (mdtraj, biopython)
|
|
128
|
+
|
|
129
|
+
- Data wrangling tools (numpy, pandas)
|
|
130
|
+
|
|
131
|
+
- Trajectories must have been preprocessed (strippin water, ions,) before feeding into TrajMapQuick
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
All library requirements are pre-installed installed via pip or conda and are available for use in CLI or via Python API
|
|
135
|
+
|
|
136
|
+
## **Examples**
|
|
137
|
+
Three trajectories and topologies files are included in the **[Test](./Test)** directory for users to try out the codes. Trajectory 1 has only 125 frames (from apo strucuture of PDB ID: 8EM8 with 789 residues) while others have 250 frames (from apo and bound strucutres of BACE1, with 389 residues). To get the full sized trajectories, see [](https://doi.org/10.5281/zenodo.20681326)
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
The Utility of the shift command (using a 500 frame trajectory) was shown by the figure below:
|
|
141
|
+
|
|
142
|
+

|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
**And that of the hotspot command by:**
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+

|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
To reproduce the figures above, download the full length trajectory (500 frames) from Zenodo [](https://doi.org/10.5281/zenodo.20681326) and run the codes below on the CLI
|
|
152
|
+
|
|
153
|
+
```bash
|
|
154
|
+
#The exact codes used to produce the results above
|
|
155
|
+
tmq shift -tr traj_9NSR_500.nc -to topol_9NSR.prmtop -st 1 -rr 1-378 -rs 272-285 -ce backbone -ma 5 -o out
|
|
156
|
+
|
|
157
|
+
tmq hotspot -tr traj_9NSR_500.nc -to topol_9NSR.prmtop -st 1 -rr 1-378 -ce backbone -o out
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
## **Improvements (Speed, Throughput and Reliability)**
|
|
162
|
+
**1.** Batch processing over the CLI and Python API
|
|
163
|
+
|
|
164
|
+
**2.** A major improvement of TrajMapQuick over TrajMap is the speed across varying **residue lengths** and **number of frames**. We evaluated a 1000 frame trajectory (at 100 frame interval) over 800 residues (at 100 residue interval) in TrajMapQuick for both subcommands (shift & hotspot). The **performance plots below:**
|
|
165
|
+
|
|
166
|
+

|
|
167
|
+
|
|
168
|
+
shows clear scaling with number of residues and frames, with completion time between **2-5 mins**. Compared to TrajMapQuick, a single 500 frame calculations across 800 residues took around **10 minutes** in TrajMap, besides the manual editing of input parameters.
|
|
169
|
+
|
|
170
|
+
**3.** The choice to select either the CA or backbone for shift calculations.
|
|
171
|
+
|
|
172
|
+
**4.** Automatic Detection of hotspots using RMSF plots and generation of associated shift plots.
|
|
173
|
+
|
|
174
|
+
**4.** TrajMapQuick allows you to work on any continous chunk of your protein, say residues 300-360 of a 500-residues protein. This reduces time and allows one to focus.
|
|
175
|
+
|
|
176
|
+
## **Contributing**
|
|
177
|
+
Contributions are welcome. Please submit a pull request with your changes.
|
|
178
|
+
|
|
179
|
+
## **License**
|
|
180
|
+
[**MIT License**](../License.md)
|
|
181
|
+
|
|
182
|
+
## **Contact**
|
|
183
|
+
|
|
184
|
+
For questions or issues, please contact us @ [Reslar Labs](reslarscience@gmail.com) **© 2026**, or [Dr. Oluyemi](oluyemiwm@abuad.edu.ng) or [Shadrach Eze](shadrachchinecheremeze@gmail.com).
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
## **Citation**
|
|
188
|
+
|
|
189
|
+
If you use TrajMapQuick, please cite: SHEDOOMTC. (2026). TrajMapQuick: Towards Fast Trajectory Map Analysis and Visualization (v1.0). Zenodo. https://doi.org/10.5281/zenodo.20681061
|
|
190
|
+
|
|
191
|
+
**Software:**
|
|
192
|
+
[](https://doi.org/10.5281/zenodo.20681061)
|
|
193
|
+
|
|
194
|
+
**Dataset:**
|
|
195
|
+
[](https://doi.org/10.5281/zenodo.20681326)
|
|
196
|
+
|
|
197
|
+
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=64", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "tmquick"
|
|
7
|
+
version = "1.0.0"
|
|
8
|
+
description = "TrajMapQuick: Towards Fast Trajectory Map Analysis and Visualization"
|
|
9
|
+
authors = [
|
|
10
|
+
{ name = "Wande M. Oluyemi (PhD)" },
|
|
11
|
+
{ name = "Adeniyi T. Adewumi (PhD)" },
|
|
12
|
+
{ name = "Shadrach C. Eze" },
|
|
13
|
+
{ name = "Stephen C. Nnemolisa" },
|
|
14
|
+
{ name = " @ Research Laboratory for Rational Design of Drugs and Biomaterials (ResLaR Labs)"},
|
|
15
|
+
{ name = "Afe Babalola University, Ado-Ekiti Nigeria"}
|
|
16
|
+
]
|
|
17
|
+
|
|
18
|
+
requires-python = ">=3.9"
|
|
19
|
+
dependencies = [
|
|
20
|
+
"numpy",
|
|
21
|
+
"pandas",
|
|
22
|
+
"matplotlib",
|
|
23
|
+
"seaborn",
|
|
24
|
+
"tqdm",
|
|
25
|
+
"biopython",
|
|
26
|
+
"scipy",
|
|
27
|
+
"netcdf4",
|
|
28
|
+
"colorama"
|
|
29
|
+
]
|
|
30
|
+
|
|
31
|
+
[project.optional-dependencies]
|
|
32
|
+
md = ["mdtraj"]
|
|
33
|
+
|
|
34
|
+
[project.urls]
|
|
35
|
+
Homepage = "https://github.com/SHEDOOMTC/TrajMapQuick.git"
|
|
36
|
+
Documentation = "https://github.com/SHEDOOMTC/TrajMapQuick/blob/7997b0076a6c31bd725dba3ccdca4349b43250d4/README.md"
|
|
37
|
+
DOI = "https://github.com/SHEDOOMTC/TrajMapQuick.git"
|
|
38
|
+
|
|
39
|
+
[project.scripts]
|
|
40
|
+
tmq = "tmq.cli:main"
|
tmquick-1.0.0/setup.cfg
ADDED
tmquick-1.0.0/setup.py
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
from setuptools import setup, find_packages
|
|
2
|
+
|
|
3
|
+
setup(
|
|
4
|
+
name="tmq",
|
|
5
|
+
version="1.0",
|
|
6
|
+
description = "Trajectory map analysis toolkit",
|
|
7
|
+
authors = "Wande M. Oluyemi (PhD), Adeniyi Adewumi (PhD), Shadrach Eze @ ResLaR Labs, Afe Babalola University, Nigeria",
|
|
8
|
+
readme = "README.md",
|
|
9
|
+
python_requires = ">=3.9",
|
|
10
|
+
packages=find_packages(include=["tmq", "tmq.*"]),
|
|
11
|
+
include_package_data=True,
|
|
12
|
+
extras_require={"md": ["mdtraj"],},
|
|
13
|
+
install_requires=[
|
|
14
|
+
"numpy",
|
|
15
|
+
"pandas",
|
|
16
|
+
"matplotlib",
|
|
17
|
+
"seaborn",
|
|
18
|
+
"tqdm",
|
|
19
|
+
"biopython",
|
|
20
|
+
"scipy",
|
|
21
|
+
"netcdf4",
|
|
22
|
+
"colorama"
|
|
23
|
+
|
|
24
|
+
],
|
|
25
|
+
entry_points={
|
|
26
|
+
"console_scripts": [
|
|
27
|
+
"tmq=tmq.cli:main",
|
|
28
|
+
]
|
|
29
|
+
},
|
|
30
|
+
)
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
__version__ = "1.0"
|
|
2
|
+
from .core.traj2pdb import traj2pdb
|
|
3
|
+
from .core.pdb2csv import pdb2csv
|
|
4
|
+
from .core.trajmap import trajmap
|
|
5
|
+
from .core.csv2shift import shift
|
|
6
|
+
from .core.shift2graph import shift2graph
|
|
7
|
+
from .core.hotspot import detect_shifts
|
|
8
|
+
from .core.hotspot import create_submatrices
|
|
9
|
+
from .core.hotspot import plot_shift_regions
|
|
10
|
+
from .core.hotspot import slice_shifts
|
|
11
|
+
from .core.hotspot import plot_slice_regions
|
|
12
|
+
from .core.hotspot import plot_hotspot_regions
|
|
13
|
+
from .core.diff2graph import diff_map
|
|
14
|
+
from .core.average_trajmap import avg_trajmap
|
tmquick-1.0.0/tmq/cli.py
ADDED
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
"""Main CLI launcher
|
|
2
|
+
"""
|
|
3
|
+
|
|
4
|
+
import argparse
|
|
5
|
+
import time
|
|
6
|
+
from .commands.traj2pdb_cli import traj2pdb_cli
|
|
7
|
+
from .commands.pdb2csv_cli import pdb2csv_cli
|
|
8
|
+
from .commands.trajmap_cli import trajmap_cli
|
|
9
|
+
from .commands.csv2shift_cli import shift_cli
|
|
10
|
+
from .commands.shift2graph_cli import shift2graph_cli
|
|
11
|
+
from .commands.hotspot_cli import detect_shift_cli
|
|
12
|
+
from .commands.hotspot_cli import create_submatrices_cli
|
|
13
|
+
from .commands.hotspot_cli import slice_shifts_cli
|
|
14
|
+
from .commands.hotspot_cli import run_hotspot_cli
|
|
15
|
+
from .commands.diff2graph_cli import diff_map_cli
|
|
16
|
+
from .commands.average_trajmap_cli import avg_trajmap_cli
|
|
17
|
+
from colorama import init, Fore, Style
|
|
18
|
+
init(convert=False)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
"""Time counter"""
|
|
22
|
+
def print_final_message(total):
|
|
23
|
+
print(
|
|
24
|
+
Fore.GREEN +
|
|
25
|
+
"\nTrajMapQuick analysis complete. \n" +
|
|
26
|
+
Fore.CYAN +
|
|
27
|
+
"\nAll tasks completed successfully.\n"+
|
|
28
|
+
Style.RESET_ALL
|
|
29
|
+
)
|
|
30
|
+
print(f"Total computation time: {total:.2f} seconds \n" +
|
|
31
|
+
Fore.MAGENTA +
|
|
32
|
+
"\nThank you for using TrajMapQuick 1.0 — ResLaR Labs, Afe Babalola University, Ado-Ekiti Nigeria.\n" +
|
|
33
|
+
Style.RESET_ALL)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
"""Display logo"""
|
|
37
|
+
def main():
|
|
38
|
+
start_time = time.perf_counter()
|
|
39
|
+
init()
|
|
40
|
+
print(Fore.GREEN + r"""
|
|
41
|
+
|
|
42
|
+
_______ _ __ __ ____
|
|
43
|
+
|__ __| (_) \/ | / __ \
|
|
44
|
+
| |_ __ __ _ _| \ / | __ _ _ __ | | | |
|
|
45
|
+
| | '__/ _` | | |\/| |/ _` | '_ \| | | |
|
|
46
|
+
| | | | (_| | | | | | (_| | |_) | |__| |
|
|
47
|
+
|_|_| \__,_| |_| |_|\__,_| .__/ \___\_\
|
|
48
|
+
_/ | | |
|
|
49
|
+
|__/ |_|
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
""" + Style.RESET_ALL)
|
|
53
|
+
print("========== Welcome to TrajMapQuick 1.0 ==========")
|
|
54
|
+
print("")
|
|
55
|
+
print("Authors : " + Fore.BLUE + "Wande M. Oluyemi, Adeniyi T. Adewumi, Shadrach C. Eze & Stephen C. Nnemolisa @ ResLaR Labs, Afe Babalola University, Ado-Ekiti Nigeria" + Style.RESET_ALL)
|
|
56
|
+
print("")
|
|
57
|
+
print("")
|
|
58
|
+
|
|
59
|
+
parser = argparse.ArgumentParser(
|
|
60
|
+
prog="tmq",
|
|
61
|
+
add_help=False,
|
|
62
|
+
formatter_class=argparse.RawTextHelpFormatter,
|
|
63
|
+
description="""
|
|
64
|
+
A command-line toolkit for MD trajectory map analysis:
|
|
65
|
+
• matrix extraction
|
|
66
|
+
• shift computation
|
|
67
|
+
• visualization
|
|
68
|
+
|
|
69
|
+
Built on the original work of Kožić & Bertoša, 2024,
|
|
70
|
+
Trajectory maps: molecular dynamics visualization and analysis,
|
|
71
|
+
https://doi.org/10.1093/nargab/lqad114
|
|
72
|
+
|
|
73
|
+
TrajMapQuick is faster, improves batch processing, and allows
|
|
74
|
+
automatic shift detection from trajectory maps.
|
|
75
|
+
"""
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
parser.add_argument(
|
|
79
|
+
"-h", "--help",
|
|
80
|
+
action="help",
|
|
81
|
+
help="Show usage information")
|
|
82
|
+
|
|
83
|
+
subparsers = parser.add_subparsers(
|
|
84
|
+
title="Available subcommands",
|
|
85
|
+
dest="command",
|
|
86
|
+
metavar=""
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
"""SHIFT SUBCOMMAND"""
|
|
90
|
+
shift_parser = subparsers.add_parser(
|
|
91
|
+
"shift",
|
|
92
|
+
help="Extract matrices, compute residue-residue shifts and make plots: For more, use tmq shift --help",
|
|
93
|
+
description=(
|
|
94
|
+
"Converts your trajectory into pdb multimodel form and then to a CSV file, "
|
|
95
|
+
"extracts a distance matrix from the CSV file and computes "
|
|
96
|
+
"a shift value between a residue range over a specified frame.\n\n"
|
|
97
|
+
"Example:\n"
|
|
98
|
+
" tmq shift --traj traj.pdb --top top.parmtop --str 1 --resr 1-300 --resrs 110-125 --cent backbone --plot --out shift_output\n\n"
|
|
99
|
+
"This will compute the shift of the backbone atoms, for residues 110-125, across the trajectory of a protein with residues 1-300, and will generate plots automatically."),
|
|
100
|
+
formatter_class=argparse.RawTextHelpFormatter
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
shift_parser.add_argument("-tr", "--traj", required=True,
|
|
104
|
+
help="Input trajectory, accepts pdb, nc, xtc xtr")
|
|
105
|
+
shift_parser.add_argument("-to", "--top", required=True,
|
|
106
|
+
help="Topology file, accepts parmtop, pdb, gro")
|
|
107
|
+
shift_parser.add_argument("-st", "--str", type=int, default=1,
|
|
108
|
+
help="Stride of the trajectory, (default: 1)")
|
|
109
|
+
shift_parser.add_argument("-rr", "--resr", type=str, required=True,
|
|
110
|
+
help="Residue range of your protein in the form start-end (e.g., 1-300")
|
|
111
|
+
shift_parser.add_argument("-rs", "--resrs", type=str, required=True,
|
|
112
|
+
help="Residue range for shift calculation, in the form start-end (e.g., 110-125")
|
|
113
|
+
shift_parser.add_argument("-ce", "--cent", type=str, default="backbone", required=True,
|
|
114
|
+
help="Centre of calculations, either the backbone " \
|
|
115
|
+
"atoms or the ca atoms, (default: backbone)")
|
|
116
|
+
shift_parser.add_argument("-ma", "--max", type=int, default=5, required=False,
|
|
117
|
+
help="Max shift value for color scaling, (default: 5)")
|
|
118
|
+
shift_parser.add_argument("-o", "--out", type=str, required=True,
|
|
119
|
+
help="Basename for all outputs")
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
"""HOTSPOT SUBCOMMAND"""
|
|
123
|
+
dehot_parser = subparsers.add_parser(
|
|
124
|
+
"hotspot",
|
|
125
|
+
help="Detect hotspots in residue shifts and create plots: For more, use tmq hotspot --help",
|
|
126
|
+
description=(
|
|
127
|
+
"Detect hotspots in residue shifts and creates publication-ready plot with trajectory map"
|
|
128
|
+
"and hotspot regions annotated, and also generates shift graphs for detected hotspot regions.\n\n"
|
|
129
|
+
"Example:\n"
|
|
130
|
+
" tmq hotspot --traj traj.pdb --top top.parmtop --str 1 --resr 1-300 --cent backbone --out hotspot_output\n\n"
|
|
131
|
+
),
|
|
132
|
+
formatter_class=argparse.RawTextHelpFormatter
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
dehot_parser.add_argument("-tr", "--traj", required=True,
|
|
136
|
+
help="Input trajectory, accepts Pdb, nc, xtc xtr")
|
|
137
|
+
dehot_parser.add_argument("-to", "--top", required=True,
|
|
138
|
+
help="Topology file, accepts .parmtop, pdb, gro")
|
|
139
|
+
dehot_parser.add_argument("-st", "--str", type=int, default=1,
|
|
140
|
+
help="Stride of the trajectory, (default: 1)")
|
|
141
|
+
dehot_parser.add_argument("-rr", "--resr", type=str, required=True,
|
|
142
|
+
help="Residue range of your protein in the form start-end (e.g., 1-300")
|
|
143
|
+
dehot_parser.add_argument("-ce", "--cent", type=str, default="backbone", required=True,
|
|
144
|
+
help="Centre of calculations, either the backbone " \
|
|
145
|
+
"atoms or the ca atoms, (default: backbone)")
|
|
146
|
+
dehot_parser.add_argument("-win", "--window", type=int, default=5, required=False,
|
|
147
|
+
help="Rolling window size for smoothing, (default: 5) (Not Required)")
|
|
148
|
+
dehot_parser.add_argument("-md", "--mindist", type=int, default=3, required=False,
|
|
149
|
+
help="Minimum distance between peaks, (default: 3) (Not Required)")
|
|
150
|
+
dehot_parser.add_argument("-hs", "--hot", type=int, default=10, required=False,
|
|
151
|
+
help="Number of top peaks to extract, (default: 10) (Not Required)")
|
|
152
|
+
dehot_parser.add_argument("-ma", "--max", type=int, default=5, required=False,
|
|
153
|
+
help="Max shift value for color scaling, (default: 5) (Not Required)")
|
|
154
|
+
dehot_parser.add_argument("-o", "--out", type=str, required=True,
|
|
155
|
+
help="Basename for outputs")
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
"""DIFFERENCE SUBCOMMAND"""
|
|
159
|
+
dehot_parser = subparsers.add_parser(
|
|
160
|
+
"diff",
|
|
161
|
+
help="Computes difference between two matrices and creates the difference map: For more, use tmq diff --help",
|
|
162
|
+
description=(
|
|
163
|
+
"Computes difference between two matrices and creates publication-ready plot with difference map.\n\n"
|
|
164
|
+
"The input matrices must be supplied by the names of the output of previous 'Shift' runs.\n\n"
|
|
165
|
+
"A subsequent downstream processing after 'Shift' runs; thus, matrices must have equal lengths.\n\n"
|
|
166
|
+
"Example:\n"
|
|
167
|
+
" tmq diff --mat1 apo --mat2 holo --resr 1-300 --max 8 --out my_diff\n\n"
|
|
168
|
+
),
|
|
169
|
+
formatter_class=argparse.RawTextHelpFormatter
|
|
170
|
+
)
|
|
171
|
+
|
|
172
|
+
dehot_parser.add_argument("-m1", "--mat1", required=True,
|
|
173
|
+
help="First matrix, accepts only the name without extension")
|
|
174
|
+
dehot_parser.add_argument("-m2", "--mat2", required=True,
|
|
175
|
+
help="Second matrix, accepts only the name without extension")
|
|
176
|
+
dehot_parser.add_argument("-rr", "--resr", type=str, required=True,
|
|
177
|
+
help="Residue range of your protein in the form start-end (e.g., 1-300")
|
|
178
|
+
dehot_parser.add_argument("-ma", "--max", type=int, default=5, required=True,
|
|
179
|
+
help="Max shift value for color scaling, (default: 5)")
|
|
180
|
+
dehot_parser.add_argument("-o", "--out", type=str, required=True,
|
|
181
|
+
help="Basename for outputs")
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
"""DIFFERENCE SUBCOMMAND"""
|
|
186
|
+
dehot_parser = subparsers.add_parser(
|
|
187
|
+
"average",
|
|
188
|
+
help="Computes average of n matrices and creates the average map: For more, use tmq average --help",
|
|
189
|
+
description=(
|
|
190
|
+
"Computes average of n matrices and creates publication-ready plot with average map. \n\n"
|
|
191
|
+
"The input matrices must be supplied by the names of the output of previous 'Shift' runs as comma separated values.\n\n"
|
|
192
|
+
"A subsequent downstream processing after 'Shift' runs; thus, matrices must have equal lengths.\n\n"
|
|
193
|
+
"Example:\n"
|
|
194
|
+
" tmq average --mat apo,holo,bound --resr 1-300 --max 8 --out my_avg\n\n"
|
|
195
|
+
),
|
|
196
|
+
formatter_class=argparse.RawTextHelpFormatter
|
|
197
|
+
)
|
|
198
|
+
|
|
199
|
+
dehot_parser.add_argument("-m", "--mat", required=True, type=str,
|
|
200
|
+
help="Comma-separated list of matrix names, accepts only the name without extension")
|
|
201
|
+
dehot_parser.add_argument("-rr", "--resr", type=str, required=True,
|
|
202
|
+
help="Residue range of your protein in the form start-end (e.g., 1-300")
|
|
203
|
+
dehot_parser.add_argument("-ma", "--max", type=int, default=5, required=True,
|
|
204
|
+
help="Max shift value for color scaling, (default: 5)")
|
|
205
|
+
dehot_parser.add_argument("-o", "--out", type=str, required=True,
|
|
206
|
+
help="Basename for outputs")
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
print("")
|
|
210
|
+
args = parser.parse_args()
|
|
211
|
+
|
|
212
|
+
if args.command == "shift":
|
|
213
|
+
traj2pdb_cli(args)
|
|
214
|
+
pdb2csv_cli(args)
|
|
215
|
+
shift_cli(args)
|
|
216
|
+
trajmap_cli(args)
|
|
217
|
+
shift2graph_cli(args)
|
|
218
|
+
end_time = time.perf_counter()
|
|
219
|
+
total = end_time - start_time
|
|
220
|
+
print_final_message(total)
|
|
221
|
+
elif args.command == "hotspot":
|
|
222
|
+
traj2pdb_cli(args)
|
|
223
|
+
pdb2csv_cli(args)
|
|
224
|
+
trajmap_cli(args)
|
|
225
|
+
detect_shift_cli(args)
|
|
226
|
+
create_submatrices_cli(args)
|
|
227
|
+
run_hotspot_cli(args)
|
|
228
|
+
slice_shifts_cli(args)
|
|
229
|
+
run_hotspot_cli(args)
|
|
230
|
+
end_time = time.perf_counter()
|
|
231
|
+
total = end_time - start_time
|
|
232
|
+
print_final_message(total)
|
|
233
|
+
|
|
234
|
+
elif args.command == "diff":
|
|
235
|
+
diff_map_cli(args)
|
|
236
|
+
end_time = time.perf_counter()
|
|
237
|
+
total = end_time - start_time
|
|
238
|
+
print_final_message(total)
|
|
239
|
+
|
|
240
|
+
elif args.command == "average":
|
|
241
|
+
avg_trajmap_cli(args)
|
|
242
|
+
end_time = time.perf_counter()
|
|
243
|
+
total = end_time - start_time
|
|
244
|
+
print_final_message(total)
|
|
245
|
+
|
|
246
|
+
else:
|
|
247
|
+
parser.print_help()
|
|
248
|
+
print("")
|
|
249
|
+
print("Cite this as: " + Fore.BLUE + "SHEDOOMTC. (2026). TrajMapQuick: Towards Fast Trajectory Map Analysis and Visualization (v1.0). Zenodo. https://doi.org/10.5281/zenodo.20681061" + Style.RESET_ALL)
|
|
250
|
+
print("")
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"""Parse input matrices, compute their element-wise average,
|
|
2
|
+
and save an averaged trajectory map PNG.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import time
|
|
6
|
+
from ..core.average_trajmap import avg_trajmap
|
|
7
|
+
import matplotlib
|
|
8
|
+
matplotlib.use("Agg")
|
|
9
|
+
import matplotlib.pyplot as plt
|
|
10
|
+
from ..utils.utils import ensure_csv_extension, ensure_png_extension, parse_range, load_matrix_4_diff_map, csv2matrix
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def avg_trajmap_cli(args):
|
|
14
|
+
start_time = time.perf_counter()
|
|
15
|
+
print("")
|
|
16
|
+
print("Plotting Average map...")
|
|
17
|
+
|
|
18
|
+
"""split the matrix argument to get list of matrices
|
|
19
|
+
"""
|
|
20
|
+
matrix_names = args.mat.split(",")
|
|
21
|
+
prefix = "_pdb2csv_"
|
|
22
|
+
matrices = [csv2matrix(ensure_csv_extension(name + prefix)) for name in matrix_names]
|
|
23
|
+
|
|
24
|
+
residue_start, residue_end = parse_range(args.resr)
|
|
25
|
+
|
|
26
|
+
"""pass the matrices to the core function
|
|
27
|
+
"""
|
|
28
|
+
fig = avg_trajmap(residue_start, residue_end, args.max, *matrices)
|
|
29
|
+
|
|
30
|
+
prefix1 = "_average_map_"
|
|
31
|
+
savename = ensure_png_extension(args.out + prefix1)
|
|
32
|
+
fig.savefig(savename, dpi=800, bbox_inches='tight')
|
|
33
|
+
print(f"Difference map saved to {savename}")
|
|
34
|
+
plt.close(fig)
|
|
35
|
+
total = time.perf_counter() - start_time
|
|
36
|
+
print(f"Time taken to plot Difference map: {total:.2f} seconds")
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"""Load a distance matrix, compute residue-range shifts across frames, and write a shift CSV.
|
|
2
|
+
"""
|
|
3
|
+
|
|
4
|
+
import time
|
|
5
|
+
from ..core.csv2shift import shift
|
|
6
|
+
from ..utils.utils import csv2matrix, ensure_csv_extension, parse_range
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def shift_cli(args):
|
|
10
|
+
start_time = time.perf_counter()
|
|
11
|
+
print("")
|
|
12
|
+
prefix = "_pdb2csv_"
|
|
13
|
+
file = ensure_csv_extension(args.out + prefix)
|
|
14
|
+
matrix = csv2matrix(file)
|
|
15
|
+
residue_start, residue_end = parse_range(args.resrs)
|
|
16
|
+
n_frames = matrix.shape[1]
|
|
17
|
+
print(f"Calculating shift for residues {residue_start} to {residue_end} "
|
|
18
|
+
f"across frames 0 to {n_frames - 1}...")
|
|
19
|
+
|
|
20
|
+
shifta = shift(matrix, residue_start, residue_end)
|
|
21
|
+
|
|
22
|
+
prefix2 = "_shift_"
|
|
23
|
+
savename = ensure_csv_extension(args.out + prefix2)
|
|
24
|
+
shifta.to_csv(savename, index=False)
|
|
25
|
+
print(f"Shift saved to {savename}")
|
|
26
|
+
total = time.perf_counter() - start_time
|
|
27
|
+
print(f"Time taken to calculate shift: {total:.2f} seconds")
|