Skip to content

KhumboPute/Python4BioinformaticsV2

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

63 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python For Bioinformatics

Introduction to Python for Bioinformatics - available at https://github.com/kipkurui/Python4BioinformaticsV2.

Python Version: 3.13 (Latest stable release)

Attribution

These tutorials are an adaptation of the Introduction to Python for Maths by Andreas Ernst, available from https://gitlab.erc.monash.edu.au/andrease/Python4Maths.git. The original version was written by Rajath Kumar and is available at https://github.com/rajathkumarmp/Python-Lectures.

These notes have been greatly amended and updated for the MSC Bioinformatics and Molecular Biology at Pwani university, sponsored by EANBiT by Caleb Kibet

Quick Introduction to Jupyter Notebooks

Throughout this course, we will be using Jupyter Notebooks.These notes are provided for you want to set it up in your Computer.

Introduction

The Jupyter Notebook is an interactive computing environment that enables users to author notebooks, which contain a complete and self-contained record of a computation. These notebooks can be shared more efficiently. The notebooks may contain:

  • Live code
  • Interactive widgets
  • Plots
  • Narrative text
  • Equations
  • Images
  • Video

It is good to note that "Jupyter" is a loose acronym meaning Julia, Python, and R; the primary languages supported by Jupyter.

The notebook can allow a computational researcher to create reproducible documentation of their research. As Bioinformatics is datacentric, use of Jupyter Notebooks increases research transparency, hence promoting open science.

First Steps

Installation

Option 1: Using Conda Environment (Recommended)

  1. Download Miniconda or Anaconda for your specific OS

    • Linux: wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
    • Mac: curl https://repo.continuum.io/miniconda/Miniconda3-latest-MacOSX-x86_64.sh
    • Windows: Download installer
  2. Install Miniconda:

    • Linux/Mac: bash Miniconda3-latest-*.sh
    • Windows: Run the downloaded .exe installer
    • Follow all prompts (accept defaults if unsure)
  3. Close and re-open your terminal

  4. Verify installation:

    conda --version
  5. Create the conda environment using the provided environment.yml file:

    conda env create -f environment.yml
  6. Activate the environment:

    conda activate python4bioinformatics

Option 2: Manual Environment Setup

If you prefer to create the environment manually:

conda create --name python4bioinformatics python=3.13
conda activate python4bioinformatics
conda install -c conda-forge jupyterlab numpy pandas matplotlib seaborn scipy biopython

How to learn from this resource?

  1. Clone the repository:

    git clone https://github.com/kipkurui/Python4BioinformaticsV2.git
    cd Python4BioinformaticsV2

    Or download as ZIP:

    wget https://github.com/kipkurui/Python4BioinformaticsV2/archive/master.zip
    unzip master.zip
    rm master.zip
    cd Python4BioinformaticsV2-master
  2. Create and activate the conda environment:

    conda env create -f environment.yml
    conda activate python4bioinformatics
  3. Launch Jupyter Lab:

    jupyter lab

Using Jupyter Notebooks:

  • Each notebook contains cells with Python code or text
  • Execute a cell: Press Shift-Enter (run and move to next) or Ctrl-Enter (run without moving)
  • We recommend using Jupyter Lab for the best experience

For Windows

Installation

Option 1: Anaconda (Recommended for Beginners)

  1. Download Anaconda from https://www.anaconda.com/download
  2. Run the installer and follow the installation wizard
  3. Anaconda includes Jupyter Notebook by default

Option 2: Miniconda + Manual Install

  1. Download Miniconda from https://docs.conda.io/en/latest/miniconda.html
  2. Install and open "Anaconda Prompt" from Start menu
  3. Install Jupyter:
    conda install jupyter

Option 3: pip (If Python already installed)

  1. Open Command Prompt or PowerShell
  2. Install Jupyter:
    pip install jupyter

Launching Jupyter

From Anaconda Navigator (GUI)

  1. Open Anaconda Navigator from Start menu
  2. Click "Launch" under Jupyter Notebook

From Command Line

  1. Open "Anaconda Prompt" (or Command Prompt/PowerShell if using pip)
  2. Navigate to your project directory:
    cd C:\path\to\your\project
  3. Launch Jupyter:
    jupyter notebook
  4. Browser window opens automatically at http://localhost:8888

Creating and Using Notebooks

  1. Click "New" → "Python 3" to create a new notebook
  2. Type code in cells and press Shift + Enter to run
  3. Use Ctrl + Enter to run cell without moving to next
  4. Press Esc for command mode, Enter for edit mode
  5. Save with Ctrl + S or File → Save

Useful Keyboard Shortcuts

Command Mode (press Esc):

  • A - Insert cell above
  • B - Insert cell below
  • DD - Delete cell
  • M - Convert to markdown
  • Y - Convert to code

Edit Mode (press Enter):

  • Shift + Enter - Run cell and move to next
  • Ctrl + Enter - Run cell in place
  • Tab - Code completion

For This Course

Navigate to the project directory and launch Jupyter:

cd C:\path\to\Python4BioinformaticsV2
jupyter notebook

Further help

To learn more about Jupyter notebooks, check the official introduction and some useful Jupyter Tricks.

Book: http://www.ict.ru.ac.za/Resources/cspw/thinkcspy3/thinkcspy3.pdf

Python for Bioinformatics

Introduction

Python is a modern, robust, high-level programming language. It is straightforward to pick up even if you are entirely new to programming.

Python, similar to other languages like Matlab or R, is interpreted hence runs slowly compared to C++, Fortran or Java. However, writing programs in Python is very quick. Python has an extensive collection of libraries for everything from scientific computing to web services. It caters for object-oriented and functional programming with a module system that allows large and complex applications to be developed in Python.

These lectures are using Jupyter notebooks which mix Python code with documentation. The python notebooks can be run on a web server or stand-alone on a computer.

Contents

This course is broken up into a number of notebooks (lectures).

Session 1

  • 00 This introduction with additional information below on how to get started in running python
  • 01 Basic data types and operations (numbers, strings)
  • 02 String manipulation

Session 2

  • 03 Data structures: Lists and Tuples
  • 04 Data structures (continued): dictionaries

Session 3

  • 05 Control statements: if, for, while, try statements
  • 06 Functions
  • 07 Scripting with python

Session 4

  • 08 Data Analysis and plotting with Pandas
  • 09 Reproducible Bioinformatics Research
  • 10 Reproducible Bioinformatics Research

This is a tutorial style introduction to Python. For a quick reminder/summary of Python syntax, the following Quick Reference Card may be useful. A longer and more detailed tutorial style introduction to python is available from the python site at: https://docs.python.org/3/tutorial/.

How to Contribute

To contribute, fork the repository, make some updates and send me a pull request.

Alternatively, you can open an issue.

License

This work is licensed under the Creative Commons Attribution 3.0 Unported License. To view a copy of this license, visit http://creativecommons.org/licenses/by/3.0/.

About

Python For Bioinformatics Training Materials

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Jupyter Notebook 100.0%