Skip to content

Failing to get somd2 to run after API setup #162

Description

@jasmin-guven

Hi again!

I'm trying to setup a somd2 RBFE run from the API. I'm following the BioSimSpace tutorials on how to setup somd2 runs:

elif engine_query == "SOMD2":
    os.makedirs(
        f"{main_dir}/outputs/{engine_query}/{lig_0}~{lig_1}/bound", exist_ok=True
    )
    BSS.Stream.save(
        system_bound,
        f"{main_dir}/outputs/{engine_query}/{lig_0}~{lig_1}/bound/{lig_0}~{lig_1}",
    )
    with open(f"{main_dir}/outputs/{engine_query}/{lig_0}~{lig_1}/bound/config.yaml", 'w') as yaml_file:
        _yaml.dump(somd2_config, yaml_file)

I've done a similar thing where I create the config file directly by constructing a config object, saving it as a yaml file (as above) and then saving my merged BioSimSpace system as a sire object:

        merged_ligand_system = self.create_hybrid_molecule()
        
        somd2_config_file = os.path.join(self.working_directory, "config.yaml")
        
        somd2_config = config.Config(
            runtime=str(self.recipe.sampling_time),
            num_lambda=self.recipe.n_lambdas,
            log_file=f"{self.transformation}_somd2_log.txt",
            timestep=str(self.recipe.dt),
            temperature=str(self.recipe.temperature),
            pressure=str(self.recipe.pressure),
            integrator="langevin",
            cutoff_type="pme",
            cutoff=str(self.recipe.nb_cutoff),
            platform=compute_platform,
            hmr=False,
            restraints=None, #how to do this???
            constraint="h_bonds",
            perturbable_constraint="h_bonds_not_heavy_perturbed",
            minimise=True,
            minimisation_constraints=False,
            minimisation_errors=False,
            equilibration_time=str(self.recipe.lambda_equilibration_time),
            equilibration_timestep=str(self.recipe.lambda_equilibration_dt),
            equilibration_constraints=True,
            opencl_platform_index=0,
            restart=False,
            use_backup=False,
            write_config=True,
            overwrite=False,
            somd1_compatibility=False,
            pert_file=None,
            output_directory=self.working_directory
        )

        config_dictionary = somd2_config.as_dict()

        with open(somd2_config_file, "w") as ofile:
            yaml.dump(config_dictionary, ofile)

        sire_system = sire.system.System(merged_ligand_system._sire_object)

        sire.stream.save(
            obj=sire_system,
            filename=f"{self.working_directory}/merged_system.bss"
        )

I then tried running somd2 with:

somd2 merged_system.bss --config config.yaml 

but I get this error:

2026-06-26 13:30:34.088 | INFO     | somd2.runner._base:__init__:105 - somd2 version: 2025.2.0.dev+268.gfdad810
2026-06-26 13:30:34.088 | INFO     | somd2.runner._base:__init__:106 - sire version: 2025.4.0+8c20f50
2026-06-26 13:30:34.088 | INFO     | somd2.runner._base:__init__:107 - biosimspace version: 2025.4.0
2026-06-26 13:30:34.089 | INFO     | somd2.runner._base:__init__:109 - ghostly version: 2025.2.0
2026-06-26 13:30:34.338 | INFO     | somd2.runner._base:__init__:325 - Applying modifications to ghost atom bonded terms
2026-06-26 13:30:34.383 | WARNING  | ghostly._ghostly:_check_rotamer_anchors:2378 - Potential rotamer anchor at λ = 0: bond 12-0 is a rotatable sp3 bond. Surviving anchor dihedrals may allow rotameric transitions of ghost atoms.
2026-06-26 13:30:34.489 | ERROR    | somd2.runner._base:_prepare_output:1343 - The following files already exist, use --overwrite to overwrite them: ['/Users/af25016/projects/meze/data/outputs/model_0/vim2/ligand_11~ligand_12/bound/config.yaml'] 

I don't want to overwrite the file as I have setup the config in a specific way. I also don't see how somd2 would know my config settings if I overwrite/delete the saved config file?

I'm sure I'm not using the scripts/package the right way, so any help with this would be really appreciated, thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions