forked from QijingZheng/pyband
-
Notifications
You must be signed in to change notification settings - Fork 0
/
aseconv.py
46 lines (35 loc) · 1.36 KB
/
aseconv.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
40
41
42
43
44
45
46
#!/usr/bin/env python
from os.path import splitext
from ase.io import read, write
from optparse import OptionParser
############################################################
def command_line_arg():
usage = "USAGE: %prog -i input_format -o output_format InputFiles"
par = OptionParser(usage=usage)
par.add_option('-i', '--inp',
action='store', type="string",
dest='in_format', default=None,
help='Format of input file.')
par.add_option('-o', '--out',
action='store', type="string",
dest='out_format', default='vasp',
help='Format of output file.')
par.add_option('-p', '--prefix',
action='store', type="string",
dest='prefix', default=None,
help='Prefix for output files.')
return par.parse_args( )
############################################################
if __name__ == '__main__':
opts, args = command_line_arg()
if opts.out_format == 'vasp':
keyArgs = {'vasp5': True, 'direct': True}
else:
keyArgs = {}
for ii, inF in enumerate(args):
geo = read(inF, format=opts.in_format)
if opts.prefix:
outF = "{:s}_{:02d}.{:s}".format(opts.prefix, ii, opts.out_format)
else:
outF = "{:s}.{:s}".format(splitext(inF)[0], opts.out_format)
write(outF, geo, **keyArgs)