Skip to content

[Bug]: Dihedrals error for more than one molecule #338

@PuridechB

Description

@PuridechB

Bug Report

Issue with identifying dihedrals when the trajectory contains more than one molecule.
Index error for protein Keap1 with peptide.
The protein alone and the peptide alone were successfully calculated in the entropy calculation, but the calculation did not work when both were together.


To Reproduce

config.yaml file

YAML configuration

run1:
top_traj_file: ["strip.parm7", "nowat_2500frames.nc"]
selection_string: 'all'
start: 0
end: 1
step: 100


### Actual output
<!-- Paste the output, logs, or error messages here -->

Fatal error during entropy calculation                            
                             ╭────────────── Traceback (most recent call last) ───────────────╮
                             │ /home/puridech/miniconda3/envs/codeentropy/lib/python3.14/site │
                             │ -packages/CodeEntropy/config/runtime.py:290 in                 │
                             │ run_entropy_workflow                                           │
                             │                                                                │
                             │   287 │   │   │   │   │   dihedral_analysis=dihedral_analysis, │
                             │   288 │   │   │   │   │   universe_operations=universe_operati │
                             │   289 │   │   │   │   )                                        │
                             │ ❱ 290 │   │   │   │   entropy_manager.execute()                │
                             │   291 │   │   │                                                │
                             │   292 │   │   │   self._logging_config.export_console()        │
                             │   293                                                          │
                             │                                                                │
                             │ /home/puridech/miniconda3/envs/codeentropy/lib/python3.14/site │
                             │ -packages/CodeEntropy/entropy/workflow.py:136 in execute       │
                             │                                                                │
                             │   133 │   │   )                                                │
                             │   134 │   │                                                    │
                             │   135 │   │   with self._reporter.progress(transient=False) as │
                             │ ❱ 136 │   │   │   self._run_level_dag(shared_data, progress=p) │
                             │   137 │   │   │   self._run_entropy_graph(shared_data, progres │
                             │   138 │   │                                                    │
                             │   139 │   │   self._finalize_molecule_results()                │
                             │                                                                │
                             │ /home/puridech/miniconda3/envs/codeentropy/lib/python3.14/site │
                             │ -packages/CodeEntropy/entropy/workflow.py:185 in               │
                             │ _run_level_dag                                                 │
                             │                                                                │
                             │   182 │   │   │   shared_data: Shared data dict that will be m │
                             │   183 │   │   │   progress: Optional progress sink provided by │
                             │   184 │   │   """                                              │
                             │ ❱ 185 │   │   LevelDAG(self._universe_operations).build().exec │
                             │   186 │   │   │   shared_data, progress=progress               │
                             │   187 │   │   )                                                │
                             │   188                                                          │
                             │                                                                │
                             │ /home/puridech/miniconda3/envs/codeentropy/lib/python3.14/site │
                             │ -packages/CodeEntropy/levels/level_dag.py:113 in execute       │
                             │                                                                │
                             │   110 │   │   │   The same shared_data mapping passed in, afte │
                             │   111 │   │   """                                              │
                             │   112 │   │   shared_data.setdefault("axes_manager", AxesCalcu │
                             │ ❱ 113 │   │   self._run_static_stage(shared_data, progress=pro │
                             │   114 │   │   self._run_frame_stage(shared_data, progress=prog │
                             │   115 │   │   return shared_data                               │
                             │   116                                                          │
                             │                                                                │
                             │ /home/puridech/miniconda3/envs/codeentropy/lib/python3.14/site │
                             │ -packages/CodeEntropy/levels/level_dag.py:133 in               │
                             │ _run_static_stage                                              │
                             │                                                                │
                             │   130 │   │   │   node = self._static_nodes[node_name]         │
                             │   131 │   │   │   if progress is not None:                     │
                             │   132 │   │   │   │   try:                                     │
                             │ ❱ 133 │   │   │   │   │   node.run(shared_data, progress=progr │
                             │   134 │   │   │   │   │   continue                             │
                             │   135 │   │   │   │   except TypeError:                        │
                             │   136 │   │   │   │   │   pass                                 │
                             │                                                                │
                             │ /home/puridech/miniconda3/envs/codeentropy/lib/python3.14/site │
                             │ -packages/CodeEntropy/levels/nodes/conformations.py:82 in run  │
                             │                                                                │
                             │    79 │   │   bin_width = int(shared_data["args"].bin_width)   │
                             │    80 │   │                                                    │
                             │    81 │   │   states_ua, states_res, flexible_ua, flexible_res │
                             │ ❱  82 │   │   │   self._dihedral_analysis.build_conformational │
                             │    83 │   │   │   │   data_container=u,                        │
                             │    84 │   │   │   │   levels=levels,                           │
                             │    85 │   │   │   │   groups=groups,                           │
                             │                                                                │
                             │ /home/puridech/miniconda3/envs/codeentropy/lib/python3.14/site │
                             │ -packages/CodeEntropy/levels/dihedrals.py:113 in               │
                             │ build_conformational_states                                    │
                             │                                                                │
                             │   110 │   │   │   if progress is not None and task is not None │
                             │   111 │   │   │   │   progress.update(task, title=f"Group {gro │
                             │   112 │   │   │                                                │
                             │ ❱ 113 │   │   │   peaks_ua, peaks_res = self._identify_peaks(  │
                             │   114 │   │   │   │   data_container=data_container,           │
                             │   115 │   │   │   │   molecules=molecules,                     │
                             │   116 │   │   │   │   bin_width=bin_width,                     │
                             │                                                                │
                             │ /home/puridech/miniconda3/envs/codeentropy/lib/python3.14/site │
                             │ -packages/CodeEntropy/levels/dihedrals.py:238 in               │
                             │ _identify_peaks                                                │
                             │                                                                │
                             │   235 │   │   │   for level in level_list:                     │
                             │   236 │   │   │   │   if level == "united_atom":               │
                             │   237 │   │   │   │   │   for res_id in range(num_residues):   │
                             │ ❱ 238 │   │   │   │   │   │   heavy_res = self._select_heavy_r │
                             │   239 │   │   │   │   │   │   dihedrals = self._get_dihedrals( │
                             │   240 │   │   │   │   │   │   num_dihedrals_ua[res_id] = len(d │
                             │   241 │   │   │   │   │   │   if num_dihedrals_ua[res_id] == 0 │
                             │                                                                │
                             │ /home/puridech/miniconda3/envs/codeentropy/lib/python3.14/site │
                             │ -packages/CodeEntropy/levels/dihedrals.py:153 in               │
                             │ _select_heavy_residue                                          │
                             │                                                                │
                             │   150 │   │   Returns:                                         │
                             │   151 │   │   │   AtomGroup containing heavy atoms in the resi │
                             │   152 │   │   """                                              │
                             │ ❱ 153 │   │   selection1 = mol.residues[res_id].atoms.indices[ │
                             │   154 │   │   selection2 = mol.residues[res_id].atoms.indices[ │
                             │   155 │   │                                                    │
                             │   156 │   │   res_container = self._universe_operations.select │
                             │                                                                │
                             │ /home/puridech/miniconda3/envs/codeentropy/lib/python3.14/site │
                             │ -packages/MDAnalysis/core/groups.py:659 in __getitem__         │
                             │                                                                │
                             │    656 │   │   if item is None:                                │
                             │    657 │   │   │   raise TypeError("None cannot be used to ind │
                             │    658 │   │   elif isinstance(item, numbers.Integral):        │
                             │ ❱  659 │   │   │   return self.level.singular(self.ix[item], s │
                             │    660 │   │   else:                                           │
                             │    661 │   │   │   if isinstance(item, list) and item:  # chec │
                             │    662 │   │   │   │   # hack to make lists into numpy arrays  │
                             ╰────────────────────────────────────────────────────────────────╯
                             IndexError: index 8 is out of bounds for axis 0 with size 8 

Expected output


Environment and Versions

  • Operating System: Ubuntu 22.04.5 LTS
  • CodeEntropy Version: 2.2.2
  • Python Version:
  • Package list:

packages.txt

Screenshots or Logs

mdanalysis.log
program.log


Additional Context

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions