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 non-fruitful function drawequitriangle

Write a non-fruitful function drawEquitriangle(someturtle, somesize) which calls drawPoly from the previous question to have its turtle draw a equilateral triangle

  Recursive sorts are easier to write in functional style

Recursive sorts are easier to write in functional style than others. Two recursive sorts are  Quicksort and Mergesort. Write functional versions of (a) Quicksort; (b) Mergesort in an  imperative language of your choice (e.g., C, Ada, C++, Python), us..

  Write a python program that starts from the starting state

Task consists of programming a Python implementation of a solver for the Desert Crossing Task - write a Python program that starts from the starting state.

  Design reusable parameterised functions

create multiple icon styles that can be drawn at different sizes, it would be very repetitive if you tried to code the whole solution using ‘brute force.' Instead you are strongly encouraged to design reusable parameterised functions to draw the i..

  Design and implement a python program which plays poker

The goal of this project is to gain practice with use of classes and creating functions. You will design and implement a Python program which plays simplified Texas Hold'em Poker.

  Implement a battleship game in python

Assignment Summary: Battleship is a children's game where players guess (x,y) coordinate positions of the opposing player's ship pieces in a 10x10 grid. For the official Hasbro rules and additional game context, read http://www.hasbro.com/common/i..

  Provide the code for a boolean-valued function

Provide the code for a Boolean-valued function perfect(n)that calculates and returns the Boolean value True or False according to whether the value of the parameter n is a perfect number or not, respectively

  Reinforce topic material on simple functions

Select 3 sets of test data that will demonstrate the correct 'normal' operation of your program. Select another 2 sets of test data that will demonstrate the "abnormal" operation of your program.

  Implement core security features

What you will be implementing here is inspired by real world cases such as the Conficker work. To have any chance of defeating such a threat, you need to understand how they defend themselves.

  Python code for grabbing data from yahoo finance

I am new to Phython. Using Spyder IDE Simple code. It is not recognizing by Data file see line 33 - The purpose of assignment is to get you familiar with the Python.

  The function should return the day name (''su'',''mo''..etc)

Write the function day(d,m) where m is an integer from 1 through 12 expressing a month, and d is an integer from 1 through 31 expressing the day part of a date in 2014.

  Write a program that produces a comparison of the balance

Write a program that produces a comparison of the balance of a bank account over time between simple, monthly and daily methods of compounding interest.

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