-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcrystal2traj.py
executable file
·41 lines (32 loc) · 1.19 KB
/
crystal2traj.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
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env python3
#
# Script to convert Crystal GO to ASE-extxyz trajectory
# by Patrick Melix
# 2018/04/16
#
# You can import the module and then call .main() or use it as a script
from ase import io
import os, glob
def main(inStr,outFile):
#if output exists mv to .bak
if os.path.isfile(outFile):
print('ATTENTION: {:} exists, moving it to {:}.bak'.format(outFile, outFile))
os.rename(outFile, outFile+'.bak')
files = glob.glob(os.path.join(inStr,'./optc*'))
files.sort()
print("Found {} frames.".format(len(files)))
for inFile in files:
if not os.path.isfile(inFile):
raise ValueError('File {:} does not exist'.format(str(inFile)))
print(inFile)
mol = io.read(inFile, format='crystal')
mol.write(outFile,append=True)
print("Trajectory written to {}.".format(outFile))
return
if __name__ == "__main__":
import argparse
parser = argparse.ArgumentParser(description='Convert Crystal GO to ASE-extxyz trajectory')
parser.add_argument('input', type=str, help='optstory dir')
parser.add_argument('output', type=str, help='output file')
args = parser.parse_args()
main(args.input,args.output)