//	This source and similar text sequences method apply to GNU General Public License. 
//			Copyright (C) 2001-2016 Jasenko Dzinleski 

//		This program is free software; you can redistribute it
//	and/or modify it under the terms of the GNU General Public License as
//	published by the Free Software Foundation; either version 2 of the
//	License, or (at your option) any later version. 

//	This program is distributed in the hope that it will be useful, but
//	WITHOUT ANY WARRANTY; without even the implied warranty of
//	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
//	General Public License for more details. 

//	You should have received a copy of the GNU General Public License along
//	with this program; if not, write to the Free Software Foundation, Inc.,
//	51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

//  	Similar Text Sequences 
//	
//	written by Dzinleski Jasenko  Jun 2016



#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

FILE	*f1,*f2;

char	infn[256]="a.txt";

//               //AG_G__A____C
//char	ss[256]="!!_!__!____!";
//               //G_G__G___G__GGGG__GG
//char	ss[256]="!_!__!___!__!!!!__!!";
//			   //A______C_______A_______T______A_____C_____G
char	ss[256]="!______!_______!_______!______!_____!_____!";


int main(int argc,char *argv[])
{

int	i,j,k,l,m,n;
int	fb;

char 	sb[256];
int		sbi=0;

	f1=fopen(infn,"rb");
	fb=getc(f1);sbi=0;while(sbi<strlen(ss)&&!feof(f1)){sb[sbi]=fb;++sbi;fb=getc(f1);while(!(fb=='A'||fb=='C'||fb=='G'||fb=='T'||fb=='_')&&!feof(f1)){fb=getc(f1);}}
	while(!feof(f1))
	{
			l=0;for(i=0;i<sbi;++i){if(sb[i]=='_'){if(sb[i]==ss[i]){++l;}else{break;}}else{++l;}}
			if(l==strlen(ss)){for(i=0;i<sbi;++i){printf("%c",sb[i]);}printf("\n");}
			for(i=1;i<sbi;++i){sb[-1+i]=sb[i];}
			fb=getc(f1);while(!(fb=='A'||fb=='C'||fb=='G'||fb=='T'||fb=='_')&&!feof(f1)){fb=getc(f1);}sb[-1+sbi]=fb;
	}
	fclose(f1);
	return(0);
}