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

  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

  Improve the structural design - haunted house game

List the things you changed and the purpose of changing it. Good reasons include making code easier to read and easier to navigate when modifying it.

  Write a python program that prints out a table

Write a Python program that prints out a table of values of all even powers of 2 from 2**0 through 2**32. For each value, print the value in decimal, hexadecimal, and binary.

  Find the number of vowels in the string

Using list and one definition for find the Number of vowels in the String.

  Create a cheat commands in the game

Create a cheat commands in the game so player can pick up any item he wants from any location in the map - Display all possible actions you can carry out in game.

  Let ll be a list of integers

Let LL be a list of integers. Use list comprehension to produce teh following lists. Each one should just take onel line. Anser questions as two comments.

  Asign true to the variable has_dups

Asign True to the variable has_dups if the string s1 has any duplicate character (that is if any character appears more than once) and False otherwise

  Write a python program that generates a small web site

ICT112 Assignment. Your task in this assignment is to write a Python program that generates a small web site to inform Sunshine Coast people about some aspect of the local environment or a local sustainability issue

  How catch market trends

How catch market trends? Crossing n1­days moving average (MA) and n2­days moving average (n1>n2). When n2­days MA crosses n1­days MA, it is an indicator for the start of upward trend, and the other way around for downward trend

  Implement your algorithm in python

Write an algorithm in structured English (pseudocode) that describes the steps required to perform the task specified and reinforce topic material related to the programming work cycle, and the input, processing, output program structure.

  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.

  Creation of a program that will assemble dna chains

The aim of this assignment is the creation of a program that will assemble DNA chains, using the fragments given

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