{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "import os.path\n",
    "import rmgpy\n",
    "from IPython.display import display\n",
    "from rmgpy.data.thermo import ThermoDatabase\n",
    "from rmgpy.molecule.resonance import generate_aromatic_resonance_structures"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "databasePath = os.path.join(rmgpy.settings['database.directory'], 'thermo')\n",
    "\n",
    "database = ThermoDatabase()\n",
    "database.load(databasePath, libraries=['C10H11', 'Lai_Hexylbenzene', 'Fulvene_H', 'naphthalene_H'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "for name, library in database.libraries.iteritems():\n",
    "    for label, entry in library.entries.iteritems():\n",
    "        mol = entry.item\n",
    "        if mol.isCyclic():\n",
    "            arom = generate_aromatic_resonance_structures(mol)\n",
    "            if len(arom) > 0:\n",
    "                entry.item = arom[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "database.saveLibraries(os.path.join(databasePath, 'libraries'))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "anaconda-cloud": {},
  "kernelspec": {
   "display_name": "Python [conda env:rmg_env]",
   "language": "python",
   "name": "conda-env-rmg_env-py"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
