pathways_cmd.py 1003 Bytes
Newer Older
eladnoor's avatar
eladnoor committed
1 2 3 4 5 6 7 8 9 10
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Oct  1 13:24:15 2017

@author: noore
"""

import argparse
import logging
11
from equilibrator_api import Pathway
eladnoor's avatar
eladnoor committed
12
from matplotlib.backends.backend_pdf import PdfPages
13
import pandas as pd
eladnoor's avatar
eladnoor committed
14 15 16 17 18 19

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
20
        'infile', type=str,
eladnoor's avatar
eladnoor committed
21 22
        help='path to input file containing reactions')
    parser.add_argument(
23 24
        'outfile', type=str,
        help='path to output PDF file')
eladnoor's avatar
eladnoor committed
25 26 27 28
    logging.getLogger().setLevel(logging.WARNING)

    args = parser.parse_args()

29
    pp = Pathway.from_sbtab(args.infile)
Elad Noor's avatar
Elad Noor committed
30

eladnoor's avatar
eladnoor committed
31 32
    output_pdf = PdfPages(args.outfile)
    mdf_res = pp.calc_mdf()
Elad Noor's avatar
Elad Noor committed
33

eladnoor's avatar
eladnoor committed
34
    output_pdf.savefig(mdf_res.conc_plot)
35
    output_pdf.savefig(mdf_res.mdf_plot)
eladnoor's avatar
eladnoor committed
36
    output_pdf.close()
Elad Noor's avatar
Elad Noor committed
37

38 39
    rxn_df = pd.DataFrame(mdf_res.report_reactions)
    cpd_df = pd.DataFrame(mdf_res.report_compounds)