
import sys
from iotbx import pdb as pdb
from mmtbx import model as mdl
from mmtbx.command_line import reduce2
# Load the mmcif file
model_filename = sys.argv[1] # Get the model file
name from the command line
protein = pdb.input(file_name=model_filename) # Load the model
model = mdl.manager(model_input=protein) # Create the model manager
#trim hidrogen atoms and solvent
model_no_H = model.remove_hydrogens() # Remove hydrogen atoms
model_no_H_no_solvent = model_no_H.remove_solvent() # Remove solvent
# add hydrogens using reduce in nuclear position
model_clean = reduce2(model = model_no_H_no_solvent, mode = 'nuclear') #
Add hydrogens
hierarchy = model_clean.get_hierarchy().expand_to_p1() # Get the
hierarchy
Il giorno gio 13 feb 2025 alle ore 23:08 Pavel Afonine
Hi Enrico,
this works for me:
phenix.fetch_pdb 2gim
phenix.model_statistics 2gim.cif
mmtbx.reduce2 2gim.cif
Something must be lost in communication. Can you provide complete set of steps that lead to the crash?
Pavel On 2/13/25 13:55, Enrico Ravera wrote:
Dear Pavel, many thanks. It ran until the reduce2 part, where it gives the following error: File "/home/ravera/miniconda3/envs/cctbx/lib/python3.13/site-packages/mmtbx/monomer_library/pdb_interpretation.py", line 1572, in resolve_unexpected mod_mod_id = mod_dict["NH1NOTPRO"] the file i am parsing is https://files.rcsb.org/view/2GIM.cif
Any clues?
Cheers,
E.
Il giorno gio 13 feb 2025 alle ore 20:42 Pavel Afonine
ha scritto: Enrico,
here are the steps (check for typos as I was typing all the below from memory):
1) read in a mmcif file (which I think I can do following the tutorial);
pdb_inp = iotbx.pdb.input(file_name = "4znn.pdb") # can be PDB or mmCIF model = mmtbx.model.manager(model_input = pdb_inp)
2) trim the solvent and hydrogen atoms (probably I can do it following the tutorial);
model_no_H = model.remove_hydrogens()
model_no_water = model.remove_solvent()
though better:
selection = model.selection("not (element H or element D or water)")
model_trimmed = model.select(selection)
3) run reduce2 to get hydrogens in the nuclear positions (no clue);
Run mmtbx.reduce OR mmtbx.reduce2 OR mmtbx.hydrogenate
to add H. I have no idea about the difference between the three commands (perhaps just the mess that someone has to finally get brave enough to clean!), but all three are supposed to add H.
Also, you should be able to access the above calls programmatically, at Python script level, not running in the CL.
4) get the full content of the unit cell (no clue).
Do you mean expand to P1 (if original symmetry is not P1)? If so, then
hierarchy = model.get_hierarchy().expand_to_p1()
Happy to answer questions! Pavel