Exemplo n.º 1
0
def main():
    # 1. Parse command line

    usage = "Usage: %prog [options]"
    version = "%prog\n" + COPYRIGHT_VERSION_STRING
    parser = OptionParser(usage=usage, version=version)
    parser.add_option("-p", "--parameters", dest="inputFile",
                      help="use the given scenario FILE", metavar="FILE")
    parser.add_option("-r", "--reactions", dest="reactionFile", help="use "
                      "reversibilities from reaction FILE", metavar="FILE")
    parser.add_option("-o", "--output", dest="outputFile", help="write output "
                      "(scenario file) to FILE", metavar="FILE")

    options, _ = parser.parse_args()
    parser.check_required("-p")
    parser.check_required("-r")
    parser.check_required("-o")

    # 2. Parse reaction file

    rparser = ReactionParser()
    model = MetabolicModel()
    try:
        model.addReactionsFromFile(options.reactionFile, rparser)
    except IOError, strerror:
        print ("An error occurred while trying to read file %s:" %
               os.path.basename(options.reactionFile))
        print strerror
        exit()
Exemplo n.º 2
0
def main():
    # 1. Parse command line

    usage = "Usage: %prog [options]"
    version = "Metabolite flux minimization\n" + COPYRIGHT_VERSION_STRING
    parser = OptionParser(usage=usage, version=version)
    parser.add_option("-r",
                      "--reactions",
                      dest="reactionFile",
                      help="perform Metabolite Flux Minimization on the"
                      " network given by the reaction FILE",
                      metavar="FILE")
    parser.add_option("-p",
                      "--parameters",
                      dest="paramFile",
                      help="use the given scenario FILE",
                      metavar="FILE")
    parser.add_option("-o",
                      "--output",
                      dest="outputFile",
                      help="write MFM output to FILE",
                      metavar="FILE")
    parser.add_option("-t",
                      "--tolerance",
                      dest="tolerance",
                      type="float",
                      help="tolerance for objective function (0 < VALUE "
                      "< 1; default: .95)",
                      metavar="VALUE")
    parser.add_option("-l",
                      "--use-full-matrix",
                      action="store_true",
                      dest="useFullMatrix",
                      help="use full matrix (disable "
                      "removal of dead ends and nonfunctional reactions)")
    parser.set_defaults(tolerance=.95, useFullMatrix=False)

    options, _ = parser.parse_args()
    parser.check_required("-r")
    parser.check_required("-p")
    parser.check_required("-o")

    if options.tolerance <= 0. or options.tolerance > 1.:
        print "Error: Tolerance must be in interval (0, 1]"
        exit()

    # 2. Parse reaction file

    rparser = ReactionParser()
    model = MetabolicModel()
    try:
        model.addReactionsFromFile(options.reactionFile, rparser)
    except IOError, strerror:
        print("An error occurred while trying to read file %s:" %
              os.path.basename(options.reactionFile))
        print strerror
        exit()
Exemplo n.º 3
0
def main():
    # 1. Parse command line

    usage = "Usage: %prog [options]"
    version = "Model assertion watcher\n" + COPYRIGHT_VERSION_STRING
    parser = OptionParser(usage=usage, version=version)
    parser.add_option("-r",
                      "--reactions",
                      dest="reactionFile",
                      help="read "
                      "metabolic model from the given reaction FILE",
                      metavar="FILE")
    parser.add_option("-p",
                      "--parameters",
                      dest="paramFile",
                      help="use the "
                      "given scenario FILE for model analysis ",
                      metavar="FILE")
    parser.add_option("-a",
                      "--assertions",
                      dest="assertionFile",
                      help="read "
                      "assertions from FILE",
                      metavar="FILE")
    parser.add_option(
        "-t",
        "--tolerance",
        dest="tolerance",
        type="float",
        help="FVA: tolerance for objective function (0 < VALUE < "
        "1; default: .95)",
        metavar="VALUE")
    parser.set_defaults(tolerance=.95)

    options, _ = parser.parse_args()
    parser.check_required("-r")
    parser.check_required("-p")
    parser.check_required("-a")

    if options.tolerance <= 0. or options.tolerance > 1.:
        print "Error: Tolerance must be in interval (0, 1]"
        exit()

    # 2. Create MetabolicModel from reaction file

    rparser = ReactionParser()
    model = MetabolicModel()
    try:
        model.addReactionsFromFile(options.reactionFile, rparser)
    except IOError, strerror:
        print("An error occurred while trying to read file %s:" %
              os.path.basename(options.reactionFile))
        print strerror
        exit()
Exemplo n.º 4
0
def main():
    # 1. Parse command line

    usage = "Usage: %prog [options]"
    version = "Flux balance analysis\n" + COPYRIGHT_VERSION_STRING
    parser = OptionParser(usage=usage, version=version)
    parser.add_option(
        "-r",
        "--reactions",
        dest="reactionFile",
        help="perform Flux Balance Analysis on the network given "
        "by the reaction FILE",
        metavar="FILE")
    parser.add_option("-p",
                      "--parameters",
                      dest="paramFile",
                      help="use the given scenario FILE for Flux Balance "
                      "Analysis",
                      metavar="FILE")
    parser.add_option("-o",
                      "--output",
                      dest="outputFile",
                      help="write output of Flux Balance Analysis to FILE",
                      metavar="FILE")
    parser.add_option("-m",
                      "--minimize-total",
                      action="store_true",
                      dest="minimizeFlux",
                      help="secondarily minimize total "
                      "flux")
    parser.add_option("-l",
                      "--use-full-matrix",
                      action="store_true",
                      dest="useFullMatrix",
                      help="use full matrix (disable "
                      "removal of dead ends and nonfunctional reactions)")
    parser.set_defaults(minimizeFlux=False, useFullMatrix=False)

    options, _ = parser.parse_args()
    parser.check_required("-r")
    parser.check_required("-p")
    parser.check_required("-o")

    # 2. Parse reaction file

    rparser = ReactionParser()
    model = MetabolicModel()
    try:
        model.addReactionsFromFile(options.reactionFile, rparser)
    except IOError, strerror:
        print("An error occurred while trying to read file %s:" %
              os.path.basename(options.reactionFile))
        print strerror
        exit()
Exemplo n.º 5
0
def main():
    # Parse command line

    usage = "Usage: %prog [options]"
    version = "%prog\n" + COPYRIGHT_VERSION_STRING
    parser = OptionParser(usage=usage, version=version)
    parser.add_option("-i",
                      "--input",
                      dest="inputFile",
                      help="use the "
                      "given reaction FILE as input",
                      metavar="FILE")
    parser.add_option("-o",
                      "--output",
                      dest="outputFile",
                      help="write output "
                      "(reaction file) to FILE (must not be the same as input "
                      "file)",
                      metavar="FILE")

    options, _ = parser.parse_args()
    parser.check_required("-i")
    parser.check_required("-o")

    if os.path.exists(options.outputFile):
        if os.path.samefile(options.outputFile, options.inputFile):
            print "Error: Output file must not be the same as input file!"
            exit()

    # Call reaction parser for fixing the reaction file

    rparser = ReactionParser()
    try:
        rparser.fixfile(options.inputFile, options.outputFile)
    except IOError, strerror:
        print(
            "An error occurred while trying to read file %s or write file "
            "%s:" % (os.path.normpath(
                options.inputFile), os.path.normpath(options.outputFile)))
        print strerror
        exit()
Exemplo n.º 6
0
def main():
    # 1. Parse command line

    usage = "Usage: %prog [options]"
    version = "Dead end finder\n" + COPYRIGHT_VERSION_STRING
    parser = OptionParser(usage=usage, version=version)
    parser.add_option("-r",
                      "--reactions",
                      dest="reactionFile",
                      help="build stoichiometric matrix from reaction FILE",
                      metavar="FILE")
    parser.add_option("-p",
                      "--parameters",
                      dest="paramFile",
                      help="use the given scenario FILE",
                      metavar="FILE")
    parser.add_option("-a",
                      "--recursive",
                      action="store_true",
                      dest="recursive",
                      help="recursively predict all fluxes"
                      "that are zero in FBA due to dead ends")
    parser.add_option("-v",
                      "--verbose",
                      action="store_true",
                      dest="verbose",
                      help="generate extra (debug) output")
    parser.add_option("-t",
                      "--transporter-regex",
                      dest="regex",
                      help="treat "
                      "reactions matching regular expression PATTERN as "
                      "transporters, i.e. temporarily ignore bounds",
                      metavar="PATTERN")
    parser.set_defaults(recursive=False, verbose=False)

    options, _ = parser.parse_args()
    parser.check_required("-r")
    parser.check_required("-p")

    # 2. Parse reaction file

    rparser = ReactionParser()
    model = MetabolicModel()
    try:
        model.addReactionsFromFile(options.reactionFile, rparser)
    except IOError, strerror:
        print("An error occurred while trying to read file %s:" %
              os.path.basename(options.reactionFile))
        print strerror
        exit()
Exemplo n.º 7
0
def main():
    # 1. Parse command line

    usage = "Usage: %prog [options]"
    version = "Transporter check\n" + COPYRIGHT_VERSION_STRING
    parser = OptionParser(usage=usage, version=version)
    parser.add_option(
        "-r",
        "--reactions",
        dest="reactionFile",
        help="perform Flux Balance Analysis on the network given "
        "by the reaction FILE",
        metavar="FILE")
    parser.add_option("-p",
                      "--parameters",
                      dest="paramFile",
                      help="use the given scenario FILE for Flux Balance "
                      "Analysis",
                      metavar="FILE")
    parser.add_option("-t",
                      "--transporters",
                      dest="transFile",
                      help="use list of transporters from FILE",
                      metavar="FILE")
    parser.add_option("-o",
                      "--output",
                      dest="outputFile",
                      help="write output of Flux Balance Analysis to FILE",
                      metavar="FILE")

    options, _ = parser.parse_args()
    parser.check_required("-r")
    parser.check_required("-p")
    parser.check_required("-t")
    parser.check_required("-o")

    # 2. Parse reaction file

    rparser = ReactionParser()
    model = MetabolicModel()
    try:
        model.addReactionsFromFile(options.reactionFile, rparser)
    except IOError, strerror:
        print("An error occurred while trying to read file %s:" %
              os.path.basename(options.reactionFile))
        print strerror
        exit()
Exemplo n.º 8
0
def main():
    # 1. Parse command line

    usage = "Usage: %prog [options]"
    version = "%prog\n" + COPYRIGHT_VERSION_STRING
    parser = OptionParser(usage=usage, version=version)
    parser.add_option("-r",
                      "--reactions",
                      dest="reactionFile",
                      help="use the given reaction FILE",
                      metavar="FILE")
    parser.add_option("-s",
                      "--solution",
                      dest="solutionFile",
                      help="parse the given FBA solution FILE",
                      metavar="FILE")
    parser.add_option("-c",
                      "--cutoff",
                      dest="cutoff",
                      type="float",
                      help="threshold below which a flux is to be considered "
                      "zero; default: 1E-10)",
                      metavar="VALUE")
    parser.set_defaults(cutoff=1E-10)

    options, _ = parser.parse_args()
    parser.check_required("-r")
    parser.check_required("-s")

    # 2. Parse reaction file

    rparser = ReactionParser()
    model = MetabolicModel()
    try:
        model.addReactionsFromFile(options.reactionFile, rparser)
    except IOError, strerror:
        print("An error occurred while trying to read file %s:" %
              os.path.basename(options.reactionFile))
        print strerror
        exit()
Exemplo n.º 9
0
def main():
    if _mpi_avail:
        comm = MPI.COMM_WORLD
        numprocs = comm.Get_size()
        rank = comm.Get_rank()
        if numprocs == 1:
            comm = None
    else:
        comm = None

    if not _mpi_avail or rank == 0:  # Start of root process code

        # 1. Parse command line

        usage = "Usage: %prog [options]"
        version = "Knockout analysis\n" + COPYRIGHT_VERSION_STRING
        parser = OptionParser(usage=usage, version=version)
        momaOptions = parser.add_option_group("General MOMA options")
        momaOptions.add_option("-r",
                               "--reactions",
                               dest="reactionFile",
                               help="perform knockout analysis on the network "
                               "given by the reaction FILE",
                               metavar="FILE")
        momaOptions.add_option("-p",
                               "--parameters",
                               dest="paramFile",
                               help="use the given scenario FILE for the "
                               "wildtype",
                               metavar="FILE")
        momaOptions.add_option("-o",
                               "--output",
                               dest="outputFile",
                               help="write"
                               " output of knockout analysis to FILE",
                               metavar="FILE")
        momaOptions.add_option("-w",
                               "--wt-solution",
                               dest="wtSolution",
                               help="use the given solution FILE for the "
                               "wildtype (optional)",
                               metavar="FILE")
        momaOptions.add_option(
            "-v",
            "--reduce-by-fva",
            dest="redFvaFile",
            help="use FVA result from FILE to reduce matrix "
            "(experimental; only works if perturbed solution"
            " space is a subset of the wildtype solution "
            "space)",
            metavar="FILE")
        koOptions = parser.add_option_group("Options for knockout analysis")
        koOptions.add_option("-f",
                             "--solution-files",
                             dest="fluxFilePrefix",
                             help="write MOMA/FBA solutions to files marked "
                             "with FILE-PREFIX (may contain path)",
                             metavar="FILE-PREFIX")
        koOptions.add_option(
            "-g",
            "--ko-groups",
            dest="koGroupDictFile",
            help="read reaction groups to be knocked out "
            "together from CSV FILE (if not given, individual "
            "reactions are knocked out)",
            metavar="FILE")
        koOptions.add_option("-n",
                             "--ko-ungrouped",
                             action="store_true",
                             dest="koUngrouped",
                             help="knock out individual "
                             "reactions that do not belong to any group (only "
                             "with -g)")
        koOptions.add_option("-m",
                             "--moma",
                             dest="useMoma",
                             help="perform MOMA"
                             ", options: 'always', 'never' (FBA only), 'auto' "
                             "(default: FBA first, then MOMA if not lethal)",
                             metavar="WHEN")
        wmOptions = parser.add_option_group("Extra options for weighted MOMA")
        wmOptions.add_option(
            "-x",
            "--wmoma",
            dest="wMomaFvaFile",
            help="perform weighted MOMA with weights computed "
            "from the given FVA solution FILE",
            metavar="FILE")
        wmOptions.add_option(
            "-a",
            "--alpha",
            dest="alpha",
            type="float",
            help="parameter ALPHA for computation of weights:"
            " w = alpha + exp(-beta*(fvaMax-fvaMin)) (default:"
            " %g)" % _DEFAULT_ALPHA)
        wmOptions.add_option(
            "-b",
            "--beta",
            dest="beta",
            type="float",
            help="parameter BETA for computation of weights: "
            "w = alpha + exp(-beta*(fvaMax-fvaMin)) (default: "
            "%g)" % _DEFAULT_BETA)
        optOptions = parser.add_option_group("Options for optimization")
        optOptions.add_option("-s",
                              "--solver",
                              dest="solver",
                              help="QP solver "
                              "to be used for MOMA (default cvxopt)",
                              metavar="SOLVER")
        optOptions.add_option("-i",
                              "--iterations",
                              dest="numIter",
                              type="int",
                              help="number of NLP runs to perform (from "
                              "different random start points) - per knockout")
        optOptions.add_option(
            "-l",
            "--use-full-matrix",
            action="store_true",
            dest="useFullMatrix",
            help="use full matrix "
            "(disable removal of dead ends and nonfunctional "
            "reactions)")
        parser.set_defaults(solver="default",
                            numIter=1,
                            koUngrouped=False,
                            useMoma="auto",
                            useFullMatrix=False,
                            alpha=_DEFAULT_ALPHA,
                            beta=_DEFAULT_BETA)

        try:
            options, _ = parser.parse_args()
            parser.check_required("-r")
            parser.check_required("-p")
            parser.check_required("-o")
        except SystemExit, e:
            _mpi_exit(comm, e.args[0])

        weighted = bool(options.wMomaFvaFile)
        if weighted:
            if options.alpha < 0.:
                print "Error: alpha must be non-negative."
                _mpi_exit(comm, 1)
            if options.beta <= 0.:
                print "Error: beta must be positive."
                _mpi_exit(comm, 1)

        if options.numIter < 1:
            print "Error: Number of NLP runs must be positive."
            _mpi_exit(comm, 1)

        try:
            useMoma = decodeWhen(options.useMoma,
                                 set((When.NEVER, When.AUTO, When.ALWAYS)))
        except KeyError:
            print(
                "Error: Illegal value for -m option (allowed values are "
                "'auto', 'never', or 'always').")
            _mpi_exit(comm, 1)

        # 2. Parse reaction file

        rparser = ReactionParser()
        model = MetabolicModel()
        try:
            model.addReactionsFromFile(options.reactionFile, rparser)
        except IOError, strerror:
            print("An error occurred while trying to read file %s:" %
                  os.path.basename(options.reactionFile))
            print strerror
            _mpi_exit(comm, 1)
Exemplo n.º 10
0
        print strerror
        exit()
    except SyntaxError, strerror:
        print("An error occurred parsing file %s:" % os.path.basename(args[0]))
        print strerror
        exit()

    if options.reactionFile is None and options.paramFile is None:
        print "Neither reaction nor scenario file given. Nothing to do."
        exit()

    # 3. Parse reaction file (if given) and check irreversibilities

    if options.reactionFile:
        model = MetabolicModel()
        rparser = ReactionParser()
        try:
            model.addReactionsFromFile(options.reactionFile, rparser)
        except IOError, strerror:
            print("An error occurred while trying to read file %s:" %
                  os.path.basename(options.reactionFile))
            print strerror
            exit()
        except SyntaxError, strerror:
            print("Error in reaction file %s:" %
                  os.path.basename(options.reactionFile))
            print strerror
            exit()

        negViolations, posViolations = checkIrrev(solution, model)
        conforms = not negViolations and not posViolations
Exemplo n.º 11
0
def main():
    # 1. Parse command line

    usage = "Usage: %prog [options]"
    version = ("Minimization of metabolic adjustment\n" +
               COPYRIGHT_VERSION_STRING)
    parser = OptionParser(usage=usage, version=version)
    momaOptions = parser.add_option_group("General MOMA options")
    momaOptions.add_option("-r",
                           "--reactions",
                           dest="reactionFile",
                           help="perform MOMA on the mutant network given by "
                           "the reaction FILE",
                           metavar="FILE")
    momaOptions.add_option("-p",
                           "--parameters",
                           dest="paramFile",
                           help="use the given scenario FILE for the mutant",
                           metavar="FILE")
    momaOptions.add_option("-w",
                           "--wt-solution",
                           dest="wtSolution",
                           help="use the given solution FILE for the wildtype",
                           metavar="FILE")
    momaOptions.add_option("-o",
                           "--output",
                           dest="outputFile",
                           help="write flux distribution computed by MOMA to "
                           "FILE",
                           metavar="FILE")
    momaOptions.add_option("-v",
                           "--reduce-by-fva",
                           dest="redFvaFile",
                           help="use FVA result from FILE to reduce matrix "
                           "(experimental; only works if perturbed solution "
                           "space is a subset of the wildtype solution space)",
                           metavar="FILE")
    wmOptions = parser.add_option_group("Extra options for weighted MOMA")
    wmOptions.add_option("-x",
                         "--wmoma",
                         dest="wMomaFvaFile",
                         help="perform "
                         "weighted MOMA with weights computed from the given "
                         "FVA solution FILE",
                         metavar="FILE")
    wmOptions.add_option(
        "-a",
        "--alpha",
        dest="alpha",
        type="float",
        help="parameter ALPHA for computation of weights: "
        "w = alpha + exp(-beta*(fvaMax-fvaMin)) (default: %g)" %
        _DEFAULT_ALPHA)
    wmOptions.add_option(
        "-b",
        "--beta",
        dest="beta",
        type="float",
        help="parameter BETA for computation of weights: "
        "w = alpha + exp(-beta*(fvaMax-fvaMin)) (default: %g)" % _DEFAULT_BETA)
    optOptions = parser.add_option_group("Options for optimization")
    optOptions.add_option("-s",
                          "--solver",
                          dest="solver",
                          help="QP/NLP solver "
                          "to be used for MOMA (default: cvxopt)")
    optOptions.add_option("-i",
                          "--iterations",
                          dest="numIter",
                          type="int",
                          help="number of NLP runs to perform (from different "
                          "random start points; default: %u)" %
                          FbaParam.DEFAULT_NUMITER,
                          metavar="N")
    optOptions.add_option("-l",
                          "--use-full-matrix",
                          action="store_true",
                          dest="useFullMatrix",
                          help="use full matrix (disable "
                          "removal of dead ends, nonfunctional reactions, and "
                          "reactions with flux restricted to zero) - slow")
    parser.set_defaults(solver="default",
                        useFullMatrix=False,
                        alpha=_DEFAULT_ALPHA,
                        beta=_DEFAULT_BETA,
                        numIter=FbaParam.DEFAULT_NUMITER)

    options, _ = parser.parse_args()
    parser.check_required("-r")
    parser.check_required("-p")
    parser.check_required("-w")
    parser.check_required("-o")

    if options.wMomaFvaFile:
        if options.alpha < 0.:
            print "Error: alpha must be non-negative."
            exit()
        if options.beta <= 0.:
            print "Error: beta must be positive."
            exit()

    if options.numIter < 1:
        print "Error: Number of NLP runs must be positive."
        exit()

    # 2. Parse reaction file

    rparser = ReactionParser()
    model = MetabolicModel()
    try:
        model.addReactionsFromFile(options.reactionFile, rparser)
    except IOError, strerror:
        print("An error occurred while trying to read file %s:" %
              os.path.basename(options.reactionFile))
        print strerror
        exit()
Exemplo n.º 12
0
def getReaEnthalpies(concentrationFile, thermodynFile, synonymFile,
                     reactionFile, temperatureCelsius):

    # result dict {reaction name : (delta G min, delta G max)}
    result = {}

    # Read synonyms from file into dictionary {synonym : preferred name}
    with open(synonymFile) as f:
        synonymReader = csv.DictReader(f, delimiter='\t')

        synonyms = {}
        for row in synonymReader:
            preferredName = _replaceChars(row[synonymReader.fieldnames[0]])
            synonyms[preferredName] = preferredName
            synonyms[_replaceChars(row[synonymReader.fieldnames[1]])] =\
                preferredName
            brendaSyn = row[synonymReader.fieldnames[3]]
            keggSyn = row[synonymReader.fieldnames[4]]
            metaSyn = row[synonymReader.fieldnames[5]]
            if brendaSyn != '-' and brendaSyn != '':
                for syn in brendaSyn.split(", "):
                    synonyms[_replaceChars(syn)] = preferredName
            if keggSyn != '-' and keggSyn != '':
                for syn in keggSyn.split("##"):
                    synonyms[_replaceChars(syn.split("::")[1])] = preferredName
            if metaSyn != '-' and metaSyn != '':
                for syn in metaSyn.split("##"):
                    synonyms[_replaceChars(syn.split("::")[1])] = preferredName

    # Read concentrations from file into dict {linear expression : (min, max)}
    with open(concentrationFile) as f:
        concentrationReader = csv.DictReader(f, delimiter=';')

        concentrations = {}
        for row in concentrationReader:

            name = _replaceChars(row[concentrationReader.fieldnames[1]])
            name = synonyms.get(name, name)

            concentrations[name] = (
                float(row[concentrationReader.fieldnames[2]]),
                float(row[concentrationReader.fieldnames[3]]))

    # Read thermodynamic data from file into a
    # dict {metabolite : list of 4-tuples}
    with open(thermodynFile) as f:
        thermodynReader = csv.reader(f, delimiter=';')
        thermodyn = defaultdict(list)
        currentName = ""
        for row in thermodynReader:
            if row[0]:
                currentName = re.sub(r" \((aq|ion|red|ox|tot)\)", "", row[0])
                currentName = _replaceChars(currentName)
                currentName = synonyms.get(currentName, currentName)
            else:
                thermodyn[currentName].append(tuple(row[1:5]))
        # We don't want the defaultdict behavior anymore after this point
        thermodyn = dict(thermodyn)

    # Parse reaction file
    rparser = ReactionParser()
    model = MetabolicModel()
    try:
        model.addReactionsFromFile(reactionFile, rparser)
    except IOError, strerror:
        print("An error occurred while trying to read file %s:" %
              os.path.basename(reactionFile))
        print strerror
        exit()
Exemplo n.º 13
0
        print("An error occurred while trying to read file %s:" %
              os.path.basename(options.paramFile))
        print strerror
        exit()
    except SyntaxError, strerror:
        print("Error in scenario file %s:" %
              os.path.basename(options.paramFile))
        print strerror
        exit()
    except ValueError, strerror:
        print strerror
        exit()

    if options.reactionFile:
        # Parse reaction file
        rparser = ReactionParser()
        model = MetabolicModel()
        try:
            model.addReactionsFromFile(options.reactionFile, rparser)
        except IOError, strerror:
            print("An error occurred while trying to read file %s:" %
                  os.path.basename(options.reactionFile))
            print strerror
            exit()
        except SyntaxError, strerror:
            print("Error in reaction file %s:" %
                  os.path.basename(options.reactionFile))
            print strerror
            exit()

        # Set flux bounds in model