forked from Angel-Jia/VASP-script
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflagck.py
48 lines (38 loc) · 1.07 KB
/
flagck.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
47
48
#!/bin/env python
import re
file_name = 'POSCAR'
with open(file_name) as input_file:
content = input_file.readlines()
pattern = re.compile('\s+')
pre_flag = []
flag = []
if re.search(r'^[Ss]', content[7]) is None:
print ""
print "Selective flag has not been found!"
print ""
exit(0)
print ""
print "Atom_id Content"
print "------------------------------------------"
for i in xrange(9, len(content)):
temp = pattern.split(content[i].strip())
if len(temp) == 1:
exit(0)
if len(temp) != 6:
print "-----------"
print "%4d: %s" % (i - 8, content[i].rstrip())
print "-----------"
continue
if len(pre_flag) == 0:
pre_flag = [temp[3], temp[4], temp[5]]
flag = [temp[3], temp[4], temp[5]]
else:
flag = [temp[3], temp[4], temp[5]]
if flag == pre_flag:
continue
else:
pre_flag = flag
print "%4d: %s" % (i - 9, content[i - 1].rstrip())
print "%4d: %s" % (i - 8, content[i].rstrip())
print "-----------"
print ""