[BioPython] ModuleNotFoundError: No module named Bio.PDB.SASA
2
0
Entering edit mode
2.2 years ago
ilyasgrand ▴ 10

Hello,

I am trying to calculate the solvent accessible surface of pdb files using Biopython.

Specifically I am trying to deduce the interaction surface of complex by substracting the solvent accessible surface of both unbound structure to the solvent accessible surface of the complex. I can do this calculation using Freesasa package but I wanted to know how to use Bio.PDB only.

The issue is in the title, BioPython is properly installed, but I wonder why this package is not found. I can find it here: https://biopython.org/docs/dev/api/Bio.PDB.SASA.html

The code for the import:

from Bio.PDB.SASA import ShrakeRupley

Error:

from Bio.PDB.SASA import ShrakeRupley
ModuleNotFoundError: No module named 'Bio.PDB.SASA'

Thanks

Biopython Bio.PDB • 2.5k views
ADD COMMENT
2
Entering edit mode
2.2 years ago
Mensur Dlakic ★ 27k

The most likely explanation is that you don't have a correct BioPython version.

Try this command:

python3 -c "import Bio; print(Bio.__version__)"

The response I get is 1.79. Above you may need to type python instead, depending on which version you are using.

ADD COMMENT
1
Entering edit mode

I think the last BioPython version that works under python2 is 1.76 and it seemingly doesn't have the SASA functionality. You may have to switch to python3 and install the latest BioPython version, or keep using the other program that worked for you.

ADD REPLY
1
Entering edit mode

@ilyasgrand without needing to do install anything on your system, you can easily access Python 3 with current biopython already installed by going here and clicking launch binder to get a full active Jupyter session in your browser via MyBinder.org. A temporary Jupyter session will spin up for you. The person who made the repository has some notebooks already in a directory there; however, you can start a new one or open a terminal and use Python or IPython there.

It doesn't have a lot of computational power; however, chances are it has more than enough.

If you click the Jupyter logo in the upper right side above the notebook, you'll open the JupyterLab interface to the same session and it can be easier to use if you've seen that before. If you prefer the classic Jupyter dashboard, from the JupyterLab view, select Help > Launch Classic Notebook. It is only a temporary session and once it disconnects no one can get it back for you, and so if you make anything useful be sure to download it back to your local computer.

You can always spin up a new session later and then upload it using the JupyterLab interface that has drag and drop, you go back to the Jupyter Dashboard in the classic interface and upload there via the 'Upload' button.

You can fetch your structure files from inside the session if they are at PDB and know command line retrieval via wget or curl. Or you can also upload that from your local computer.

ADD REPLY
0
Entering edit mode

So the problem was the version, I was on 1.78 on my conda environment with python3 as default. Thought it was the last version (maybe there was a clash with a previously installed version of biopython). I upgraded to 1.79 via conda and it worked perfectly. Thank you for your answer !

ADD REPLY
0
Entering edit mode

I see now. It seems the news for Biopython doesn't get indexed at Google very well, and so that addition in 1.79 wasn't easy to note searching 'Bio.PDB.SASA' or 'biopython SASA' alone today or yesterday.

I had to find the text in the raw news that came up down the list from a search of 'biopython SASA' then search with text from there, specifically 'New module Bio.PDB.SASA implements the Shrake-Rupley'.
Then you can find the news from the June 2021 release of Biopython version 1.79 here and here.

"– A new module Bio.PDB.SASA implements the Shrake-Rupley algorithm to calculate solvent accessible areas natively, without requiring third-party tools such as DSSP or NACCESS."- SOURCE

ADD REPLY
1
Entering edit mode
2.2 years ago
Wayne ★ 2.0k

Besides a possible issue with the version that Mensur Dlakic (Mesur Dlkavic) points out, another possibility is that Biopython is installed on your computer; however, the actual environment you are currently working in is not seeing it. This is often the issue when using Jupyter. Any chance you are using Jupyter? If you are, just run in a cell inside a notebook, one of the following lines, depending on what package manager you are most using to keep your environments maintained:

%pip install biopython
%conda install biopython

(The % at the start of the line will mean that pip or conda magics will be used for installation to the proper environment backing the notebook and is the recommended way to do installations from inside a notebook these days, see here. Because automagics are often enabled in most Jupyter systems by default, including no symbol at the front will do the same thing; importantly, you want to avoid outdated advice to use an exclamation point in front of pip or conda.)

Even if you aren't using Jupyter, the place it was installed and where you are working possibly still could be different.
I'm curious what makes you say it is properly installed in your post? From where you are currently working, you can do other things with Biopython?

ADD COMMENT
1
Entering edit mode

"I'm curious what makes you say it is properly installed in your post? From where you are currently working, you can do other things with Biopython?" : Yes I was using biopython to parse some pdbfiles. I use conda to manage my environments, it was only a problem of version. Thank you for your answer!

ADD REPLY

Login before adding your answer.

Traffic: 2700 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6