Ejemplo n.º 1
0
 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()
Ejemplo n.º 2
0
    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)
Ejemplo n.º 3
0
    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]
Ejemplo n.º 5
0
 def testOpenMultipleSBtab(self):
     ds = SBtabTools.openMultipleSBtab(
         'tests/EMP_glycolysis_full_SBtab.tsv')
     self.assertEqual(4, len(ds))
Ejemplo n.º 6
0
 def testOpenMultipleSBtabFromFile(self):
     with open('tests/EMP_glycolysis_full_SBtab.tsv') as f:
         ds = SBtabTools.openMultipleSBtabFromFile(f)
         self.assertEqual(4, len(ds))
Ejemplo n.º 7
0
 def testOpenMultipleSBtab(self):
     ds = SBtabTools.openMultipleSBtab(
         'pathways/test/EMP_glycolysis_full_SBtab.tsv')
     self.assertEqual(3, len(ds))