How to extract specific data from trajectory (txt file) in python?

Viewed 10

The original file format is below, the first line is the frame number of the trajectory, the second line is the number of atoms, and I want to extract the XYZ file, the last three numbers of each row (eg: 23 24 25). Drop the atomic number and rename all atoms to C, each frame has box size data (30.20159 30.20159 30.20159), I'd like to average them and remove them from the file. Really appreciate your help.

Comments ... frame 1
456 # number of atoms
1ARG S0 1 23 24 25
1ARG B1 2 11 12 21
...
114ARG B3 456 2 23 5
30.20159  30.20159  30.20159 # the box size 
Comments ... frame 2
456 # number of atoms
1ARG S0 1 3 24 25
...
then repeat

The file I want to get

456 # number of atoms
Comments ... frame 1
C 23 24 25
C 11 12 21
...
C 2 23 5
456 # number of atoms
Comments ... frame 2
C 3 24 25
...
then repeat
0 Answers
Related