Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

QUESTION I this exercise you will continue analysis of the data contained in the file ChromosomeFragmentData.zip Here, we are concerned with triplets that occure in

QUESTION

I this exercise you will continue analysis of the data contained in the file ChromosomeFragmentData.zip Here, we are concerned with triplets that occure in the data found in ChromosomeFragmentData.txt. There are 64 unique triplets that can be built from the four nucleotide bases C, G, A and T.

This exercise asks you to use the below code structure (or if you wish, write your own) to:

Create a dictionary of all 64 triplets;

Count the occurrences of each of the 64 triplets in the chromosomal data found in file ChromosomeFragmentData.txt;

Output the triplet counts for each of the 64 triplets; and finally

Output the triplet densities for each of the 64 triplets.

(wherever you see the comment ######## YOUR CODE GOES HERE ########) To do the triplet counting, you may use FOR loops or you may use the string count() method. If you choose to use the string count() method, please ensure that the method is providing you with correct answers! To determine that, you may want to test the count() method first, on smaller strings, just to ensure that its behavior is what you expect.

Code should look like below -

#To begin, we read in the datafile ChromosomeFragmentData.txt and assign

#the string data to a variable called ChromosomeFragmentData

#You should use the same read statement that you used to read the

#data for in-class programming assignment #2

######## YOUR CODE GOES HERE ########

#Then we create an empty dictionary and an empty list

#which we will subsequently USE to gather and organize

#nucleotide base triplet counts from a chromosome fragment:

TripletCount = {} #Two ways to create an empty dictionary: dict() or {}

TripletList = [] #Two ways to create an empty list: list() or []

#Initialize the triplet dictionary entries to zero counts for each

#triplet key. That is, each key is initialized with a value of 0.

######## YOUR CODE GOES HERE ########

#Now count the triplets. Begin at index 0, and step 2.

#That is, we consider ChromosomeFragmentData[0:3] to be

#one triplet, then ChromosomeFragmentData[3:6] to be another

#triplet, etc. We do not consider overlapping triplets.

#Also initialize the total triplet count to zero.

total_triplets = 0

######## YOUR CODE GOES HERE ########

#Print out the triplet COUNTS:

print(' TRIPLET COUNTS')

print('==============================')

######## YOUR CODE GOES HERE ########

#Next, print out the triplet DENSITIES:

#(Note: The density of any triplet, say, ATG, is equal to the

#count of triplet ATG divided by the total number of triplets)

print(' TRIPLET DENSITIES')

print('==================================')

######## YOUR CODE GOES HERE ########

#And finally print out the total triplet count in this chromosome fragment:

######## YOUR CODE GOES HERE ########

MY QUESTION AND WORK SO FAR

WE NEED THIS CODE IN PYTHON AND SO FAR THIS IS WHAT I HAVE but I keep getting zero for the key''s value instead of it counting!

with open('/Users/jerusalemwogayehu/Desktop/ChromosomeFragmentData.txt', 'r') as data_file: ChromosomeFragmentData = data_file.read().replace(' ', '') Triplet_count = [] for indx1 in ['G' , 'C', 'T', 'A']: for indx2 in ['G' , 'C', 'T', 'A']: for indx3 in ['G' , 'C', 'T', 'A']: indx = indx1 + indx2 + indx3 Triplet_count.append(indx) Triplet= {} for i in Triplet_count: Triplet[i] = 0 #print (Triplet) triplet_keys = Triplet.keys() #print(triplet_keys) three = '' value = 0 for i in range (0,2,len(ChromosomeFragmentData)): three = ChromosomeFragmentData[i] + ChromosomeFragmentData[i+1] + ChromosomeFragmentData[i+2] for j in triplet_keys: if three == j: value = value + 1 Triplet[j] = value print(Triplet)

Below is a screenshot of my work!!

image text in transcribed

Spyder (Python 3.6) Ecitor Users jerusalemwogayehuvuntitled2.py ) untitled2.py 1 with open('/Users/jerusalemwogayehu/Desktop/ChromosomeFragmentData. txt', 3 Triplet_count I Source Console Object 'r') as data-file : ChromosomeFra tData data-file. read ( ) . replace(' . Usage for indx2 in 'G', 'C, 'T, 'A': for indx3 in ['G' 'C, 'T', Here you can get help of any object by pressing Cmd+1 in front of it, either on the Editor or the Console. Triplet count.append (indx) 9 Triplet-C) 18 for i in Triplet count: 11 Triplet [1]=0 12#print (Triplet) 13 triplet-keys Tr1plet, keys() 14 #print( triplet-keys) 15 three = 16 value0 17 for i in range (,2,len(ChronosomeFragnentData)) 18 three-ChromosomeFragnentDatali]ChromosomeFragnentData[i+ChromosomeFragmentData[i+2] 19 Torj in triplet keys: 20 Help can also be shown automatically after writing a left parenthesis next to an object. You can activate this behavior in Preferences > Help. New to Spyder? Read our tutorial if three = j: value = value + 1 Triplet ]value print (Triplet) Python console 3 Console I/A In [1841: runt i le(Users/jerusalemwogayehu/untitled2.py., Users/jerusalemwogayehu') wdr= 29 40 In [185]: Python console History log Permissions: RWEnd-of-lines: LF Encoding: ASCIi Line: 24 Column: 1 Memory: 81% 5 Spyder (Python 3.6) Ecitor Users jerusalemwogayehuvuntitled2.py ) untitled2.py 1 with open('/Users/jerusalemwogayehu/Desktop/ChromosomeFragmentData. txt', 3 Triplet_count I Source Console Object 'r') as data-file : ChromosomeFra tData data-file. read ( ) . replace(' . Usage for indx2 in 'G', 'C, 'T, 'A': for indx3 in ['G' 'C, 'T', Here you can get help of any object by pressing Cmd+1 in front of it, either on the Editor or the Console. Triplet count.append (indx) 9 Triplet-C) 18 for i in Triplet count: 11 Triplet [1]=0 12#print (Triplet) 13 triplet-keys Tr1plet, keys() 14 #print( triplet-keys) 15 three = 16 value0 17 for i in range (,2,len(ChronosomeFragnentData)) 18 three-ChromosomeFragnentDatali]ChromosomeFragnentData[i+ChromosomeFragmentData[i+2] 19 Torj in triplet keys: 20 Help can also be shown automatically after writing a left parenthesis next to an object. You can activate this behavior in Preferences > Help. New to Spyder? Read our tutorial if three = j: value = value + 1 Triplet ]value print (Triplet) Python console 3 Console I/A In [1841: runt i le(Users/jerusalemwogayehu/untitled2.py., Users/jerusalemwogayehu') wdr= 29 40 In [185]: Python console History log Permissions: RWEnd-of-lines: LF Encoding: ASCIi Line: 24 Column: 1 Memory: 81% 5

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions