Beispiel #1
0
 def test_build_works(self, large):
     opt = CORDA(*large)
     opt.build()
     include = [c for c in opt.conf if opt.conf[c] == 3]
     assert len(include) > 3
     rec = opt.cobra_model("reconstruction")
     sol = rec.optimize()
     assert sol.f > 1
Beispiel #2
0
 def test_impossible_req(self, model):
     mod, conf = model
     D = Metabolite("D")
     mod.add_metabolites([D])
     opt = CORDA(mod, conf, met_prod=["D"])
     need = opt.associated(["EX_CORDA_0"])
     assert len(need) == 0
     assert "EX_CORDA_0" in opt.impossible
Beispiel #3
0
 def test_impossible_req(self, model):
     mod, conf = model
     D = Metabolite("D")
     mod.add_metabolites([D])
     opt = CORDA(mod, conf, met_prod=["D"])
     need = opt.associated(["EX_CORDA_0"])
     assert len(need) == 0
     assert "EX_CORDA_0" in opt.impossible
Beispiel #4
0
 def test_build_works(self, large):
     opt = CORDA(*large)
     opt.build()
     include = [c for c in opt.conf if opt.conf[c] == 3]
     assert len(include) > 3
     rec = opt.cobra_model("reconstruction")
     sol = rec.optimize()
     assert sol.f > 1
Beispiel #5
0
 def test_conf_vals(self, large):
     mod, conf = large
     for r in mod.reactions:
         conf[r.id] = 1
     conf["r60"] = 3
     conf["r42"] = 0
     conf["r12"] = 1
     opt = CORDA(mod, conf)
     opt.build()
     include = [c for c in opt.conf if opt.conf[c] == 3]
     assert len(include) > 3
Beispiel #6
0
 def test_redundancy_works(self, model):
     mod, conf = model
     conf["r2"] = 2
     opt = CORDA(mod, conf, met_prod="C ->")
     need = opt.associated(["EX_CORDA_0"], conf)
     assert len(need) == 4
     assert opt.redundancies["EX_CORDA_0"] == 2
     opt = CORDA(mod, conf, met_prod="C ->", n=1)
     need = opt.associated(["EX_CORDA_0"], conf)
     assert len(need) == 2
     assert opt.redundancies["EX_CORDA_0"] == 1
Beispiel #7
0
 def test_conf_vals(self, large):
     mod, conf = large
     for r in mod.reactions:
         conf[r.id] = 1
     conf["r60"] = 3
     conf["r42"] = 0
     conf["r12"] = 1
     opt = CORDA(mod, conf)
     opt.build()
     include = [c for c in opt.conf if opt.conf[c] == 3]
     assert len(include) > 3
Beispiel #8
0
 def test_mock_add(self, model):
     mod, conf = model
     opt = CORDA(mod, conf, met_prod={"C": -1})
     r = opt.model.reactions.get_by_id("EX_CORDA_0")
     assert "mock" in r.notes
     opt = CORDA(mod, conf, met_prod="C ->")
     r = opt.model.reactions.get_by_id("EX_CORDA_0")
     assert "mock" in r.notes
     with pytest.raises(TypeError):
         CORDA(mod, conf, met_prod=[["C"]])
     opt.build()
     mod = opt.cobra_model()
     assert all(mr not in mod.reactions for mr in opt.mocks)
Beispiel #9
0
 def test_mock_add(self, model):
     mod, conf = model
     opt = CORDA(mod, conf, met_prod={"C": -1})
     r = opt.model.reactions.get_by_id("EX_CORDA_0")
     assert "mock" in r.notes
     opt = CORDA(mod, conf, met_prod="C ->")
     r = opt.model.reactions.get_by_id("EX_CORDA_0")
     assert "mock" in r.notes
     with pytest.raises(TypeError):
         CORDA(mod, conf, met_prod=[["C"]])
     opt.build()
     mod = opt.cobra_model()
     assert all(mr not in mod.reactions for mr in opt.mocks)
Beispiel #10
0
 def test_redundancy_works(self, model):
     mod, conf = model
     conf["r2"] = 2
     opt = CORDA(mod, conf, met_prod="C ->")
     need = opt.associated(["EX_CORDA_0"], conf)
     assert len(need) == 4
     assert opt.redundancies["EX_CORDA_0"] == 2
     opt = CORDA(mod, conf, met_prod="C ->", n=1)
     need = opt.associated(["EX_CORDA_0"], conf)
     assert len(need) == 2
     assert opt.redundancies["EX_CORDA_0"] == 1
Beispiel #11
0
 def test_performance_metrics(self, model):
     opt = CORDA(model[0], model[1])
     assert "not built" in str(opt)
Beispiel #12
0
 def test_performance_metrics(self, large):
     opt = CORDA(*large)
     opt.build()
     assert "reconstruction complete" in str(opt)
     assert "/60" in str(opt)
Beispiel #13
0
 def test_conf_check(self, model):
     mod, conf = model
     co = conf.copy()
     del co["EX_A"]
     with pytest.raises(ValueError):
         CORDA(mod, co)
Beispiel #14
0
 def test_valid_conf(self, model):
     mod, conf = model
     co = conf.copy()
     co["EX_A"] = 4
     with pytest.raises(ValueError):
         CORDA(mod, co)
Beispiel #15
0
                            elif rxns_mapped_expr[
                                    r.id] <= lista_th_lower[th_l]:
                                rxns_conf[r.id] = -1
                            # Si no hay información de algún gen, como de los mitocondriales.
                            elif rxns_mapped_expr[r.id] == -1:
                                rxns_conf[r.id] = 0
                            else:
                                rxns_conf[r.id] = 1
                        else:
                            rxns_conf[r.id] = 0
                    rxns_conf[
                        "biomass_reaction"] = 3  # Esta el 'objetive funtion' del FBA.

                    print('------RECONSTRUYENDO EL MODELO-----')
                    # Reconstruyes el modelo celula_especifico
                    CORDA_builder = CORDA(reference_model, rxns_conf)
                    CORDA_builder.build()

                    csm2 = CORDA_builder.cobra_model()
                    write_sbml_model(
                        csm2, './thresholding/Th_upper_y_lower/' + cell_line +
                        '/csm2_%s_%s.sbml' % (th_l, th_u))
                    print('Numero de reacciones de modelo reconstruido:',
                          str(len(csm2.reactions)))

                    # Identificando los genes esenciales, como los genes cuya deleccion individual no producen crecimiento (Ecuación biomasa < 0.01).
                    print('------SINGLE GENE DELETION-----')
                    resultado_knocked_out = single_gene_deletion(
                        csm2, proprocesses=1)
                    rename_dict = {
                        i: list(i)[0]
Beispiel #16
0
 def _():
     opt = CORDA(mod, conf)
     opt.build()
Beispiel #17
0
 def test_association_works(self, model):
     mod, conf = model
     opt = CORDA(mod, conf, met_prod="C ->")
     need = opt.associated(["EX_CORDA_0"])
     solutions = (["EX_A", "r1"], ["EX_B", "r2"])
     assert list(need) in solutions
Beispiel #18
0
 def test_init_works(self, large):
     opt = CORDA(*large)
     assert len(opt.conf) > 0
Beispiel #19
0
 def test_association_work(self, large):
     opt = CORDA(*large)
     need = opt.associated(["r60"])
     assert len(need) > 0
Beispiel #20
0
 def test_performance_metrics(self, large):
     opt = CORDA(*large)
     opt.build()
     assert "reconstruction complete" in str(opt)
     assert "/60" in str(opt)
Beispiel #21
0
 def test_association_works(self, model):
     mod, conf = model
     opt = CORDA(mod, conf, met_prod="C ->")
     need = opt.associated(["EX_CORDA_0"])
     solutions = (["EX_A", "r1"], ["EX_B", "r2"])
     assert list(need) in solutions
Beispiel #22
0
 def _():
     opt = CORDA(mod, conf)
     opt.build()
Beispiel #23
0
 def test_association_work(self, large):
     opt = CORDA(*large)
     need = opt.associated(["r60"])
     assert len(need) > 0