forked from hmcezar/dicetools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_conf_traj.py
executable file
·29 lines (24 loc) · 931 Bytes
/
get_conf_traj.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/env python3
"""
Given the filename of a DICE xyz trajectory and a number of a configuration
returns the configuration.
Author: Henrique Musseli Cezar
Date: DEC/2018
"""
import argparse
if __name__ == '__main__':
parser = argparse.ArgumentParser(description="Given the filename of a DICE xyz trajectory and a number of a configuration returns the configuration.")
parser.add_argument("trajfile", help="the DICE trajectory in .xyz")
parser.add_argument("confnum", type=int, help="the number of the configuration to be extracted")
args = parser.parse_args()
with open(args.trajfile,'r') as f:
n_atoms = int(f.readline())
for line in f:
if ("Configuration number" in line) and (str(args.confnum) in line):
# print the config and exit
print(n_atoms)
print(line,end='')
for i in range(n_atoms):
lin = f.readline()
print(lin,end='')
break