Question: I need help writing a code in Python 3. This program needs to take a desired string sequence (ex. ATGCCGTGCAAT), with a maximum length of

I need help writing a code in Python 3. This program needs to take a desired string sequence (ex. ATGCCGTGCAAT), with a maximum length of 12, and a minimum of 4. This string needs to be seperated into all possible substrings, by decreasing length (so stops at a count of 4). All the possible substrings need to account for their reversed counterparts (ex. the 12mer above comes reversed to account for the other strand). Once all of these are found, they need to be put on a list together from longest to shortest. Then the program needs to loop through the list of substrings and stop when the first sequence is found in a bigger sequence (it would be the biggest possible string). It would finally need to return the sequence. Any help would be much appreciated!
Im going to attempt at refining this post, to provide some more clarity into what I am asking.
An example of what I am trying to get my code to do is:
string =ATTGCAGTCGCTTAAGTCC
sub = GCAGTCC (the condition is: min = 3, max=6, but if the length of sub is somewhere in this range, thats fine)
Break down sub into all possible variants from max len of sequence to min len, and place on list:
6 --> GCAGTCC, CGTCAGG (max)
5--> GCAGTC, CGTCAG
4 --> GCAGT, CGTCA
3--> GCAG, CGTC (min)
Then all these values are complied onto a list from the highest length to the lowest. Ideally it would look like: [GCAGTCC, CGTCAGG, GCAGTC, CGTCAG, ...]. Then I would need to make a loop to find which sequence (the longest one) exists in the original string. Then it would need to return the matching sequence back to the user. In the case of the example, it would be GCAGTC (also seen as 5 above). Let me know if this needs more clarification!

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!