# -*- coding:utf-8 -*-
#static functions
import re


#functions for general energy profile
def get_relative_energy_tuple(energy_tuple):
    "Set is energy as 0, other energies are relative."
    energy_list = list(energy_tuple)
    reference_energy = energy_list[0]
    for i in xrange(len(energy_list)):
        energy_list[i] = energy_list[i] - reference_energy
    return tuple(energy_list)


def equation2list(rxn_equation):
    "Convert rxn_equation string to rxn_list."
    states_regex = re.compile(r'([^\<\>]*)(?:\<?\-\>)' +
                              r'(?:([^\<\>]*)(?:\<?\-\>))?([^\<\>]*)')
    m = states_regex.search(rxn_equation)
    rxn_list = []
    for idx in range(1, 4):
        if m.group(idx):
            rxn_list.append(m.group(idx))

    return rxn_list


#functions for merged energy profile
def verify_multi_shape(multi_rxn_equations, multi_energy_tuples):
    "Verify the legitimacy of input data."
    for rxn_equations, energy_tuples in \
            zip(multi_rxn_equations, multi_energy_tuples):
        if len(rxn_equations) != len(energy_tuples):
            raise ValueError('Unmatched shape.\n' +
                             'Check your input data please.')
        for rxn_equation, energy_tuple in zip(rxn_equations, energy_tuples):
            rxn_list = equation2list(rxn_equation)
            if len(rxn_list) != len(energy_tuple):
                raise ValueError("unmatched shape: %s, %s" %
                                 (rxn_equation, str(energy_tuple)))
    return


def verify_attrlen(attr, n):
    "Verify length of iterable attr."
    if hasattr(attr, '__getitem__'):  # if iterable
        if len(attr) != n:
            raise ValueError('length of %s is not equal to %d' %
                             (str(attr), n))
    else:
        raise ValueError('%s is not iterable!' % str(attr))


def line2list(line, field=' ', dtype=float):
    "Convert text data in a line to data object list."
    strlist = line.strip().split(field)
    if type(dtype) != type:
        raise TypeError('Illegal dtype.')
    datalist = [dtype(i) for i in strlist if i != '']

    return datalist


@@ -45,16 +45,61 @@
 ort re%0A%0A
+from catplot.chem_parser import RxnEquation%0A%0A
 %0A#functi
@@ -1010,22 +1010,8 @@
  in 
-%5C%0A            
 zip(
@@ -1158,42 +1158,8 @@
 e.%5Cn
-' +%0A                             '
 Chec
@@ -1182,24 +1182,25 @@
 a please.')%0A
+%0A
         for 
@@ -1287,29 +1287,27 @@
 _list = 
-e
+RxnE
 quation
-2list
 (rxn_equ
@@ -1308,24 +1308,33 @@
 xn_equation)
+.tolist()
 %0A           
@@ -1729,37 +1729,8 @@
 d' %25
-%0A                            
  (st
@@ -1817,291 +1817,4 @@
 ))%0A%0A
-%0Adef line2list(line, field=' ', dtype=float):%0A    %22Convert text data in a line to data object list.%22%0A    strlist = line.strip().split(field)%0A    if type(dtype) != type:%0A        raise TypeError('Illegal dtype.')%0A    datalist = %5Bdtype(i) for i in strlist if i != ''%5D%0A%0A    return datalist%0A%0A

Use tolist() method of RxnEquation instead of rxn2list