Coders Packet

Repeating DNA subsequences using Sliding Window Technique in C++

By G Ganga Jathin

Finding repeating subsequences of size 10 from a given DNA sequence using sliding window technique in C++

Given a DNA Sequence consisting of ATGC characters, We try to devise a code to find a repeating subsequence of size 10 in this DNA Sequence.

To achieve this we use Sliding Window Technique in C++

The main principle of the code is to take first 10 characters of the string add it in map to increase its counter and then continuously remove the first character and append to last character to get a new subsequence in this way we will find if the map value becomes 2 it is a repeating subsequence

vectorv;
if(s.length() < 10)return v;
map<string,int> m;
string temp = "";
for(int i = 0;i < 10;i++)temp += s[i];
m[temp]++;
for(int i = 10;i < s.length();i++)
{
    temp.erase(temp.begin());
    temp.push_back(s[i]);
    m[temp]++;
    if(m[temp] == 2)v.push_back(temp);
}
return v;

This is the implementation of the above technique to find the Repeating subsequence

 

How to use it:- 

1) Open the Zip file
2) Extract the corresponding source file
3)Run the source file in the ide of your choice 
4)Give input DNA Sequence of the string to obtain repeating Subsequence

Download Complete Code

Comments

No comments yet

Download Packet

Reviews Report

Submitted by G Ganga Jathin (GangaJathin)

Download packets of source code on Coders Packet