#include <iostream>
#include <string>
#include <map>
using namespace std;
int main(int argc, char* argv[])
{
  map<string,string> splice_variants;
  splice_variants["gene1"]="ACTGACTGACTGACTGACTGACTGGTCA";
  splice_variants["gene2"]="ACTGAFDSTCTGACTGACTGACTGACTGGTCA";
  splice_variants["gene4"]="GCGAGTGTGACGAGTGAACGGGTGCTGCTGAGTGACGACGGCATG";

  string todetect="ACGGGTGCTGCTGAGTGACGACGGCATGGCGTGC";
  const int l=20;
  // we try each possible substring of length l
  for(int l = todetect.size(); l>=1; l--)
    {
      bool probe_found=false;
      for(int i = 0 ; i <= todetect.size()-l && !probe_found; i++)
	{
	  string subseq=todetect.substr(i,l);
	  bool stop=false;
	  // will this subsequence match any of the existing elements ?
	  for(map<string,string>::iterator it=splice_variants.begin();
	      it!=splice_variants.end() && !stop; it++)
	    {
	      string variant=it->second;
	      // first we try a substring match
	      int pos=variant.find(subseq);
	      if (pos>=0) 
		{
		  // cout << subseq << " cannot be used due to match against " 
		  // << it->first << "\n";
		  stop=true;
		}
	    }
	  if (!stop) 
	    {
	      // after running through all known splice variants we know that
	      // this subsequence wil not match. It is in other words a good 
	      // choice for this particular length
	      cout << subseq << " is a proper probe\n";
	      probe_found=true;
	    }
	}
      if (!probe_found)
	{
	  // we did not find a probe for this particular length, meaning that 
	  // we can stop the entire program. The last usable one has been
	  // already printed.
	  break;
	}
    }
}

