[SOLVED] 代写 python Go Assignment 2

30 $

File Name: 代写_python_Go_Assignment_2.zip
File Size: 273.18 KB

SKU: 6337128093 Category: Tags: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

Or Upload Your Assignment Here:


Assignment 2
Programming 3 & 4

Due Thursday 10/31 20:00

There are 12+2 points total (2 bonus points). I’d suggest that for each question, you create a program file (e.g. hw2_q1.py) and work on it till it is done. Once you finish all questions, copy and paste your answers to a file called “OmicsData_hw02_yourname.py” and mail it to 91085 through web teaching & learning platform of CAU. Please do your best to make sure your program can run.

•[4pt, 1 bonus] Get the following tab-delimited file from course server:

/mnt/scratch/yling/Genomis/Hw02/interactions.txt

This file contains four lines:

GeneA GeneB Lethality
g21 g1020.9
g3041 g10.1
g21 g3030.5
g93 g21 0.7

Write a python program that will:
•Take a string as argument so you can pass the file name “interactions.txt” to the program,
•Have try..except statements so if the file does not exist, it will print “ERR: file absent” and quit the program. [Hint: IOError]
•Go through the file (based on the argument passed) with a while loop,
•Get the names for GeneA and GeneB as well as the lethality with the split function,
•Count the number of pairs with lethality ≥0.5 and print out “Qualified pairs:” and the number of qualified pairs at the end, and
•Generate an space-delimited output file with the name output_yourname (e.g. output_LingYi) containing all gene pairs with lethality ≥0.5. You must use string formatting (Hint: %). The output file should look like:

GeneA GeneB
g21 g102
g21 g303
g93 g21

Comment on every line of your codes. You must close your input and output.

•[4pt, 1 bonus] Write a program that will:
•Read all lines in the file in question 1 into a list (must use the readlines function) called line_list.
•Use a for loop to go through line_list,
•Store gene names and lethality values in a dictionary called pair_dict where:
•The key is GeneA and,
•Its corresponding value is a list of GeneBs that interact with the GeneA in question.
•The dictionary should looks like:

{“g21”:[“g102″,”g303″],”g3041”:[“g1″],”g93”:[“g21”]}

•At the end of the program, print out the dictionary with the print command.

Comment on every line of your codes.

•[4pt] Let’s create a nested dictionary called new_dict:

•Assume that you have already created the line_list that is a list with all the lines in the interaction.txt file.
•In the dictionary:
•The key is a gene X (can be in the GeneA or GeneB column, so there should be six keys at this level),
•Its corresponding value is another dictionary where:
•The key is a gene that interact with gene X
•Its corresponding value is lethality converted into a floating point number.
•So this nested dictionary looks like:

{“g21”:{“g102” :0.9,
“g303” :0.1,
“g93”:0.7},
“g102” :{“g21”:0.9},
“g303” :{“g21”:0.5},
“g3041”:{“g1” :0.1},
“g1” :{“g3041”:0.1}
“g93”:{“g21”:0.7}
}

•Note that for example g21 have two entries as GeneA and one entry as GeneB in the file.So the value corresponds to g21 should contain three genes.
•At the end of the program, print out the dictionary with the print command.

Comment on every line of your codes.

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] 代写 python Go Assignment 2
30 $