diff --git a/meeko/cli/mk_prepare_receptor.py b/meeko/cli/mk_prepare_receptor.py index 8085cdf..214e7c4 100755 --- a/meeko/cli/mk_prepare_receptor.py +++ b/meeko/cli/mk_prepare_receptor.py @@ -81,6 +81,11 @@ def get_args(): "--read_with_prody", metavar="MACROMOL_FILENAME", help=f"reads PDB/mmCIF file with Prody{need_prody_msg}") + io_group.add_argument( + "-ij", + "--read_json", + metavar="MACROMOL_JSON_FILENAME", + help=f"reads receptor JSON file") io_group.add_argument( "-o", "--output_basename", @@ -216,17 +221,15 @@ def get_args(): ) args = parser.parse_args() - if args.read_pdb is None and args.read_with_prody is None: - parser.print_help() - msg = "Need input filename: use either -i/--read_with_prody or --read_pdb" + num_input_args = sum([args.read_pdb is not None, args.read_with_prody is not None, args.read_json is not None]) + if num_input_args != 1: + msg = ( + f"Need exactly one input argument: -i/--read_with_prody or --read_pdb or -ij/--read_json \n" + f"but {num_input_args} inputs were given. " + ) print(eol + msg) sys.exit(2) - if args.read_pdb is not None and args.read_with_prody is not None: - msg = "Can't use both -i/--read_with_prody and --read_pdb" - print(eol + msg, file=sys.stderr) - sys.exit(2) - if args.write_gpf is not None and args.write_pdbqt is None: # there's a few of places that assume this condition has been checked msg = "--write_gpf requires --write_pdbqt because autogrid expects" @@ -435,7 +438,17 @@ def main(): templates.add_json_file(fn) # create polymers - if args.read_with_prody is not None: + if args.read_json is not None: + try: + with open(args.read_json, "r") as file: + json_string = file.read() + polymer = Polymer.from_json(json_string) + + except Exception as e: + print(e) + sys.exit(1) + + elif args.read_with_prody is not None: if not _got_prody: print(_prody_import_error, file=sys.stderr) print("option --read_with_prody requires Prody, which is not installed.")