bio_tools 0.1.1

Install, run, and inspect computational biology and chemistry tools, e.g. AlphaFold, Boltz, RFdiffusion, and ProteinMPNN
Documentation
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
use std::{fs, path::Path, process::Command};

use super::{
    InstallError, Installer,
    common::{PipOptions, ScratchDir},
};
use crate::tool_definitions::Tool;

struct FetchedScript {
    name: &'static str,
    url: &'static str,
}

struct UvRecipe {
    slug: &'static str,
    python: &'static str,
    requirements: &'static [&'static str],
    scripts: &'static [&'static str],
    torch: &'static [&'static str],
    extra_indexes: &'static [&'static str],
    index_strategy: Option<&'static str>,
    no_build_isolation: bool,
    extra_env: &'static [(&'static str, &'static str)],
    fetched_scripts: &'static [FetchedScript],
    gpu_probe: Option<&'static str>,
    verify: Option<(&'static str, &'static [&'static str])>,
}

impl UvRecipe {
    const fn simple(
        slug: &'static str,
        python: &'static str,
        requirements: &'static [&'static str],
        scripts: &'static [&'static str],
    ) -> Self {
        Self {
            slug,
            python,
            requirements,
            scripts,
            torch: &[],
            extra_indexes: &[],
            index_strategy: None,
            no_build_isolation: false,
            extra_env: &[],
            fetched_scripts: &[],
            gpu_probe: None,
            verify: None,
        }
    }
}

pub(super) fn install(installer: &mut Installer, tool: Tool) -> Result<(), InstallError> {
    match tool {
        Tool::Chai1 => install_recipe(
            installer,
            UvRecipe {
                extra_indexes: &["https://download.pytorch.org/whl/cu124"],
                gpu_probe: Some(
                    "import torch; assert torch.cuda.is_available() and \
                     torch.cuda.is_bf16_supported(), 'Chai-1 requires a CUDA GPU with bfloat16'",
                ),
                ..UvRecipe::simple(
                    Tool::Chai1.slug(),
                    "3.11",
                    &["chai_lab==0.6.1"],
                    &["chai-lab"],
                )
            },
        ),
        Tool::Protenix => install_recipe(
            installer,
            UvRecipe {
                gpu_probe: Some(
                    "import torch; assert torch.cuda.is_available(), 'Protenix requires CUDA'",
                ),
                ..UvRecipe::simple(Tool::Protenix.slug(), "3.11", &["protenix"], &["protenix"])
            },
        ),
        Tool::EsmFold2 => install_esmfold(installer),
        Tool::ImmuneBuilder => install_recipe(
            installer,
            UvRecipe::simple(
                Tool::ImmuneBuilder.slug(),
                "3.11",
                &["ImmuneBuilder", "openmm", "pdbfixer", "anarci"],
                &["ABodyBuilder2", "NanoBodyBuilder2", "TCRBuilder2"],
            ),
        ),
        Tool::BioPhi => install_recipe(
            installer,
            UvRecipe::simple(
                Tool::BioPhi.slug(),
                "3.11",
                &[
                    "biophi @ git+https://github.com/Merck/BioPhi@main",
                    "abnumber",
                ],
                &["biophi"],
            ),
        ),
        Tool::ProteinMpnnDdg => install_proteinmpnn_ddg(installer),
        Tool::RfDiffusion => install_rfdiffusion(installer),
        Tool::RfAntibody => install_rfantibody(installer),
        Tool::IgDesign => install_igdesign(installer),
        Tool::ThermoMpnn => install_checkout_recipe(
            installer,
            UvRecipe {
                torch: &["torch==2.7.1"],
                ..UvRecipe::simple(
                    Tool::ThermoMpnn.slug(),
                    "3.12",
                    &[
                        "numpy<2",
                        "pandas",
                        "biopython",
                        "tqdm",
                        "omegaconf",
                        "pytorch-lightning",
                    ],
                    &[],
                )
            },
            "https://github.com/Kuhlman-Lab/ThermoMPNN",
            "ThermoMPNN",
        ),
        Tool::DeepSp => install_deepsp(installer),
        Tool::DeepImmuno => install_checkout_recipe(
            installer,
            UvRecipe::simple(
                Tool::DeepImmuno.slug(),
                "3.10",
                &["tensorflow<2.16", "pandas", "numpy<2", "scikit-learn"],
                &[],
            ),
            "https://github.com/frankligy/DeepImmuno",
            "DeepImmuno",
        ),
        Tool::TlImmuno2 => install_checkout_recipe(
            installer,
            UvRecipe::simple(
                Tool::TlImmuno2.slug(),
                "3.10",
                &[
                    "tensorflow<2.16",
                    "pandas",
                    "pyarrow",
                    "numpy<2",
                    "scikit-learn",
                ],
                &[],
            ),
            "https://github.com/XSLiuLab/TLimmuno2",
            "TLimmuno2",
        ),
        Tool::NetSolP => install_netsolp(installer),
        Tool::DeepStabP => install_deepstabp(installer),
        Tool::DlkCat => install_checkout_recipe(
            installer,
            UvRecipe {
                torch: &["torch==2.7.1"],
                ..UvRecipe::simple(
                    Tool::DlkCat.slug(),
                    "3.10",
                    &["numpy<2", "rdkit", "scikit-learn"],
                    &[],
                )
            },
            "https://github.com/SysBioChalmers/DLKcat",
            "DLKcat",
        ),
        Tool::CatPred => install_catpred(installer),
        Tool::Anarcii => install_recipe(
            installer,
            UvRecipe {
                torch: &["torch==2.7.1"],
                verify: Some((
                    "python",
                    &[
                        "-c",
                        "import anarcii; print('anarcii', anarcii.__version__)",
                    ],
                )),
                ..UvRecipe::simple(Tool::Anarcii.slug(), "3.12", &["anarcii"], &["anarcii"])
            },
        ),
        Tool::Placer => install_placer(installer),
        Tool::Gromacs => install_gromacs(installer),
        Tool::BoltzAdme => install_recipe(
            installer,
            UvRecipe::simple(Tool::BoltzAdme.slug(), "3.13", &["boltz-api~=0.45.0"], &[]),
        ),
        _ => Err(InstallError::InvalidConfiguration(format!(
            "{} has no uv/executable recipe",
            tool.name()
        ))),
    }
}

fn install_recipe(installer: &mut Installer, recipe: UvRecipe) -> Result<(), InstallError> {
    let backend = (!recipe.torch.is_empty())
        .then(|| installer.select_torch_backend())
        .transpose()?;
    installer.create_venv(recipe.slug, recipe.python)?;
    if let Some(backend) = backend {
        installer.install_torch(recipe.slug, recipe.torch, backend)?;
    }
    installer.pip_install(
        recipe.slug,
        recipe.requirements,
        PipOptions {
            extra_indexes: recipe.extra_indexes,
            index_strategy: recipe.index_strategy,
            no_build_isolation: recipe.no_build_isolation,
            extra_env: recipe.extra_env,
            ..PipOptions::default()
        },
    )?;
    for script in recipe.fetched_scripts {
        installer.install_fetched_python_script(recipe.slug, script.url, script.name)?;
    }
    for script in recipe.scripts {
        let path = installer.venv_script(recipe.slug, script);
        if !path.is_file() {
            return Err(InstallError::InvalidConfiguration(format!(
                "{} installed, but {script} was not created in its environment",
                recipe.slug
            )));
        }
    }
    if let Some(probe) = recipe.gpu_probe {
        let mut command = Command::new(installer.venv_python(recipe.slug));
        command.args(["-c", probe]);
        installer.checked(&mut command)?;
    }
    if let Some((script, arguments)) = recipe.verify {
        let executable = if script == "python" {
            installer.venv_python(recipe.slug)
        } else {
            installer.venv_script(recipe.slug, script)
        };
        let mut command = Command::new(executable);
        command.args(arguments);
        installer.checked(&mut command)?;
    }
    Ok(())
}

fn install_checkout_recipe(
    installer: &mut Installer,
    recipe: UvRecipe,
    url: &str,
    directory: &str,
) -> Result<(), InstallError> {
    install_recipe(installer, recipe)?;
    let target = installer.tools_root().join(directory);
    installer.clone_or_update(url, &target)
}

fn install_esmfold(installer: &mut Installer) -> Result<(), InstallError> {
    install_recipe(
        installer,
        UvRecipe {
            torch: &["torch==2.7.1"],
            no_build_isolation: true,
            extra_env: &[("NVCC_APPEND_FLAGS", "-std=c++17")],
            fetched_scripts: &[FetchedScript {
                name: "esm-fold",
                url: "https://raw.githubusercontent.com/facebookresearch/esm/v2.0.0/scripts/esmfold_inference.py",
            }],
            ..UvRecipe::simple(
                Tool::EsmFold2.slug(),
                "3.11",
                &[
                    "fair-esm[esmfold]~=2.0.0",
                    "openfold @ git+https://github.com/aqlaboratory/openfold.git@4b41059694619831a7db195b7e0988fc4ff3a307",
                ],
                &["esm-fold"],
            )
        },
    )
}

fn install_proteinmpnn_ddg(installer: &mut Installer) -> Result<(), InstallError> {
    install_recipe(
        installer,
        UvRecipe {
            fetched_scripts: &[FetchedScript {
                name: "proteinmpnn-ddg",
                url: "https://raw.githubusercontent.com/PeptoneLtd/proteinmpnn_ddg/main/predict.py",
            }],
            gpu_probe: Some(
                "import jax; assert any(d.platform == 'gpu' for d in jax.devices()), \
                 'ProteinMPNN-ddG requires a JAX CUDA device'",
            ),
            ..UvRecipe::simple(
                Tool::ProteinMpnnDdg.slug(),
                "3.10",
                &[
                    "ProteinMPNN-ddG[cuda12] @ git+https://github.com/PeptoneLtd/proteinmpnn_ddg.git@main",
                    "dm-haiku==0.0.13",
                ],
                &["proteinmpnn-ddg"],
            )
        },
    )
}

fn install_rfdiffusion(installer: &mut Installer) -> Result<(), InstallError> {
    install_recipe(
        installer,
        UvRecipe {
            extra_indexes: &["https://download.pytorch.org/whl/cu118"],
            index_strategy: Some("unsafe-best-match"),
            gpu_probe: Some(
                "import torch; assert torch.cuda.is_available(), 'RFdiffusion requires CUDA'",
            ),
            ..UvRecipe::simple(
                Tool::RfDiffusion.slug(),
                "3.10",
                &[
                    "dgl @ https://data.dgl.ai/wheels/torch-2.3/cu118/dgl-2.4.0%2Bcu118-cp310-cp310-manylinux1_x86_64.whl",
                    "numpy<2",
                    "e3nn==0.3.3",
                    "hydra-core",
                    "icecream",
                    "opt_einsum",
                    "scipy",
                    "pandas",
                    "decorator",
                    "pyrsistent",
                    "dllogger @ git+https://github.com/NVIDIA/dllogger.git@master",
                    "se3-transformer @ git+https://github.com/RosettaCommons/RFdiffusion.git@main#subdirectory=env/SE3Transformer",
                    "rfdiffusion @ git+https://github.com/RosettaCommons/RFdiffusion.git@main",
                ],
                &[],
            )
        },
    )?;
    let target = installer.tools_root().join("RFdiffusion");
    installer.clone_or_update("https://github.com/RosettaCommons/RFdiffusion", &target)?;
    let weights = target.join("models");
    for (directory, filename) in [
        ("6f5902ac237024bdd0c176cb93063dc4", "Base_ckpt.pt"),
        ("e29311f6f1bf1af907f9ef9f44b8328b", "Complex_base_ckpt.pt"),
        (
            "60f09a193fb5e5ccdc4980417708dbab",
            "Complex_Fold_base_ckpt.pt",
        ),
        ("74f51cfb8b440f50d70878e05361d8f0", "InpaintSeq_ckpt.pt"),
        (
            "76d00716416567174cdb7ca96e208296",
            "InpaintSeq_Fold_ckpt.pt",
        ),
        ("5532d2e1f3a4738decd58b19d633b3c3", "ActiveSite_ckpt.pt"),
        ("12fc204edeae5b57713c5ad7dcb97d39", "Base_epoch8_ckpt.pt"),
    ] {
        installer.download(
            &format!("https://files.ipd.uw.edu/pub/RFdiffusion/{directory}/{filename}"),
            &weights.join(filename),
        )?;
    }
    Ok(())
}

fn install_rfantibody(installer: &mut Installer) -> Result<(), InstallError> {
    install_recipe(
        installer,
        UvRecipe {
            extra_indexes: &["https://download.pytorch.org/whl/cu118"],
            index_strategy: Some("unsafe-best-match"),
            gpu_probe: Some(
                "import torch; assert torch.cuda.is_available(), 'RFantibody requires CUDA'",
            ),
            ..UvRecipe::simple(
                Tool::RfAntibody.slug(),
                "3.10",
                &[
                    "dgl @ https://data.dgl.ai/wheels/torch-2.3/cu118/dgl-2.4.0%2Bcu118-cp310-cp310-manylinux1_x86_64.whl",
                    "rfantibody @ git+https://github.com/RosettaCommons/RFantibody.git@main",
                ],
                &["rfdiffusion", "proteinmpnn", "rf2"],
            )
        },
    )?;
    let target = installer.tools_root().join("RFantibody");
    installer.clone_or_update("https://github.com/RosettaCommons/RFantibody", &target)?;
    let weights = target.join("weights");
    for (url, filename) in [
        (
            "https://files.ipd.uw.edu/pub/RFantibody/RFdiffusion_Ab.pt",
            "RFdiffusion_Ab.pt",
        ),
        (
            "https://files.ipd.uw.edu/pub/RFantibody/ProteinMPNN_v48_noise_0.2.pt",
            "ProteinMPNN_v48_noise_0.2.pt",
        ),
        (
            "https://files.ipd.uw.edu/pub/RFantibody/RF2_ab.pt",
            "RF2_ab.pt",
        ),
        (
            "https://zenodo.org/records/17488258/files/RFab_noframework-nosidechains-5-10-23_trainingparamsadded.pt?download=1",
            "RFab_noframework-nosidechains-5-10-23_trainingparamsadded.pt",
        ),
    ] {
        installer.download(url, &weights.join(filename))?;
    }
    Ok(())
}

fn install_igdesign(installer: &mut Installer) -> Result<(), InstallError> {
    install_recipe(
        installer,
        UvRecipe {
            extra_indexes: &["https://download.pytorch.org/whl/cu118"],
            index_strategy: Some("unsafe-best-match"),
            gpu_probe: Some(
                "import torch; assert torch.cuda.is_available(), 'IgDesign requires CUDA'",
            ),
            ..UvRecipe::simple(
                Tool::IgDesign.slug(),
                "3.11",
                &[
                    "torch==2.7.1+cu118",
                    "pandas>=2.0,<2.1",
                    "numpy<2",
                    "setuptools<81",
                    "lightning>=2.0,<2.1",
                    "cytoolz>=0.12.3",
                    "einops>=0.8.0",
                    "hydra-core>=1.3.2",
                    "biopython>=1.84",
                    "datasets>=2.20.0",
                    "anarci",
                    "huggingface_hub>=0.24.5",
                    "transformers>=4.42.4",
                    "torchtyping>=0.1.4",
                ],
                &[],
            )
        },
    )?;
    let target = installer.tools_root().join("igdesign");

    installer.clone_or_update("https://github.com/AbSciBio/igdesign", &target)?;
    // Normal VCS installation exposes no modules; upstream documents an editable checkout.
    let target_argument = target.to_string_lossy().into_owned();
    installer.pip_install(
        Tool::IgDesign.slug(),
        &["-e", &target_argument],
        PipOptions::default(),
    )?;
    let download = target.join("download_ckpts.sh");
    if download.is_file() {
        installer.run_upstream_script(&download, &[], &target)?;
    } else {
        installer.note(format!(
            "IgDesign has no checkpoint downloader; place its checkpoints under {}",
            target.join("ckpts").display()
        ));
    }
    Ok(())
}

fn install_deepsp(installer: &mut Installer) -> Result<(), InstallError> {
    install_checkout_recipe(
        installer,
        UvRecipe {
            torch: &["torch==2.7.1"],
            ..UvRecipe::simple(
                Tool::DeepSp.slug(),
                "3.11",
                &["tensorflow", "pandas", "numpy", "biopython", "anarcii"],
                &[],
            )
        },
        "https://github.com/Lailabcode/DeepSP",
        "DeepSP",
    )?;
    copy_support_script(
        installer,
        "tool_scripts/deepsp_cli.py",
        "DeepSP/deepsp_cli.py",
    )
}

fn install_deepstabp(installer: &mut Installer) -> Result<(), InstallError> {
    install_checkout_recipe(
        installer,
        UvRecipe {
            torch: &["torch==2.7.1"],
            ..UvRecipe::simple(
                Tool::DeepStabP.slug(),
                "3.11",
                &[
                    "transformers<5",
                    "sentencepiece",
                    "protobuf",
                    "biopython",
                    "pandas",
                    "pytorch-lightning",
                ],
                &[],
            )
        },
        "https://github.com/CSBiology/deepStabP",
        "deepStabP",
    )?;
    copy_support_script(
        installer,
        "tool_scripts/deepstabp_cli.py",
        "deepStabP/src/Api/deepstabp_cli.py",
    )
}

fn install_netsolp(installer: &mut Installer) -> Result<(), InstallError> {
    install_checkout_recipe(
        installer,
        UvRecipe {
            torch: &["torch==2.7.1"],
            ..UvRecipe::simple(
                Tool::NetSolP.slug(),
                "3.11",
                &["fair-esm~=2.0.0", "pandas", "numpy<2"],
                &[],
            )
        },
        "https://github.com/tvinet/NetSolP-1.0",
        "NetSolP-1.0",
    )?;
    let models = installer
        .tools_root()
        .join("NetSolP-1.0/PredictionServer/models");
    if let Some(url) = installer.config.netsolp_models_url.clone() {
        let scratch = ScratchDir::new_in(installer.tools_root(), "netsolp-models")?;
        let archive = scratch.path().join("netsolp_models.tar.gz");
        installer.download(&url, &archive)?;
        installer.extract_archive(&archive, &models)?;
    } else {
        installer.note(
            "NetSolP model checkpoints require DTU licence acceptance; set NETSOLP_MODELS_URL \
             when an archive is available",
        );
    }
    Ok(())
}

fn copy_support_script(
    installer: &Installer,
    source: &str,
    destination: &str,
) -> Result<(), InstallError> {
    let Some(source) = installer.support_file(source) else {
        installer.note(format!(
            "Optional adapter helper {source} was not supplied; the upstream checkout is installed"
        ));
        return Ok(());
    };
    let destination = installer.tools_root().join(destination);
    if let Some(parent) = destination.parent() {
        fs::create_dir_all(parent).map_err(|error| {
            InstallError::io(format!("unable to create {}", parent.display()), error)
        })?;
    }
    fs::copy(&source, &destination).map_err(|error| {
        InstallError::io(
            format!(
                "unable to copy {} to {}",
                source.display(),
                destination.display()
            ),
            error,
        )
    })?;
    Ok(())
}

fn install_catpred(installer: &mut Installer) -> Result<(), InstallError> {
    install_recipe(
        installer,
        UvRecipe {
            extra_indexes: &["https://download.pytorch.org/whl/cu124"],
            ..UvRecipe::simple(
                Tool::CatPred.slug(),
                "3.10",
                &[
                    "catpred @ git+https://github.com/maranasgroup/CatPred.git@main",
                    "ipdb",
                    "fair-esm",
                    "progres",
                    "transformers",
                    "sentencepiece",
                    "seaborn",
                    "rotary_embedding_torch==0.6.5",
                    "faiss-cpu",
                    "torch-geometric",
                ],
                &[],
            )
        },
    )?;
    let target = installer.tools_root().join("CatPred");
    installer.clone_or_update("https://github.com/maranasgroup/CatPred", &target)?;
    let data = target.join("capsule_data");
    if !data.join("data/pretrained").is_dir() {
        installer.step("Downloading the CatPred checkpoint archive (about 10 GiB)");
        let scratch = ScratchDir::new_in(installer.tools_root(), "catpred")?;
        let archive = scratch.path().join("capsule_data_update.tar.gz");
        if let Err(first_error) = installer.download(
            "https://catpred.s3.us-east-1.amazonaws.com/capsule_data_update.tar.gz",
            &archive,
        ) {
            installer.note(format!(
                "The regional CatPred URL failed ({first_error}); trying the fallback"
            ));
            installer.download(
                "https://catpred.s3.amazonaws.com/capsule_data_update.tar.gz",
                &archive,
            )?;
        }
        installer.extract_archive(&archive, &data)?;
    }
    if data.join("data/pretrained").is_dir() {
        create_catpred_links(&target)?;
    } else {
        installer.note(
            "The CatPred checkpoint layout was not recognized; set a checkpoint directory manually",
        );
    }
    Ok(())
}

#[cfg(unix)]
fn create_catpred_links(target: &Path) -> Result<(), InstallError> {
    use std::os::unix::fs::symlink;

    let reproduce = target.join("capsule_data/data/pretrained/reproduce_checkpoints");
    let links = target.join("checkpoint_links");
    fs::create_dir_all(&links)
        .map_err(|error| InstallError::io("unable to create CatPred checkpoint links", error))?;
    for (name, source) in [
        ("kcat", reproduce.join("kcat/seed0/fold_0")),
        (
            "km",
            reproduce.join("km/seed0/seqemb36_attn6_esm_ens10/fold_0"),
        ),
        (
            "ki",
            reproduce.join("ki/seed0/seqemb36_attn6_ens10_Pretrained_egnnFeats/fold_0"),
        ),
    ] {
        let destination = links.join(name);
        if destination
            .symlink_metadata()
            .is_ok_and(|metadata| metadata.file_type().is_symlink() || metadata.is_file())
        {
            fs::remove_file(&destination).map_err(|error| {
                InstallError::io(
                    format!("unable to replace {}", destination.display()),
                    error,
                )
            })?;
        } else if destination.is_dir() {
            return Err(InstallError::InvalidConfiguration(format!(
                "{} is a real directory; refusing to replace it with a symlink",
                destination.display()
            )));
        }
        symlink(source, destination)
            .map_err(|error| InstallError::io("unable to link CatPred checkpoints", error))?;
    }
    Ok(())
}

#[cfg(not(unix))]
fn create_catpred_links(_target: &Path) -> Result<(), InstallError> {
    Ok(())
}

fn install_placer(installer: &mut Installer) -> Result<(), InstallError> {
    install_recipe(
        installer,
        UvRecipe {
            extra_indexes: &["https://download.pytorch.org/whl/cu118"],
            index_strategy: Some("unsafe-best-match"),
            gpu_probe: Some(
                "import torch; assert torch.cuda.is_available(), 'PLACER requires CUDA'",
            ),
            ..UvRecipe::simple(
                Tool::Placer.slug(),
                "3.10",
                &[
                    "dgl @ https://data.dgl.ai/wheels/torch-2.3/cu118/dgl-2.4.0%2Bcu118-cp310-cp310-manylinux1_x86_64.whl",
                    "torch==2.3.1",
                    "opt_einsum==3.4.0",
                    "openbabel-wheel==3.1.1.22",
                    "networkx>=3.2",
                    "numpy<2",
                    "pandas==2.2.3",
                    // Upstream pins 0.5.4, but that release exists on conda-forge rather than
                    // PyPI. Installing its matching Git tag keeps this uv recipe resolvable.
                    "e3nn @ git+https://github.com/e3nn/e3nn.git@0.5.4",
                    // PLACER imports NVIDIA's DGL SE(3) Transformer. Upstream's Conda manifest
                    // installs it from this subdirectory; omitting it leaves a checkout that
                    // passes dependency resolution but fails as soon as the runner imports.
                    "se3-transformer @ git+https://github.com/NVIDIA/DeepLearningExamples.git@729963dd47e7c8bd462ad10bfac7a7b0b604e6dd#subdirectory=DGLPyTorch/DrugDiscovery/SE3Transformer",
                ],
                &[],
            )
        },
    )?;
    let target = installer.tools_root().join("PLACER");
    installer.clone_or_update("https://github.com/baker-laboratory/PLACER", &target)
}

fn install_gromacs(installer: &mut Installer) -> Result<(), InstallError> {
    let version = installer.config.gromacs_version.clone();
    let prefix = installer
        .config
        .gromacs_prefix
        .clone()
        .unwrap_or_else(|| installer.tools_root().join("gromacs"));
    let executable = prefix.join("bin/gmx");
    if executable.is_file() {
        let mut version_command = Command::new(&executable);
        version_command.arg("--version");
        if installer.capture(&mut version_command).is_ok_and(|output| {
            String::from_utf8_lossy(&output.stdout).contains(&version)
                || String::from_utf8_lossy(&output.stderr).contains(&version)
        }) {
            installer.note(format!("GROMACS {version} is already installed"));
            return Ok(());
        }
    }

    let scratch = ScratchDir::new_in(installer.tools_root(), "gromacs")?;
    let tarball = format!("gromacs-{version}.tar.gz");
    let archive = scratch.path().join(&tarball);
    installer.download(
        &format!("https://ftp.gromacs.org/gromacs/{tarball}"),
        &archive,
    )?;
    installer.extract_archive(&archive, scratch.path())?;
    let source = scratch.path().join(format!("gromacs-{version}"));
    let build = source.join("build");
    fs::create_dir_all(&build)
        .map_err(|error| InstallError::io("unable to create the GROMACS build directory", error))?;

    let mut configure = Command::new("cmake");
    configure
        .arg("..")
        .arg("-DGMX_BUILD_OWN_FFTW=ON")
        .arg(format!("-DCMAKE_INSTALL_PREFIX={}", prefix.display()))
        .current_dir(&build);
    installer.checked(&mut configure)?;
    let jobs = std::thread::available_parallelism()
        .map(usize::from)
        .unwrap_or(1)
        .to_string();
    let mut build_command = Command::new("cmake");
    build_command
        .args(["--build", ".", "--parallel", &jobs])
        .current_dir(&build);
    installer.checked(&mut build_command)?;
    let mut install_command = Command::new("cmake");
    install_command.args(["--install", "."]).current_dir(&build);
    installer.checked(&mut install_command)?;

    if !executable.is_file() {
        return Err(InstallError::InvalidConfiguration(format!(
            "GROMACS built, but {} was not created",
            executable.display()
        )));
    }
    let mut verify = Command::new(executable);
    verify.arg("--version");
    installer.checked(&mut verify)
}