diff --git a/scripts/align.py b/scripts/align.py index 4620e62..902678a 100644 --- a/scripts/align.py +++ b/scripts/align.py @@ -11,28 +11,24 @@ def main(): parser = argparse.ArgumentParser(description="aligner") - parser.add_argument("-d", "--version-dir", required=True, help="Path to version dir") - parser.add_argument( - "-m", "--metadata_file", default=Constants.METADATA_XTAL_FILENAME.format(""), help="Metadata YAML file" - ) - parser.add_argument("-a", "--assemblies", help="Assemblies YAML file") + parser.add_argument("-d", "--dir", help="Working directory") - parser.add_argument("-l", "--log-file", help="File to write logs to") parser.add_argument("--log-level", type=int, default=0, help="Logging level") parser.add_argument("--validate", action="store_true", help="Only perform validation") args = parser.parse_args() - if args.log_file: - log = args.log_file + if args.dir: + log = str(Path(args.dir) / 'aligner.log') else: - log = str(Path(args.version_dir).parent / 'aligner.log') - print("Using {} for log file".format(str(log))) + log = 'aligner.log' logger = utils.Logger(logfile=log, level=args.log_level) logger.info("aligner: ", args) + logger.info("Using {} for log file".format(str(log))) + utils.LOG = logger - a = Aligner(args.version_dir, args.metadata_file, args.assemblies, logger=logger) + a = Aligner(args.dir, logger=logger) num_errors, num_warnings = a.validate() if not args.validate: diff --git a/scripts/collate.py b/scripts/collate.py index c0d9abb..9b35588 100644 --- a/scripts/collate.py +++ b/scripts/collate.py @@ -1,23 +1,42 @@ import argparse import shutil +from pathlib import Path from xchemalign import utils -from xchemalign.collator import Collator +from xchemalign import setup +from xchemalign.collator import Collator, _check_working_dir def main(): parser = argparse.ArgumentParser(description="collator") - parser.add_argument("-c", "--config-file", default="config.yaml", help="Configuration file") + parser.add_argument("-d", "--dir", help="Working directory") parser.add_argument("-l", "--log-file", help="File to write logs to") parser.add_argument("--log-level", type=int, default=0, help="Logging level") parser.add_argument("-v", "--validate", action="store_true", help="Only perform validation") + parser.add_argument("--no-git-info", action="store_false", help="Don't add GIT info to metadata") args = parser.parse_args() - c = Collator(args.config_file, log_file=args.log_file, log_level=args.log_level) + if args.dir: + working_dir = Path(args.dir) + else: + working_dir = Path.cwd() + + if _check_working_dir(working_dir): + print("Working dir does not seem to have been initialised - missing 'upload_current' symlink") + inp = input("Do you want the working dir to be initialised? (Y/N)") + if inp == "Y" or inp == "y": + print("Initialising working dir") + s = setup.Setup(args.dir) + s.run() + exit(1) + + c = Collator(working_dir, log_file=args.log_file, log_level=args.log_level, include_git_info=args.no_git_info) + logger = c.logger logger.info("collator: ", str(args)) + utils.LOG = logger meta = c.validate()