Write reaction info to db file

        Parameters
        ----------
        values: dict

        The values dict can include:
        {'chemical_composition': str (chemical composition on empty slab) ,
        'surface_composition': str (reduced chemical composition or
                                         shortname),
        'facet': str
        'sites': dict
            adsorption sites of species.
            f.ex: {'OH': 'ontop', 'O': 'hollow'}
        'coverages': dict
            coverage of adsorbates relative to the unit cell
            f.ex. {'OH': 0.25, 'O': 0.5})
        'reactants'/ 'products': dict
            keys with name of chemical species folloved by phase (gas, *)
            values are the prefactor in the reaction.
            For reaction H2Ogas -> 2Hstar + O star you would write:
            'reactants': {OHstar: 1, Hstar: 2}
            'products': {OHstar: 1, Hstar: 2}
        'reaction_energy': float
        'activation_energy': float
        'dft_code': str
        'dft_functional': str
        'username': str
        'pub_id': str
            Should match the pub_id of the corresponding publications
        }

def write(self, values, data=None):
        """
        Write reaction info to db file

        Parameters
        ----------
        values: dict

        The values dict can include:
        {'chemical_composition': str (chemical composition on empty slab) ,
        'surface_composition': str (reduced chemical composition or
                                         shortname),
        'facet': str
        'sites': dict
            adsorption sites of species.
            f.ex: {'OH': 'ontop', 'O': 'hollow'}
        'coverages': dict
            coverage of adsorbates relative to the unit cell
            f.ex. {'OH': 0.25, 'O': 0.5})
        'reactants'/ 'products': dict
            keys with name of chemical species folloved by phase (gas, *)
            values are the prefactor in the reaction.
            For reaction H2Ogas -> 2Hstar + O star you would write:
            'reactants': {OHstar: 1, Hstar: 2}
            'products': {OHstar: 1, Hstar: 2}
        'reaction_energy': float
        'activation_energy': float
        'dft_code': str
        'dft_functional': str
        'username': str
        'pub_id': str
            Should match the pub_id of the corresponding publications
        }
        """
        con = self.connection or self._connect()
        self._initialize(con)
        cur = con.cursor()

        pub_id = values['pub_id']
        ase_ids = values['ase_ids']
        energy_corrections = values['energy_corrections']

        if ase_ids is not None:
            check_ase_ids(values, ase_ids)
        else:
            ase_ids = {}
        values = (values['chemical_composition'],
                  values['surface_composition'],
                  values['facet'],
                  json.dumps(values['sites']),
                  json.dumps(values['coverages']),
                  json.dumps(values['reactants']),
                  json.dumps(values['products']),
                  values['reaction_energy'],
                  values['activation_energy'],
                  values['dft_code'],
                  values['dft_functional'],
                  values['username'],
                  values['pub_id']
                  )

        """ Write to reaction table"""
        q = self.default + ',' + ', '.join('?' * len(values))
        cur.execute('INSERT INTO reaction VALUES ({})'.format(q),
                    values)
        id = self.get_last_id(cur)

        reaction_structure_values = []

        """ Write to publication_system and reaction_system tables"""
        for name, ase_id in ase_ids.items():
            if name in energy_corrections:
                energy_correction = energy_corrections[name]
            else:
                energy_correction = 0
            reaction_structure_values.append([name, energy_correction,
                                              ase_id, id])
            insert_statement = """INSERT OR IGNORE INTO
            publication_system(ase_id, pub_id) VALUES (?, ?)"""
            cur.execute(insert_statement, [ase_id, pub_id])

        cur.executemany('INSERT INTO reaction_system VALUES (?, ?, ?, ?)',
                        reaction_structure_values)

        if self.connection is None:
            con.commit()
            con.close()

        return id