New User Special Price Expires in

Let's log you in.

Sign in with Facebook


Don't have a StudySoup account? Create one here!


Create a StudySoup account

Be part of our community, it's free to join!

Sign up with Facebook


Create your account
By creating an account you agree to StudySoup's terms and conditions and privacy policy

Already have a StudySoup account? Login here

Study Guide for the Bio-Comp Test

by: Marina Notetaker

Study Guide for the Bio-Comp Test CSE 6613

Marketplace > Mississippi State University > Buttler Hall > CSE 6613 > Study Guide for the Bio Comp Test
Marina Notetaker
GPA 4.0

Preview These Notes for FREE

Get a free preview of these Notes, just enter your email below.

Unlock Preview
Unlock Preview

Preview these materials now for free

Why put in your email? Get access to more of this material and other relevant free materials for your school

View Preview

About this Document

Includes questions, detailed answers and all information given in class up to now! Check it out at the first pages that can be seen as example!
Andy Perkins
Study Guide
50 ?




Popular in Bio-computing

Popular in Buttler Hall

This 22 page Study Guide was uploaded by Marina Notetaker on Thursday September 22, 2016. The Study Guide belongs to CSE 6613 at Mississippi State University taught by Andy Perkins in Fall 2016. Since its upload, it has received 25 views. For similar materials see Bio-computing in Buttler Hall at Mississippi State University.


Reviews for Study Guide for the Bio-Comp Test


Report this Material


What is Karma?


Karma is the currency of StudySoup.

You can buy or earn more Karma at anytime and redeem it for class notes, study guides, flashcards, and more!

Date Created: 09/22/16
STUDY GUIDE – TEST 1: Bio-computing This study guide includes a list of questions followed at the end by answers/codes and figures. Theoretical questions and exercises to perform on Python. It includes all material given before the test. Also includes additional sum of codes to remind before the test. 1) What Crimson Editor is that for? 2) What are the advantages of using Python? What is Python? 3) Reasons for doing programming. At least 2 reasons. 4) Give two situations in which programming is not recommended. 5) How to open Python? 6) What does ‘..’ means? 7) Why you cannot use word for Python? 8) Write a code in which you must print - A number multiplied by 2 - Sum of two numbers - Subtraction of two numbers - Exponentiation of two numbers - Modulus of two numbers - Division between two numbers - Average of two numbers 9) Which a code in which you must have: - Ask the person to insert a file name on the keyboard - Open to read only a file containing a list of numbers (at least 5 numbers) - Sum all numbers from a list - Average all numbers from a list - Multiply all numbers from a list by 2 - Verify which number if odd or even from a list - Divide all numbers from a list by 5 - Give the standard deviation from the list - Add a second list (2,4,8) to the list - Add the number 10 - Remove the last number from the list - Remove the number on the position 2 of your list - Print the number on the location 3 from your list - Count how many times the number 5 appears on your list - Remove the number 4 on your list 10)From your keyboard write: - String - Repeat your spring twice - Add two different strings together - Print two strings together with a space in between - Print all in upper case - Print all in lower case - Print all in title case 11)When you should use ‘..’ and “..”? 12)Give two ways to scape a quote. 13)Give two ways to print in different lines. 14)Give one way to insert 2 tab spaces between given 2 strings: hello world. 15)What is a conditional statement? 16)Write a code in which you test if a number is equal to 5. If it is true print true, otherwise print false. 17)Write a code in which you test if a number is greater than 3 and lesser than 10. If it is true print true, otherwise print false. 18)How tab is organized in a multiple intentional levels? 19)Write a code in which you test if a number is equal to 5 and print if it is true. Then if a number is lesser than 3. Then if a number is greater than 2. Print if it is all false. How manyintentional levels do you have? 20)Can you use spaces instead of tabs? 21)What if you want to test if one out of 3 statements are true? What would be the code? Give an example. 22)What code print a result in which all testing statements are true? 23) Write a code in which: - DNA sequence must be inserted from the keyboard - Test if it has a start codon - Test if it has a stop codon - Print if it is not any of them 24)How to turn a string in numerical keyboard? And decimal? 25)Write a code in which: - Initial statement is that a is a result from a number multiplied by 5 - Print if a is not equal to 15 - Print if a is not greater than 15 26)Write a code that multiply a number by 10 and test if it is equal to 100. 27)What is loop? What are the two main codes for that? 28)Write a code in which: - Loop starts from 0 and ends in 10, excluding 10 - Counting up adding 1 29)Write a code in which: - Loop goes from 0 to 10, excluding 10 - Counting down by multiples of 2 30)When the loop is infinite? 31)Write a code in which: - Initial number should be written from the keyboard and is less than 100 - Count up by all multiples of 3 - Print what is outside the loop 32)What is an element? 33)Given the sequence ATGCAG: - Give location of T - Give the first codon - Print the sequence from T to the end - Print the sequence from the beginning till C 34)Find the location of the codon TTT from the sequence ATTGCCTTTAG. 35)What are the parts of a program? 36)Write a code in which: - Insert a DNA sequence at the keyboard – at least 10 letters - Print the letters located from 0 to 6, including 6 - Count the numbers of each base pair - Give the length of the sequence - Give the GC content - Print all codons without overlapping bases 37)What is scales and lists? 38) Give the following codes: - Insert/write a list - Locate a character from a list - Give the character from a specific location - Indicate how many times a specific character appears on the list - Add a character in the list - Remove a character in the list (2 ways) - Concatenate a list - Length of list - Find location of a string from a list - Remove last character from a list - Save a character before removing it and then adding the character - Ordering in numerical/alphabetical order - Deleting a slice of your list - Opening an empty list - Cleaning a list 39)Write a code in which: - Ask to give a file name from the keyboard (file must have one sequence/line at least 5) - Read the file - Print the file without jumping lines - Turn the file into a list - Give the length of each line - Give the average of the length - Give the standard deviation of the length - Find the longest sequence - Find the shortest sequence - Calculate GC content from each sequence and in all sequences together - Output sequences into a file where include the ones greater than 10bp 40)What are the commands for: - Read all lines - Read one line at a time From now on, there are detailed notes from the last two weeks before the test. After these notes, the answers from the questions above are also given in detail!! Working on Tuple – Python 1) Types of tuples: -2 tuple or pair tuple: (x, y) -3 tuple: (x, z, y) -4 tuple: (x, y, w, z) -n tuple: (1, 2, 3, 4, ..n) It is an easy way to store things. 2) Tuples can be treated as lists. But they are not lists! They are ordered pair or ordered ‘n’ things. - Just like lists, it can give you the number as you ask the location Note that it can gives you a comma, so you know it is a tuple. However, if you ask [0:2], it will print (1,2) and not a comma because it supposes you already know it is a tuple. List of Comprehensions 1) List comprehension is a list of tuples. 2) Remind that list is always between [ ]. -Following codes show how to print a list -how to print all possible combinations between two lists (when it does, it becomes a tuple) -how to turn coordinates or tuples into a list -for to work on functional graphs 3) Another way to print out all possible combinations between lists by just using one line: - On python: - On interpreter 4) Note: you don’t need to have same number of variables on each list, x can have 3 numbers, y can have 5 and z can have 2, for example. 5) If you just want to append numbers that are not equal in both lists, just print once a number. 6) You can have more than one conditional to print your combinations. For example, you have a tuple of (x, y) in which x can’t be equal to y and also can’t be greater than 3 7) Something you might be asked to do with list of comprehensions 8) List versus range: it looks like the same, can be treated equally but they work differently See same on python: Note that when you ask it to print the list, it only gives you the number where it starts, ends and how much it is adding. It does not give you all numbers because it does not store it. If you want it to print all, what you can do is: turn your range list into a list object and print the list object, as follow: >>>>>>>>>>>>>>>>>>>>> So when you do print(list(list range)), it does a loop and print all numbers from the loop for you. 9) Empty Pairs are: empty = ( ) 10)Singleton is a tuple with only one thing on it, but for being considered a tuple with only one thing you need to type a comma after your ‘thing’ otherwise it will treat it as a string So when it is a string, you see the length is 5 and it is printed as ‘string’. When is it a singleton, the length becomes 1 and it printed as (‘string’, ) So you need a comma to python understand that it is a tuple! A singleton can be all ‘x’ values you want to use for a function or it can be all sequences you want to use to calculate a GC content data after, such as pair = (‘sequence’, GC%). SETS 1) Sets look like list but are not. Sets are a collection of objects in no particular order and no duplicates. Objects can be numbers or strings, it does not matter. In math it looks like this: A= {1,2,3}.  It is not a tuple. If it was a tuple it would be (1,2,3) and the order would be relevant. 2) Operation Union on sets: x in A Union B if x is in A or x is in B. Code: set1.union(set2) A = {1,2,3} B= {3,4,5} A U B = {1,2,3,4,5} You can use union for more than one set so a.union(b,c,d) 3) Operation Intersection: x is in A intersect B if x in A and x in B. Code: set1.intersection(set2) A ∩ B = {3} 4) Operation difference: gives you what one set have that the other does not: set1.difference(set2) 5) To have an order, you need to turn it into a list, so you use the code list(set) and print it. Now it becomes a list. List the order matter as long as you tell python to order your list, otherwise every time you print your list it may come in a different order. So, turn to a list >> list(set) >>note it is then printed in [ list ] You still cannot sort it because you don’t have a name for your list. Name your list>>> mylist = list(set) Put into order >>> mylist.sort( ) Print it. It is done. If necessary you can always save the order it was before sorting, but remember it does not mean it was the original order depending on how much you have “touched” your list. 6) Turning a list into a set. Remember, it does not have duplicates! myset = set (list) Note that once you add 7 and you set it, it won’t print 7 twice. No duplicates. For any change you do on your list (a), to have it update on your set, you need to last to set(a) again, because any change you do on your list, it changes the ID. 7) You can treat sets like numbers for loops >>>>>>>>>>>>>>>>>>>>>>> 8) Suppose you want to take out duplicates from your list. You can do that by changing your list into a set and then taking back into a list: Making a list from the keyboard 1) Imagine you want to sum a list of numbers that should be entered on the keyboard. You can ask on the interpreter and use a loop for that: Note, in the “fast way” you put a limit of 4 numbers to be inserted on the keyboard. 2) Now imagine you want the same thing as before but the person on the keyboard that must choose how much numbers to put into the count. First one just let you insert a maximum of 5 numbers, which you can change it and the person insert till the maximum number you estipulate or till it writes done. Second one, no limit for writing a number and will only stop counting when writing done. KEYS - DICTIONARY 1) Themainoperationsinvolvingadictionaryisusingakeythatmatcheswithavalue.Soyoucanmanipulate your value by using your key. It is also called associative ray. Key is something that matches with a specific value. Looks like a pair of things but it is a little different because it is a list of that. Key can only appear on your list one time. How you write it is between { }, the key is ‘key’. Example: dictionary = {‘key1’ : 00, ‘key2’ : 1} You can write on python or at interpreter. Useful: you always something associated with something else, for example, a gene and its expression value or a gene associate with sequence or name of someone and phone numbers. List does not associate. So it is difference. Tuples can do that and allows repeats, however, it is difficult to analyze. *List or dictionary? You should always use dictionary if you need to do an association. 2) Giving the value from a key: - On Python: dictionary [‘key’] - If the key does not exist on your dictionary, it gives you an error. 3) Adding a key + value on dictionary: dictionary [‘newkey’] = value 4) Changing the value of your key: dictionary [‘key’] = new value 5) Deleting a key + value: del(dictionary [‘key’]) 6) You cannot have duplicate keys but you can have duplicate values, for example, Bob and Anna can have same number on dictionary. 7) Your value can be a list or a tuple or more than one value associated to same key. Note, now Bob has a tuple value. You can now get the specific number from each tuple value from Bob by asking the number by its location>> dictionary [‘key’] [location] So you can store a tuple inside a dictionary. You can also store a tuple inside a tuple. You can store a list inside a tuple and vice-versa. Note, now Bob is a list. *** Keys cannot be a list or a dictionary. Keys are usually a number or a string. It may be possible to a key be a tuple. But you value can be anything you like. 8) Asking for the keys: list(dictionary.keys( )) This give you the list of the keys. If you just write dictionary.keys( ), it will give you something like dict_keys([ list of keys]). But it is not worthy because you cannot do too much with that. 9) Asking for the values: list(dictionary.values ( )) We never know which order the values will come! Same can be done at the interpreter: 10) Turning your dictionary into tuples of (‘key’, value): Dictionary.items( ) Whenever you write dictionary.items( ), python knows that it is to turn into a tuple of (k, v). EXAMPLE 1 - DICTIONARY Building a dictionary that would store genes and its sequences from another txt file. My file is: Dictionary should be { } and you can also do genes=dict() or also gene=[ ] but the last one looks like a list so it is not advise. ** Don’t forget to close your files whenever you open because it if you do a loop it won’t stops and consume memory of your computer. a) Open your file: f = open(‘file’, ‘r’) b) First code to make it read your lines : for line in f: c) Make each line to be read one at time without jumping lines: line=line.strip( ) d) Split the key and the value, which means separate whatever have spaces in between: fields=line.split( ) Note, line.strip( ), makes you print each line together, no jumping lines. Line.split ( ) will turn your line into a list [gene, sequence]. Line is: gene sequence. Field is: [‘gene1’ GTATGAGTATAGG] Genes is: {‘gene1, GTATGAGTATAGG} e) Creating your dictionary. So you created an empty dictionary called gene= {}. Now you write what it will be on your dictionary. Note that you are doing for line in f, which means, a loop. Because it is a loop, it will print adding each character at the time, adding in duplicates (each field at time). When you say genes [fields[0]] = fields [1], you telling that on your dictionary the key (fields[0]) should be associated with the value (fields[1]) f) Taking out the headline (gene sequence) from your file, which is your first line. g) Asking the person on the keyboard to write the name of the gene that she/he wants to know the sequence: Note: it just allows you to enter a single gene and get its sequence. h) Enter as many genes as you want to know the sequence: In this case, would be good if you write “if repeat.upper( )==’N’:” so you make sure if the person on the keyboard write ‘n’ instead of ‘N’ and it will still works. **Another way: Note: you can write ‘y’ or ‘Y’, because you wrote .upper( ), it will convert ‘y’ always to upper case if it is not. Also, whatever word that is not ‘y’, will stop your loop. Identifying if it is integer or string Integer is a number while string is bunch of words. So python can give you what it is: type(x) It is useful because when you apply codes like dict.items( ), you are treatment all as a list but you don’t know is it’s a list of strings or numbers. EXAMPLE 2 – DICTIONARY Make a dictionary where your key = gene and the value will be a list, such as [1.5, 2.1, 7.0]. The file will be: And if you wanted to work only with the first and third value? Different ways to do it: Now you want to sum all values together, then you want to sum only the values related to the same gene. You can use: So for the dictionary items, sum the values. Note in this second one you have sums = dictionary and sum = sum of values. So in this segment code you are printing your resulted values from same gene in a dictionary where {gene, single value}. *** If you write the sum=0 outside the loop, it will sum numbers from different genes. It would be gene1 = sum of its values, gene 2= sum of gene1 + sum of values from gene2, etc. Another way to print it… Instead of printing as a dictionary, you can print in each line the gene and its summed value. EXAMPLE 3 – getting rid of repeats Suppose you have a list of sequences and you want to print this list containing the sequences, without repeat sequences that are equal. So, you can turn your list into a dictionary because dictionary cannot have repeats. Then you want to know how many repeated sequences you have on your list. WORKING WITH MATRIX 1) Suppose you want to store a matrix into a program. So basically you create a list of lists. 2) Ask to print a number in a specific location of a matrix. So, matrix [row] [column] It will print 9 on the keyboard. 3) The problem happens when you do a matrix with a bunch of zeros. It is called sparse matrix, matrix with lots of zeros. The problem is that if you need to do many calculations you will end up with more zeros. The problem it occupies memory because in this case it will store 24 numbers in which only 4 matters. Because zeros are irrelevant. Matrixes are important in molecular biology because you can store a matrix with sequence similarities, like the ones produced by Clustal Omega. 4) Trying to find a number on the matrix from your keyboard. So you can tell that same matrix above you have 1 in the positions (1,0), (4,2) and (0,4). And put these positions on a dictionary. So, dict = {(1,0):1, (4,2):1, (0,4):1} That means that (row:col) has 1. Then you can ask what number it is on: Dict = (row, col) However, because you did not define what numbers you have on other positions at first it will give you an error. You can use dict.get ((row,col), number) where number turns to be the missing number you want it to be. So it this case I want that the positions I didn’t insert a number become zero and so all other positions, using same code, if they had a number described before, they still have same number (1). Dic.get = let you treat a dictionary as a matrix. So number can be a number or a string. It does not matter. Same thing can be done on your interpreter. So there, you can turn your matrix in a dictionary and just input where the numbers that are not zero are. Dictionary.get((row,col), number) can also be use on your interpreter. Doing the same code, but asking to print the numbers on the same line. Turning your matrix in a dictionary is a good way to save memory on your computer. …………………………………………………………………………………………………………… *** When you have a list you can use codes to work on the list of comprehension. For example, imagine you have a list and you want to multiply all your numbers from your list by 2. You can do the same thing using a loop, “for num in a: num*2…” If you want a list of that, you just append the number. If you do a*2 instead of a[index]*2, instead of multipliying each number from a, it will make 2 copies of a. .................................……………………………………………………………………………………………… Back to your matrix… Build a matrix. When you write matrix = [0*5], it means that you have a matrix with 5 zeros in one line. When you write matrix = [[0*5]*5], it means you have a matrix with 5 zeros in 5 lines. WORKING ON MATRIX OF GENE EXPRESSION Imagine you have a matrix where each line represents a single gene and each column gives you expression of different samples from that same gene. You input file will look like this: So, first same steps as always: Imagine you can take the average of these numbers and print it in a dictionary **Dictionary can be treated as lists, with same commands. For example, if you have 2 dictionaries and one is equal to the other one and you change one, because both have same ID, the other one will change too. So if you want to change one without affect the other you need to save copy. STUDY GUIDE – TEST 1 - ANSWERS: Bio-computing 1) Crimson editor is a programing interpreter for Python where you can save, share, change codes. 2) Python is a computer programming. Reasons to use it: very common and known, can work with lots of texts, don’t need or require additional programs such as Java. 3) Reasons: repetitive commands and things that are too much complex to do by hand. 4) Not recommended: when programing take longer than doing by other ways or it will never be used again. 5) Open command file > cd desktop > python 6) ‘..’ is a level up. Return a level up on your command file 7) Python does not recognize word extension. 8) 9) At the document named “working on list of numbers” 10) 11)It does not matter. Usually “..” is used to scape a quote. 12)Scape quote: 13)Print in different lines 14) Give 2 tab spaces 15)It is a statement in which you test if something is true or false. 16).. 17).. 18) The tabs organize the multiple intentional levels. Each tab count for a block on the intentional level. 19).. 3 intentional levels 20)No. 21)Code = OR. 22)Instead of OR, you use AND. 23).. 24)Turn a string in numerical order: int(string) or float(string). Float turns to decimal number. 25)You could also say e = input(‘please give a number’) 26).. 27)Loop is a way in which a number or a string goes from a start point to a ending point. Two main codes: - While > or < ..: - For .. in range (start, end, how much jump) 28).. 29).. 30) The loop never ends if it is always true. 31).. 32)Element is a character that is part/letter/number from a list or string. 33).. 34)Use the code string.find(‘TTT’) 35)Parts of a program: - Initialization - Testing - Increment 36).. 37)Scales are single values and list are group of values/elements. 38)Codes for: - Insert/write a list: list = [z,w,v] - Locate a character from a list: list.find(‘character’) - Give the character from a specific location: list[location] - Indicate how many times a specific character appears on the list: list.count(‘character’) - Add a character in the list: list.append(character) - Remove a character in the list (2 ways): list.remove(character) or list.pop(location) - Concatenate a list: list = list + [z,a,w,b] - Length of list: len(list) - Find location of a string from a list: list.index(‘string’) - Remove last character from a list: list.pop( ) - Save a character before removing it and then adding the character: save=list.pop( ), list.append(save) - Ordering in numerical/alphabetical order: list.sort( ) - Deleting a slice of your list: del list [start: end] - Opening an empty list: list [ ] - Cleaning a list: list [ ] 39).. 40)F.readlines( ): read all lines from a file f.readline( ): read one line at a time from a file


Buy Material

Are you sure you want to buy this material for

50 Karma

Buy Material

BOOM! Enjoy Your Free Notes!

We've added these Notes to your profile, click here to view them now.


You're already Subscribed!

Looks like you've already subscribed to StudySoup, you won't need to purchase another subscription to get this material. To access this material simply click 'View Full Document'

Why people love StudySoup

Steve Martinelli UC Los Angeles

"There's no way I would have passed my Organic Chemistry class this semester without the notes and study guides I got from StudySoup."

Jennifer McGill UCSF Med School

"Selling my MCAT study guides and notes has been a great source of side revenue while I'm in school. Some months I'm making over $500! Plus, it makes me happy knowing that I'm helping future med students with their MCAT."

Bentley McCaw University of Florida

"I was shooting for a perfect 4.0 GPA this semester. Having StudySoup as a study aid was critical to helping me achieve my goal...and I nailed it!"

Parker Thompson 500 Startups

"It's a great way for students to improve their educational experience and it seemed like a product that everybody wants, so all the people participating are winning."

Become an Elite Notetaker and start selling your notes online!

Refund Policy


All subscriptions to StudySoup are paid in full at the time of subscribing. To change your credit card information or to cancel your subscription, go to "Edit Settings". All credit card information will be available there. If you should decide to cancel your subscription, it will continue to be valid until the next payment period, as all payments for the current period were made in advance. For special circumstances, please email


StudySoup has more than 1 million course-specific study resources to help students study smarter. If you’re having trouble finding what you’re looking for, our customer support team can help you find what you need! Feel free to contact them here:

Recurring Subscriptions: If you have canceled your recurring subscription on the day of renewal and have not downloaded any documents, you may request a refund by submitting an email to

Satisfaction Guarantee: If you’re not satisfied with your subscription, you can contact us for further help. Contact must be made within 3 business days of your subscription purchase and your refund request will be subject for review.

Please Note: Refunds can never be provided more than 30 days after the initial purchase date regardless of your activity on the site.