forked from ReactionMechanismGenerator/RMG-database
-
Notifications
You must be signed in to change notification settings - Fork 0
/
exportOldDatabase.py
60 lines (40 loc) · 1.64 KB
/
exportOldDatabase.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
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env python
# encoding: utf-8
"""
This script exports the database to the old RMG-Java format. The script
requires two command-line arguments: the path to the database to import, and
the path to save the old RMG-Java database to.
"""
import os
import sys
import logging
from rmgpy.data.rmg import RMGDatabase
from rmgpy.data.base import Entry
from rmgpy.reaction import Reaction
from rmgpy.kinetics import Arrhenius, ArrheniusEP, KineticsData
###############################################################################
def main():
if len(sys.argv) != 3:
raise Exception('You must pass input and output '
'directories as parameters.')
newPath = sys.argv[1]
oldPath = os.path.join(sys.argv[2], 'RMG_database')
export(newPath, oldPath)
###############################################################################
def export(input, output, database=None):
print 'Loading the new RMG-Py database...'
if not database:
database = RMGDatabase()
database.load(input)
print 'Constructing additional rate rules from kinetics depository...'
for family in database.kinetics.families.values():
family.addKineticsRulesFromTrainingSet(thermoDatabase=database.thermo)
print "Deleting thermo library entries with atoms RMG-Java can't understand..."
database.thermo.pruneHeteroatoms(allowed=['C','H','O','S'])
print 'Saving old RMG-Java database...'
database.saveOld(output)
print "Done!"
###############################################################################
if __name__ == '__main__':
logging.getLogger().setLevel(logging.INFO)
main()