示例#1
0
def get_all_reactions(rxns_file):
    '''
    Given a .rxns input file, returns a list of reaction entries.

    The return data structure is pretty complex. It's a list of tuples of lists
    of dictionaries which values being tuples. Example return:
    [
        (15, {'reactants': [(1, 'H'), (2, 'O')], 'products': [(3, 'H2O')]}),
        (15, {'reactants': ..., 'products': ...}), 
        (30, {'reactants': [(10, 'H'), (12, 'O')], 'products': [(13, 'H2O')]}),
        (30, {'reactants': ..., 'products': ...}), 
        etc.,
    ]
    '''
    reactions = Reactions_Wrapper()
    reactions.load(rxns_file)
    all_reactions = []
    for each_iteration_reactions in reactions:
        if each_iteration_reactions != []:
            for each_reaction in each_iteration_reactions:
                all_reactions.append(
                    (reactions.iteration, each_reaction)
                )

    return all_reactions
示例#2
0
 def __init__(self):
     self.reactions_wrapper = Reactions_Wrapper()
     pass