Part 3: Flow Control
Outline
- If, else if, else
- For loops
- List comprehension
- While, Iterators
- Break, Continue, Pass, Try, Except
- Simple Functions
- Group Exercise
If, else if, else.
- If, elif (else if), and else statements are used in python to control what happens based on the circumstance of one or more events:
- The following are valid orders of statements. In both scenarios where elif is, as many elif statements can be there as desired.
if True:
print("Hi there!")
if 22:
print("Hello world")
if True or False:
print("Binary operators work here.")
if 0:
print("This won't be printed")
elif 1:
print("Any value other then 0 is treated as True")
else:
print("This won't be printed")
>>> if True:
... print("Hi there!")
...
Hi there!
>>> if 22:
... print("Hello world")
...
Hello world
>>> if True or False:
... print("Binary operators work here.")
...
Binary operators work here.
>>>
>>> if 0:
... print("This won't be printed")
... elif 1:
... print("Any value other then 0 is treated as True")
... else:
... print("This won't be printed")
...
Any value other then 0 is treated as True
>>> # Be sure to include a couple of enters here so it all executes!
For loops
Iterating through lists
wizard_list = ["Harry", "Ron", "Hermione", "Fred", "George"]
for name in wizard_list:
print(name + " says Wingardium Leviosa")
>>> wizard_list = ["Harry", "Ron", "Hermione", "Fred", "George"]
>>> for name in wizard_list:
... print(name + " says Wingardium Leviosa")
...
Harry says Wingardium Leviosa
Ron says Wingardium Leviosa
Hermione says Wingardium Leviosa
Fred says Wingardium Leviosa
George says Wingardium Leviosa
Iterating through dictionaries
- Looping through the keys in a dictionary, or iterating through other objects while construction a dictionary is a valuable way to construct robust objects that are easy to build upon.
- We can loop through the
.keys()
or.values()
as well.items()
which is both the key and value pair together like this.for key, value in d.items(): print(key, value)
wizard_dict = {"Harry": "Lumos", "Ron": "Alohomora", "Hermione": "Wingardium Leviosa", "Fred": "Riddikulus", "George": "Sectumsempra"}
for wizard in wizard_dict.keys():
print(wizard + " says " + wizard_dict[wizard])
for spell in wizard_dict.values():
print(f"A wizard says {spell}")
>>> wizard_dict = {"Harry": "Lumos", "Ron": "Alohomora", "Hermione": "Wingardium Leviosa", "Fred": "Riddikulus", "George": "Sectumsempra"}
>>> for wizard in wizard_dict.keys():
... print(wizard + " says " + wizard_dict[wizard])
...
Harry says Lumos
Ron says Alohomora
Hermione says Wingardium Leviosa
Fred says Riddikulus
George says Sectumsempra
>>>
>>> for spell in wizard_dict.values():
... print(f"A wizard says {spell}")
...
A wizard says Lumos
A wizard says Alohomora
A wizard says Wingardium Leviosa
A wizard says Riddikulus
A wizard says Sectumsempra
List Comprehension
- In python you can construct extremely custom lists in just a line of code.
- List comprehensions enables a lot of really cool 1-liners using a for loop and if, elif, else statements in a 1-line format.
wizard_dict = {"Harry Potter": "Lumos", "Ron Weasley": "Alohomora", "Hermione Granger": "Wingardium Leviosa", \ "Fred Weasley": "Riddikulus", "George Weasley": "Sectumsempra"} weasley_list = [wizard for wizard in wizard_dict.keys() if "Weasley" in wizard] weasley_list h_list = [wizard if "H" in wizard else "Voldemort" for wizard in wizard_dict.keys()] h_list
>>> wizard_dict = {"Harry Potter": "Lumos", "Ron Weasley": "Alohomora", "Hermione Granger": "Wingardium Leviosa", \
... "Fred Weasley": "Riddikulus", "George Weasley": "Sectumsempra"}
>>> weasley_list = [wizard for wizard in wizard_dict.keys() if "Weasley" in wizard]
>>> weasley_list
['Ron Weasley', 'Fred Weasley', 'George Weasley']
>>> h_list = [wizard if "H" in wizard else "Voldemort" for wizard in wizard_dict.keys()]
>>> h_list
['Harry Potter', 'Voldemort', 'Hermione Granger', 'Voldemort', 'Voldemort']
Challenge Questions:
While and Iterators
Iterators
- Lists, tuples, dictionaries, and sets are all iterable objects. They are iterable containers which you can get an iterator from.
- All these objects have a
iter()
method which is used to get an iterator. - We can also use a for loop to iterate through an iterable object or
next(some_iterator)
to ge the next object.
While loops
- Evaluated as long as the condition is true. Instead of a True False value (boolean) it can also be a non-empty list or empty list, respectively.
h_iter = iter(h_list)
cont = True
while cont:
if "Voldemort" == next(h_iter):
cont = False
else:
print(next(h_iter))
h_iter = iter(h_list)
cont = True
while cont:
value = next(h_iter)
if "Voldemort" == value:
cont = False
else:
print(value)
>>>
>>> h_iter = iter(h_list)
>>> cont = True
>>> while cont:
... if "Voldemort" == next(h_iter):
... cont = False
... else:
... print(next(h_iter))
...
Voldemort
Voldemort
>>> h_iter = iter(h_list)
>>> cont = True
>>> while cont:
... value = next(h_iter)
... if "Voldemort" == value:
... cont = False
... else:
... print(value)
...
Harry Potter
Break, continue, pass, try, except
Break vs Continue vs Pass
- Pass: When you call pass, the rest of the code outside of the if, elif, else statements will continue to execute.
- Continue: When you call continue, the continue will immediately return to the next part of the for loop.
- Break: When you call break nothing within the for loop, including the for loop will continue execution.
a = [0, 1, 2]
for element in a:
if not element:
pass
print(element)
for element in a:
if not element:
continue
print(element)
for element in a:
if not element:
break
print(element)
>>> a = [0, 1, 2]
>>> for element in a:
... if not element:
... pass
... print(element)
...
0
1
2
>>> for element in a:
... if not element:
... continue
... print(element)
...
1
2
>>> for element in a:
... if not element:
... break
... print(element)
...
Try and Except:
- Try:
- Except:
Simple Functions: parameters, scope, returning, passing
Lets define two functions or definitions
The two following functions are used to compare the different way that parameters can or can not have default arguments defined.
- simple_function:
def simple_function(some_string):
string_passed = True
if some_string:
final_string = "You passed the following string: %s" % some_string
else:
string_passed =False
final_string = None
return string_passed, final_string
def default_function(some_string="Default string"):
string_passed = True
if some_string:
final_string = "You passed the following string: %s" % some_string
else:
string_passed =False
final_string = None
return string_passed, final_string
simple_function()
simple_function("Testing")
default_function()
default_function("Testing")
# these are kind of advanced topics but good to briefly introduce you to
default_function(**{"some_string": "Dictionary_testing"})
default_function(*["some_string"])
>>> def simple_function(some_string):
... string_passed = True
... if some_string:
... final_string = "You passed the following string: %s" % some_string
... else:
... string_passed =False
... final_string = None
... return string_passed, final_string
...
>>> def default_function(some_string="Default string"):
... string_passed = True
... if some_string:
... final_string = "You passed the following string: %s" % some_string
... else:
... string_passed =False
... final_string = None
... return string_passed, final_string
...
>>>
>>> simple_function()
Traceback (most recent call last):
File
TypeError: simple_function() missing 1 required positional argument: 'some_string'
>>> simple_function("Testing")
(True, 'You passed the following string: Testing')
>>> default_function()
(True, 'You passed the following string: Default string')
>>> default_function("Testing")
(True, 'You passed the following string: Testing')
>>>
>>> # these are kind of advanced topics but good to briefly introduce you to
>>> default_function(**{"some_string": "Dictionary_testing"})
(True, 'You passed the following string: Dictionary_testing')
>>> default_function(*["some_string"])
(True, 'You passed the following string: some_string')
Group Exercises (~30 mins)
- Use the below to perform the following tasks:
seq = "CGGTAAGGCACTTGATATATTAATGTTCAGGCGGACATCGGCAGGGTATATTGCGTTAGGATCTAATTAATCTATCAGACTACTTGAGGATTGTCACCTGATGGTAATAGCGTAGTGGGGATCGCTAATCCTACTGTCGATAGACGGCTGCGGTTAAACTAAGCATCTTGCTTCCGGACGGTGGAACCGATTCAAGCGTTAGCAAATGTCAGGTTCACACTAAAGAATCAGCGGGTCTCCCCTACATCTTGAGTTTTATGGCTAACCCTATATCTGTCGATAGCATGGCAGGTTCAATTTAATCACAGTGCTTGCACTGACCTCGCCTACCGGAAGCCCCGCCGCCCAAAGTGACACCAGAGTCTTCGTCACGCAGATAACGCCCCGTGCTATCTGTCCCCCGTCCTTCGAGCAGGAGTTTGGTCTGACGCCTACTTCGGCGAACGTAACCCCTCCTTGTCTGTATTAAACTGCCCCGGATGTCGACTGGTAACAAGACGGACTACAAATAATGTGTACCTTTAGACGTTCTTTAGTGATATATTGTGACCACGTATTACAGAGATACACGACATCTCCTTTATAGGTACACATAACCTAGGATCCGTAGCACCGGGCCGGATTCTGCCCAGCAAGGTGCATCCCATAAGCGTAAACACTGCACGGCGGTCAGAACTCCCCACAATCGATACGGTGTCAACTATGGTACGGATGTCAGTCGGTCCTGTAGATGCACTTGGAAGTGTACCGCGTAGCGTCGCAGGAGCGTAAACATCACCTGGACGGTCCTTTCCAGTAATGAGGAACTCAAACATATAGGGCAGG"
- What is the complement of this strand of DNA?
- What is the reverse complement of this strand of DNA?
- Use the below to perform the following tasks:
table = { 'AUA':'I', 'AUC':'I', 'AUU':'I', 'AUG':'M', 'ACA':'T', 'ACC':'T', 'ACG':'T', 'ACU':'T', 'AAC':'N', 'AAU':'N', 'AAA':'K', 'AAG':'K', 'AGC':'S', 'AGU':'S', 'AGA':'R', 'AGG':'R', 'CUA':'L', 'CUC':'L', 'CUG':'L', 'CUU':'L', 'CCA':'P', 'CCC':'P', 'CCG':'P', 'CCU':'P', 'CAC':'H', 'CAU':'H', 'CAA':'Q', 'CAG':'Q', 'CGA':'R', 'CGC':'R', 'CGG':'R', 'CGU':'R', 'GUA':'V', 'GUC':'V', 'GUG':'V', 'GUU':'V', 'GCA':'A', 'GCC':'A', 'GCG':'A', 'GCU':'A', 'GAC':'D', 'GAU':'D', 'GAA':'E', 'GAG':'E', 'GGA':'G', 'GGC':'G', 'GGG':'G', 'GGU':'G', 'UCA':'S', 'UCC':'S', 'UCG':'S', 'UCU':'S', 'UUC':'F', 'UUU':'F', 'UUA':'L', 'UUG':'L', 'UAC':'Y', 'UAU':'Y', 'UAA':'Stop', 'UAG':'Stop', 'UGC':'C', 'UGU':'C', 'UGA':'Stop', 'UGG':'W', } rna = "AUGAGCGCGAGUCUUGGUCUCGCAUGGCCCGUGGUCGGGACAGCUGCACAUGGGGGACCAGUUAUCCUCAGUAUAACUUUCUGCACCGAGACAAUGACUCAGUUACAGCGUAAUUUCAUUCUCCCUUCGCCAAAUGAUCCCUGGCUAAGUAACCAAAUUAAGCCCAAGCCUUGGACCGGCAGGAGUGAGCUGCUCUUUCAUAGGGGCAAAUCCAGCACGCCGCGGACGUCGAAGCCGUUGAAUCCACCACCGACGGUAUCGGGCUCCGGCAAUACACCAAUAAUUCCCUGCUUAACCCGUCCGUCUACUUCAGCUGUGACCCCAACGCGUGAUGACUGGCUGCGCCACGAGCACCCAGGACUCCGGAACCUUGAGCAUGGAAUGAUAAAAUUGGGCUCAGCCUGCUCAGUUCAAAGGGGCCCUUCAAGCUUACGCCCGAUCAGACAUUACAGCACUUCGAGGGAUCGUAUAAGAGCUUGUCUCCAUAACACGACCCGAUGGGGCCAACAGACACUACUUCGAACUGCCGGGGGUCGAGAAUUAAUUCUACUGAC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CGUCGAAGCUUGCCCCGCGACUCCAUCAUUUGUAUCUAGGGAUCUCGACGUAG"
- What is the protein encoded?
- OPTIONAL: What are ALL the possible proteins possible from this rna string given any start position?
- Use the below to perform the following tasks:
str1 = "GCAGTGTCCACGGGATGTAAACCCCGTTTGGGACCTGCCAGGCTTCCGCACTACAGTGTGTTGCGCGTACTAGACCTTATGCCCATATGAACCTAGCTCGGGCTACTTGGATCGAGGAACTCGATACTTCCCCTACTGCAGCCCAACAATATCGTAGAAGGCAATCGAATCGCCTAAAAATTTATCGCCGCATTTTACGTATATGCCGGCTGTGGCGTATAGCAGAAAACCGCTCCTCGCAAAGTCTGGAGTATTGGATGAACAGTACCCTGGATAGAGTTAAAGGGCCAGAAAAAGCCCAAGACCATGGCTTACCAAGTTCCGTCCTATTCAATATAACCTCAGGCAGCTATGCGGAACTTTCAATAAAATACCAAGACATGTCTCTGTCTGCTCCAGAGCGAGTGGATAGGCCCGATTATTTATGTGTCGGAGGACCATGGTTCGCAATTACACTCAAGCGAGCGATTTTTTAACTGTCCGTTCACCTCACGGACCTCGGGAGGATACAGAATCGGGTGGTAATATAACGAACATAACCGTTTGTGATCCTGGAAATACACAAGTTCATAAAAAGTGTGACCCGAAAGTGGTTTCACTATATAGGTATTCCCCCTAGTATGGCAATCTCGGTCAGTCAGCACTGGCCGATGGCTCAAGGCAACATTAGGGGTCGGCGAACGCAGTTGCTCCAAATACAAGTGTGGTTGCAAGTAGCATACGGCACACCGCGGTCTGGGTATGAGCCATACGTGTGATTTTGGTCAATTACCTAAGCAGCTTGTAGTCATAGCTATCTTACCGATTAGCGAACCCAATGAAGAGTTCCAGCATTCGCGAATGGGGGGTACAAGTAGGCTCTCGGCCGCCTACTAGACCGGGCGGTAAGGTGGCGTGTAGACCAAATCCTTA" str2 = "AACTAATCAAACTGGCTGGGATTCCTTCGGCTAAATACAGTCCCATCCAAGTATAGTCTGTTATTTGTGCTACGCCTCAAGCCTCTGATATGCGGTACCCTTGGATTTGGAGTGTAGGCCACCAGATCTGTTTTGATCCGGCCGGATCGTATCGAAAGATACTGAAGGAGCTCATAAACATTGAGCGTGTCAGAGTGGCCGAACGCCGGCGGTCGCTACAACAACAGGTCGTCGACTCCCTAACGCGCTGACATAGGTCTAATAGTCACGTGTATGGTTCTATCTGTGGAACAAAAACTAAAGCTCTTGGCTTAAGATGATCGTACCTGACGGATGTAAGATTCGACAACTAAACCGTTTTATCGTTAAAACATGCCGACCTGACTGTTGCTTCTACAGAGCGCGTTCAAAATCGTGCCTATCCTACAGTCGTACGCTGAGTGAACGCTCTTAAAATCTAGGAAGAGTAATCTTGCATATCCGAACCGAGCTTAGCCCTCCAATGAATAGAAGTACGCGCCTTTGTATTCCGAACATTTTCGTCTGCGATACTGGAAACATGTATGATCGTAAACACTGGGACCCGTCATTAGGTCTTTGATAGTATCGGTGCCTATATGGTGTCATTCTTATTCGGGCTAAACGAACGCTTGGCTCTGCGAATTGTAACCTGAGCTGAGGCGCACTCATAACACAACAAACGGAGCCTGGATATATCATAATGATTCTCCTGGGATGGGTACACGAGGCACCTTAGACTGCGCATTGCTCTAAGCACACCTAAGAGCCTGGTCAAGAACAGCTATTTGCGTACGCAAAGATGCGTTGATTCAATGGGGAACGCCGGGATCTTCTAGACTCGCAGCGCCCTCACTGCCGGGTGCGTAGCCTTGCGCCTGTCCATGATCACCA"
- How many matches are there between the two strings?
- How many mismatches are there between the two strings?
- What is the GC content of the first string?
- What is the GC content of the second string?
- If you have any free time after these tasks take a moment to check out Rosalind. It is a great platform for continuing to challenge your python and bioinformatics!