Python regular expressions and dictionaries

Assignment Help Python Programming
Reference no: EM131291169

Python Regular Expressions and Dictionaries

Module Overview

In this module you'll use Python regular expressions to parse /scratch/go- basic.obo and put the fields in a dictionary with GO id as the key. The GO records in this file are multiline, so you'll need to use a record separator other than the newline character. Unlike Perl, Python doesn't allow you to change the record separator for the readline() method, so you'll read the whole file in with the read() method and then use a regular expression to split the file into records.

Since you want to find all the records with your regular expression, you'll need to use re.findall(r"your regex here",goFile, re.DOTALL), which returns a list of matches. re.DOTALL tells Python to match across line breaks with .*.

Required Reading

- Python for Biologists Chapter 7
- Python for Biologists Chapter 8

SwissProt Parser

The code shown below parses a SwissProt file. SwissProt records are multi-­-line, so it's very similar to what you need to do to parse go-­-basic.obo.

1478_Figure.jpg

Assignment

Complete as many exercises from the book as necessary to understand the concepts. These will not be graded. The graded part of the assignment is to use regular expressions to parse /scratch/go-basic.obo and put the results in a dictionary. Your program should be written for Python3 and named

~/BIOL6200/Module10/parseGoInfo.py.

- Parse the GO id, name, namespace, and is_a values for each term.
- Create a string with namespace on the first line followed by a line for name, and one line per is_a.
- Put the string as the value in a dictionary where go_id is the key.
- Iterate over the keys in the dictionary, printing go_id followed by a tab, then the string containing the name, namespace, and is_a values.
- Create a function for splitting the file into records, and a function for splitting the records into fields.
- Your output should look something like this:

16_Figure1.jpg

Reference no: EM131291169

Questions Cloud

What kind of risk do the mcos assess : What kind of risk do the MCOs assess? Does risk-based compensation limit the freedom of primary care physicians in any way in terms of patient care? Why or why not? How does the capitation model of reimbursement work?
Two of the nation biggest airlines challenged : Please provide a comparison between Delta and American Airlines regarding concerns of capacity growth exceeding demand.
Find optimal solution to given integer programming problem : Find the optimal solution to the given integer programming problem.- Suppose that instead of maximizing profit from surgeries, our objective is to minimize the cost incurred due to surgeries.
Examples of economies and diseconomies of scale : Provide and discuss some examples of economies and diseconomies of scale in a college environment. Discuss some forecasting issues that you encounter in your daily life. How do you make your forecasts? Provide some examples of time series that exhibi..
Python regular expressions and dictionaries : Complete as many exercises from the book as necessary to understand the concepts. These will not be graded. The graded part of the assignment is to use regular expression
Determine the intrinsic value of the call : On December 9 of a particular year, a January Swiss franc call option with an exercise price of 46 had a price of 1.63. The January 46 put was at 0.14. The spot rate was 47.28.
What are the trends movements and key buildings or projects : What are the trends, movements, and key buildings/projects? Is architecture in 2016 still modernist? Why or why not? Write a three-page (750 word) essay on that topic, using specific examples as needed to reinforce your argument.
Managing dynamic enviroment : For this assignment, you should create a plan to hire an employee for a position within your organization to support a recent change. In this plan, you should include the following:
Identify the appropriate arbitrage opportunity : Identify the appropriate arbitrage opportunity and show the appropriate arbitrage strategy.

Reviews

len1291169

11/26/2016 2:26:41 AM

python. i will be running it on my server when done to check if i got the right output• Parse the GO id, name, namespace, and is_a values for each term. • Create a string with namespace on the first line followed by a line for name, and one line per is_a. • Put the string as the value in a dictionary where go_id is the key. • Iterate over the keys in the dictionary, printing go_id followed by a tab, then the string containing the name, namespace, and is_a values. • Create a function for splitting the file into records, and a function for splitting the records into fields.

Write a Review

Python Programming Questions & Answers

  Write a python program to implement the diff command

Without using the system() function to call any bash commands, write a python program that will implement a simple version of the diff command.

  Write a program for checking a circle

Write a program for checking a circle program must either print "is a circle: YES" or "is a circle: NO", appropriately.

  Prepare a python program

Prepare a Python program which evaluates how many stuck numbers there are in a range of integers. The range will be input as two command-line arguments.

  Python atm program to enter account number

Write a simple Python ATM program. Ask user to enter their account number, and print their initail balance. (Just make one up). Ask them if they wish to make deposit or withdrawal.

  Python function to calculate two roots

Write a Python function main() to calculate two roots. You must input a,b and c from keyboard, and then print two roots. Suppose the discriminant D= b2-4ac is positive.

  Design program that asks user to enter amount in python

IN Python Design a program that asks the user to enter the amount that he or she has budget in a month. A loop should then prompt the user to enter his or her expenses for the month.

  Write python program which imports three dictionaries

Write a Python program called hours.py which imports three dictionaries, and uses the data in them to calculate how many hours each person has spent in the lab.

  Write python program to create factors of numbers

Write down a python program which takes two numbers and creates the factors of both numbers and displays the greatest common factor.

  Email spam filter

Analyze the emails and predict whether the mail is a spam or not a spam - Create a training file and copy the text of several mails and spams in to it And create a test set identical to the training set but with different examples.

  Improve the readability and structural design of the code

Improve the readability and structural design of the code by improving the function names, variables, and loops, as well as whitespace. Move functions close to related functions or blocks of code related to your organised code.

  Create a simple and responsive gui

Please use primarily PHP or Python to solve the exercise and create a simple and responsive GUI, using HTML, CSS and JavaScript.Do not use a database.

  The program is to print the time

The program is to print the time in seconds that the iterative version takes, the time in seconds that the recursive version takes, and the difference between the times.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd