diff options
Diffstat (limited to 'scripts/rqtl2/install_phenos.py')
-rw-r--r-- | scripts/rqtl2/install_phenos.py | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/scripts/rqtl2/install_phenos.py b/scripts/rqtl2/install_phenos.py index 21b5f00..a6cdacc 100644 --- a/scripts/rqtl2/install_phenos.py +++ b/scripts/rqtl2/install_phenos.py @@ -1,10 +1,10 @@ """Load pheno from R/qtl2 bundle into the database.""" import sys -import logging import traceback from pathlib import Path from zipfile import ZipFile from functools import reduce +from logging import Logger, getLogger, StreamHandler import MySQLdb as mdb from MySQLdb.cursors import DictCursor @@ -16,9 +16,6 @@ from scripts.cli_parser import init_cli_parser, add_global_data_arguments from r_qtl import r_qtl2 as rqtl2 from functional_tools import take -stderr_handler = logging.StreamHandler(stream=sys.stderr) -logger = logging.getLogger("install_phenos") -logger.addHandler(stderr_handler) def insert_probesets(dbconn: mdb.Connection, platformid: int, @@ -95,11 +92,13 @@ def cross_reference_probeset_data(dbconn: mdb.Connection, } for row in dataids)) return cursor.rowcount -def install_pheno_files(dbconn: mdb.Connection, - speciesid: int, - platformid: int, - datasetid: int, - rqtl2bundle: Path) -> int: +def install_pheno_files(#pylint: disable=[too-many-arguments, too-many-locals] + dbconn: mdb.Connection, + speciesid: int, + platformid: int, + datasetid: int, + rqtl2bundle: Path, + logger: Logger = getLogger()) -> int: """Load data in `pheno` files and other related files into the database.""" with ZipFile(str(rqtl2bundle), "r") as zfile: try: @@ -155,13 +154,16 @@ if __name__ == "__main__": return parser.parse_args() + thelogger = getLogger("install_phenos") + thelogger.addHandler(StreamHandler(stream=sys.stderr)) main = build_main( cli_args(), lambda dbconn, args: install_pheno_files(dbconn, args.speciesid, args.platformid, args.datasetid, - args.rqtl2bundle), - logger, + args.rqtl2bundle, + thelogger), + thelogger, "DEBUG") sys.exit(main()) |