Closed mayank-kohli closed 1 month ago
Are you able to share the input that triggers the exception? It's impossible for us to debug without more information. (There are unit tests for the restraint search that pass during the CI.) Also, in future, could you please enter the requested information such as the operating system and version numbers for Sire and BioSimSpace.
From the error it appears that MDAnalysis is simply unable to read the trajectory files generated by the GROMACS process, i.e.:
/output/restraint_search/gromacs.xtc
and /output/restraint_search/gromacs.tpr
. Are you able to share these files so that we can investigate what went wrong? Do they load with other trajectory parsers, e.g. MDTraj, or Sire?
When I used the earlier versions of Sire and BioSimSpace in 2023 for the same protein and ligand complex, I did not encounter this error. However, with the current versions, I am now experiencing this issue.
Version in use: Biosimspace; 2024.2.0 Sire: 2024.2.0 Ubuntu 20.04.6 LTS
please find the files
Thanks, this is really helpful. Here's the error from MDAnalysis:
In [1]: import MDAnalysis
In [2]: u = MDAnalysis.Universe("gromacs.tpr", "gromacs1.xtc")
---------------------------------------------------------------------------
NotImplementedError Traceback (most recent call last)
File ~/.conda/envs/openbiosim/lib/python3.12/site-packages/MDAnalysis/core/universe.py:110, in _topology_from_file_like(topology_file, topology_format, **kwargs)
109 with parser(topology_file) as p:
--> 110 topology = p.parse(**kwargs)
111 except (IOError, OSError) as err:
112 # There are 2 kinds of errors that might be raised here:
113 # one because the file isn't present
114 # or the permissions are bad, second when the parser fails
File ~/.conda/envs/openbiosim/lib/python3.12/site-packages/MDAnalysis/topology/TPRParser.py:212, in TPRParser.parse(self, tpr_resid_from_one, **kwargs)
211 try:
--> 212 th = tpr_utils.read_tpxheader(data) # tpxheader
213 except (EOFError, ValueError):
File ~/.conda/envs/openbiosim/lib/python3.12/site-packages/MDAnalysis/topology/tpr/utils.py:233, in read_tpxheader(data)
232 fileVersion = data.unpack_int() # version of tpx file
--> 233 fileVersion_err(fileVersion)
235 # This is for backward compatibility with development version 77-79 where
236 # the tag was, mistakenly, placed before the generation.
237 # These versions are development versions between the 4.5 and 4.6 series.
File ~/.conda/envs/openbiosim/lib/python3.12/site-packages/MDAnalysis/topology/tpr/utils.py:208, in fileVersion_err(fver)
207 if fver not in setting.SUPPORTED_VERSIONS:
--> 208 raise NotImplementedError(
209 f"Your tpx version is {fver}, which this parser does not support, yet "
210 )
NotImplementedError: Your tpx version is 133, which this parser does not support, yet
During handling of the above exception, another exception occurred:
ValueError Traceback (most recent call last)
Cell In[2], line 1
----> 1 u = MDAnalysis.Universe("gromacs.tpr", "gromacs1.xtc")
File ~/.conda/envs/openbiosim/lib/python3.12/site-packages/MDAnalysis/core/universe.py:356, in Universe.__init__(self, topology, all_coordinates, format, topology_format, transformations, guess_bonds, vdwradii, fudge_factor, lower_bound, in_memory, in_memory_step, *coordinates, **kwargs)
354 if not isinstance(topology, Topology) and not topology is None:
355 self.filename = _check_file_like(topology)
--> 356 topology = _topology_from_file_like(self.filename,
357 topology_format=topology_format,
358 **kwargs)
360 if topology is not None:
361 self._topology = topology
File ~/.conda/envs/openbiosim/lib/python3.12/site-packages/MDAnalysis/core/universe.py:125, in _topology_from_file_like(topology_file, topology_format, **kwargs)
121 raise IOError("Failed to load from the topology file {0}"
122 " with parser {1}.\n"
123 "Error: {2}".format(topology_file, parser, err))
124 except (ValueError, NotImplementedError) as err:
--> 125 raise ValueError(
126 "Failed to construct topology from file {0}"
127 " with parser {1}.\n"
128 "Error: {2}".format(topology_file, parser, err))
129 return topology
ValueError: Failed to construct topology from file gromacs.tpr with parser <class 'MDAnalysis.topology.TPRParser.TPRParser'>.
Error: Your tpx version is 133, which this parser does not support, yet
It looks like this is an MDAnalysis issue, i.e. it doesn't support the TPR format from the version of GROMACS that you have installed. Could you try an older version of GROMACS to see if that fixes things. Assuming the file format hasn't changed significantly, we might just be able to patch MDAnalysis to override the version check.
Just to say that I removed the version check in MDAnalysis and it loads just fine, so that should be an option if you can't get a working environment with an older version of GROMACS.
Ohh, I have recently updated gromacs to version 2024, along with the biosimspace and sire that explains everything, thank you for the clarification. I ll try it with an older version of gromacs.
No problem. I'll make a note to expose more exception messages from the trajectory interface since the issue was quite clear once I could see the traceback.
Hello,
I have been getting the following error during restraint search step:
_warnings.warn( ╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮ │ /simulation/fep_abfe/sub.py:47 in │
│ │
│ 44 # Run the simulation │
│ 45 restraint_search.start() │
│ 46 # Wait for the simulation to finish (block=True), then analyse the simulation to find th │
│ ❱ 47 restraint = restraint_search.analyse(method='BSS', block=True) │
│ 48 │
│ 49 type(restraint) │
│ 50 restraint.getCorrection() │
│ │
│ /anaconda3/envs/bsstutorials2/lib/python3.10/site-packages/BioSimSpace/Sandpit/Exs │
│ cientia/FreeEnergy/_restraint_search.py:395 in _analyse │
│ │
│ 392 │ │ │
│ 393 │ │ # Return the result of calling the staticmethod, passing in the working │
│ 394 │ │ # directory of this object. │
│ ❱ 395 │ │ return RestraintSearch.analyse( │
│ 396 │ │ │ str(self._work_dir), │
│ 397 │ │ │ self._system, │
│ 398 │ │ │ self._process.getTrajectory(), │
│ │
│ /anaconda3/envs/bsstutorials2/lib/python3.10/site-packages/BioSimSpace/Sandpit/Exs │
│ cientia/FreeEnergy/_restraint_search.py:673 in analyse │
│ │
│ 670 │ │ │ ligand_selection_str += append_to_ligand_selection │
│ 671 │ │ │
│ 672 │ │ if restraint_type.lower() == "boresch": │
│ ❱ 673 │ │ │ return RestraintSearch._boresch_restraint( │
│ 674 │ │ │ │ u, │
│ 675 │ │ │ │ system, │
│ 676 │ │ │ │ temperature, │
│ │
│ anaconda3/envs/bsstutorials2/lib/python3.10/site-packages/BioSimSpace/Sandpit/Exs │
│ cientia/FreeEnergy/_restraint_search.py:794 in _boresch_restraint │
│ │
│ 791 │ │ │ │ ) │
│ 792 │ │ │
│ 793 │ │ elif method == "BSS": │
│ ❱ 794 │ │ │ return RestraintSearch._boresch_restraint_BSS( │
│ 795 │ │ │ │ u, │
│ 796 │ │ │ │ system, │
│ 797 │ │ │ │ temperature, │
│ │
│ anaconda3/envs/bsstutorials2/lib/python3.10/site-packages/BioSimSpace/Sandpit/Exs │
│ cientia/FreeEnergy/_restraint_search.py:1734 in _boresch_restraint_BSS │
│ │
│ 1731 │ │ │ return restraint │
│ 1732 │ │ │
│ 1733 │ │ # Find pairs with lowest SD │
│ ❱ 1734 │ │ pairs_ordered_sd = RestraintSearch._findOrderedPairs( │
│ 1735 │ │ │ u, ligand_selection_str, receptor_selection_str, cutoff │
│ 1736 │ │ ) │
│ 1737 │
│ │
│ /anaconda3/envs/bsstutorials2/lib/python3.10/site-packages/BioSimSpace/Sandpit/Exs │
│ cientia/FreeEnergy/_restraint_search.py:1011 in _findOrderedPairs │
│ │
│ 1008 │ │ │ the trajectory. │
│ 1009 │ │ """ │
│ 1010 │ │ │
│ ❱ 1011 │ │ lig_selection = u.select_atoms(ligand_selection_str) │
│ 1012 │ │ pair_variance_dict = {} │
│ 1013 │ │ │
│ 1014 │ │ # Get all receptor atoms within specified distance of cutoff │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
AttributeError: 'NoneType' object has no attribute 'select_atoms'
Thank you