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 create_molecule_from_pattern(molecule_pattern, idx): tmp_molecule = st.Molecule(molecule_pattern['moleculeName'], idx) if 'moleculeCompartment' in molecule_pattern: tmp_molecule.compartment = molecule_pattern['moleculeCompartment'][1] if 'components' in molecule_pattern.keys(): for idx2, component in enumerate(molecule_pattern['components']): tmp_component = st.Component(component['componentName'], '{0}_{1}'.format(idx, idx2)) if 'state' in component: for state in component['state']: if state != '': tmp_component.addState(state) if 'bond' in component.keys(): for bond in component['bond']: tmp_component.addBond(bond) tmp_molecule.addComponent(tmp_component) return tmp_molecule
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 is not 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