
Could you help with the code and explanation?
![Write a function in Python that takes a DNA sequence and kmer size (integer) as input, and returns a dictionary of all kmers (keys) in the string with a list of
positions as values. The positions should start at 1. Use your function to make a dictionary of the 'seq' string below and print the dictionary.
The following sequence with size = 3 should return:
seq =
'ATCGTTCATCG'
kmerdict(seq,3)
{'АTC': [1, 8],
"CAT': [7],
'CGT': [3],
GTT': [4],
'TCA': [6],
'TCG': [2, 9],
TTC': [5]}
Note that the order in the output is not important.
Use your function and the second string and print the positions of all ATGS
]:
seg
'АТCGTTCAТCG'
def kmerdict(sequence, size):
index
{ }
return index
"САСТТСАСТССАТGGCCСАТСТСТСАTGAATCAGTАССАААТGCAСТСАСАТСАТТАTGCACGGCACTTGCCТСAGCGGTCТАТАСССТGTтGCCATTTACССАТААСGCСС
"Here are all the ATG positions in seg2: ")
seq2
%3D
print(](https://content.bartleby.com/qna-images/question/2ae3c598-5ca0-4a09-8f44-c28883b8b5eb/8464e8ec-1710-4037-a445-f902844c5eb0/08cuwxh_thumbnail.png)

The approach i used is as follows:-
- First find all the possible substrings of the string and get them in the list
- Then only take those substrings which are of the size in our case it is 3
- Then find the occurence of those substring in the sequecne using startswith
- Then add the occurences one by one in the list
- Add the record in the dictionary as the substring as key and list of occurence as value
- Finally return the dictionary
Everything is mentioned in the code comments
Code is added in the step 2 along with screenshot for the code and output
#To find all the substring of string
We use approach in which 1 string hold the index of current element and other element take the substrings
Ex. Hello
Now i will hold H and j will also hold H first substring = H
Now i stays there only and j increment to e second substring = He again j increments we get substring = Hel
Like this we do till end but at end j will be at o hence we will get hello but we eliminate that and not add that
Then i increment to e and also j = e hence another substring = e again j keeps incrementing till end
Trending nowThis is a popular solution!
Step by stepSolved in 2 steps with 3 images

- Please elaborate on the concept of testability, and if it's not too much trouble, provide a brief overview of the compiler as well.arrow_forwardWhat exactly is a procedure footer?arrow_forwardWhat exactly is the goal of debugging, and how does the process work in actuality? In what ways does this information relate to the methodology that will be used to evaluate the candidates?arrow_forward
- What do you mean when you say that the parts of a procedure header that appear inside the brackets are "informall"?arrow_forward4.14 LAB: Smallest number Write a program whose inputs are three integers, and whose output is the smallest of the three values. Ex: If the input is: 7 15 3 the output is: 3 462500.3140334.qx3zqy7 LAB ACTIVITY www 4.14.1: LAB: Smallest number 1 Type your code here. ''' main.py 0/10 Load default template...arrow_forwardThe question is, how long until anything breaks? Where is the link between this and shifting between different contexts?arrow_forward
- What is the definition of a preamble?arrow_forwardWhen and why do you use debugging, and how does it work in real life? How does this information fit with the factors that are used to decide?arrow_forwardWhat exactly do you mean when you say that you are talking "informally" about the parts of a procedure header that are located between the parentheses?arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





