about summary refs log tree commit diff
path: root/scripts/rqtl2/install_phenos.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/rqtl2/install_phenos.py')
-rw-r--r--scripts/rqtl2/install_phenos.py31
1 files changed, 12 insertions, 19 deletions
diff --git a/scripts/rqtl2/install_phenos.py b/scripts/rqtl2/install_phenos.py
index b5cab8e..9059cd6 100644
--- a/scripts/rqtl2/install_phenos.py
+++ b/scripts/rqtl2/install_phenos.py
@@ -1,11 +1,12 @@
 """Load pheno from R/qtl2 bundle into the database."""
 import sys
+import argparse
 import traceback
-from pathlib import Path
 from zipfile import ZipFile
 from functools import reduce
-from logging import Logger, getLogger, StreamHandler
+from logging import Logger, getLogger
 
+from redis import Redis
 import MySQLdb as mdb
 from MySQLdb.cursors import DictCursor
 
@@ -18,6 +19,8 @@ from r_qtl import r_qtl2_qc as rqc
 
 from functional_tools import take
 
+__MODULE__ = "scripts.rqtl2.install_phenos"
+
 def insert_probesets(dbconn: mdb.Connection,
                      platformid: int,
                      phenos: tuple[str, ...]) -> int:
@@ -93,14 +96,15 @@ def cross_reference_probeset_data(dbconn: mdb.Connection,
             } for row in dataids))
         return cursor.rowcount
 
-def install_pheno_files(#pylint: disable=[too-many-arguments, too-many-locals]
+def install_pheno_files(#pylint: disable=[too-many-locals]
+        rconn: Redis,#pylint: disable=[unused-argument]
         dbconn: mdb.Connection,
-        speciesid: int,
-        platformid: int,
-        datasetid: int,
-        rqtl2bundle: Path,
+        fullyqualifiedjobid: str,#pylint: disable=[unused-argument]
+        args: argparse.Namespace,
         logger: Logger = getLogger()) -> int:
     """Load data in `pheno` files and other related files into the database."""
+    (speciesid, platformid, datasetid, rqtl2bundle) = (
+        args.speciesid, args.platformid, args.datasetid, args.rqtl2bundle)
     with ZipFile(str(rqtl2bundle), "r") as zfile:
         try:
             rqc.validate_bundle(zfile)
@@ -155,16 +159,5 @@ 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,
-                                                 thelogger),
-        thelogger,
-        "DEBUG")
+    main = build_main(cli_args(), install_pheno_files, __MODULE__)
     sys.exit(main())