aboutsummaryrefslogtreecommitdiff
path: root/scripts/rqtl2/install_genotypes.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/rqtl2/install_genotypes.py')
-rw-r--r--scripts/rqtl2/install_genotypes.py16
1 files changed, 8 insertions, 8 deletions
diff --git a/scripts/rqtl2/install_genotypes.py b/scripts/rqtl2/install_genotypes.py
index 733ccf9..bfe17b8 100644
--- a/scripts/rqtl2/install_genotypes.py
+++ b/scripts/rqtl2/install_genotypes.py
@@ -1,11 +1,11 @@
"""Load genotypes 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 typing import Iterator, Optional
+from logging import Logger, getLogger, StreamHandler
import MySQLdb as mdb
from MySQLdb.cursors import DictCursor
@@ -18,10 +18,6 @@ from scripts.rqtl2.entry import build_main
from scripts.rqtl2.cli_parser import add_common_arguments
from scripts.cli_parser import init_cli_parser, add_global_data_arguments
-stderr_handler = logging.StreamHandler(stream=sys.stderr)
-logger = logging.getLogger("install_genotypes")
-logger.addHandler(stderr_handler)
-
def insert_markers(dbconn: mdb.Connection,
speciesid: int,
markers: tuple[str, ...],
@@ -158,11 +154,13 @@ def cross_reference_genotypes(dbconn: mdb.Connection,
} for row in dataids))
return cursor.rowcount
-def install_genotypes(dbconn: mdb.Connection,
+def install_genotypes(#pylint: disable=[too-many-arguments, too-many-locals]
+ dbconn: mdb.Connection,
speciesid: int,
populationid: int,
datasetid: int,
- rqtl2bundle: Path) -> int:
+ rqtl2bundle: Path,
+ logger: Logger = getLogger()) -> int:
"""Load any existing genotypes into the database."""
count = 0
with ZipFile(str(rqtl2bundle.absolute()), "r") as zfile:
@@ -223,6 +221,8 @@ if __name__ == "__main__":
return parser.parse_args()
+ thelogger = getLogger("install_genotypes")
+ thelogger.addHandler(StreamHandler(stream=sys.stderr))
main = build_main(
cli_args(),
lambda dbconn, args: install_genotypes(dbconn,
@@ -230,6 +230,6 @@ if __name__ == "__main__":
args.populationid,
args.datasetid,
args.rqtl2bundle),
- logger,
+ thelogger,
"INFO")
sys.exit(main())