Finding Restriction Sites - Rosalind Problem
1
0
Entering edit mode
3.5 years ago

This is the Rosalind problem that I am working on:

A DNA string is a reverse palindrome if it is equal to its reverse complement. For instance, GCATGC is a reverse palindrome because its reverse complement is GCATGC. See Figure 2.

Given: A DNA string of length at most 1 kbp in FASTA format.

Return: The position and length of every reverse palindrome in the string having length between 4 and 12. You may return these pairs in any order.

This is the code that I have so far:

DNAstrand = "TCAATGCATGCGGGTCTATATGCAT"

def reverseComplement(DNAstrand): x = {"A":"T", "T":"A", "C":"G", "G":"C"} return''.join([x[nuc] for nuc in DNAstrand])[::-1]

substrings = [DNAstrand[x:y] for x in range (len(DNAstrand)) for y in range((x + 1), ((len(DNAstrand)) + 1))]

def string_Length(substrings): """Given a string, return all substrings between 4 and 12 characters in length""" return[string for string in substrings if 4 <= len(string) <= 12]

list = (string_Length(substrings))

for substring in list: if substring == reverseComplement(substring): print(DNAstrand.find(substring))

The output that I should be getting is 4 6 5 4 6 6 7 4 17 4 18 4 20 6 21 4

This is the output I am getting 4 5 6 7 17 18 4 5

Does anyone have suggestions for finding the length of the substrings and printing the position of the substrings at positions 20 and 21?

genome • 949 views
ADD COMMENT
0
Entering edit mode
3.5 years ago

Double check if your script will find sites if the recognition sites overlap. Lots of simple searches will miss these.

ADD COMMENT

Login before adding your answer.

Traffic: 2139 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6