
This course includes our updated coding exercises so you can practice your skills as you learn.
See a demo
Explore how Python helps biologists write algorithms, analyze data, and publish research, using gene enrichment analysis in RNA-seq and single-cell workflows with Python packages.
Define python as a programming language and install python3 on Windows or macOS by downloading from python.org, selecting the correct installer, and adding python to the path.
Explore how to write and run Python code using the interactive mode in the terminal or command prompt, verify Python installation, and run a simple input and print example.
Create a python script with a .py extension, save it, and run it from the command line using python or python3 to print prompts and greet the user by name.
Learn to write and run Python code using an integrated development environment, such as Visual Studio Code or PyCharm, by installing the Python extension and running code in the IDE.
Explore Python's modes and learn how to write and run code, then get a simple, practical introduction to Python that you can apply.
All the scripts that you will see in the videos have been provided. Download them and follow me during the course.
Learn how to create and use variables in Python, with inputs and outputs like hello world, using the print function, assignment, and memory during execution.
Learn how to write valid identifiers by using letters and numbers (not starting with a number), internal underscores, and mixed case, while the underscore signals private variables.
Discover how to store data in memory using variables, enabling reuse across functions and methods. Learn how to choose valid identifiers for variable names.
Explains python's case sensitivity in identifiers, shows why using print as a variable causes an error, and suggests using at least one uppercase letter to avoid conflicts.
Identify and avoid errors from language keywords, leverage case sensitivity, and recognize that functions and methods have fixed syntax, while variables refer to data across different functions or methods.
Learn how Python distinguishes code from comments, where the interpreter executes code while ignoring comments, and how to use hash marks or triple quotes for multi-line notes.
Learn to create comments in Python using a hash for single-line notes and triple quotes for multi-line blocks. Understand how these comment styles document code.
Learn how to save data in memory, print variables to the screen, and receive user input in Python with the input() function, using vaR1 and vaR2 and semicolon separation.
Explain the difference between variable names inside and outside strings, show a simple input function usage, and place statements on one line with a semicolon in the command interface.
Organize data by saving a value into multiple variables on one line with commas and an equal sign. Keep counts aligned by matching variables and values, then print to verify.
Explore organizational methods for assigning values to variables in Python for biologists, and choose between organizing these variables or writing them in traditional ways.
Explore how variables allocate memory to store data for running code, distinguish data types like numbers and strings (characters between single quotes) used to save and organize data in Python.
Explore how Python handles numbers: integers, floats, and complex numbers, how Python auto-detects int vs float, and how the print function outputs multiple values with a space separator.
Explore the Python string data type, a sequence of characters written in single, double, or triple quotes, and see how strings relate to DNA, RNA, and protein data.
Learn about list and tuple data types in Python, including brackets vs parentheses and the key difference: tuples are read-only, while lists can change.
Understand the dictionary data type: a key and value pair separated by a colon inside braces, where keys can be numbers, strings, or tuples, and values can be any type.
Explore Python data types, including five types with the string and the number as basic units, and list, tuple, and dictionary structures; compare lists and tuples and show dictionary syntax.
Explore converting data types in Python, turning strings into numbers when using input or reading files. Learn practical functions to convert user input and file data to numeric types.
convert integers to floats and floats to integers using float() and int(), then inspect the resulting types with type() and print the results to confirm successful conversion.
Create complex numbers with complex(real, imag) and extract the real and imaginary parts using .real and .imag, showing float outputs and chained dot notation.
Learn to convert numbers to strings with str() and verify types with type(), then convert strings back to numbers using int() and float(), and handle decimal strings for int().
Explore converting between int, float, and complex numbers in Python, create complex numbers from ints or floats, and extract floats from complexes, plus string-number conversions.
Learn how converting a string to a list or tuple works using list() and tuple(), with each character becoming an item, and why reverse conversions like str() differ.
Create a dictionary from a list or tuple using the dict() function by pairing two-item elements as keys and values, including mixtures of lists and tuples.
Learn to convert strings to lists or tuples, and why not to use str() for converting back to string, then build dictionaries from lists or tuples in a specific format.
Explore how indices enable data access in Python for biologists. Start at zero and go to length minus one to distinguish items, as shown with a two-letter string.
Master zero-based indexing in Python by accessing string items, using len() to measure length, converting to lists, and handling out-of-range errors.
Explore negative indexing in Python to access the end of lists, strings, and tuples with -1 for the last item, -2 for the penultimate, and understand range limits.
Learn to access dictionary items and convert lists to dictionaries with dict(). Distribute list items by indices to form dictionary entries and observe the created dictionary.
Explore extracting dictionary keys and values with keys() and values(), and access values by key using dict[key], noting the difference between function and method and the shared index order.
Explore the concept of indexes in data types where indexing is available and learn how to access dictionary items using index and key methods.
Learn to map IUPAC nucleotide codes to bases with a Python dictionary, handle ambiguous nucleotides and SNPs, and prepare external data for storage in Python.
Learn how to build a tiny Python program that takes a capital letter as an IUPAC nucleotide code, looks up possible nucleotides in a dictionary, and prints the result.
Map IUPAC nucleotide codes to bases and back using a dictionary, keys and values as lists, and index retrieval to create consensus sequences.
Explore Python operators, including arithmetic, assignment, bitwise, comparison, membership, logical, and identity, and see how addition and subtraction yield results and boolean conditions.
Explore python arithmetic with multiplication, division, floor division, and exponent operators, using examples like 10*2=20, 10/2=5.0, floor division 10//2=5, and 10**2=100.
Learn how modulus yields the remainder of division, with examples such as 21 mod 2 is 1, 22 mod 2 is 0, and 45 mod 3 is 0.
Identify seven arithmetic operators in Python: plus for addition, minus for subtraction, asterisk for multiplication, double-asterisk for exponent, forward slash for division, double-forward slash for floor division, percent for modulus.
Explore arithmetic operators for strings, lists, and tuples, using plus for concatenation and asterisk for repetition, with examples of combining and repeating data types.
Learn how the plus operator concatenates data and the asterisk operator repeats data for strings, lists, and tuples.
Learn how operator precedence governs arithmetic in Python, with exponentiation, then multiplication, division, floor division, and modulus, followed by addition and subtraction, and how parentheses enforce a desired order.
Explain operator precedence in Python: exponentiation executes first, then multiplication, division, floor division, and modulus, and finally addition and subtraction, with parentheses used to override the order.
Develop a Python code to detect extra nucleotides in cDNA before translation, using modulus to reveal residues after dividing sequence length by three, and relate to codons and amino acids.
Learn to write a Python program that reads a DNA sequence, computes its length with len, and calculates extra nucleotides before translation by codon length three, with hands-on tests.
Explore how to create simple Python code and clear data representations that make it easier to work with big data for users and researchers.
Learn how the assignment operator updates variables in Python with a = a + b and shorthand a += b. See how equals combines with arithmetic operators to modify values.
Explore how assignment operators update variables in Python for biologists. Clarify their role and demonstrate their practical use in coding tasks.
Learn how Python's comparison operators evaluate equality and inequality using == and !=, producing booleans, and how to inspect types with type() across numbers, strings, lists, tuples, and dictionaries.
Explore greater than, less than, or equal to operators for numbers, strings by length or content, and list or tuple comparisons, including elementwise checks and type consistency.
Clarifies comparison operators in Python for biologists, explains how each operator works with numbers and other data, and shows how to determine the answer.
Compare two sequences by length and content using two input sequences and the '==' operator to detect substitution, insertion, and deletion mutations.
Explore how a comparison operator compares sequences and learn to design code that handles large data with repetitive tests, such as comparing ten sequences to a single reference.
Master Python's membership operators in and not in to test if the left operand belongs to right operand, using numbers, strings, lists, tuples, or dictionaries (keys only), noting case sensitivity.
Explore the membership operators, learn how to use them, and identify data types for each of the left and right operands.
Search a restriction enzyme recognition site in a DNA sequence using Python's in operator. Learn to receive user input and verify an EcoRI example.
Learn how logical operators in Python combine conditions, including and, or, and not, with string examples like 'A in s' and 'T in s' to yield true or false.
Explore the and, or, and not operators, understanding when each yields true or false based on answers to questions. Learn how the not operator reverses the result of any operator.
Learn to test for multiple restriction sites in a DNA sequence by coding the and/or logic, using EcoRI and HindIII as examples.
Use operators in two cases with examples, and emphasize that the questions are crucial, whether you explore the data yourself or work with other biologists.
Explore identity operators in Python, using is and is not to compare data by memory location with id() across strings, numbers, tuples, lists, and dictionaries, including user input strings.
Clarify identity operators across different data types in Python for biologists, outlining how these operators respond to diverse data types.
Learn how bitwise operators work on integers and how to convert between integers and binary using bin() and int(..., base=2), including 0b prefixes and left padding to eight bits.
Explore bitwise operators in Python. See how and requires both bits true, how or yields one when any bit is true, and xor yields one for differing bits.
Explore bitwise operators in Python, including the complement (~) and two's complement, plus left and right shifts, with practical examples and explanations of MSB and negative numbers.
Clarify six types of bitwise operators with examples, noting their limited use in our field, while explaining positive and negative numbers in binary for numbers and strings.
Learn decision-making in Python with if, elif, and else statements, using boolean conditions (comparison, logical, membership, identity) and a modulo example for extra nucleotides in a sequence.
Explain how decision-making can be written and demonstrate the use of if, elif, and else in Python for biologists.
Write a small Python snippet that uses the in operator to detect thymine or uracil in a user sequence and classify it as DNA or RNA.
Explore zero, non-zero, null, and non-null values in Python and effects on if statements. Learn to use nested ifs to handle empty input and report when no sequence is entered.
Python for biologists teaches you to implement nested if statements to validate nucleotide sequences, enforce a minimum length of three nucleotides for codons, and provide clear user feedback.
Explore how the while loop in Python repeats code by condition. Compare with the for loop, observe counter updates, and note the else and assignment like counter += 1.
Clarify the loop concept by showing how to repeat code with the while loop, prevent infinite loops with a condition, and explain else at loop end versus else with if.
Calculate GC content from a DNA sequence using a while loop, counting G and C nucleotides with len() to get sequence length, and compute the percentage.
Learn how the for loop iterates over data items—strings, lists, tuples, or dictionaries—using an iteration variable and ends after the last item, unlike the while loop.
Apply a for loop to the gc content calculation, replacing the while loop, and count g and c nucleotides to determine the sequence's gc content.
Explore how break, continue, and pass control loops in Python, with emphasis on while and for loops, execution order, and avoiding infinite loops.
Explore how break ends a loop, how continue skips following codes, and how pass serves as a filler for constructs that may issue errors from the lack of lines.
Practice indexing and slicing strings in Python, using zero-based indices to access characters, concatenate with plus, and extract substrings with start:end notation.
Learn how to access and update strings in python and master slicing to extract substrings.
Examine escape characters in Python strings, including newline, tab, carriage return, and Windows vs Linux newline behavior, plus backslash handling and raw strings.
Explore escape characters, their importance, and how each of them works in Python for biologists.
Learn Python string formatting with percent formatting (types %c, %s, %i, %f) to embed data without the plus operator, and apply it in loops with enumerate for codon numbers.
Explore a method of string formatting and how it facilitates the concatenation of strings and numbers in Python.
Learn how the Python format function enhances string formatting by inserting arguments inside braces, using positional and named arguments, and combining data types like lists, tuples, and dictionaries.
Describe a better, organized method for string concatenation, showcasing an improved approach over previous techniques.
Learn how the capitalize method converts the first character of a string to uppercase while turning the remaining letters to lowercase, demonstrated by print(a.capitalize()).
Center a string within a total width using the center() method, with a filler character like '='; place the string in the middle of a 50-character line.
Learn how to align strings within a fixed width using Python's center, ljust, and rjust methods. Replace center with ljust or rjust to achieve left or right justified text.
Learn to use the count() method to count occurrences of characters or substrings in a string, with optional start and end indices, using a DNA sequence example.
Learn how to use the endswith() method to check a string's suffix, test stop codons with a tuple, and specify start and end indices in Python.
Learn how the startswith() method tests whether a string or substring begins with a start codon. Specify start and end positions and relate to endswith().
Explore how Python's expandtabs(tabsize) converts tabs to spaces in a two-column table with gene_name and geneID, showing how increasing tabsize moves the second column farther apart.
Learn how the find method locates a pattern's position in a string, returning the starting index or -1 if not found, and how to locate subsequent occurrences.
Use rfind() to locate a pattern from the end of a string in Python. Set the end index to access subsequent occurrences, contrasting rfind with find.
Compare the index() and find() methods for locating substrings, noting that index raises an error if not found while find returns -1, guiding when to use each.
Explore how the rindex() method searches for a pattern from the reverse string, mirroring the rfind() and index() methods. Handle errors when the pattern does not exist.
Use the isalnum() method to test strings for only letters and numbers, as shown with geneSymbol returning true while accession (with underscores and dots) returns false.
Learn to use Python's isalpha() to detect letters-only sequences in biology data; identify gaps or non-letter characters, and compare with the find method as a faster alternative.
Demonstrate how the isdigit() method tests whether a string contains only digits, by comparing numeric gene ids, gene symbols, and accessions that include letters, numbers, and other characters.
Learn to detect uppercase and lowercase in strings using islower() and isupper(), and convert between cases with lower() and upper() to ensure accurate comparisons and counts in biological data.
Compare isdecimal, isdigit, and isnumeric in Python to see how they treat roman numerals and Unicode fractions; isnumeric includes fractions as numbers, unlike the other two.
Learn how to test if a string contains white space using isspace() in Python. The method returns true when the string has any whitespace and false for single-character strings.
Explore how to convert strings to title case with the title() method and verify capitalization with istitle(), demonstrating false for lowercase and true for the title-cased string.
Learn to concatenate list or tuple items into a single string using the join() method, choosing separators like tab, newline, or a dash.
Learn the len() function to get the length of a string, list, or tuple. Pass the variable inside parentheses to obtain a number, as used previously.
Learn to clean strings by removing characters from both sides with strip, or from one side with lstrip or rstrip, including removing dashes and a poly a tail.
Learn to remove specified characters from the left and right of a string using strip, lstrip, and rstrip, with examples like a dash and polyA.
Learn how to replace characters or patterns in strings using the replace method, with a dna to rna conversion example that replaces t with u and shows the updated string.
Apply the replace method to substitute a substring a specified number of times, as shown by replacing the first two T characters with U in a sequence.
Learn to build a translation table with maketrans and translate a DNA sequence to its complement by mapping A to T and G to C using a dictionary-based substitution.
Use min() and max() on strings to identify lowest and highest ASCII values, revealing nucleotide quality in fastq data, including raw strings and examples like ! (33) and F (70).
Learn how to convert a string into a list in Python using the split method and splitlines, join lines to measure sequence length and separate header from sequence.
Apply the swapcase method to invert the case of each character in a string, turning uppercase letters to lowercase and vice versa, as shown in a string with uppercase letters.
Learn how to pad a string with zeros using zfill() to a fixed total length, as an rjust()-style technique, demonstrated with forty zeros.
Review the basics of working with lists in Python: create lists with splitlines, access via indices, slice with 0:2, update items, delete elements, and print results.
Use len() to get a list’s length, and min() and max() to find the smallest and largest items, demonstrated on lists of strings with order by decimal value.
Learn how to extend a list in Python using append() to add items at the end and insert() to place items at a specific index, with examples.
Learn to extend a host list with another using the extend() method, compare it to plus-concatenation, and decide when to modify the original list versus creating a new one.
Learn how to count occurrences of a specific item in a Python list using the count method, with an example counting 'TTT' and printing the result.
Learn to use the index method on strings and lists to locate an item's position, with optional start parameters to find subsequent occurrences, and handle not found errors.
Delete items by index with pop(), confirm by printing the list, or remove items by value with remove(), which deletes only the first match while del also uses an index.
Explore how to sort a list with sort(), convert a string to a list with splitlines(), then print and compare before and after sorting.
Learn to reverse a list using the reverse() method, which flips the item order so the first item becomes the last, then print the list to verify.
Remove duplicates from a list by converting a string to a list, using set to drop duplicates, and sorting the result to preserve order, illustrated with the BCL2A1 gene name.
Learn how tuples in Python act as read-only collections, accessible by index and slice, with functions len, min, and max to handle homogeneous numeric or string data.
Course description
This course is designed for beginners in programming with a biological background who want to deal with biotechnology data such as DNA, RNA, and protein, or who want to enter the field of bioinformatics.
This course requires you to install Python (this was explained in detail in the first section), and we will also need to install the Integrated Development Environment in order to write codes in it (this was also explained in the first section).
All the Python files in which the codes were written, which you will see in the videos from the beginning to the end of the course, we have provided in a folder that you will download from the first section of the course.
I want you to read this well because it will explain many things to you that will help you to continue learning the Python language by clarifying the fruit of each section of the course.
In the first section, you will install Python, then you will know the modes through which you can write the codes, then you will learn the basics of the Python language, such as variables and what is related to them, comments, printing data to the user, and receiving data from the user.
From this part, you will be able to learn how to receive data from the user, how to store the data inside the code, and how to output data to the user.
In the second section, you will learn about data types in Python. The meaning of data types in Python is the form in which Python understands user data. And you will learn about converting from one data type to another.
One of the fruits of the first section is storing data in variables. Here you will learn more about the format in which the data will be stored in these variables, and this varies according to the nature of the data that the user will enter. It may be a number, DNA sequence, table, file, and so on.
In the third section, you will learn how to access just one element of data.
After storing the data in a type of Python data, you will be able to delve into the data through Python, so you can access a very small part of the data and thus be able to deal with it however you want.
In the fourth section, you will work with me on simple code. We will rely mostly on the information that we learned in the first three sections, where we will store data in Python, then receive data from the user, then search for it in the stored data, and output information to the user related to the information entered.
In the fifth section, which is extremely important, we will learn operations that can be performed on the entered data and how the data can be updated. We will also put questions or conditions about the data that will give us one of two answers, either true or false.
This section will give you the power to make decisions about the data.
In the sixth section, you will learn how to write your decisions in code and help write procedures based on the decisions made.
This part is very related to the fifth part, so they must be linked together.
In the seventh section, you will learn how to use loops.
These are precisely the ones that a person is unable to perform because they are characterized by repeating a set of commands at the speed of a computer, and therefore they can do complex things that a person cannot do in a short time, and therefore you must understand them well.
In the eighth, ninth, tenth, and eleventh sections, we will learn many functions in Python that manipulate data.
Knowing many functions enables the programmer to manipulate data, which is reflected in the effectiveness of the extracted information.
In the twelfth section, one of the most important sections in the language in general and in the field of bioinformatics in particular, in which you will learn a new method of input and output, where input and output were functions, but now they are files, which are the biological data storage unit.
You will also handle operating system paths within Python.
In the thirteenth section, you will learn how to deal with time and date, and this section may be useful in calculating the time and printing it in the output.
You will find, for example, in some programs that contain more than one process, that the time and date are printed for each process.
In the fourteenth section, you will learn how to separate code and put it into structures that only work by calling, which is building your own functions.
This is the first way to build the code for the user in a usable form.
In the fifteenth section, you will learn to build scripts and modules that are considered the official output from the codes. That is, once you reach this stage, you can create your codes in modules that can be imported into Python easily.
In the sixteenth section, you will learn to build the package, which is a collection of modules.
There will be a project consisting of three modules that will be implemented step by step in front of you, and there will be improvements and error corrections, and therefore you will get good information and experience from this section.
In the end, you will find that the course will teach you information and experiences about how to receive data from the user, how to deal with it, and finally how to output the information that the user wants.
This is what you will need to build your code, whether it will be complete applications or some code that deals with data slightly, or contribute to the use of existing Python packages.