Commit 56ff92fb authored by eladnoor's avatar eladnoor

fixing minor issues in scripts

parent 30b021ba
Pipeline #47041536 passed with stage
in 18 minutes and 37 seconds
......@@ -39,7 +39,7 @@ if __name__ == '__main__':
parser = argparse.ArgumentParser(
description='Calculate potentials for a number of reactions.')
parser.add_argument('infile', type=argparse.FileType(),
parser.add_argument('infile', type=argparse.FileType('r'),
help='path to input file containing reactions')
parser.add_argument('outfile', type=argparse.FileType('w'),
help='path to output file')
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -39,10 +39,10 @@ if __name__ == '__main__':
parser = argparse.ArgumentParser(
description='Calculate the Max-min Driving Force (MDF) of a pathway.')
parser.add_argument(
'infile', type=str,
'infile', type=argparse.FileType('r'),
help='path to input file containing reactions')
parser.add_argument(
'outfile', type=str,
'outfile', type=argparse.FileType('wb'),
help='path to output PDF file')
logging.getLogger().setLevel(logging.WARNING)
......
......@@ -31,17 +31,16 @@ from io import IOBase
from typing import Callable, Iterable, List, TextIO, Tuple
import numpy as np
from scipy.linalg import fractional_matrix_power
from equilibrator_cache.reaction import (
create_stoichiometric_matrix_from_reactions)
from sbtab import SBtab
from scipy.linalg import fractional_matrix_power
from . import Compound, ccache
from . import Compound
from .bounds import Bounds
from .component_contribution import ComponentContribution
from .phased_reaction import PhasedReaction
from .settings import Q_, ureg, R, default_I, default_pH, default_pMg, \
default_T
from .settings import Q_, R, default_I, default_pH, default_pMg, default_T, ureg
from .thermo_models import PathwayThermoModel
......@@ -72,7 +71,11 @@ class Pathway(object):
fluxes: np.array,
standard_dg_primes: np.array = None,
dg_uncertainties: np.array = None,
bounds: Bounds = None
bounds: Bounds = None,
p_h: float = default_pH,
p_mg: float = default_pMg,
ionic_strength: float = default_I,
temperature: float = default_T
) -> object:
"""Initialize.
......@@ -91,21 +94,15 @@ class Pathway(object):
assert self.fluxes.shape == (Nr, )
if standard_dg_primes is None:
self.set_aqueous_params()
self.standard_dg_primes, self.dg_uncertainties = \
self.comp_contribution.standard_dg_prime_multi(self.reactions)
# TODO: right now MDF does not work with uncertainties, and we
# need to fix that. In the meantime, we use a 0-matrix to
# indicate there is no uncertainty in the dG'0 estimates.
# for i in range(Nr):
# for j in range(Nr):
# if i != j:
# self.dg_uncertainties[i, j] *= 0.0
else:
self.standard_dg_primes = standard_dg_primes
self.dg_uncertainties = dg_uncertainties
assert dg_uncertainties is None
comp_contribution = ComponentContribution(
p_h=p_h, p_mg=p_mg, ionic_strength=ionic_strength,
temperature=temperature)
standard_dg_primes, dg_uncertainties = \
comp_contribution.standard_dg_prime_multi(self.reactions)
self.standard_dg_primes = standard_dg_primes
self.dg_uncertainties = dg_uncertainties
assert self.standard_dg_primes.shape == (Nr,)
assert self.standard_dg_primes.check("[energy]/[substance]")
assert self.dg_uncertainties.shape == (Nr, Nr)
......@@ -151,18 +148,6 @@ class Pathway(object):
"""
self.compound_names = list(map(mapping, self.S.index))
@ureg.check(None, None, None, '[concentration]', '[temperature]')
def set_aqueous_params(
self,
p_h: float = default_pH,
p_mg: float = default_pMg,
ionic_strength: float = default_I,
temperature: float = default_T
) -> None:
self.comp_contribution = ComponentContribution(
p_h=p_h, p_mg=p_mg, ionic_strength=ionic_strength,
temperature=temperature)
def calculate_dgs(self) -> None:
self.standard_dg_primes, self.dg_uncertainties = \
self.comp_contribution.standard_dg_prime_multi(self.reactions)
......@@ -277,7 +262,11 @@ class Pathway(object):
sbtab_contents = sbtab.read()
if type(sbtab_contents) == bytes:
sbtab_contents = sbtab_contents.decode('utf-8')
sbtabdoc = SBtab.SBtabDocument("pathway", sbtab_contents, "unnamed_sbtab.tsv")
sbtabdoc = SBtab.SBtabDocument("pathway", sbtab_contents,
"unnamed_sbtab.tsv")
else:
raise ValueError("sbtab must be either a file name or a Stream "
"object")
table_ids = ['ConcentrationConstraint', 'Reaction', 'RelativeFlux',
'Parameter']
dfs = []
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment