mirror of
https://github.com/Athemis/pyKinetics.git
synced 2025-04-06 06:56:04 +00:00
Proper check for dependencies; Fallback if appropriate
This commit is contained in:
parent
28bf76029b
commit
d9179b4221
1 changed files with 47 additions and 19 deletions
|
@ -4,13 +4,35 @@
|
||||||
import argparse
|
import argparse
|
||||||
import logging
|
import logging
|
||||||
import csv
|
import csv
|
||||||
import matplotlib.pyplot as plt
|
|
||||||
import numpy as np
|
|
||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from colorlog import ColoredFormatter
|
|
||||||
|
|
||||||
import libkinetics
|
# check for third party modules. Matplotlib and NumPy are essential
|
||||||
|
try:
|
||||||
|
import matplotlib.pyplot as plt
|
||||||
|
except ImportError:
|
||||||
|
print('----- Matplotlib must be installed! -----')
|
||||||
|
|
||||||
|
try:
|
||||||
|
import numpy as np
|
||||||
|
except ImportError:
|
||||||
|
print('----- NumPy must be installed! -----')
|
||||||
|
|
||||||
|
# colorlog is optional; inform user of non-colored output if not found
|
||||||
|
try:
|
||||||
|
from colorlog import ColoredFormatter
|
||||||
|
COLORED_LOG = True
|
||||||
|
except ImportError:
|
||||||
|
COLORED_LOG = False
|
||||||
|
print('----- Module colorlog not found. Console output will not be '
|
||||||
|
'colored! -----')
|
||||||
|
pass
|
||||||
|
|
||||||
|
# check for libkinetics; if not found, there is something wrong with the
|
||||||
|
# installation if pyKinetics
|
||||||
|
try:
|
||||||
|
import libkinetics
|
||||||
|
except ImportError:
|
||||||
|
print('---- Cannot find libkinetics! Check your installation! -----')
|
||||||
|
|
||||||
|
|
||||||
class ExperimentHelper():
|
class ExperimentHelper():
|
||||||
|
@ -150,17 +172,23 @@ def initialize_logger():
|
||||||
'fh' which logs to a log file and 'ch' which logs to standard output.
|
'fh' which logs to a log file and 'ch' which logs to standard output.
|
||||||
:return logger: returns a logger instance
|
:return logger: returns a logger instance
|
||||||
"""
|
"""
|
||||||
fmt = '%(log_color)s%(levelname)-8s%(reset)s %(message)s'
|
if COLORED_LOG:
|
||||||
formatter = ColoredFormatter(fmt,
|
fmt = '%(log_color)s%(levelname)-8s%(reset)s %(message)s'
|
||||||
datefmt=None,
|
formatter = ColoredFormatter(fmt,
|
||||||
reset=True,
|
datefmt=None,
|
||||||
log_colors={'DEBUG': 'cyan',
|
reset=True,
|
||||||
'INFO': 'green',
|
log_colors={'DEBUG': 'cyan',
|
||||||
'WARNING': 'yellow',
|
'INFO': 'green',
|
||||||
'ERROR': 'red',
|
'WARNING': 'yellow',
|
||||||
'CRITICAL': 'red,bg_white'},
|
'ERROR': 'red',
|
||||||
secondary_log_colors={},
|
'CRITICAL': 'red,bg_white'},
|
||||||
style='%')
|
secondary_log_colors={},
|
||||||
|
style='%')
|
||||||
|
else:
|
||||||
|
fmt = '%(levelname)-8s%(message)s'
|
||||||
|
formatter = logging.Formatter(fmt,
|
||||||
|
datefmt=None,
|
||||||
|
style='%')
|
||||||
|
|
||||||
logging.captureWarnings(True)
|
logging.captureWarnings(True)
|
||||||
logger = logging.getLogger('pyKinetics-cli')
|
logger = logging.getLogger('pyKinetics-cli')
|
||||||
|
@ -190,8 +218,8 @@ def main():
|
||||||
args = parse_arguments()
|
args = parse_arguments()
|
||||||
# initialize logger
|
# initialize logger
|
||||||
logger = initialize_logger()
|
logger = initialize_logger()
|
||||||
|
# grab fitting window from provided arguments
|
||||||
xlim = (args.start, args.end)
|
fitting_window = (args.start, args.end)
|
||||||
|
|
||||||
if args.hill:
|
if args.hill:
|
||||||
do_hill = args.hill
|
do_hill = args.hill
|
||||||
|
@ -225,7 +253,7 @@ def main():
|
||||||
msg = '{} including Hill kinetics'.format(msg)
|
msg = '{} including Hill kinetics'.format(msg)
|
||||||
logger.info('{}'.format(msg))
|
logger.info('{}'.format(msg))
|
||||||
exp = libkinetics.Experiment(data_files,
|
exp = libkinetics.Experiment(data_files,
|
||||||
xlim,
|
fitting_window,
|
||||||
do_hill=do_hill,
|
do_hill=do_hill,
|
||||||
logger=logger,
|
logger=logger,
|
||||||
fit_to_replicates=fit_to_replicates)
|
fit_to_replicates=fit_to_replicates)
|
||||||
|
|
Loading…
Add table
Reference in a new issue