def test_from_full_sbtab(self): # Happens to be the order in this file. rxns, fluxes, keqs, bounds = SBtabTools.openMultipleSBtab( 'pathways/test/EMP_glycolysis_full_SBtab.tsv') path = pathways.ParsedPathway.from_full_sbtab(rxns, fluxes, bounds, keqs) path.print_reactions()
def testFromSBtab(self): ds = SBtabTools.openMultipleSBtab('pathways/test/EMP_glycolysis_full_SBtab.tsv') bs = Bounds.from_sbtab(ds[-1]) for key in bs.lower_bounds: lb = bs.GetLowerBound(key) ub = bs.GetUpperBound(key) msg = 'bounds for %s lb = %.2g, ub = %.2g' % (key, lb, ub) self.assertLessEqual(lb, ub, msg=msg)
def from_sbtab(self, sbtab): """ read the sbtab file (can be a filename or file handel) and use it to initialize the Pathway """ if type(sbtab) == str: with open(sbtab, 'r') as sbtabfile: sbtabs = SBtabTools.openMultipleSBtabFromFile(sbtabfile) elif type(sbtab) == io.TextIOWrapper: sbtabs = SBtabTools.openMultipleSBtabFromFile(sbtab) tdict = dict([(t.getTableInformation()[1].upper(), t) for t in sbtabs]) expected_tnames = [ 'REACTION', 'RELATIVEFLUX', 'CONCENTRATIONCONSTRAINT', 'REACTIONCONSTANT' ] assert set(expected_tnames).issubset(tdict.keys()) sbtabs = [tdict[n] for n in expected_tnames] return Pathway.from_separate_sbtabs(*sbtabs)
def read_sbtabs(f): """Return reactions, fluxes, keqs, bounds.""" sbtabs = SBtabTools.openMultipleSBtabFromFile(f) tdict = dict([(t.getTableInformation()[1].upper(), t) for t in sbtabs]) expected_tnames = [ 'REACTION', 'RELATIVEFLUX', 'REACTIONCONSTANT', 'CONCENTRATIONCONSTRAINT' ] assert set(expected_tnames).issubset(tdict.keys()) return [tdict[n] for n in expected_tnames]
def testOpenMultipleSBtab(self): ds = SBtabTools.openMultipleSBtab( 'tests/EMP_glycolysis_full_SBtab.tsv') self.assertEqual(4, len(ds))
def testOpenMultipleSBtabFromFile(self): with open('tests/EMP_glycolysis_full_SBtab.tsv') as f: ds = SBtabTools.openMultipleSBtabFromFile(f) self.assertEqual(4, len(ds))
def testOpenMultipleSBtab(self): ds = SBtabTools.openMultipleSBtab( 'pathways/test/EMP_glycolysis_full_SBtab.tsv') self.assertEqual(3, len(ds))