# Find reactions with different names. if firstReactions[rxnId]['name'] != secondReactions[rxnId]['name']: diffNames.add(rxnId) different.add(rxnId) # Find reactions with different status. if firstReactions[rxnId]['status'] != secondReactions[rxnId]['status']: diffStatus.add(rxnId) different.add(rxnId) # Find reactions with different stoichiometry. Convert the dictionaries to a tuple # so we can use set operations to compare. firstReactants = set() firstProducts = set() reactants, products = helper.parseEquation(firstReactions[rxnId]['equation']) for index in range(len(reactants)): cpd = helper.parseCompoundIdStoich(reactants[index]) firstReactants.add( ( cpd['stoich'], cpd['compound'] ) ) for index in range(len(products)): cpd = helper.parseCompoundIdStoich(products[index]) firstProducts.add( ( cpd['stoich'], cpd['compound'] ) ) secondReactants = set() secondProducts = set() reactants, products = helper.parseEquation(secondReactions[rxnId]['equation']) for index in range(len(reactants)): cpd = helper.parseCompoundIdStoich(reactants[index]) secondReactants.add( ( cpd['stoich'], cpd['compound'] ) ) for index in range(len(products)): cpd = helper.parseCompoundIdStoich(products[index]) secondProducts.add( ( cpd['stoich'], cpd['compound'] ) )
# name, abbreviation, formula, defaultCharge, isCofactor helper = BiochemHelper() compounds = helper.readCompoundsFile(args.compoundfile, includeLinenum=False) for index in range(len(compounds)): biochem['compounds'].append(compounds[index]) # Add the reactions from the reactions file. Required fields: id, name, # abbreviation, direction, thermoReversibility, status, defaultProtons, reagents. reactions = helper.readReactionsFile(args.reactionfile, includeLinenum=False) for index in range(len(reactions)): rxn = reactions[index] reactants, products = helper.parseEquation(rxn['equation']) if reactants is None and products is None: # @todo Need to confirm this continue rxn['reagents'] = list() for rindex in range(len(reactants)): cpd = helper.parseCompoundIdStoich(reactants[rindex]) reagent = dict() reagent['compound_ref'] = '~/compounds/id/' + cpd['compound'] reagent['compartment_ref'] = '~/compartments/id/' + cpd[ 'compartmentId'] reagent['coefficient'] = cpd['stoich'] * -1.0 reagent[ 'isCofactor'] = 0 # @todo Is this set separately from value in compound? rxn['reagents'].append(reagent) for pindex in range(len(products)): cpd = helper.parseCompoundIdStoich(products[pindex])
# Check for invalid direction. if rxn['direction'] != '<' and rxn['direction'] != '>' and rxn['direction'] != '=': badDirection.append(index) # Check for unknown or invalid reversibility. if rxn['reversibility'] == '?': unknownReversibility.append(index) elif rxn['reversibility'] != '<' and rxn['reversibility'] != '>' and rxn['reversibility'] != '=': badReversibility.append(index) # Check for different equation and code fields. if rxn['equation'] != rxn['code']: diffEquationCode.append(index) # Check for missing reactants and/or products. reactants, products = helper.parseEquation(rxn['equation']) if reactants is None and products is None: noEquation.append(index) else: if len(reactants) == 0: noReactants.append(index) if len(products) == 0: noProducts.append(index) # reactants, products = helper.parseEquation(rxn['definition']) # if reactants is None and products is None: # noDefinition.append(index) # Check reaction status. if rxn['status'] == 'OK': okStatus += 1