Click here to Skip to main content
15,915,163 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
this is my regular expression- G{3,5}[ATGC]{1,7}G{3,5}[ATGC]{1,7}G{3,5}[ATGC]{1,7}G{3,5}

and the code is given below in which i tried for only few string for length 15 and 16..

PHP
 $G1  = array
   (
   array("G","G","G","G","G","",""),
  
   );
$N1 = array
   (
   array("A","A","A","A","A","A","A","","","","","","",),
   array("T","T","T","T","T","T","T","","","","","","",),
   array("G","G","G","G","G","G","G","","","","","","",),
   array("C","C","C","C","C","C","C","","","","","","",)
   );
   $G2  = array
   (
   array("G","G","G","G","G"),
  
   );
   $N2 = array
   (
   array("A","A","A","A","A","A","A",),
   array("T","T","T","T","T","T","T",),
   array("G","G","G","G","G","G","G",),
   array("C","C","C","C","C","C","C",)
   );
   $G3  = array
   (
   array("G","G","G","G","G"),
  
   );
   $N3 = array
   (
   array("A","A","A","A","A","A","A","","","","","","",),
   array("T","T","T","T","T","T","T",),
   array("G","G","G","G","G","G","G",),
   array("C","C","C","C","C","C","C",)
   );
   $G4  = array
   (
   array("G","G","G","G","G"),
  
   );
   $t=0;
   $s=0;
   for($i1=2;$i1<=3;$i1++){
    
    if($i1>=3)
    {
        $t--;
    }
    

   for($k=0;$k<=3;$k++){
   for($j=0;$j<=3;$j++){
   for($i=0;$i<=3;$i++){
   echo $G1[0][0].$G1[0][1].$G1[0][2].$G1[0][$t+5].$G1[0][$t+6].$N1[$k][0].$N1[$k][$s+7].$N1[$k][$s+8].$N1[$k][$s+9].$N1[$k][$s+10].$N1[$k][$s+11].$N1[$k][$s+12].$G2[0][0].$G2[0][1].$G2[0][2].$N2[$j][0].$G3[0][0].$G3[0][1].$G3[0][2].$N3[$i][0].$G4[0][0].$G4[0][1].$G4[0][2]."<br>";
}}}}
?></br>
Posted
Updated 5-Jun-15 2:31am
v2
Comments
Sergey Alexandrovich Kryukov 5-Jun-15 12:25pm    
Why? Even if for this regular expression the number of all possible strings is probably finite, it's a lot of them. In general case, the regular expression can generate theoretically infinite number of matching solutions (with * or +). Why doing all that? I just wonder.
—SA
Matt T Heffron 30-Jun-15 20:45pm    
The number of possibilities here is mind-boggling:
Just accounting for the 3 sets of [ACGT]{1,7} gives 2.8e14 combinations.
((4^8 - 1)^3)
Patrice T 30-Jun-15 21:01pm    
Didn't try to enumerate it by myself, and don't want to.
I know, it a is geometric thing. :)

1 solution

If you need the list for only this expression, you can write a program ad-hoc.

you should take advantage of the fact that your regex is repeating 2 regex
G{3,5} and [ATGC]{1,7}
enumerate theses 2 regex
then do some nested loops to enumerate the whole expression.

By the way, did you search internet for "enumeration" and "regex"
 
Share this answer
 
Comments
Matt T Heffron 30-Jun-15 20:52pm    
Good luck with that ;-) ... see my comment above.
Patrice T 30-Jun-15 21:00pm    
not my problem :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900