pathways_cmd.py 2.13 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
# The MIT License (MIT)
#
# Copyright (c) 2013 Weizmann Institute of Science
# Copyright (c) 2018 Institute for Molecular Systems Biology,
# ETH Zurich
# Copyright (c) 2018 Novo Nordisk Foundation Center for Biosustainability,
# Technical University of Denmark
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
eladnoor's avatar
eladnoor committed
26 27 28 29


import argparse
import logging
30
from equilibrator_api import Pathway
eladnoor's avatar
eladnoor committed
31
from matplotlib.backends.backend_pdf import PdfPages
32
import pandas as pd
eladnoor's avatar
eladnoor committed
33 34 35 36 37 38

if __name__ == '__main__':

    parser = argparse.ArgumentParser(
        description='Calculate the Max-min Driving Force (MDF) of a pathway.')
    parser.add_argument(
Elad Noor's avatar
Elad Noor committed
39
        'infile', type=str,
eladnoor's avatar
eladnoor committed
40 41
        help='path to input file containing reactions')
    parser.add_argument(
42 43
        'outfile', type=str,
        help='path to output PDF file')
eladnoor's avatar
eladnoor committed
44 45 46 47
    logging.getLogger().setLevel(logging.WARNING)

    args = parser.parse_args()

48
    pp = Pathway.from_sbtab(args.infile)
Elad Noor's avatar
Elad Noor committed
49

eladnoor's avatar
eladnoor committed
50 51
    output_pdf = PdfPages(args.outfile)
    mdf_res = pp.calc_mdf()
Elad Noor's avatar
Elad Noor committed
52

eladnoor's avatar
eladnoor committed
53 54
    output_pdf.savefig(mdf_res.compound_plot)
    output_pdf.savefig(mdf_res.reaction_plot)
eladnoor's avatar
eladnoor committed
55
    output_pdf.close()
Elad Noor's avatar
Elad Noor committed
56

57 58
    rxn_df = mdf_res.reaction_df
    cpd_df = mdf_res.compound_df