☰ Menu

      Introduction to Python For Bioinformatics

Home
Introduction
Intro to the Workshop and Core
Installing python3 and VSCode
Bioinformatics File Types
Python
Intro
Basic Data Types
Flow Control, Functions, Files, Errors
Writing Programs
Biopython and bamnostic/pysam
Next Steps
Exercise Solutions
ETC
Github Page
Biocore website

Part 1: Intro to Python

Why learn Python?

Python

https://businessoverbroadway.com/2019/01/13/programming-languages-most-used-and-recommended-by-data-scientists/


Background

What is a programming language and why do we need it?

Speaking to a computer in its native language is tedious and complicated. A programming language is a way for humans to describe a set of operations to a computer in a more abstract and understandable way. A helper program then translates our description of the operations into a set of instructions (machine code) for the computer to carry out.

Some day we may develop a programming language that allows us to communicate our instructions to the computer in our native language (Alexa, turn on the TV). Except for simple cases, this option doesn’t exist yet, largely because human languages are complicated and instructions can be difficult to understand (even for other humans).

In order for the helper program to work properly, we need to use a concise language:

Specifically in Python:

PythonInterpreter


A brief history of Python


Interesting features of Python


Base Python and the extensive package ecosystem


Your first Python program

First, open VSCode:

vscode

You will be asked to choose a language for the new file. VSCode supports many different programming languages, including C, C++, Java, Perl, Python. Choose Python.

vscode

vscode

Hello, World! is traditionally the first program to write in any new programming language.

Copy and paste (or type) this into your new file:

print("Hello, World!")

Save the file and name it “helloworld.py”. Python code files typically use the “.py” extension. Then click the triangle “play” button to run your code in the terminal. Congratulations! You are now a python coder!

vscode