|
27 | 27 | from rdkit.Chem.Draw import rdMolDraw2D |
28 | 28 | from plip.basic import config |
29 | 29 | from MDAnalysis.analysis import rms |
| 30 | +from MDAnalysis.coordinates.DCD import DCDWriter |
30 | 31 | from tqdm import tqdm |
31 | 32 |
|
32 | 33 |
|
@@ -102,6 +103,12 @@ def main(): |
102 | 103 | help='Dataframe (use if the interactions were already calculated, default name would be "df_all.csv")', |
103 | 104 | default=None, |
104 | 105 | ) |
| 106 | + parser.add_argument( |
| 107 | + "-f", |
| 108 | + dest="frames", |
| 109 | + help="final frame of the analysis (if you want to analyze only a certain part of the trajectory)", |
| 110 | + default=None, |
| 111 | + ) |
105 | 112 | parser.add_argument( |
106 | 113 | "-m", |
107 | 114 | dest="min_transition", |
@@ -162,14 +169,12 @@ def main(): |
162 | 169 | help="Calculate the representative frame for each binding mode. Defaults to False", |
163 | 170 | default=False, |
164 | 171 | ) |
165 | | - |
166 | 172 | parser.add_argument( |
167 | 173 | "--watereps", |
168 | 174 | dest="water_eps", |
169 | 175 | help="Set the Eps for clustering, this defines how big clusters can be spatially in Angstrom", |
170 | 176 | default=1.0, |
171 | 177 | ) |
172 | | - |
173 | 178 | parser.add_argument( |
174 | 179 | "--figure", |
175 | 180 | dest="figure_type", |
@@ -268,6 +273,14 @@ def main(): |
268 | 273 | if not pdb_md: |
269 | 274 | pdb_md = mda.Universe(topology, trajectory) |
270 | 275 |
|
| 276 | + if frames != None: |
| 277 | + print(f"\033[1mWriting out the first {frames} out for the analysis\033[0m") |
| 278 | + ag = pdb_md.select_atoms("all") |
| 279 | + with DCDWriter(f"{frames}.dcd", ag.n_atoms) as w: |
| 280 | + for ts in pdb_md.trajectory[: int(frames) + 1]: |
| 281 | + w.write(ag) |
| 282 | + pdb_md = mda.Universe(topology, f"{frames}.dcd") |
| 283 | + |
271 | 284 | trajsaver = TrajectorySaver(pdb_md, ligand, special_ligand, receptor_nucleic) |
272 | 285 |
|
273 | 286 | # TODO maybe put this part into a function possibly in visualization_functions.py TrajectorySaver |
@@ -815,6 +828,8 @@ def main(): |
815 | 828 | topology, "representative_waters.pdb", water_eps |
816 | 829 | ) |
817 | 830 |
|
| 831 | + if frames != None: |
| 832 | + os.remove(f"{frames}.dcd") |
818 | 833 |
|
819 | 834 | if __name__ == "__main__": |
820 | 835 | main() |
0 commit comments