Skip to content

Commit c276c9f

Browse files
fix: align PR2 with PR1 minimized scoring flow
1 parent 56294bf commit c276c9f

2 files changed

Lines changed: 11 additions & 9 deletions

File tree

matcha/cli.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,6 @@ def _print_usage_and_exit() -> None:
317317
318318
[bold]Options:[/bold]
319319
-g, --device TEXT Device: auto, cpu, cuda, cuda:N, mps
320-
--n-samples INT Poses per ligand (default: 20)
321320
--gpus TEXT Multi-GPU ids for batch mode, e.g. 2,3
322321
--n-samples INT Poses per ligand (default: 20)
323322
--scorer TEXT gnina / custom / none (default: gnina)
@@ -382,7 +381,7 @@ def run_matcha(
382381
from omegaconf import OmegaConf # noqa: F811
383382
from rdkit import Chem # noqa: F811
384383
from matcha.utils.esm_utils import compute_esm_embeddings, compute_sequences
385-
from matcha.utils.inference_utils import run_v2_inference_pipeline
384+
from matcha.utils.inference_utils import run_v2_inference_pipeline, compute_fast_filters_from_sdf
386385
from matcha.utils.multigpu import parse_gpus, run_multigpu_batch
387386
from matcha.scoring import create_scorer
388387
from matcha.utils.device import resolve_device
@@ -679,8 +678,8 @@ def _read_scored_sdf_affinity(sdf_path: Path) -> List[float]:
679678

680679
# Optional GNINA scoring
681680
scorer_used = False
682-
sdf_scored = preds_root / dataset_name / "scored_sdf_predictions"
683-
best_scored_dir = preds_root / dataset_name / "best_scored_predictions"
681+
sdf_scored = preds_root / dataset_name / "minimized_sdf_predictions"
682+
best_scored_dir = preds_root / dataset_name / "best_minimized_predictions"
684683
if scorer_type != "none" and scorer_type.startswith("gnina") and not resolved_device.startswith("cuda"):
685684
console.print(f"[bold yellow][matcha][/bold yellow] GNINA requires CUDA; skipping scoring on {resolved_device}")
686685
scorer_type = "none"
@@ -690,7 +689,7 @@ def _read_scored_sdf_affinity(sdf_path: Path) -> List[float]:
690689
scorer = create_scorer(scorer_type, scorer_path=str(scorer_path) if scorer_path else None,
691690
minimize=scorer_minimize)
692691
sdf_input = preds_root / dataset_name / "sdf_predictions"
693-
filters_path = preds_root / dataset_name / "filters_results.json"
692+
filters_path = preds_root / dataset_name / "filters_results_minimized.json"
694693
if scorer_type.startswith("gnina") and batch_mode:
695694
if gnina_batch_mode not in {"combined", "per-ligand"}:
696695
raise typer.BadParameter("--gnina-batch-mode must be 'combined' or 'per-ligand'")
@@ -702,8 +701,14 @@ def _read_scored_sdf_affinity(sdf_path: Path) -> List[float]:
702701
n_samples=n_samples,
703702
device=cuda_device_idx,
704703
)
704+
compute_fast_filters_from_sdf(conf, run_name, sdf_type='minimized', n_preds_to_use=n_samples)
705+
scorer.select_top_poses(
706+
str(sdf_scored), str(best_scored_dir),
707+
filters_path=str(filters_path), n_samples=n_samples
708+
)
705709
else:
706710
scorer.score_poses(str(receptor), str(sdf_input), str(sdf_scored), device=cuda_device_idx)
711+
compute_fast_filters_from_sdf(conf, run_name, sdf_type='minimized', n_preds_to_use=n_samples)
707712
scorer.select_top_poses(str(sdf_scored), str(best_scored_dir),
708713
filters_path=str(filters_path), n_samples=n_samples)
709714
scorer_used = True

matcha/dataset/pdbbind.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -494,10 +494,7 @@ def _load_embeddings(self, embeddings_path, sequences_path, complex_names):
494494

495495
tokenized_aa_sequence = np.array(
496496
[self.aa_mapping.get(aa, 0) for aa in id_to_sequence[key]])[:, None]
497-
aa_sequence = np.array([aa for aa in id_to_sequence[key]])
498-
499-
if '_superlig' in key_name:
500-
key_name = key_name.split('_superlig')[0]
497+
aa_sequence = np.array(list(id_to_sequence[key]))
501498
chain_embeddings_dictlist[key_name].append(embedding)
502499
chain_sequences_dictlist[key_name].append(aa_sequence)
503500
tokenized_chain_sequences_dictlist[key_name].append(

0 commit comments

Comments
 (0)