def parseComponent(component): ''' parses a bngxml molecule types section ''' comp = st.Component(component.get('id'),component.get('id')) states = component.find('.//{http://www.sbml.org/sbml/level3}ListOfAllowedStates') if states != None: for state in states.getchildren(): comp.addState(state.get('id')) return comp
def createMolecule(molecule, bonds): nameDict = {} mol = st.Molecule(molecule.get('name'),molecule.get('id')) if molecule.get('compartment') not in ['',None]: mol.setCompartment(molecule.get('compartment')) nameDict[molecule.get('id')] = molecule.get('name') listOfComponents = molecule.find('.//{http://www.sbml.org/sbml/level3}ListOfComponents') if listOfComponents != None: for element in listOfComponents: component = st.Component(element.get('name'),element.get('id')) nameDict[element.get('id')] = element.get('name') if element.get('numberOfBonds') in ['+','?']: component.addBond(element.get('numberOfBonds')) elif element.get('numberOfBonds') != '0': component.addBond(findBond(bonds, element.get('id'))) state = element.get('state') if element.get('state') != None else '' component.states.append(state) component.activeState = state mol.addComponent(component) return mol, nameDict