forked from maranasgroup/CatPred
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdemo_run.py
More file actions
64 lines (54 loc) · 1.83 KB
/
Copy pathdemo_run.py
File metadata and controls
64 lines (54 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
"""
Enzyme kinetics parameter prediction CLI for local/demo usage.
Usage:
python demo_run.py --parameter <kcat|km|ki> --input_file <path_to_input_csv> --checkpoint_dir <path_to_checkpoint_dir> [--use_gpu]
"""
import argparse
import subprocess
from catpred.inference import PredictionRequest, run_prediction_pipeline
def main(args: argparse.Namespace) -> int:
request = PredictionRequest(
parameter=args.parameter.lower(),
input_file=args.input_file,
checkpoint_dir=args.checkpoint_dir,
use_gpu=args.use_gpu,
repo_root=".",
)
print("Predicting.. This will take a while..")
try:
final_output = run_prediction_pipeline(request=request, results_dir="../results")
except (ValueError, FileNotFoundError) as exc:
print(str(exc))
return 1
except subprocess.CalledProcessError as exc:
print(f"Prediction command failed with exit code {exc.returncode}.")
return exc.returncode if exc.returncode is not None else 1
print(f"Output saved to {final_output}")
return 0
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Predict enzyme kinetics parameters.")
parser.add_argument(
"--parameter",
type=str,
choices=["kcat", "km", "ki"],
required=True,
help="Kinetics parameter to predict (kcat, km, or ki)",
)
parser.add_argument(
"--input_file",
type=str,
required=True,
help="Path to the input CSV file",
)
parser.add_argument(
"--use_gpu",
action="store_true",
help="Use GPU for prediction (default is CPU)",
)
parser.add_argument(
"--checkpoint_dir",
type=str,
required=True,
help="Path to the model checkpoint directory",
)
raise SystemExit(main(parser.parse_args()))