954,525 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

DNA Questions

def binding_locations(strA, strB):

The first parameter represents a strand of DNA. The second parameter is one strand from a recognition sequence. Return a list of all the indices where the recognition sequence appears in the DNA strand. (These are the restriction sites.) For example, if the DNA palindrome appears at the beginning of the DNA strand, then 0 would be one of the items in the returned list. Only look from left to right; don't reverse the first parameter and look backwards. str.find will probably be helpful.

Example:
the first string is 'AAAAAAAAGGTTCCGTCGAAAA' for example and the second string is 'AAAA'

---------------------------------------------

def match_enzymes(str, list, list):

The first parameter is a DNA strand; the second is a list of strings that are restriction enzyme names; and the third is a list of recognition sequences that are matched by the corresponding restriction enzymes. The first list might be ['BamHI', 'TaqI'] and the second list might be ['GGATCC', 'TCGA'], for example. Return a list of tuples where the first item of each tuple is the name of a restriction enzyme and the second item is the list of indices (in the DNA strand) of the restriction sites that the enzyme cuts.

Example:
match_enzymes("TCGAGGATCC", ['BamHI', 'TaqI'], ['GGATCC', 'TCGA'])

return [('BamHI', [4]), ('TaqI', [0])]

---------------------------------------------------------

def one_cutters(str, list, list):

The first parameter is a DNA strand; the second is a list of strings that are restriction enzyme names; and the third is a list of recognition sequences that are matched by the corresponding restriction enzymes. Return a list of tuples representing the 1-cutters for that strand. The first item of each tuple is the name of a restriction enzyme and the second item is the index (in the DNA strand) of the one restriction site that the enzyme cuts.

This function is the same as the previous match_enzymes function but instead, it will return the index of where the first cut of the DNA strand occurs.

Please help me out.

Thanks

mms6
Newbie Poster
13 posts since Oct 2009
Reputation Points: 10
Solved Threads: 0
 

anyone plz help me out here

mms6
Newbie Poster
13 posts since Oct 2009
Reputation Points: 10
Solved Threads: 0
 

hi
after reading the specification like 5 times here's what I came up with :)

first part:

def binding_locations( strA, strB ):
    indexes = []
    i = 0
    while i < len( strA ):
       # compare the strA cut from the index i to whatever size strB is
       # and if the strings are equal add the index to the list and increment the value of i depending on the length of strB
        if strA[ i : i + len( strB ) ] == strB:
            indexes += [ i ]
            i += len( strB ) - 1
        i += 1           #go to next index
    return indexes


second part:

def match_enzymes( strand, enzymes, recognitionSequence ):
    l = []
    # basically using the first function :)
    for i in range( len( enzymes ) ):
        indexes = binding_locations( strand, recognitionSequence[ i ] )
        l += [ ( enzymes[ i ], indexes ) ]
    return l


I couldn't understand the specification for the third part if you could provide an example I'll try to help :)

masterofpuppets
Posting Whiz in Training
272 posts since Jul 2009
Reputation Points: 20
Solved Threads: 74
 

P.S I tested this using your examples and here are my results:

>>> binding_locations( "AAAAAAAAGGTTCCGTCGAAAA", "AAAA" )
[0, 4, 18]
>>> binding_locations( "AAAAAAAAGGTTCCGTCGAAAA", "GT" )
[9, 14]
>>> match_enzymes( "TCGAGGATCC", ['BamHI', 'TaqI'], ['GGATCC', 'TCGA'] )
[('BamHI', [4]), ('TaqI', [0])]
>>>
masterofpuppets
Posting Whiz in Training
272 posts since Jul 2009
Reputation Points: 20
Solved Threads: 74
 
anyone plz help me out here


We're not here to do your homework for you. But good job on copy-pasting your assignment.hi
after reading the specification like 5 times here's what I came up with :)
Dear MasterofPuppets,
You shouldn't be spoon feeding people looking for us to do their homework for them. Even though you provided good code, it doesn't help the OP at all because he's obviously going to just copy-paste your solutions and turn them in exactly in the same manner as he copy-pasted his assignment and posted it here.

jlm699
Veteran Poster
1,112 posts since Jul 2008
Reputation Points: 355
Solved Threads: 292
 

If the OP has not even given an example of what has been tried, I would prod them to at least give an idea of how they would approach the solution. Then you can give hints how to proceed.

Another way to help is to give a related example that would be a part of the solution. At least this way the OP gets involved in the quest to solve the problem.

If you had fun with the challenge to solve the problem, be a little patient and don't post your solution right away.

vegaseat
DaniWeb's Hypocrite
Moderator
5,989 posts since Oct 2004
Reputation Points: 1,345
Solved Threads: 1,417
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You