def modelReader(modelfile, mtype, readertype='extended'): '''! Function to switch between different model specification readers to read a given model specification into a dictionary of objects. @param modelfile String: Relative path to the model specification file. @param mtype String: Type of model specification file. Allowable types are 'ASM' (AdvanceSyn Model Specification). Default = 'ASM'. @param readertype String: Additional options based on mtype. If mtype is ASM, then allowable types are 'basic' and 'extended'. @return: A tuple of (Object containing the processed model, Dictionary of objects where key is the object name and value is the object numbering) ''' if mtype == 'ASM': if readertype == 'extended': (spec, modelobj) = ASModeller.process_asm_model(modelfile) if readertype == 'basic': spec = ASModeller.modelspec_reader(modelfile, 'basic') modelobj = None if mtype == 'MO': with open(modelfile, 'rb') as f: loaded_data = pickle.load(f) spec = loaded_data[0] modelobj = loaded_data[1] return (spec, modelobj)
def readASModelSpecification(modelfile): '''! Function to read the AdvanceSyn model specification file and print out its details after processing into model objects. Usage: python astools.py readASM --modelfile=models/asm/glycolysis.modelspec @param modelfile String: Relative path to the model specification file. ''' (spec, modelobj) = ASModeller.process_asm_model(modelfile) print('-------- Model Identifiers --------') for key in spec['Identifiers']: print('%s: %s' % (str(key), str(spec['Identifiers'][key]))) print('') print('-------- Model Objects --------') for key in modelobj: obj = modelobj[key] print('Name: %s' % str(obj.name)) print('Description: %s' % str(obj.description)) print('Initial: %s' % str(obj.value['initial'])) print('Influx:') pprint(obj.influx) print('Outflux:') pprint(obj.outflux) print('')