// -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- // Copyright (C) 2007 Author: Fathi Elloumi. // 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 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- #include #include "slist.h" #include Slist::Slist() { head=NULL;queue=NULL; } Slist::~Slist() { Listnode *p; while (head!=NULL) { p=head->succ; //---------- delete [] head->pattern; head->lstseqpos.deleteall(); //----------------- delete head; head=p; }; queue=NULL; } void Slist::append(Slist & liste) { if (liste.head!=NULL) { if (head==NULL) { head= liste.head; queue= liste.queue; } else { queue->succ=liste.head; queue=liste.queue; }; liste.head=liste.queue=NULL; }; } void Slist::append_v2(Slist & liste) { Listnode *p1,*p2,*sec,*pred1; if (liste.head!=NULL) { if (head==NULL) { head= liste.head; queue= liste.queue; } else { // queue->succ=liste.head; // queue=liste.queue; p1=head; sec=p2=liste.head; if (p2->difference < p1->difference) { p2=p2->succ; sec->succ=head; head=sec; p1=head; }; while ((p1!=NULL) && (p2!=NULL) ) { if (p2->difference >= p1->difference) { pred1=p1; p1=p1->succ; } else { sec=p2->succ; pred1->succ=p2; p2->succ=p1; pred1=p2; p2=sec; }; }; if (p2!=NULL) {queue->succ=p2; queue=liste.queue; }; }; liste.head=liste.queue=NULL; }; } void Slist::delete_list_pattern() { Listnode *p; while (head!=NULL) { p=head->succ; //---------- delete [] head->pattern; head->lstseqpos.deleteall(); //----------------- delete head; head=p; }; queue=NULL; } void Slist::delete_support_less(int val) { Listnode *p,*q,*qpred; bool stop = false; if (head!=NULL) { while ((head!=NULL) && (!stop)) { if (head->support >= val) stop=true; else {p=head->succ; //---------- delete [] head->pattern; head->lstseqpos.deleteall(); //----------------- delete head; head=p;}; }; if (head==NULL) queue=NULL; else { q=head->succ;qpred=head; while (q!=NULL) { if (q->support < val) { if (q==queue) queue=qpred; qpred->succ=q->succ; //---- delete [] q->pattern; q->lstseqpos.deleteall(); //---- delete q; q=qpred->succ; } else {qpred=q;q=q->succ;}; }; }; }; } void Slist::visu(Listnode *p) { cout <<"\n"<<"Pattern "<pattern<<"\n" ; cout <<" support "<support ; cout <<" total "<total ; cout <<" pvalue "<pvalue<<"\n" ; cout <<" the sequences & positions"<<"\n" ; p->lstseqpos.gofirst(); bool finish=false; while (!p->lstseqpos.atend() || !finish) { cout <lstseqpos.value().seq<<"-"<lstseqpos.value().pos<<"," ; if (p->lstseqpos.atend()) {finish=true; continue;}; p->lstseqpos.next(); }; } void Slist::affich() //throw(Emerror) { Listnode *p; // if (head==NULL) throw(Emerror()); p= head; while (p!=NULL) { cout <<"\n"<<"Pattern "<pattern<<"\n" ; cout <<" support "<support ; cout <<" total "<total ; cout <<" pvalue "<pvalue<<"\n" ; cout <<" the sequences & positions"<<"\n" ; p->lstseqpos.gofirst(); bool finish=false; while (!p->lstseqpos.atend() || !finish) { cout <lstseqpos.value().seq<<"-"<lstseqpos.value().pos<<"," ; if (p->lstseqpos.atend()) {finish=true; continue;}; p->lstseqpos.next(); }; p=p->succ; }; } ///////////////////// int Slist::matchfile_fast(char *fich) { FILE *in; char ligne[500],ligrev[500]; char interm; int comptage=0; Listnode *p; // Debut : ouverture des fichiers p=head; while (p!=NULL) { p->pvalue=0.0; in = fopen(fich,"r") ; if (in==NULL) return -1; while ( !feof(in) ) { fscanf(in,"%s", ligne); if ( feof(in) ) break; fscanf(in,"%s", ligrev); if (matchpattern(p->pattern, ligne)) p->pvalue++; else { if (matchpattern(p->pattern, ligrev)) p->pvalue++; }; }; fclose(in);comptage++; printf(">> %i patterns matched against DB\n",comptage); p=p->succ; }; return 0; } ///////////////////// int Slist::matchfile(char *fich) { FILE *in; char ligne[500],ligrev[500]; int i,comptage=0; char interm; int vlong,compt=0;bool first; Listnode *p; // Debut : ouverture des fichiers // verif format fichier & comptage in = fopen(fich,"r") ; if (in==NULL) return 0; while ( !feof(in) ) { fscanf(in,"%s", ligne); if ( feof(in) ) break; if (ligne[0]=='>') { compt++; } else return 0; fscanf(in,"%s", ligne); if ( feof(in) ) return 0; }; fclose(in); ///////////////////////////////// p=head; while (p!=NULL) { p->pvalue=0.0; in = fopen(fich,"r") ; if (in==NULL) return 0; while ( !feof(in) ) { fscanf(in,"%s", ligne); if ( feof(in) ) break; // if (ligne[0]=='>') // { if (first) compt++; } // else return 0; fscanf(in,"%s", ligne); // if ( feof(in) ) return 0; if (matchpattern(p->pattern, ligne)) p->pvalue++; else { vlong=strlen(ligne); for (i=0;i<=vlong-1;i++) { ligrev[vlong-1-i]=complem(ligne[i]); } ligrev[vlong]='\0'; if (matchpattern(p->pattern, ligrev)) p->pvalue++; }; }; fclose(in);comptage++; printf(">> %i patterns checked\n",comptage); p=p->succ; }; return compt; } //////////////////////////////////// void Slist::affichmatch(char * fich,int nbre,int nbre_bd) //throw(Emerror) {// avec estimation probab du pattern :positions independantes FILE * outrec; Listnode *p; int i,densite; long double sbd; // if (head==NULL) throw(Emerror()); outrec= fopen(fich,"w"); p= head; fprintf(outrec,"Pattern\t") ; fprintf(outrec,"Length\t") ; fprintf(outrec,"Density\t") ; fprintf(outrec,"Support\t") ; fprintf(outrec,"Total\t") ; fprintf(outrec,"Proba\t") ; fprintf(outrec,"Pvalue\t") ; fprintf(outrec,"Sequences_and_Positions\n") ; while (p!=NULL) { ///---stat------------------ densite=0; for (i=0;idifference+2;i++) { if (p->pattern[i]!='.') densite++; }; sbd = p->pvalue/nbre_bd; p->pvalue=binocum(nbre,p->support,p->pvalue/nbre_bd); ///---fin stat------------------ fprintf(outrec,"%s\t",p->pattern) ; fprintf(outrec,"%i\t",p->difference+2) ; fprintf(outrec,"%i\t",densite) ; fprintf(outrec,"%i\t",p->support) ; fprintf(outrec,"%i\t",p->total) ; fprintf(outrec,"%Le\t",sbd) ; fprintf(outrec,"%Le\t",p->pvalue) ; p->lstseqpos.gofirst(); bool finish=false; while (!p->lstseqpos.atend() || !finish) { fprintf(outrec,"%i-%i,",p->lstseqpos.value().seq,p->lstseqpos.value().pos); if (p->lstseqpos.atend()) {finish=true; continue;}; p->lstseqpos.next(); }; fprintf(outrec,"\n") ; p=p->succ; }; fclose(outrec); } /////////////////// long double Slist::affichjmp(char * fich,int Tseq[],int nbre,long double T[4], int tseq) //throw(Emerror) {// avec estimation probab du pattern :positions independantes FILE * outrec, * in; Listnode *p; long double proba,toto,zssup,zstot,var,qi,vari,expi,pi,varbis; int i,densite,v1,v3; // int Tseq[100] tableau des tailles des sequences; char v2[500]; char buffer1 [50000],bufferpos [33],bufferseq [33]; int N,elen,currentpos,currentseq,j,exp,posover; ///////////////// try { /////// // if (head==NULL) throw(Emerror()); outrec= fopen(fich,"w"); /* in= fopen(fich2,"r"); i=1; while (i<=nbre) { fscanf(in,"%i %s %i",&v1,v2,&v3); //printf("\n%i %s %i",v1,v2,v3); fscanf(in,"%i %s %i",&v1,v2,&v3); //printf("\n%i %s %i",v1,v2,v3); Tseq[i-1]=v3; i++; }; fclose(in); */ p= head; fprintf(outrec,"Pattern\t") ; fprintf(outrec,"Length\t") ; fprintf(outrec,"Density\t") ; fprintf(outrec,"Support\t") ; fprintf(outrec,"Total\t") ; fprintf(outrec,"Zs-sup\t") ; fprintf(outrec,"Zs-tot\t") ; fprintf(outrec,"Sequences_and_Positions\n") ; toto=0.0; while (p!=NULL) { ///---stat------------------ toto++; proba=1.0;densite=0; for (i=0;idifference+2;i++) { switch (p->pattern[i]) { case 'A': proba=proba*T[0];densite++; break; case 'G': proba=proba*T[2];densite++; break; case 'C': proba=proba*T[1];densite++; break; case 'T': proba=proba*T[3];densite++; break; //default: ; }; }; //printf("\n%s dif%i dens%i s%i t%i\n",p->pattern,p->difference,densite,p->support,p->total); // p->lstseqpos.gofirst(); bool finish=false; // currentseq=-1;currentpos=-1;j=0;elen=p->difference+2;buffer1[0]='\0';posover=0; //compte=0; while (!p->lstseqpos.atend() || !finish) { //compte++; //printf("compte =%i",compte); itoa (p->lstseqpos.value().seq,bufferseq,10);itoa (p->lstseqpos.value().pos,bufferpos,10); strcat(buffer1,bufferseq);strcat(buffer1,"-");strcat(buffer1,bufferpos);strcat(buffer1,","); if (p->lstseqpos.value().seq!=currentseq) { currentseq=p->lstseqpos.value().seq;currentpos=p->lstseqpos.value().pos; j++; if (currentpos+elen-1 <= Tseq[currentseq/2]-elen+1) posover=posover+elen-1; else posover=posover+Tseq[currentseq/2]-elen-currentpos+1;// new } else { if (p->lstseqpos.value().pos>=(currentpos+elen)) { currentpos=p->lstseqpos.value().pos; j++; if (currentpos+elen-1 <= Tseq[currentseq/2]-elen+1) posover=posover+elen-1; else posover=posover+Tseq[currentseq/2]-elen-currentpos+1;// new } }; if (p->lstseqpos.atend()) {finish=true; continue;}; p->lstseqpos.next(); }; //printf("j=%i compte=%i\n",j,compte); // N= nombre d'occurences total // j = nombre non overlap occurences N= 2 * (tseq + nbre * (1- p->difference - 2 )); // Nbis=N; //fprintf(outrec,"%i\t",j) ; //printf("\n proba=%Le,total occ=%i,occ_without_over=%i,matchpos=%i", proba,N,j,N-j*(elen-1)); //N=N-j*(elen-1); // deduction du nombre overlap // if (N-j*(elen-1) < 0) // { // printf("\n pattern=%s",p->pattern); // printf("\n proba=%Le,total occ=%i,occ_without_over=%i,length=%i,positions k-1=%i", proba,Nbis,j,elen,posover); // }; // ---------------------------------------- comm N=N-posover; // deduction du nombre overlap- nouvelle version //exp= (int) (N * proba); var= (N * proba * (1-proba)); //zs= (j - exp)/sqrt((double) var); //zstot= (j - exp)/sqrtl(var); zstot= (j - (N * proba))/sqrtl(var); // printf("\n zstot=%Le",zstot) ; //--------------------------------------- comm expi=0.0;vari=0.0;i=0; while (isupport,vari); //zssup= (p->support - (int) expi)/sqrtl(vari); if (vari < 0.0) printf("\n vari=%Le",vari); // --------------------------------------------- com zssup= (p->support - expi)/sqrtl(vari); // printf("\n zssup=%Le",zssup) ; //--------------------------------------- comm // printf("\n%s--------------------------",p->pattern); //---------------------------------comm ///---fin stat------------------ fprintf(outrec,"%s\t",p->pattern) ; fprintf(outrec,"%i\t",p->difference+2) ; fprintf(outrec,"%i\t",densite) ; fprintf(outrec,"%i\t",p->support) ; fprintf(outrec,"%i\t",p->total) ; fprintf(outrec,"%Le\t", zssup) ; fprintf(outrec,"%Le\t",zstot) ; fprintf(outrec,"%s\n",buffer1) ; /* p->lstseqpos.gofirst(); finish=false; while (!p->lstseqpos.atend() || !finish) { fprintf(outrec,"%i-%i,",p->lstseqpos.value().seq,p->lstseqpos.value().pos); if (p->lstseqpos.atend()) {finish=true; continue;}; p->lstseqpos.next(); }; fprintf(outrec,"\n") ; */ // printf("\n toto=%Lf var=%Le sqr-var=%Le vari=%Le sqr-vari=%Le", toto,var,sqrtl(var),vari,sqrtl(vari)); p=p->succ; }; printf("Total patterns for this family= %12.0Lf\n",toto) ; fclose(outrec); ///////////////////////// } catch (exception &e) { printf("exception: %s\n",e.what()) ; //printf("\n var=%Le", var); // ---------------------------------------- comm //printf("\n zstot=%Le",zstot) ; //--------------------------------------- comm //printf("\n vari=%Le",vari); // --------------------------------------------- com //printf("\n zssup=%Le",zssup) ; //--------------------------------------- comm //printf("\n%s--------------------------",p->pattern); //---------------------------------comm } //return 0; //////////////////////// return toto; } ///////////////////////////////// long double Slist::affichjmp2(char * fich,int Tseq[],int nbre,long double T[4]) //throw(Emerror) {// avec estimation probab du pattern :positions independantes FILE * outrec, * in; Listnode *p; long double proba,toto,zssup,zstot,var,qi,vari,expi,pi,varbis; int i,densite,v1,v3; // int Tseq[100] tableau des tailles des sequences; char v2[500]; char buffer1 [50000],bufferpos [33],bufferseq [33]; int N,elen,currentpos,currentseq,j,exp,Nbis,posover; ///////////////// try { /////// // if (head==NULL) throw(Emerror()); outrec= fopen(fich,"w"); /* in= fopen(fich2,"r"); i=1; while (i<=nbre) { fscanf(in,"%i %s %i",&v1,v2,&v3); //printf("\n%i %s %i",v1,v2,v3); fscanf(in,"%i %s %i",&v1,v2,&v3); //printf("\n%i %s %i",v1,v2,v3); Tseq[i-1]=v3; i++; }; fclose(in); */ p= head; fprintf(outrec,"Pattern\t") ; fprintf(outrec,"Length\t") ; fprintf(outrec,"Density\t") ; fprintf(outrec,"Support\t") ; fprintf(outrec,"Total\t") ; fprintf(outrec,"Zs-sup\t") ; fprintf(outrec,"Zs-tot\t") ; fprintf(outrec,"Sequences_and_Positions\n") ; toto=0.0; while (p!=NULL) { ///---stat------------------ toto++; proba=1.0;densite=0; for (i=0;idifference+2;i++) { switch (p->pattern[i]) { case 'A': proba=proba*T[0];densite++; break; case 'G': proba=proba*T[2];densite++; break; case 'C': proba=proba*T[1];densite++; break; case 'T': proba=proba*T[3];densite++; break; //default: ; }; }; //printf("\n%s dif%i dens%i s%i t%i\n",p->pattern,p->difference,densite,p->support,p->total); elen=p->difference+2; //------------------------------------------------------------------------------------ zstot=0.0; // pour aller rapidement dans les statistiques de ZSSUP expi=0.0;vari=0.0;i=0; while (isupport,vari); //zssup= (p->support - (int) expi)/sqrtl(vari); //if (vari < 0.0) printf("\n vari=%Le",vari); // --------------------------------------------- com zssup= (p->support - expi)/sqrtl(vari); // printf("\n zssup=%Le",zssup) ; //--------------------------------------- comm // printf("\n%s--------------------------",p->pattern); //---------------------------------comm ///---fin stat------------------ fprintf(outrec,"%s\t",p->pattern) ; fprintf(outrec,"%i\t",p->difference+2) ; fprintf(outrec,"%i\t",densite) ; fprintf(outrec,"%i\t",p->support) ; fprintf(outrec,"%i\t",p->total) ; fprintf(outrec,"%Le\t", zssup) ; fprintf(outrec,"%Le\t",zstot) ; //fprintf(outrec,"%s\n",buffer1) ; fprintf(outrec,"%s\n","no-list-occurences") ; /* p->lstseqpos.gofirst(); finish=false; while (!p->lstseqpos.atend() || !finish) { fprintf(outrec,"%i-%i,",p->lstseqpos.value().seq,p->lstseqpos.value().pos); if (p->lstseqpos.atend()) {finish=true; continue;}; p->lstseqpos.next(); }; fprintf(outrec,"\n") ; */ // printf("\n toto=%Lf var=%Le sqr-var=%Le vari=%Le sqr-vari=%Le", toto,var,sqrtl(var),vari,sqrtl(vari)); p=p->succ; }; printf("Total patterns for this family= %12.0Lf\n",toto) ; fclose(outrec); ///////////////////////// } catch (exception &e) { printf("exception: %s\n",e.what()) ; //printf("\n var=%Le", var); // ---------------------------------------- comm //printf("\n zstot=%Le",zstot) ; //--------------------------------------- comm //printf("\n vari=%Le",vari); // --------------------------------------------- com //printf("\n zssup=%Le",zssup) ; //--------------------------------------- comm //printf("\n%s--------------------------",p->pattern); //---------------------------------comm } //return 0; //////////////////////// return toto; } ///////////////////////////////// void Slist::affichredond(int maxsize) //throw(Emerror) { Listnode *vp,*vpp; char *ch; bool stop; ch = new(nothrow) char[maxsize+3]; if (ch==NULL) {Cherror e; throw(e);}; ch[0]='\0'; vp=head; while (vp!=NULL) { vpp = vp->succ;stop=false; while ((vpp!=NULL)&& (!stop)) { if (vp->difference != vpp->difference) {stop=true;continue;}; if (strcmp(vp->pattern,vpp->pattern)==0) printf("egalite chaine %s\n",vp->pattern); else { if ((vpp->total==vp->total) && (vpp->support==vp->support) && (matching(ch,vpp->pattern,vp->pattern)==0) ) { if ((vpp->lstseqpos).szequal(vp->lstseqpos)) { printf(" egalite ensemble %s %s\n",vp->pattern,vpp->pattern); }; }; }; vpp=vpp->succ; }; vp=vp->succ; }; } void Slist::update(int diff,const Tseqpos & x,char c1,char c2, Listnode *p) //throw(Cherror) { p->support=p->total=1; p->lstseqpos.insertafter(x); p->difference=diff; // p->pattern= new char[diff+3]; // if (p->pattern==NULL) {Cherror e; throw(e);}; concat(p->pattern,c1,diff,c2); //strcpy(p->pattern,concat(c1,diff,c2)); p->succ=NULL; } void Slist::insert(int diff,Tseqpos x,char c1,char c2,int maxsize) throw(Sperror,Cherror) { Listnode *p,*q,*pred; if (head==NULL) { p= new(nothrow) Listnode; if (p==NULL) {Sperror e; throw(e);}; p->pattern= new(nothrow) char[maxsize+3]; if (p->pattern==NULL) {Cherror e1; throw(e1);}; update(diff,x,c1,c2,p); head=queue=p; } else { if (diffdifference) { p= new(nothrow) Listnode; if (p==NULL) {Sperror e; throw(e);}; p->pattern= new(nothrow) char[maxsize+3]; if (p->pattern==NULL) {Cherror e1; throw(e1);}; update(diff,x,c1,c2,p); p->succ=head; head=p; } else if (diff>queue->difference) { p= new(nothrow) Listnode; if (p==NULL) {Sperror e; throw(e);}; p->pattern= new(nothrow) char[maxsize+3]; if (p->pattern==NULL) {Cherror e1; throw(e1);}; update(diff,x,c1,c2,p); queue->succ=p; queue=p; } else { q=head; while (diff>q->difference) { pred=q; q=q->succ; }; if (diff==q->difference) { if (x.verif(q->lstseqpos.value())) (q->support)++; // if (!x.overlap(q->lstseqpos.value(),q->difference+2)) (q->tnoverlap)++; (q->total)++; q->lstseqpos.insertafter(x); } else { p= new(nothrow) Listnode; if (p==NULL) {Sperror e; throw(e);}; p->pattern= new(nothrow) char[maxsize+3]; if (p->pattern==NULL) {Cherror e1; throw(e1);}; update(diff,x,c1,c2,p); pred->succ=p; p->succ=q; }; }; }; } /////////////////// void Slist::bidon() throw(Sperror,Cherror) { int i; Listnode *p; for (i=0;i<50000000;i++) { p= new(nothrow) Listnode; if (p==NULL) {Sperror e; throw(e);}; p->pattern= new(nothrow) char[1000]; if (p->pattern==NULL) {Cherror e1; throw(e1);}; if (head==NULL) { head=queue=p; } else { queue->succ=p; queue=p; }; }; } //////////////////// void Slist::join( Listgen * A1, Listgen * A2,int taille,char c1,char c2,int support,int maxsize) { //head=NULL;queue=NULL; Listgen L; int i; bool finish1,finish2,stop; Tseqpos y; int diff; //cout <<"entree"<maxsize) break; y.seq=i; y.pos=A1[i].value(); // cout << "appel insert"<<"\n" ; (*this).insert(diff,y,c1,c2,maxsize); // cout << "retour insert"<<"\n" ; if (L.atend()) finish2=true; else L.next(); }; L.gofirst(); if (A1[i].atend()) finish1=true; else A1[i].next() ; } else { if ( A1[i].value() == L.value()) { if (A1[i].atend()) finish1=true; else L.next(); } else { stop=false; while ( A1[i].value() > L.value()) { if (L.atend()) {stop=true; break; } else L.next(); }; if (stop) break; }; }; }; }; (*this).delete_support_less(support); // return 0; } ///////////////////////////////////////////////////// void Slist::morespecific_v2(int val_support,int maxsize) throw(Sperror,Cherror,Spacerror) //version 3 in fact { Listnode *p,*current,*successor,*predecessor,*vp,*vpp,*future; char * ch; char * chaine; // bool passez,passez2,attention,stop; // bool finish; bool stop; int support,total,con; Tseqpos zero; Listgen liste_interm_occ; zero.seq=0;zero.pos=0; chaine = new(nothrow) char[maxsize+3]; if (chaine==NULL) {Cherror e; throw(e);}; ch = new(nothrow) char[maxsize+3]; if (ch==NULL) {Cherror e; throw(e);}; chaine[0]='\0';ch[0]='\0'; current=head; // predcurrent=head; while (current!=NULL) { //printf("---current :---------------> %s difference %i\n",current->pattern,current->difference); successor=head; predecessor=head; future=current->succ; while (successor!=current) { // printf(" successor : %s\n",successor->pattern); // attention=false; //printf("****** Point1" ); if (current->difference>successor->difference) { //printf("****** Point2"); // matching(chaine,current->pattern,successor->pattern); //printf("****** Point3" ); if (matching(chaine,current->pattern,successor->pattern)== 0)// ca marche //if (chaine!=NULL) { //printf("****** Point4" ); if ( (current->total==successor->total) && (current->support==successor->support) && ( (current->lstseqpos).szequal(successor->lstseqpos)) ) // if3 { // printf("cas2: le successor est extensible: doit etre supprimer "); // printf(" succ extensible et doit etre supprimer : %s\n",chaine); //delete[] current->pattern; //current->pattern=new char[strlen(chaine)+1]; //if (current->pattern==NULL) throw(Cherror()); strcpy(current->pattern,chaine); p=successor; if (successor==head) {head=head->succ; successor=predecessor=head;} else {predecessor->succ=successor->succ; successor=successor->succ;}; delete [] p->pattern; p->lstseqpos.deleteall(); delete p; continue; } else // if3 { (current->lstseqpos).intersect(successor->lstseqpos,liste_interm_occ,support,total,zero); //printf("****** Point5" ); if (support>=val_support) //if4 { // printf("****** bon suuport Point6" ); if ((support==current->support) && (total==current->total)) //if5 { // printf("cas31: modif courant "); strcpy(current->pattern,chaine); } else //if5 { //printf("****** recherche Point7" ); // recherche si existe deja vpp=current; vp=current->succ; stop=false; while ((vp!=NULL) && (!stop)) {//W //printf(" vp pattern : %s\n",vp->pattern); if (current->difference!=vp->difference) //wif1 { //printf("cas1"); break; } else //wif1 { if (current->pattern[current->difference+1]!=vp->pattern[current->difference+1])//wif2 { //printf("cas2"); break; } else //wif2 { //printf("****** recherche Point9" ); if (strcmp(chaine,vp->pattern)==0) //wif3 { stop=true; //printf("cas3"); break; } else //wif3 { //printf("cas4 " ); if ((total==vp->total) && (support==vp->support) && (matching(ch,chaine,vp->pattern)==0) ) //wif4 { //printf("cas41 egalite" ); if (liste_interm_occ.szequal(vp->lstseqpos)) { // matching(vp->pattern,chaine,vp->pattern); strcpy(vp->pattern,ch); stop=true; // printf(" NOUVEAU vp pattern: %s\n",vp->pattern); break; }; }; // wif4 vpp=vp; vp=vp->succ; };// wif3 }; // wif2 };//wif1 };//end w // printf("****** fin recherche Point8" ); // if (stop) printf(" trouve"); else printf(" non trouve"); if ((support==successor->support) && (total==successor->total)) //if6 { // printf("cas42: successor extensible "); // printf(" succ extensible et doit etre deplace ou supprimer si existe : %s\n",chaine); p=successor; if (successor==head) {head=head->succ; successor=predecessor=head;} else {predecessor->succ=successor->succ; successor=successor->succ;}; if (!stop) // non trouve { //delete[] p->pattern; //p->pattern=new char[strlen(chaine)+1]; //if (p->pattern==NULL) throw(Cherror()); strcpy(p->pattern,chaine);p->difference=current->difference; if (vp==NULL) { p->succ=NULL;queue->succ=p; queue=p;} else { p->succ=vp; vpp->succ=p; }; } else { delete[] p->pattern; p->lstseqpos.deleteall(); delete p; }; continue; } else //if6 { // printf("cas43: nouveau elt more specific que successor "); // printf(" nouv : ajoute si existe pas : %s\n",chaine); if (!stop) { p= new(nothrow) Listnode; /// p = NULL; if (p==NULL) {Sperror e; throw(e);}; p->support= support; p->total= total; liste_interm_occ.copyspec(p->lstseqpos); p->difference=strlen(chaine)-2; p->pattern= new(nothrow) char[maxsize+3]; if (p->pattern==NULL) {Cherror e1; throw(e1);}; //p->pattern= new char[strlen(chaine)+1]; //if (p->pattern==NULL) throw(Cherror()); strcpy(p->pattern,chaine); if (vp==NULL) { p->succ=NULL;queue->succ=p; queue=p;} else { p->succ=vp; vpp->succ=p; }; }; }; //if6 }; //if5 }; // if4 liste_interm_occ.deleteall(); }; //if3 };//if2 };//if1 predecessor=successor; successor=successor->succ; }; //w2 current=future; }; //w1 }