-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcleandb.py
More file actions
30 lines (25 loc) · 818 Bytes
/
cleandb.py
File metadata and controls
30 lines (25 loc) · 818 Bytes
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
#!/bin/python
# this is a template for cleaning scripts which should be placed in sub-dataset folders
# should not be run by itself
from ase.db import connect
import pdb
def cleaner_demo(atoms):
return False
def clean_db(db_in, db_out, cleaners = [cleaner_demo]):
# list of function handles
with db_out as output:
for row in db_in.select():
atoms = row.toatoms()
flag = False
# loop over
for clnr in cleaners:
new_flag = clnr(atoms)
flag = flag or new_flag
if new_flag:
print(row.name, ': ', clnr.__name__)
if not flag:
output.write(atoms, name=row.name)
else:
print(row.name)
if __name__ == '__main__':
clean_db()