示例#1
0
文件: models.py 项目: jerkos/kepavi
    def get_cobra_model(self):

        if self.kegg_org is not None:
            model = BiomodelMongo.objects(organism=self.kegg_org).first()
        else:
            model = BiomodelMongo.objects(name=self.name).first()

        # try to load the cobra model
        cobra_model = None
        try:
            cobra_model = cobra.io._from_dict(model.cobra_model)
        except Exception as e:
            logging.error(e)
        return cobra_model
示例#2
0
文件: manage.py 项目: jerkos/kepavi
def test_read_models():
    m = BiomodelMongo.objects(organism='sse').first()
    import cobra.io
    import json
    try:
        # s = json.dumps(m.cobra_model).encode('utf-8')
        # with open('test.json', 'w') as f:
        #     f.write(s)
        sbml_model = cobra.io._from_dict(m.cobra_model)
        #sbml_model = cobra.io.load_json_model('test.json')
    except Exception as e:
        print "Got an exception:", e
        return None
    print "NOTES:", sbml_model.reactions[1].notes
    return sbml_model