# Biopython BLAST module help

**URL:** <https://discuss.streamlit.io/t/biopython-blast-module-help/33546>\
**Category:** Community Cloud\
**Created:** [November 19, 2022, 12:03am UTC](https://discuss.streamlit.io/t/biopython-blast-module-help/33546 "2022-11-19T00:03:03Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![rdd48](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/rdd48/32/20207_2.png) [@rdd48](https://discuss.streamlit.io/u/rdd48)\
**Post date:** [November 19, 2022, 12:03am UTC](https://discuss.streamlit.io/t/biopython-blast-module-help/33546/1 "2022-11-19T00:03:03Z")

</div>

Hello, I am trying to deploy an app which uses [Biopython’s wrapper for the the NCBI blastP](https://biopython.org/docs/1.76/api/Bio.Blast.Applications.html) package. Unfortunately, I keep getting the error `/bin/sh: 1: blastp: not found` when deployed (though the code does work locally using streamlit run app.py).

An example code snipped for what I’m trying to do is below. The NamedTemporaryFile part is because the NcbiblastpCommandLine module requires local paths to files, and I’m not sure if this is also what’s causing the above error. Thank you for any help on this specific issue!

```auto
from Bio.Blast.Applications import NcbiblastpCommandline
with NamedTemporaryFile(dir='.', suffix='.fasta') as f:
        f.write(input_string)

        cline_pblast = NcbiblastpCommandline(
            query=f.name, 
            subject=f.name
        )
        
        out = cline_pblast()

```

---

<div class="post-metadata">

**Author:** ![mathcatsand](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/mathcatsand/32/48006_2.png) [@mathcatsand](https://discuss.streamlit.io/u/mathcatsand)\
**Post date:** [November 19, 2022, 12:53am UTC](https://discuss.streamlit.io/t/biopython-blast-module-help/33546/2 "2022-11-19T00:53:58Z")

</div>

What is in your requirements file and/or can you link your repository?

> **[App dependencies - Streamlit Docs](https://docs.streamlit.io/streamlit-cloud/get-started/deploy-an-app/app-dependencies)**

---

<div class="post-metadata">

**Author:** ![rdd48](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/rdd48/32/20207_2.png) [@rdd48](https://discuss.streamlit.io/u/rdd48)\
**Post date:** [November 19, 2022, 1:38am UTC](https://discuss.streamlit.io/t/biopython-blast-module-help/33546/3 "2022-11-19T01:38:57Z")

</div>

Sure thing. Here is a link to the [requirements.txt](https://github.com/rdd48/st_apps/blob/main/lefi/requirements.txt) file

[Repository link here](https://github.com/rdd48/st_apps/tree/main/lefi) with the page I’m having issues with at [pages/generate\_lefi\_data.py](https://github.com/rdd48/st_apps/blob/main/lefi/pages/generate_lefi_data.py)

---

<div class="post-metadata">

**Author:** ![mathcatsand](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/mathcatsand/32/48006_2.png) [@mathcatsand](https://discuss.streamlit.io/u/mathcatsand)\
**Post date:** [November 19, 2022, 2:15am UTC](https://discuss.streamlit.io/t/biopython-blast-module-help/33546/4 "2022-11-19T02:15:07Z")

</div>

I’ve never used this package, so I’m no expert. Looking at the documentation I gather you’ll need to get the setup for BLAST+ also included with your dependencies. The app dependencies link I posted above would be the starting point if you need to go beyond what you can pip install. I don’t know how quick I’m going to find the exact answer or if there will be some fundamental incompatibility depending on the exact architecture of BLAST+, but I thought I’d share at least that much while I’m passively poking around at it. 🙂

---

<div class="post-metadata">

**Author:** ![rdd48](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/rdd48/32/20207_2.png) [@rdd48](https://discuss.streamlit.io/u/rdd48)\
**Post date:** [November 20, 2022, 12:26am UTC](https://discuss.streamlit.io/t/biopython-blast-module-help/33546/5 "2022-11-20T00:26:41Z")

</div>

(post deleted by author)

---

<div class="post-metadata">

**Author:** ![rdd48](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/rdd48/32/20207_2.png) [@rdd48](https://discuss.streamlit.io/u/rdd48)\
**Post date:** [November 20, 2022, 12:37am UTC](https://discuss.streamlit.io/t/biopython-blast-module-help/33546/6 "2022-11-20T00:37:02Z")

</div>

Hi, I did try adding in BLAST+ as a dependency via a conda environment.yml file, since BLAST+ didn’t appear to be installable via pip. Here is the link to my .yml file. Unfortunately I am still getting the error message message `'/bin/sh: 1: blastp: not found'`

---

<div class="post-metadata">

**Author:** ![mathcatsand](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/mathcatsand/32/48006_2.png) [@mathcatsand](https://discuss.streamlit.io/u/mathcatsand)\
**Post date:** [November 20, 2022, 1:40am UTC](https://discuss.streamlit.io/t/biopython-blast-module-help/33546/7 "2022-11-20T01:40:04Z")

</div>

I did a quick search to see if I could find another use case, and I found an example with blast where the dependency was recorded as `blast` instead of `blast-plus`. Did you by chance try it both ways? (I am kind of stabbing in the dark here, but just checking.)

---

<div class="post-metadata">

**Author:** ![mathcatsand](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/mathcatsand/32/48006_2.png) [@mathcatsand](https://discuss.streamlit.io/u/mathcatsand)\
**Post date:** [November 20, 2022, 1:41am UTC](https://discuss.streamlit.io/t/biopython-blast-module-help/33546/8 "2022-11-20T01:41:58Z")

</div>

Here was the gist I found: [blast yaml file · GitHub](https://gist.github.com/ypriverol/1bffb357c741b1c8a64b0821c9d44de5)

---

<div class="post-metadata">

**Author:** ![rdd48](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/rdd48/32/20207_2.png) [@rdd48](https://discuss.streamlit.io/u/rdd48)\
**Post date:** [November 20, 2022, 5:46pm UTC](https://discuss.streamlit.io/t/biopython-blast-module-help/33546/9 "2022-11-20T17:46:35Z")

</div>

Yep, I’ve tried both. I separated blast and blast-plus into two separate apps ([blast .yml link here](https://github.com/rdd48/st_apps/blob/main/lefi/lefi_blast/environment.yml), [blast-plus .yml link here](https://github.com/rdd48/st_apps/blob/main/lefi/lefi_blastplus/environment.yml)) and weirdly I’m getting new errors for both. It appears to be a streamlit/conda issue that I’m having a difficult time resolving. Thanks for all of your help and ideas so far!

Here is the full error message for the blast version, which is the same I get for the blast-plus version. The important line seems to be `OSError: Could not find a suitable TLS CA certificate bundle, invalid path: /home/appuser/.local/lib/python3.9/site-packages/certifi/cacert.pem` but I don’t understand why I’m getting that.

```auto
# >>>>>>>>>>>>>>>>>>>>>> ERROR REPORT <<<<<<<<<<<<<<<<<<<<<<

    Traceback (most recent call last):

      File "/home/appuser/.conda/lib/python3.9/site-packages/conda/exceptions.py", line 1129, in __call__

        return func(*args, **kwargs)

      File "/home/appuser/.conda/lib/python3.9/site-packages/conda_env/cli/main.py", line 80, in do_call

        exit_code = getattr(module, func_name)(args, parser)

      File "/home/appuser/.conda/lib/python3.9/site-packages/conda/notices/core.py", line 75, in wrapper

        display_notices(

      File "/home/appuser/.conda/lib/python3.9/site-packages/conda/notices/core.py", line 39, in display_notices

        channel_notice_responses = http.get_notice_responses(channel_name_urls, silent=silent)

      File "/home/appuser/.conda/lib/python3.9/site-packages/conda/notices/http.py", line 36, in get_notice_responses

        return tuple(

      File "/home/appuser/.conda/lib/python3.9/site-packages/conda/notices/http.py", line 39, in <genexpr>

        (

      File "/home/appuser/.conda/lib/python3.9/concurrent/futures/_base.py", line 609, in result_iterator

        yield fs.pop().result()

      File "/home/appuser/.conda/lib/python3.9/concurrent/futures/_base.py", line 439, in result

        return self.__get_result()

      File "/home/appuser/.conda/lib/python3.9/concurrent/futures/_base.py", line 391, in __get_result

        raise self._exception

      File "/home/appuser/.conda/lib/python3.9/concurrent/futures/thread.py", line 58, in run

        result = self.fn(*self.args, **self.kwargs)

      File "/home/appuser/.conda/lib/python3.9/site-packages/conda/notices/http.py", line 42, in <lambda>

        lambda args: get_channel_notice_response(*args), url_and_names

      File "/home/appuser/.conda/lib/python3.9/site-packages/conda/notices/cache.py", line 37, in wrapper

        return_value = func(url, name)

      File "/home/appuser/.conda/lib/python3.9/site-packages/conda/notices/http.py", line 58, in get_channel_notice_response

        resp = session.get(url, allow_redirects=False, timeout=5) # timeout: connect, read

      File "/home/appuser/.conda/lib/python3.9/site-packages/requests/sessions.py", line 600, in get

        return self.request("GET", url, **kwargs)

      File "/home/appuser/.conda/lib/python3.9/site-packages/requests/sessions.py", line 587, in request

        resp = self.send(prep, **send_kwargs)

      File "/home/appuser/.conda/lib/python3.9/site-packages/requests/sessions.py", line 701, in send

        r = adapter.send(request, **kwargs)

      File "/home/appuser/.conda/lib/python3.9/site-packages/requests/adapters.py", line 460, in send

        self.cert_verify(conn, request.url, verify, cert)

      File "/home/appuser/.conda/lib/python3.9/site-packages/requests/adapters.py", line 263, in cert_verify

        raise OSError(

    OSError: Could not find a suitable TLS CA certificate bundle, invalid path: /home/appuser/.local/lib/python3.9/site-packages/certifi/cacert.pem

`$ /home/appuser/.conda/bin/conda-env update -n base --file environment.yml`

  environment variables:

                 CIO_TEST=<not set>

  CONDA_AUTO_UPDATE_CONDA=false

               CONDA_ROOT=/home/appuser/.conda

           CURL_CA_BUNDLE=<not set>

                     PATH=/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin

                          :/bin

    PYTHON_GET_PIP_SHA256=36c6f6214694ef64cc70f4127ac0ccec668408a93825359d998fb31d24968d67

       PYTHON_GET_PIP_URL=https://github.com/pypa/get-

                          pip/raw/6d265be7a6b5bc4e9c5c07646aee0bf0394be03d/public/get-pip.py

       PYTHON_PIP_VERSION=22.0.4

PYTHON_SETUPTOOLS_VERSION=58.1.0

           PYTHON_VERSION=3.9.15

       REQUESTS_CA_BUNDLE=<not set>

            SSL_CERT_FILE=<not set>

     active environment : None

       user config file : /home/appuser/.condarc

 populated config files : /home/appuser/.condarc

          conda version : 22.9.0

    conda-build version : not installed

         python version : 3.9.12.final.0

       virtual packages : __linux=5.10.133=0

                          __glibc=2.31=0

                          __unix=0=0

                          __archspec=1=x86_64

       base environment : /home/appuser/.conda (writable)

      conda av data dir : /home/appuser/.conda/etc/conda

  conda av metadata url : None

           channel URLs : https://repo.anaconda.com/pkgs/main/linux-64

                          https://repo.anaconda.com/pkgs/main/noarch

                          https://repo.anaconda.com/pkgs/r/linux-64

                          https://repo.anaconda.com/pkgs/r/noarch

          package cache : /home/appuser/.conda/pkgs

       envs directories : /home/appuser/.conda/envs

               platform : linux-64

             user-agent : conda/22.9.0 requests/2.28.1 CPython/3.9.12 Linux/5.10.133+ debian/11 glibc/2.31

                UID:GID : 1000:1000

             netrc file : None

           offline mode : False

An unexpected error has occurred. Conda has prepared the above report.

[17:32:24] ❗️ installer returned a non-zero exit code

[17:32:24] ❗️ Error during processing dependencies! Please fix the error and push an update, or try restarting the app.

[17:33:55] ❗️ Streamlit server consistently failed status checks

[17:33:55] ❗️ Please fix the errors, push an update to the git repo, or reboot the app.

```

---

<div class="post-metadata">

**Author:** ![mathcatsand](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/mathcatsand/32/48006_2.png) [@mathcatsand](https://discuss.streamlit.io/u/mathcatsand)\
**Post date:** [November 20, 2022, 6:20pm UTC](https://discuss.streamlit.io/t/biopython-blast-module-help/33546/10 "2022-11-20T18:20:13Z")

</div>

When I try to get to the BLAST+ install files from [here](https://blast.ncbi.nlm.nih.gov/Blast.cgi?PAGE_TYPE=BlastDocs&DOC_TYPE=Download), I do get a username/password prompt from the FTP link. I did see in a gist that someone specified some security information in the configuration for BLAST+ (for something other than Streamlit Cloud), so my non-expert thought is that if this is possible, it will be necessary to manually copy the setup files for BLAST+ into your repository. However, I really am wondering if Streamlit Cloud will be able to accommodate the installation. I don’t know how complex of a thing BLAST+ is. It says it’s command line tools (rather than a Python package), so I don’t know if there _is_ a way to get it on Streamlit Cloud or not. I haven’t personally done anything vastly complicated with the system myself.

Hopefully someone with deeper knowledge can chime in here, as I don’t think I’ll be quick to figure out more. 🙂

---

<div class="post-metadata">

**Author:** ![rdd48](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/rdd48/32/20207_2.png) [@rdd48](https://discuss.streamlit.io/u/rdd48)\
**Post date:** [November 20, 2022, 6:22pm UTC](https://discuss.streamlit.io/t/biopython-blast-module-help/33546/11 "2022-11-20T18:22:26Z")

</div>

Thans for all the work to look into it! I’ve been downloading the tools using conda ([blast](https://anaconda.org/bioconda/blast), [blast-plus](https://anaconda.org/biocore/blast-plus)) so I didn’t need to copy BLAST+ setup files or provide a username/password.

---

<div class="post-metadata">

**Author:** ![rdd48](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/rdd48/32/20207_2.png) [@rdd48](https://discuss.streamlit.io/u/rdd48)\
**Post date:** [November 20, 2022, 6:30pm UTC](https://discuss.streamlit.io/t/biopython-blast-module-help/33546/12 "2022-11-20T18:30:06Z")

</div>

I’ll also add that I’ve tried troubleshooting the above error `OSError: Could not find a suitable TLS CA certificate bundle, invalid path: /home/appuser/.local/lib/python3.9/site-packages/certifi/cacert.pem` based on this [previous forum post](https://discuss.streamlit.io/t/oserror-could-not-find-a-suitable-tls-ca-certificate-bundle-invalid-path/31157) to little success. I get one of two errors based on my setup:

- If I set the .yml python requirement to \>= 3.9 and deploy with python3.10 in the advanced settings, the app loads but can’t find any packages that were installed via pip
- If I set the .yml python requirement to == 3.10 and deploy with 3.10, the app fails to load with an error reading: `ModuleNotFoundError: No module named 'conda.cli.main_info'`

---

<div class="post-metadata">

**Author:** ![edsaac](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/edsaac/32/47599_2.png) [@edsaac](https://discuss.streamlit.io/u/edsaac)\
**Post date:** [November 21, 2022, 4:52pm UTC](https://discuss.streamlit.io/t/biopython-blast-module-help/33546/13 "2022-11-21T16:52:44Z")

</div>

Maybe unrelated, but where in the repo are you putting the dependencies file? I noticed that the app is within the `lefi/` folder and you were putting `environment.yml` in that same folder as well. I remember Streamlit Cloud failing if the dependencies file was not in the root of the repo, or if you had multiple dependency files – then the whole thing had to be rebooted.

---

<div class="post-metadata">

**Author:** ![rdd48](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/rdd48/32/20207_2.png) [@rdd48](https://discuss.streamlit.io/u/rdd48)\
**Post date:** [November 25, 2022, 7:55pm UTC](https://discuss.streamlit.io/t/biopython-blast-module-help/33546/14 "2022-11-25T19:55:10Z")

</div>

Good point – I made sure to remove the environment.yml file in the root lefi/ directory, but I’m still getting similar conda issues. For example, this app ([github repo here](https://github.com/rdd48/st_apps/tree/main/lefi/lefi_blastplus)), using python3.10 during deployment, gives this error: `ModuleNotFoundError: No module named 'conda.cli.main_info'`

---

<div class="post-metadata">

**Author:** ![rdd48](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/rdd48/32/20207_2.png) [@rdd48](https://discuss.streamlit.io/u/rdd48)\
**Post date:** [November 25, 2022, 7:58pm UTC](https://discuss.streamlit.io/t/biopython-blast-module-help/33546/15 "2022-11-25T19:58:36Z")

</div>

Generally, it’d be helpful to get more useful conda environment error messages-- it’s very difficult to troubleshoot things like this.

---

<div class="post-metadata">

**Author:** ![edsaac](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/edsaac/32/47599_2.png) [@edsaac](https://discuss.streamlit.io/u/edsaac)\
**Post date:** [November 25, 2022, 10:10pm UTC](https://discuss.streamlit.io/t/biopython-blast-module-help/33546/16 "2022-11-25T22:10:28Z")

</div>

This seems to work in a [separate repo](https://edsaac-lefi-blastplus-graph-lefi-output-brh2ii.streamlit.app/generate_lefi_data) using a `requirements.txt`. But not sure what kind of file is expected to test further, I just put some random fasta sequence and got an error (unrelated to dependencies).

---

<div class="post-metadata">

**Author:** ![rdd48](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/rdd48/32/20207_2.png) [@rdd48](https://discuss.streamlit.io/u/rdd48)\
**Post date:** [November 26, 2022, 12:00am UTC](https://discuss.streamlit.io/t/biopython-blast-module-help/33546/17 "2022-11-26T00:00:27Z")

</div>

What type of error did you get? It would be great to replicate what you made, since I’ve had issues using the requirements.txt approach since the blast package seems to require conda for installation. It’s possible that the error you got is related to what I’ve been dealing with.

I’d initially linked a requirements file I had been using but I unfortunately deleted it to try troubleshooting some of the other options (in retrospect, I should’ve kept things in separate directories).

---

<div class="post-metadata">

**Author:** ![edsaac](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/edsaac/32/47599_2.png) [@edsaac](https://discuss.streamlit.io/u/edsaac)\
**Post date:** [November 26, 2022, 1:32am UTC](https://discuss.streamlit.io/t/biopython-blast-module-help/33546/18 "2022-11-26T01:32:28Z")

</div>

It was not related to a missing dependency, it is an `IndexError: string index out of range`, coming from the `process_fasta` function. (Just curious, why not use Bio.SeqIO to parse the file?)

> **Traceback:**
>
> ```auto
> Traceback (most recent call last):
> 
> File "/home/appuser/venv/lib/python3.10/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 564, in _run_script
> exec(code, module. __dict__ )
> File "/app/lefi_blastplus/pages/generate_lefi_data.py", line 175, in <module>
> nodes, edges = fasta_to_dicts(fasta_file)
> File "/app/lefi_blastplus/pages/generate_lefi_data.py", line 50, in fasta_to_dicts
> fasta_dict = process_fasta(fasta_file)
> File "/app/lefi_blastplus/pages/generate_lefi_data.py", line 26, in process_fasta
> while lines[new_index][0] != '>':
> IndexError: string index out of range
> 
> ```

---

<div class="post-metadata">

**Author:** ![rdd48](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/rdd48/32/20207_2.png) [@rdd48](https://discuss.streamlit.io/u/rdd48)\
**Post date:** [November 29, 2022, 4:37pm UTC](https://discuss.streamlit.io/t/biopython-blast-module-help/33546/19 "2022-11-29T16:37:19Z")

</div>

No good reason–I realized my mistake though and fixed the bug [here](https://github.com/rdd48/st_apps/blob/main/lefi/pages/generate_lefi_data.py). Very dumb error when I tried to make the parsing better, and I should probably just move to the SeqIO method.

Any other thoughts on how to get this to work? I’m still finding the conda environment-related error messages difficult to understand. Thanks for everyone’s input so far; I realize this is a bit tricky.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/streamlit/original/3X/c/f/cf4c2ee0d938358f82448c5fe4b9c3c91d7ce19c.svg) [@system](https://discuss.streamlit.io/u/system)\
**Post date:** [November 29, 2023, 4:37pm UTC](https://discuss.streamlit.io/t/biopython-blast-module-help/33546/20 "2023-11-29T16:37:23Z")

</div>

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
