michellab / BioSimSpace

Code and resources for the EPSRC BioSimSpace project.
https://biosimspace.org
GNU General Public License v3.0
77 stars 19 forks source link

Unable to import BioSimSpace after mamba installation #410

Closed akalpokas closed 1 year ago

akalpokas commented 1 year ago

Hello,

After installing biosimspace using mamba I am unable to import it in python.

I have installed it using:

mamba create -n biosimspace23 -c conda-forge -c michellab biosimspace

I tried importing it using:

import BioSimSpace as BSS

Which gives:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[1], line 1
----> 1 import BioSimSpace as BSS

File ~/miniconda3/envs/biosimspace23/lib/python3.9/site-packages/BioSimSpace/__init__.py:209
    206     del _shlex
    207     del _subprocess
--> 209 from . import Align
    210 from . import Box
    211 from . import FreeEnergy

File ~/miniconda3/envs/biosimspace23/lib/python3.9/site-packages/BioSimSpace/Align/__init__.py:43
      1 ######################################################################
      2 # BioSimSpace: Making biomolecular simulation a breeze!
      3 #
   (...)
     23 # https://github.com/MobleyLab/Lomap, which is released under the MIT
     24 # license.
     26 """
     27 .. currentmodule:: BioSimSpace.Align
     28
   (...)
     40     viewMapping
     41 """
---> 43 from ._align import *

File ~/miniconda3/envs/biosimspace23/lib/python3.9/site-packages/BioSimSpace/Align/_align.py:79
     77 from .._Exceptions import AlignmentError as _AlignmentError
     78 from .._Exceptions import MissingSoftwareError as _MissingSoftwareError
---> 79 from .._SireWrappers import Molecule as _Molecule
     81 from .. import IO as _IO
     82 from .. import Units as _Units

File ~/miniconda3/envs/biosimspace23/lib/python3.9/site-packages/BioSimSpace/_SireWrappers/__init__.py:40
      1 ######################################################################
      2 # BioSimSpace: Making biomolecular simulation a breeze!
      3 #
   (...)
     19 # along with BioSimSpace. If not, see <http://www.gnu.org/licenses/>.
     20 #####################################################################
     22 """
     23 .. currentmodule:: BioSimSpace._SireWrappers
     24
   (...)
     37     SearchResult
     38 """
---> 40 from ._atom import *
     41 from ._bond import *
     42 from ._molecule import *

File ~/miniconda3/envs/biosimspace23/lib/python3.9/site-packages/BioSimSpace/_SireWrappers/_atom.py:34
     30 __all__ = ["Atom"]
     32 from sire.legacy import Mol as _SireMol
---> 34 from ..Types import Coordinate as _Coordinate
     35 from ..Types import Length as _Length
     36 from ._sire_wrapper import SireWrapper as _SireWrapper

File ~/miniconda3/envs/biosimspace23/lib/python3.9/site-packages/BioSimSpace/Types/__init__.py:44
      1 ######################################################################
      2 # BioSimSpace: Making biomolecular simulation a breeze!
      3 #
   (...)
     19 # along with BioSimSpace. If not, see <http://www.gnu.org/licenses/>.
     20 #####################################################################
     22 """
     23 .. currentmodule:: BioSimSpace.Types
     24
   (...)
     41     Volume
     42 """
---> 44 from ._angle import *
     45 from ._area import *
     46 from ._charge import *

File ~/miniconda3/envs/biosimspace23/lib/python3.9/site-packages/BioSimSpace/Types/_angle.py:35
     31 from sire import units as _SireUnits
     33 from ._type import Type as _Type
---> 35 class Angle(_Type):
     36     """An angle type."""
     38     # A list of the supported Sire unit names.

File ~/miniconda3/envs/biosimspace23/lib/python3.9/site-packages/BioSimSpace/Types/_angle.py:42, in Angle()
     39 _sire_units = ["radian", "degree"]
     41 # Dictionary of allowed units.
---> 42 _supported_units = { "RADIAN" : _SireUnits.radian,
     43                      "DEGREE" : _SireUnits.degree }
     45 # Map unit abbreviations to the full name.
     46 _abbreviations = { "R" : "RADIAN",
     47                    "D" : "DEGREE" }

AttributeError: module 'sire.units' has no attribute 'radian'

BioSimSpace version: 2023.0.0 Sire version: 2023.0.3 (011b6f6edb831eeb5447b6d4e2a015123a99b2a2/GitHub/2023-01-10T10:14:37+00:00 | UNCLEAN)

I have tried this by installing the development version too using:

mamba create -n biosimspace23-dev -c conda-forge -c michellab/label/dev biosimspace

Which gives the same error when importing as well. If I force mamba to install BioSimSpace version 2022.2.1 then it works.

I hope this helps, thanks.

lohedges commented 1 year ago

Yes, it looks like we've incorrectly specified the Sire version range for our 2023 pre-release version of BioSimSpace. You should also be able to fix things by specifying the Sire version. For example, I think the 2023.0.2 development version of Sire should work with the latest devel conda package.

mamba create -n biosimspace23-dev -c conda-forge -c michellab/label/dev sire=2023.0.2 biosimspace
akalpokas commented 1 year ago

Yup, that works. Thanks for your help!

lohedges commented 1 year ago

No problem, thanks for reporting. Once the full 2023.1.0 release is available I'll delete the pre-release packages. This will avoid other people running into the same issue in future.

RiesBen commented 1 year ago

Hej, fyi: I have the same problem with your conda-forge version :(

lohedges commented 1 year ago

Thanks, we don't have a package on conda-forge. Does the solution posted above not work for you?

RiesBen commented 1 year ago

ah! my bad! but yes the the fix works (I was installing it like this: conda install -c conda-forge biosimspace - that's where my confusion came from)

velocirraptor23 commented 1 year ago

Hi, I have installed biosimspace on this way. However when I am analyzing the relative free-energy value it gives an error.

AnalysisError Traceback (most recent call last) Cell In[12], line 1 ----> 1 pmf_free, overlap_matrix_free = BSS.FreeEnergy.Relative.analyse(f'o_xylene_benzene/free') 2 pmf_bound, overlap_matrix_bound = BSS.FreeEnergy.Relative.analyse(f'o_xylene_benzene/bound') 3 freenrg_rel = BSS.FreeEnergy.Relative.difference(pmf_bound, pmf_free)

File /cluster/ddu/cmmartinez001/miniconda3/envs/biosimspace-dev/lib/python3.9/site-packages/BioSimSpace/FreeEnergy/_relative.py:431, in Relative.analyse(work_dir) 429 # SOMD. 430 if len(data) > 0: --> 431 return Relative._analyse_somd(work_dir) 433 # Now check for GROMACS output. 434 else: 435 data = _glob(workdir + "/lambda*/gromacs.xvg")

File /cluster/ddu/cmmartinez001/miniconda3/envs/biosimspace-dev/lib/python3.9/site-packages/BioSimSpace/FreeEnergy/_relative.py:605, in Relative._analyse_somd(work_dir) 598 proc = _subprocess.run( 599 _Utils.command_split(command), 600 shell=False, 601 stdout=_subprocess.PIPE, 602 stderr=_subprocess.PIPE, 603 ) 604 if proc.returncode != 0: --> 605 raise _AnalysisError("SOMD free-energy analysis failed!") 607 # Re-run without subsampling if the subsampling has resulted in less than 50 samples. 608 with open("%s/mbar.txt" % work_dir) as file:

AnalysisError: SOMD free-energy analysis failed!

In a previosu version it worked without any problem. Not sure if the code has been updated. Thanks

Cesar

lohedges commented 1 year ago

Thanks, I'll try to reproduce this later and get back to you.

lohedges commented 1 year ago

Hmmm, it's working for me with some existing ethane/methanol solvation free energy data. Is it possible to share the data for which it's failing. You could also edit the file shown in the error message above to print the standard output and error, e.g.:

print(proc.stdout)
print(proc.stderr)

(Do the above after adding text=True to the subprocess.run parameters.)

lohedges commented 1 year ago

For reference, I did find an issue with our GROMACS analysis which resulted from the new (well, not so new) way we split command-line arguments for subprocess. This means that we now need to expand the glob for xvg files prior to running gmx bar. This is now fixed. For the few cases I've tested, SOMD analysis still appears to work just fine.

lohedges commented 1 year ago

Also, when we figure out what the actual problem is I'll move it to a new issue thread, since it appears to have nothing to do with the original question. In future, please open a new issue when the query us unrelated. It makes book-keeping much easier.

Cheers.

lohedges commented 1 year ago

I've tested using some example output from here (same system as you are looking at) and it still works for me.