How to attach number of xtc file without stop?

Hi,

I have a number of .xtc files (more than 1000). I would like to attach all these files. For this purpose, I have written a Python code to read the files and I used trjcat command. But at each level, it asks me to write “c” or “l” to attach them. I need to enter “c”. how can I change the command to do it continuously without asking for “c”?
This is the python code:

import subprocess

# Define the range of indices for the .xtc files
start_index = 1
end_index = 1000 # Adjust this to the last index of the files

# List of .xtc files to concatenate
xtc_files = [f"md{i}.xtc" for i in range(start_index, end_index+1)]

# Construct the trjcat command
command = ['gmx', 'trjcat', '-f'] + xtc_files + ['-o', 'combined_2.xtc', '-cat', 'yes', '-settime', 'yes']

# Run the trjcat command
subprocess.run(command)

Dear @mj.rezayani,

You can echo and pass the echoed letter to gmx, that is, do something like this

echo "c" | gmx trjcat -f ...

So just cut down the whole command with echo into substring that work for the subprocess.run python function. Two things though:

i) there is a python API for GROMACS which you can find useful

ii) if you use wildcards such as gmx trjcat -f traj_*.xtc -o ... you should be able to do the same without having to rely on a python script. Just rename all the files accordingly. If time ordering is important as well, keep in mind that the naming should follow the same ordering you want into the final output file or you can supply a file specifying the ordering with the -demux flag.

Dear,

Thank you very much for your reply. It worked!