In [ ]:
from collections import OrderedDict
from base64 import b64encode
from IPython.display import display, HTML, Image

from rmgpy.chemkin import loadChemkinFile

In [ ]:
chem_1 = "/home/mjliu/Documents/Models/Naphthalene/acetylene/run7/chem0190.inp"
dict_1 = "/home/mjliu/Documents/Models/Naphthalene/acetylene/run7/species_dictionary.txt"

chem_2 = "/home/mjliu/Documents/Models/Naphthalene/acetylene/run7/chem0170.inp"
dict_2 = "/home/mjliu/Documents/Models/Naphthalene/acetylene/run7/species_dictionary.txt"

In [ ]:
spcs_1, rxns_1 = loadChemkinFile(chem_1, dict_1)

# Restore chemkin labels
spcs_dict_1 = OrderedDict()
for spc in spcs_1:
    label = "{0}({1})".format(spc.label, spc.index) if spc.index != -1 else spc.label
    spc.label = label
    spcs_dict_1[label] = spc

In [ ]:
spcs_2, rxns_2 = loadChemkinFile(chem_2, dict_2)

# Restore chemkin labels
spcs_dict_2 = OrderedDict()
for spc in spcs_2:
    label = "{0}({1})".format(spc.label, spc.index) if spc.index != -1 else spc.label
    spc.label = label
    spcs_dict_2[label] = spc

In [ ]:
only_1 = OrderedDict()
only_2 = OrderedDict()

for label, spc in spcs_dict_1.iteritems():
    if spc.label not in spcs_dict_2:
        only_1[spc.label] = spc

for label, spc in spcs_dict_2.iteritems():
    if spc.label not in spcs_dict_1:
        only_2[spc.label] = spc

In [ ]:
len(only_1), len(only_2)

In [ ]:
html = ['<table style="width:100%;table-layout:fixed;">']
html += ['<tr><th colspan="{0}">Model 1 has {1} unique species</th></tr>'.format(2, len(only_1))]
for label, species in only_1.iteritems():
    html += ['<tr><td colspan="{0}">{1}</td>'.format(1, label)]
    html += ['<td colspan="{0}"><img src="data:image/png;base64,{1}"></td></tr>'.format(1, b64encode(species._repr_png_()))]
html += ['</table>']

display(HTML(''.join(html)))

In [ ]:
html = ['<table style="width:100%;table-layout:fixed;">']
html += ['<tr><th colspan="{0}">Model 2 has {1} unique species</th></tr>'.format(2, len(only_2))]
for label, species in only_2.iteritems():
    html += ['<tr><td colspan="{0}">{1}</td>'.format(1, label)]
    html += ['<td colspan="{0}"><img src="data:image/png;base64,{1}"></td></tr>'.format(1, b64encode(species._repr_png_()))]
html += ['</table>']

display(HTML(''.join(html)))

In [ ]: