Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: 'restraint' must be of type 'BioSimSpace.FreeEnergy.Restraint' for free leg of simulation. #33

Open
yasirkhanqu opened this issue Feb 18, 2025 · 2 comments

Comments

@yasirkhanqu
Copy link

Hi,

I am working with a system with a protein, an acceptor substrate of (three) carbohydrate subunits parameterised with GLYCAM, MG2+ ion, and a donor substrate (LIG), parameterised with gaff forcefield.

Everything works fine for the bound leg until this error erupts (which is for the free leg as I can see from the error). I have attached the input files and the overall output.log file. I have also attached the restraint configuration file from bound/restraint/input/somd.cfg. Additionally, I have attached the param files and the restrain folder from bound/restrain.

Scoring candidate Boresch anchor points. Anchor set no:  96%|█████████▌| 48/50 [24:44<00:59, 29.84s/it]
Scoring candidate Boresch anchor points. Anchor set no: 100%|██████████| 50/50 [25:46<00:00, 30.92s/it]
INFO - 2025-02-18 02:01:45,283 - Leg (type = BOUND)_306 - Writing input files for BOUND leg RESTRAIN stage
INFO - 2025-02-18 02:01:45,307 - Leg (type = BOUND)_306 - Perturbation type: restraint
╭───────────────────── Traceback (most recent call last) ──────────────────────╮
│ /home/yasir/a3fe/glft2_param/abfe.py:3 in <module>                           │
│                                                                              │
│    1 import a3fe as a3                                                       │
│    2 calc = a3.Calculation(ensemble_size = 5)                                │
│ ❱  3 calc.setup()                                                            │
│    4 # Get optimised lambda schedule with thermodynamic speed                │
│    5 # of 2 kcal mol-1                                                       │
│    6 calc.get_optimal_lam_vals(delta_er = 2)                                 │
│                                                                              │
│ /home/yasir/.conda/envs/a3fe/lib/python3.12/site-packages/a3fe/run/calculati │
│ on.py:211 in setup                                                           │
│                                                                              │
│   208 │   │   │   │   stream_log_level=self.stream_log_level,                │
│   209 │   │   │   )                                                          │
│   210 │   │   │   self.legs.append(leg)                                      │
│ ❱ 211 │   │   │   leg.setup(configs[leg_type])                               │
│   212 │   │                                                                  │
│   213 │   │   # Save the state                                               │
│   214 │   │   self.setup_complete = True                                     │
│                                                                              │
│ /home/yasir/.conda/envs/a3fe/lib/python3.12/site-packages/a3fe/run/leg.py:24 │
│ 2 in setup                                                                   │
│                                                                              │
│    239 │   │   │   system = self.run_ensemble_equilibration(sysprep_config=c │
│    240 │   │                                                                 │
│    241 │   │   # Write input files                                           │
│ ❱  242 │   │   self.write_input_files(system, config=cfg)                    │
│    243 │   │                                                                 │
│    244 │   │   # Make sure the stored restraints reflect the restraints used │
│    245 │   │   # make this more robust my using the SOMD functionality to ex │
│                                                                              │
│ /home/yasir/.conda/envs/a3fe/lib/python3.12/site-packages/a3fe/run/leg.py:76 │
│ 2 in write_input_files                                                       │
│                                                                              │
│    759 │   │   │   )                                                         │
│    760 │   │   │   self._logger.info(f"Perturbation type: {stage_type.bss_pe │
│    761 │   │   │   # Ensure we remove the velocites to avoid RST7 file writi │
│ ❱  762 │   │   │   _BSS.FreeEnergy.AlchemicalFreeEnergy(                     │
│    763 │   │   │   │   pre_equilibrated_system,                              │
│    764 │   │   │   │   protocol,                                             │
│    765 │   │   │   │   engine="SOMD",                                        │
│                                                                              │
│ /home/yasir/.conda/envs/a3fe/lib/python3.12/site-packages/BioSimSpace/Sandpi │
│ t/Exscientia/FreeEnergy/_alchemical_free_energy.py:361 in __init__           │
│                                                                              │
│    358 │   │   # For free leg simulations, the restraint will be None.       │
│    359 │   │   if restraint is not None:                                     │
│    360 │   │   │   if not isinstance(restraint, _Restraint):                 │
│ ❱  361 │   │   │   │   raise TypeError(                                      │
│    362 │   │   │   │   │   "'restraint' must be of type 'BioSimSpace.FreeEne │
│    363 │   │   │   │   )                                                     │
│    364 │   │   │   else:                                                     │
╰──────────────────────────────────────────────────────────────────────────────╯
TypeError: 'restraint' must be of type 'BioSimSpace.FreeEnergy.Restraint'.

Here is bound/restraint/input/somd.cfg file.

### For information on options and defaults, run `somd-freenrg --help-config`

### Integrator - ncycles modified as required by a3fe ###
nmoves = 25000
ncycles = 60
timestep = 4 * femtosecond
constraint = hbonds
hydrogen mass repartitioning factor = 3.0
integrator = langevinmiddle
inverse friction = 1 * picosecond
temperature = 25 * celsius
# Thermostatting already handled by langevin integrator
thermostat = False

### Barostat ###
barostat = True
pressure = 1 * atm

### Non-Bonded Interactions ###
cutoff type = PME
cutoff distance = 10 * angstrom
reaction field dielectric = 78.3

### Trajectory ###
buffered coordinates frequency = 5000
center solute = True

### Minimisation ###
minimise = True

### Alchemistry - restraints added by a3fe ###
perturbed residue number = 1
energy frequency = 200

perturbed_residue number = 1
use boresch restraints = True
turn on receptor-ligand restraints mode = True
charge difference = 0
lambda array = 0.0, 0.125, 0.25, 0.375, 0.5, 1.0

param_log_restrain.zip

@Roy-Haolin-Du
Copy link
Contributor

Hi, thanks so much for your inofrmation.

I guess you resubmitted the run.
But in your first run, you had already created discharge, vanish, and restrain directories under bound. When rerun, it would load again, it detects these existing files and doesn’t recreate them. However, the boresch restrain file must be in a specific format, so it throws an error.

So what you need to do before rerunning is delete Calculation.log and Calculation.pkl. Also, delete bound/discharge, vanish, restrain, Leg.log, Leg.pkl, and virtual_quee.log and free/discharge, vanish, Leg.log, Leg.pkl, and virtual_quee.log" Only Only keep bound/ensemble_quil_12345, free/ensemble_quil_12345, and the input folder.😊

Give it a try and let me know if the progress is going well.

Cheers,

@Roy-Haolin-Du
Copy link
Contributor

By the way, for you somd.cfg

### Non-Bonded Interactions ###
cutoff type = PME
cutoff distance = 10 * angstrom
reaction field dielectric = 78.3

when using PME, it's best to remove reaction field dielectric = 78.3 under the ### Non-Bonded Interactions ### section.

Thanks~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants