Coverage for model_workflow/tools/get_summarized_trajectory.py: 0%
7 statements
« prev ^ index » next coverage.py v7.9.2, created at 2025-07-23 10:54 +0000
« prev ^ index » next coverage.py v7.9.2, created at 2025-07-23 10:54 +0000
1# This script is used to get a reduced version of a given trajectory
2# The summarized trajectory frames are frames selected along the whole trajectory
3# This process is carried by Gromacs
5from subprocess import run, PIPE, Popen
7from model_workflow.utils.constants import GROMACS_EXECUTABLE
9# input_topology_filename - The name string of the input topology file (path)
10# Tested supported formats are .pdb and .tpr
11# input_trajectory_filename - The name string of the input trajectory file (path)
12# Tested supported formats are .trr and .xtc
13# summarized_trajectory_filename - The name string of the output summarized trajectory file (path)
14# Tested supported format is .pdb
15def get_summarized_trajectory (
16 input_topology_filename : str,
17 input_trajectory_filename : str,
18 summarized_trajectory_filename : str
19 ) -> str:
21 # Run Gromacs
22 p = Popen([
23 "echo",
24 "System",
25 ], stdout=PIPE)
26 # Run Gromacs
27 logs = run([
28 GROMACS_EXECUTABLE,
29 "trjconv",
30 "-s",
31 input_topology_filename,
32 "-f",
33 input_trajectory_filename,
34 '-o',
35 summarized_trajectory_filename,
36 '-dt',
37 '10',
38 '-quiet'
39 ], stdin=p.stdout, stdout=PIPE).stdout.decode()
40 p.stdout.close()
42 # Return gromacs logs
43 return logs