Amherst College I.T. I.T. home. Amherst College.
I.T. home.
ATS > Software > Scientific Programming with Python > Bioinformatics

Scientific Programming with Python

Part 4: Bioinformatics

Previous: Simulating a Magnet

Current: Bioinformatics

Next: Demographic Data


Biopython provides a number of tools useful for studying genetic sequencing.

Topics


Installing Biopython

Biopython is available through the conda package manager, but is not installed by default.


Biopython

Generally speaking, if you are installing specialized software that may depend on a lot of other software, it’s a good idea to create a new conda environment, which will isolate these packages and even let you use different versions of python (e.g. because a package hasn’t been updated for newer versions).

Procedure 1: Setting Up a Biopython Environment

Recall that working with Conda requires using a shell, a command-line interpreter that is available on both Macs and Windows; each statement must end with the key return (Macs) or Enter (Windows) to submit them for execution.

  1. Launch a shell:
    • On Windows: Menu Start> Anaconda3 > Anaconda PowerShell Prompt.
    • On Macs: Navigate to the folder Applications and then the folder Utilities, and open the application Terminal.

    A window will appear with a text prompt that looks something like:

    (base) [username@hostname ~]$

    If (base) appears, it represents the conda default environment; ~ is an abbreviation for your home folder.

  2. Create a conda environment by typing, for example:
  3. conda create -n biopython

    Conda will provide some setup information and then ask if you want to Proceed ([y]/n)?; type y.

  4. Activate this environment, for example:
  5. conda activate biopython

    Your prompt will now show this environment at its beginning, for example:

    (biopython) [username@hostname ~]$

  6. Install other packages into this environment, for example:
  7. conda install biopython

    Again, Conda will provide some setup information and then ask if you want to Proceed ([y]/n)?; type y.

  8. Test that the package is available by running Python and loading one of its modules, for example:
  9. python
    import Bio

    If the package is properly installed, there will be no response. Type exit() or ctrl-D to leave Python.

  10. Also any other packages you might need, e.g. matplotlib
  11. conda install matplotlib

  12. To use a new environment with Spyder:
    1. Install Spyder components in the environment:
    2. conda install spyder-kernels=2.5

      The version assignment seen here will install the appropriate version of this package for version 5 of Spyder, which is provided with the 2025 version of Anaconda.

    3. Quit Spyder if it’s open.
    4. Open Spyder.
    5. Menu python > Preferences….
    6. In the dialog Preferences, in the left-side list, choose Python interpretor:

    7. In the section Python Interpreter, click on the button Use the following Python interpreter:.
    8. In the menu of possible interpreters, all of your environments will be listed (note they will all be in a subfolder named envs). Select the option for your new environment, e.g. /opt/anaconda3/envs/biopython/bin/python.
    9. Click on the button OK to both apply these changes and close the dialog.
    10. In the pane iPython Console, in the upper right corner, menu ꠵ Options > Restart kernel.
    11. Test that the environment and package(s) you just installed are available in Spyder by loading one of its modules, e.g.:
    12. import Bio

      If the environment and package(s) are properly installed, there will be no response.

Now you can start up Spyder and import Biopython in IPython:

import biopython as bp

For today, we’ll follow this tutorial.


Alphafold

Alphafold is an AI program developed by DeepMind, a subsidiary of Alphabet (the parent of Google), which performs predictions of protein structure.

To try it out, make a copy of the example folder and change directory into it:

cp -r /home/common/examples/alphafold3 ~

cd ~/alphafold3/

 


Previous:
Simulating a Magnet

Scientific Programming with Python:
Bioinformatics

Next:
Demographic Data

Top of Page  | Using IT DocumentationIT Home  |  IT Site Map  |  Search IT