Пример #1
0
def main():
	
    parser = OptionParser()
    parser.add_option("-i","--input",dest="input",
    	default='input.xml',type="string",
    	help="The input SBML file in xml format. Default = 'input.xml'",metavar="FILE")
    parser.add_option("-o","--output",dest="output",
    	default='output.bngl',type="string",
    	help="the output file where we will store our matrix. Default = output.bngl",metavar="FILE")
          
    (options, args) = parser.parse_args()
    reader = SBMLReader()
    document = reader.readSBMLFromFile(options.input)
    print options.input
    parser =SBML2BNGL(document.getModel())
    param2 = parser.getParameters()
    param,rules,functions = parser.getReactions()
    
    
    molecules,species,observables = parser.getSpecies()
    
    param += param2
    print rules
         
    writer.finalText(param,molecules,species,observables,rules,functions,options.output)
Пример #2
0
def main():

    if libsbml == None:
        return
    parser = OptionParser()
    parser.add_option("-i","--input",dest="input",
		default='',type="string",
		#default='/home/proto/Downloads/model.xml',type="string",
        help="The input SBML file in xml format. Default = 'input.xml'",metavar="FILE")
    parser.add_option("-o","--output",dest="output",
		type="string",
		help="the output JSON file. Default = <input>.py",metavar="FILE")
    (options, args) = parser.parse_args()
    reader = libsbml.SBMLReader()
    nameStr = options.input
    if options.output == None:
        outputFile = nameStr + '.json'
    else:
        outputFile = options.output
    document = reader.readSBMLFromFile(nameStr)
    if document.getModel() == None:
        #logging.error('A model with path "{0}" could not be found'.format(nameStr))
        return
    #logging.info('An SBML file was found at {0}.Attempting import'.format(nameStr))
    parser = SBML2JSON(document.getModel())

    parameters,observables =  parser.getParameters()

    #compartments = parser.getRawCompartments()
    molecules,release = parser.getMolecules()
    reactions,release2,molecules2 =  parser.getReactions(parameters)
    molecules.extend(molecules2)
    release.extend(release2)
    #release.extend(release2)
    definition = {}
    definition['par_list'] = parameters
    definition['mol_list'] = molecules
    definition['rxn_list'] = reactions
    definition['rel_list'] = release
    definition['obs_list'] = observables
    #definition['comp_list'] = compartments
    with open(outputFile,'w') as f:
        json.dump(definition,f,sort_keys=True,indent=1, separators=(',', ': '))
Пример #3
0
def main():
	
    #command line arguments
    parser = OptionParser()
    parser.add_option("-i","--input",dest="input",
		default='bngl2mcell/rec_dim_sbml.xml',type="string",
		help="The input SBML file in xml format. Default = 'input.xml'",metavar="FILE")
    parser.add_option("-o","--output",dest="output",
		type="string",
		help="the output JSON file. Default = <input>.py",metavar="FILE")
    (options, args) = parser.parse_args()
    reader = libsbml.SBMLReader()
    nameStr = options.input
    if options.output == None:
        outputFile = nameStr + '.py'
    else:
        outputFile = options.output
        
    #libsbml initialization stuff
    document = reader.readSBMLFromFile(nameStr)
    if document.getModel() == None:
        print 'No such input file'
        return
    #get data
    parser = SBML2JSON(document.getModel())
    parameters =  parser.getParameters()
    molecules,release = parser.getMolecules()      
    reactions =  parser.getReactions(parameters)
    definition = {}
    definition['par_list'] = parameters
    definition['mol_list'] = molecules
    definition['rxn_list'] = reactions
    definition['rel_list'] = release
    print 'Writing output to {0}'.format(outputFile)
    #output
    with open(outputFile,'w') as f:
        json.dump(definition,f,sort_keys=True,indent=1, separators=(',', ': '))