/*make sure you should let validLength be larger than minLenOfRepeat.*/ #include #include #include #include #include #include #define maxCloneLen 501 #define wordLen 18 #define genomelen 182625 #define maxReadNum 2558 #define groupNum 400 #define classNum 7 #define MBIG 1000000000 #define MSEED 16183398 #define MZ 0 #define FAC (1.0/MBIG) static long inext,inextp; static long ma[56]; static long iff=0; typedef struct readlist { long value; long positionInRead; struct readlist *next; } mylist; typedef struct myhashElement { int flag; double value; long number; mylist read; struct myhashElement *next; } mytable; long factorial(long n) { long i,j=1; for (i=2;i<=n;i++) j *= i; return j; } void myEM(long *group,double *a,double *b,int *count) { int i,j,k; double t1,t2,t3,t4,t5,c[classNum],d[classNum]; if (*count>32000) return; else (*count)++; for (t1=0,i=1;i1e-3 ) myEM(group,a,b,count); } void myHist(mytable *data,long *group) { mytable *p1; long i,j,m=genomelen-maxCloneLen+1; for ( i=0;inumber!=0 ) { if ( p1->number>groupNum-1 ) j = groupNum-1; else j = p1->number; group[j]+=1; } p1 = p1->next; } } return; } double encode(char *str) { double t1,t2; int i; for (t1=0,i=0;inumber==0 ) { p1->value=t1; p1->read.value=readnum; p1->read.positionInRead=i; p1->read.next = NULL; p1->number=1; } else { flag =0; while(p1!=NULL&&flag==0) { if ( p1->value!=t1 ) { p3 = p1; p1= p1->next; } else { (p1->number)++; lp1 = &(p1->read); lp2 = lp1; n = lp1->value; while(lp1!=NULL&&n<=readnum) { lp2 = lp1; lp1 = lp1->next; if (lp1!=NULL) n = lp1->value; } lp3 = (mylist *)(calloc)(1,sizeof(mylist)); lp3->value = readnum; lp3->positionInRead=i; lp3->next = NULL; if (lp1!=NULL) { if (lp1==lp2) { n = lp1->value; l = lp1->positionInRead; lp1->value = readnum; lp1->positionInRead= i; lp3->next = lp1->next; lp3->value = n; lp3->positionInRead=l; lp1->next = lp3; } else { lp3->next = lp1; lp2->next = lp3; } } else lp2->next = lp3; flag =1 ; } } if ( flag == 0 ) { p2 = (mytable *)(calloc)(1,sizeof(mytable)); if ( p2==NULL) { printf("\nWhat's wrong with the p2 in myhash"); exit(0); } p2->flag = 1; p3->next = p2; p2->next= NULL; p2->read.value=readnum; p2->read.positionInRead=i; p2->read.next = NULL; p2->value = t1; p2->number =1; } } } void myhash(char *str,mytable *head, long readnum) { int i,length; double t1,t2,m=pow(4,wordLen); long k=genomelen-maxCloneLen+1; length= strlen(str); if (lengthvalue!=t1) p1 = p1->next; occurrenceNum[n]= p1->number; n++; for ( i=wordLen;ivalue!=t1) p1 = p1->next; occurrenceNum[n]= p1->number; n++; } } long partition(long *data1,long i, long j) { long x,y; long m,n; x = data1[i]; data1[i] =data1[j]; data1[j] = x; n = j+1; m = i-1; while (mx); do {m++;} while(data1[m]strlen(&str1[data1[j]*(maxCloneLen+1)])+data2[j] ) { k = data1[i]; data1[i] = data1[j]; data1[j] = k; l = data2[i]; data2[i] = data2[j]; data2[j] = l; } } void main() { mytable *head,*p1,*p2; long occurrenceNum[maxCloneLen-wordLen+2],i,j,k1; double a[classNum],t1,t2,t3,t4,b[classNum],coverage; char *str1,*str,*seq,ch; long m1,randSeed=15,m3,group[groupNum],readPosition[maxReadNum]; long length,readNum; FILE *fp1,*fp2; mylist *lp1,*lp2; int count; head = (mytable *)(calloc)(genomelen-maxCloneLen+1,sizeof(mytable)); str1 = (char *)(calloc)((maxCloneLen+1)*maxReadNum,sizeof(char)); str = (char *)(calloc)(maxCloneLen+1,sizeof(char)); seq = (char *)(calloc)(genomelen+1,sizeof(char)); if ( str1==NULL||head==NULL||str==NULL) { printf("\nwe can't find so much space for str"); exit(0); } occurrenceNum[maxCloneLen-wordLen+1] = 0; m1 = genomelen - maxCloneLen +1; fp1 = fopen("test2.txt","aw"); fp2 = fopen("c:\\xiaomanFile\\NM\\repeatData\\H_NH0140H23\\p1seq.txt","r"); if ( fp1==NULL||fp2==NULL) { printf("\nThere is no enough space for output the files"); exit(0); } i = 0; while (imaxReadNum) { printf("\nPlease increase maxReadNum"); exit(0); } for (i=0;inext; lp1 = &p1->read; lp1 = lp1->next; p1->read.next=NULL; while (lp1!=NULL) { lp2 = lp1->next; free(lp1); lp1 = lp2; } free(p1); p1 = p2; } } for ( m3=0;m3