MDAnalysis / mdanalysis

MDAnalysis is a Python library to analyze molecular dynamics simulations.
https://mdanalysis.org
Other
1.3k stars 647 forks source link

Bio.alphabet has been removed from biopython #2952

Closed Hendejac closed 4 years ago

Hendejac commented 4 years ago

Expected behavior

The expected behavior is to import mdanalysis, but there seems to be a problem with Bio.alphabet. Also, when I conda install MDAnalysis it has some problems solving the environment.

Actual behavior and code to reproduce the behavior

The actual behavior I get when I try to conda install MDAnalysis is as follows.

''' conda install mdanalysis Collecting package metadata (current_repodata.json): done Solving environment: failed with initial frozen solve. Retrying with flexible solve. Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source. Collecting package metadata (repodata.json): done Solving environment: done

environment location: /home/rotation/jackh/software/anaconda3

added / updated specs:

The following NEW packages will be INSTALLED:

biopython conda-forge/linux-64::biopython-1.78-py37h8f50634_0 cftime conda-forge/linux-64::cftime-1.2.1-py37h03ebfcd_0 griddataformats conda-forge/noarch::griddataformats-0.5.0-py_0 gsd conda-forge/linux-64::gsd-2.2.0-py37h161383b_0 hdf4 conda-forge/linux-64::hdf4-4.2.13-0 libnetcdf pkgs/main/linux-64::libnetcdf-4.7.3-hb80b6cc_0 mdanalysis conda-forge/linux-64::mdanalysis-0.20.1-py37he1b5a44_0 mmtf-python conda-forge/noarch::mmtf-python-1.1.2-py_0 netcdf4 pkgs/main/linux-64::netcdf4-1.5.3-py37hbf33ddf_0

...

''' After the installation I open python and import MDAnalsysis.

Then I get the following error message. I think the issue just has to do with the updated version of biopython which was updated about 5 days ago.


import MDAnalysis

Python 3.7.6 (default, Jan  8 2020, 19:59:22)
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import MDAnalysis
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/rotation/jackh/software/anaconda3/lib/python3.7/site-packages/MDAnalysis/__init__.py", line 184, in <module>
    from .lib import log
  File "/home/rotation/jackh/software/anaconda3/lib/python3.7/site-packages/MDAnalysis/lib/__init__.py", line 40, in <module>
    from . import NeighborSearch
  File "/home/rotation/jackh/software/anaconda3/lib/python3.7/site-packages/MDAnalysis/lib/NeighborSearch.py", line 37, in <module>
    from MDAnalysis.core.groups import AtomGroup, Atom
  File "/home/rotation/jackh/software/anaconda3/lib/python3.7/site-packages/MDAnalysis/core/__init__.py", line 465, in <module>
    from . import AtomGroup
  File "/home/rotation/jackh/software/anaconda3/lib/python3.7/site-packages/MDAnalysis/core/AtomGroup.py", line 28, in <module>
    from . import universe
  File "/home/rotation/jackh/software/anaconda3/lib/python3.7/site-packages/MDAnalysis/core/universe.py", line 128, in <module>
    from .topology import Topology
  File "/home/rotation/jackh/software/anaconda3/lib/python3.7/site-packages/MDAnalysis/core/topology.py", line 64, in <module>
    from .topologyattrs import Atomindices, Resindices, Segindices
  File "/home/rotation/jackh/software/anaconda3/lib/python3.7/site-packages/MDAnalysis/core/topologyattrs.py", line 40, in <module>
    import Bio.Alphabet
  File "/home/rotation/jackh/software/anaconda3/lib/python3.7/site-packages/Bio/Alphabet/__init__.py", line 21, in <module>
    "Bio.Alphabet has been removed from Biopython. In many cases, the alphabet can simply be ignored and removed from scripts. In a few cases, you may need to specify the ``molecule_type`` as an annotation on a SeqRecord for your script to work correctly. Please see https://biopython.org/wiki/Alphabet for more information."
ImportError: Bio.Alphabet has been removed from Biopython. In many cases, the alphabet can simply be ignored and removed from scripts. In a few cases, you may need to specify the ``molecule_type`` as an annotation on a SeqRecord for your script to work correctly. Please see https://biopython.org/wiki/Alphabet for more information.

'''

## Current version of MDAnalysis ##

python version 3.7.6
MDAnalysis Version: v1.0.0
RMeli commented 4 years ago

Hi @Hendejac , thank you for reporting the issue. This problem was addressed in #2457 and therefore should be solved in 1.0.0.

From your logs, it seems that conda is still trying to install 0.20.1:

 mdanalysis conda-forge/linux-64::mdanalysis-0.20.1-py37he1b5a44_0

Can you try to install MDAnalysis as follows?

 conda install -c conda-forge mdanalysis=1.0.0
Hendejac commented 4 years ago

Sorry, that's completely my oversight. I have updated MDA to 1.0.0 and it appears to be working perfectly now, thank you!

Rulong-Ma commented 1 year ago

Hi @RMeli, I have same issue about Bio.alphabet. However, the command did not work on my computer ( conda install -c conda-forge mdanalysis=1.0.0). Could you help me to sovle this issue?

Here is the error. In [2]: import MDAnalysis

ImportError Traceback (most recent call last)

in ----> 1 import MDAnalysis ~/anaconda3/lib/python3.7/site-packages/MDAnalysis/__init__.py in 196 197 # Bring some often used objects into the current namespace --> 198 from .core.universe import Universe, as_Universe, Merge 199 from .core.groups import AtomGroup, ResidueGroup, SegmentGroup 200 from .coordinates.core import writer as Writer ~/anaconda3/lib/python3.7/site-packages/MDAnalysis/core/__init__.py in 463 from . import groups 464 from . import selection --> 465 from . import AtomGroup ~/anaconda3/lib/python3.7/site-packages/MDAnalysis/core/AtomGroup.py in 26 from .groups import (Atom, AtomGroup, Residue, ResidueGroup, Segment, 27 SegmentGroup) ---> 28 from . import universe 29 30 ~/anaconda3/lib/python3.7/site-packages/MDAnalysis/core/universe.py in 126 Atom, Residue, Segment, 127 AtomGroup, ResidueGroup, SegmentGroup) --> 128 from .topology import Topology 129 from .topologyattrs import AtomAttr, ResidueAttr, SegmentAttr 130 ~/anaconda3/lib/python3.7/site-packages/MDAnalysis/core/topology.py in 62 import numpy as np 63 ---> 64 from .topologyattrs import Atomindices, Resindices, Segindices 65 from ..exceptions import NoDataError 66 ~/anaconda3/lib/python3.7/site-packages/MDAnalysis/core/topologyattrs.py in 38 import Bio.Seq 39 import Bio.SeqRecord ---> 40 import Bio.Alphabet 41 from collections import defaultdict 42 import copy ~/anaconda3/lib/python3.7/site-packages/Bio/Alphabet/__init__.py in 19 20 raise ImportError( ---> 21 "Bio.Alphabet has been removed from Biopython. In many cases, the alphabet can simply be ignored and removed from scripts. In a few cases, you may need to specify the ``molecule_type`` as an annotation on a SeqRecord for your script to work correctly. Please see https://biopython.org/wiki/Alphabet for more information." 22 ) ImportError: Bio.Alphabet has been removed from Biopython. In many cases, the alphabet can simply be ignored and removed from scripts. In a few cases, you may need to specify the ``molecule_type`` as an annotation on a SeqRecord for your script to work correctly. Please see https://biopython.org/wiki/Alphabet for more information. The command ran more than 12 hours, but it did not solve the issue. ![mdanalysis](https://github.com/MDAnalysis/mdanalysis/assets/48371827/63c8bf0d-969f-49d9-8e82-4fea95548221)
IAlibay commented 1 year ago

@Rulong-Ma MDAnalysis 1.0.0 is now very very old, is there any reason to use that version over a much newer one?

Rulong-Ma commented 1 year ago

@IAlibay, Here is a clear discription of my issue. MDAnalysis worked well on my computer half-year ago. Recently, when I wanted to use MDAnalysis again, the issue happened (Bio.alphabet has been removed from biopython ). I found the solution here ( conda install -c conda-forge mdanalysis=1.0.0). However, this solution can not solve the issue. Now, according to the instrcution ( https://userguide.mdanalysis.org/stable/installation.html), I have install the MDAnalysis again ( conda install -c conda-forge mdanalysis ). However, I still found the same issue . I do not know how to fix it. could you help me? (I unpdated python in the past several months )

MDA_instal

Here is the error.

Python 3.7.6 (default, Jan 8 2020, 19:59:22) Type 'copyright', 'credits' or 'license' for more information IPython 7.12.0 -- An enhanced Interactive Python. Type '?' for help. Using matplotlib backend: Qt5Agg

In [1]: import MDAnalysis as mda

ImportError Traceback (most recent call last)

in ----> 1 import MDAnalysis as mda ~/anaconda3/lib/python3.7/site-packages/MDAnalysis/__init__.py in 182 ) 183 --> 184 from .lib import log 185 from .lib.log import start_logging, stop_logging 186 ~/anaconda3/lib/python3.7/site-packages/MDAnalysis/lib/__init__.py in 38 from . import mdamath 39 from . import distances # distances relies on mdamath ---> 40 from . import NeighborSearch 41 from . import formats 42 from . import pkdtree ~/anaconda3/lib/python3.7/site-packages/MDAnalysis/lib/NeighborSearch.py in 35 from MDAnalysis.lib.util import unique_int_1d 36 ---> 37 from MDAnalysis.core.groups import AtomGroup, Atom 38 39 ~/anaconda3/lib/python3.7/site-packages/MDAnalysis/core/__init__.py in 463 from . import groups 464 from . import selection --> 465 from . import AtomGroup ~/anaconda3/lib/python3.7/site-packages/MDAnalysis/core/AtomGroup.py in 26 from .groups import (Atom, AtomGroup, Residue, ResidueGroup, Segment, 27 SegmentGroup) ---> 28 from . import universe 29 30 ~/anaconda3/lib/python3.7/site-packages/MDAnalysis/core/universe.py in 126 Atom, Residue, Segment, 127 AtomGroup, ResidueGroup, SegmentGroup) --> 128 from .topology import Topology 129 from .topologyattrs import AtomAttr, ResidueAttr, SegmentAttr 130 ~/anaconda3/lib/python3.7/site-packages/MDAnalysis/core/topology.py in 62 import numpy as np 63 ---> 64 from .topologyattrs import Atomindices, Resindices, Segindices 65 from ..exceptions import NoDataError 66 ~/anaconda3/lib/python3.7/site-packages/MDAnalysis/core/topologyattrs.py in 38 import Bio.Seq 39 import Bio.SeqRecord ---> 40 import Bio.Alphabet 41 from collections import defaultdict 42 import copy ~/anaconda3/lib/python3.7/site-packages/Bio/Alphabet/__init__.py in 19 20 raise ImportError( ---> 21 "Bio.Alphabet has been removed from Biopython. In many cases, the alphabet can simply be ignored and removed from scripts. In a few cases, you may need to specify the ``molecule_type`` as an annotation on a SeqRecord for your script to work correctly. Please see https://biopython.org/wiki/Alphabet for more information." 22 ) ImportError: Bio.Alphabet has been removed from Biopython. In many cases, the alphabet can simply be ignored and removed from scripts. In a few cases, you may need to specify the ``molecule_type`` as an annotation on a SeqRecord for your script to work correctly. Please see https://biopython.org/wiki/Alphabet for more information.
RMeli commented 1 year ago

@Rulong-Ma The latest version of MDAnalysis only supports Python 3.9 onwards. Unless you really need MDAnalysis 1.0.0 (which is no longer supported), I'd suggest to update your conda to the newest version, and then create a new environment with Python 3.10 or 3.11 where to install MDAnalysis.

conda create -n mda python=3.11 mdanalysis MDAnalysisTests

The command ran more than 12 hours

conda is (was? you are using an old version) notoriously slow at solving environments. I'd suggest to try mamba instead (although creating a fresh and up-to-date environment as suggested above should not take too long).

RMeli commented 1 year ago

PS: I think the error persisted because you did not ask explicitly for MDAnalysis 2.5.0 to be installed (conda install -c conda-forge MDAnalysis=2.5.0), so nothing was installed since you already had MDAnalysis 1.0.0 (see the "All requested packages already installed message" you got).

Rulong-Ma commented 1 year ago

@RMeli Thank you for your suggestion. However, I failed to install Python 3.10 on my computer. I do not expect to install latest version of MDAnalysis. I just need the HOLE function of MDAnalysis. Now, I just want to install one version of MDAnalysis that works on my computer. Can you give me any suggestion?

I installed MDAnalysis two year ago and it worked well before 3 months ago. However, it does not work now, and the error is about "Bio.Alphabet has been removed from Biopython ". This error may result from the Python updates. ############## system: Ubuntu20 ############## MDAnalysis information:

MDAnalysis

############## Python information: base) rulong@rulong:~$ ipython --matplotlib Python 3.7.6 (default, Jan 8 2020, 19:59:22) Type 'copyright', 'credits' or 'license' for more information IPython 7.12.0 -- An enhanced Interactive Python. Type '?' for help. Using matplotlib backend: Qt5Agg ############# the error when I import MDAnalysis Bio Alphabet_error

##############

RMeli commented 1 year ago

However, I failed to install Python 3.10 on my computer.

@Rulong-Ma, what did you try and how did it fail? The installation command suggested above did not work?

Now, I just want to install one version of MDAnalysis that works on my computer.

As mentioned above, I think the easiest way forward would be to install the latest version of MDAnalysis in a fresh conda environment:

conda create -n mda python=3.10 mdanalysis MDAnalysisTests

This command should install the latest version of MDAnalysis in a separate conda environment called mda. It will also install all the necessary dependencies and Python 3.10.

Your base conda environment will remain intact (as it is), and with Python 3.7.

I installed MDAnalysis two year ago and it worked well before 3 months ago.

I see from your screenshots that you are using the base conda environment, so it is not surprising that something that was working two years ago does not work anymore if you installed/updated other packages in the same environment in the meantime.

What might have happened is that BioPython was updated in your base environment and therefore it is no longer compatible with the old version of MDAnalysis you have installed there.

If you want to use the old version of MDAnalysis and Python 3.7 you have currently installed (we are now at Python 3.11, so 3.7 is rather old), you can try to downgrade BioPython to an older version which still has Bio.Alphabet and that is compatible with the MDAnalysis version you have installed.

Rulong-Ma commented 1 year ago

@RMeli Thank you for your help. The command ( conda create -n mda python=3.10 mdanalysis MDAnalysisTests ) works on my compters. install_md_python3 10

Now, how to run MDAnalysis? In the past, I ran MDAnalysis in ipython (--matplotlib). As you said, my base conda environment stiil remain intact (as it is), and with Python 3.7. if ran the command ( import MDAnalysis as mda) in ipython. I still found the error about Bio.Alphabet. I just want to need the HOLE funciton of MDAnalysis. ( https://userguide.mdanalysis.org/stable/examples/analysis/polymers_and_membranes/hole2.html) Could you tell me how to run MDAnalysis in the new conda environment? Thanks.

RMeli commented 1 year ago

@Rulong-Ma, I'm glad the creation of the conda environment worked. Now you have a conda environment called mda that you can activate with conda activate mda and deactivate with conda deactivate (this will bring you back to the base environment.

Now, how to run MDAnalysis? In the past, I ran MDAnalysis in ipython

Your workflow should not change. You can activate the new environment with

conda activate mda

With the command I suggested above you installed only MDAnalysis (and its dependencies), but you can install whatever you want in this environment. Once you are in the mda environment (your shell prompt should change from (base) to (mda)) you can install IPython and matplotlib with

conda install ipython matplotlib

and everything should (hopefully) work as you would expect.

For hole2 you might also be interested in this MDAKit, but this is a separate discussion: https://mdakits.mdanalysis.org/hole2-mdakit.html#hole2-mdakit

Rulong-Ma commented 1 year ago

@RMeli MDAnalysis works well on my computer. Thanks you so much. The issue: the python updates lead to the incompatibility between python and MDAnalysis. The solution: conda create -n mda python=3.10 mdanalysis MDAnalysisTests conda activate mda conda install ipython matplotlib @RMeli Thank you again.