MF_About.cxx010064400004310000036000000045611025260130200135630ustar00goutbiomol00004410000024/* MF_About.cxx */ #include #include "MF_About.H" #include "MF_MainWindow.H" extern MF_MainWindow * _MAINW_; void ok_cb(Fl_Widget * w) { _MAINW_->clearAbout(); } MF_AboutText::MF_AboutText(int x, int y, int w, int h) : Fl_Widget(x, y, w, h) { int btx, bty, btw, bth; btw = 50; bth = 25; btx = x + w/2 - btw/2; bty = y + h - bth - 5; bt_ = new Fl_Button(btx, bty, btw, bth, "OK"); bt_->callback(ok_cb); bt_->shortcut(FL_Enter); } void MF_AboutText::draw(void) { int posx, posx2, posy, lgw, lgh; char *txt; fl_color(FL_BLACK); fl_font(FL_HELVETICA_BOLD, 14); txt = strdup("LALNVIEW : A graphical viewer for pairwise alignments"); lgw = lgh = 0; fl_measure(txt, lgw, lgh); posx = x() + w()/2 - lgw/2; posy = 30; fl_draw(txt, posx, posy); free(txt); fl_font(FL_HELVETICA, 12); txt = strdup("Version : lalnview 3.0"); lgw = lgh = 0; fl_measure(txt, lgw, lgh); posx = x() + w()/2 - lgw/2; posy += 30; fl_draw(txt, posx, posy); free(txt); posx = x()+20; posy += 40; fl_draw("Lalnview is licensed under the GNU General Public License (http://www.gnu.org)", posx, posy); posx = x()+40; posy+=50; fl_draw("Laurent Duret", posx, posy); posy += fl_height(); fl_draw("Laboratoire de Biometrie et Biologie Evolutive", posx, posy); posy += fl_height(); fl_draw("CNRS / Universite Lyon I", posx, posy); posy += fl_height(); // fl_draw("e-mail : duret@biomserv.univ-lyon1.fr", posx, posy); fl_draw("e-mail : ", posx, posy); lgw = lgh = 0; fl_measure("e-mail : ", lgw, lgh); posx2 = posx + lgw + 2; fl_color(FL_BLUE); fl_draw("duret@biomserv.univ-lyon1.fr", posx2, posy); fl_color(FL_BLACK); posy += 50; fl_draw("Jean-Francois Gout", posx, posy); posy += fl_height(); fl_draw("e-mail : ", posx, posy); fl_color(FL_BLUE); fl_draw("gout@biomserv.univ-lyon1.fr", posx2, posy); fl_color(FL_BLACK); posy = y() + h() - 80; fl_draw("lalnview uses the FLTK project (http://www.fltk.org) for its user interface", posx, posy); posy = y() + h() -60; fl_draw("lalnview uses the PDFlib lite library (http://www.pdflib.org) for PDF output", posx, posy); posy += 15; fl_line( x(), posy, x()+w(), posy); int ret = bt_->take_focus(); } MF_About::MF_About(int x, int y, int w, int h) : Fl_Window(x, y, w, h, "About lalnview") { tin_ = new MF_AboutText(0, 0, w, h); this->add(tin_); } MF_BestSeries.cxx010064400004310000036000000032721025260567600146010ustar00goutbiomol00004410000024/* MF_BestSeries.cxx */ #include "MF_BestSeries.H" #include "MF_MainWindow.H" #include "dijkstra.H" #include "globals.h" extern MF_MainWindow * _MAINW_; /* void chk_cb(Fl_Widget *w) The callback method for the Fl_Check_Button 'chk_'. */ void chk_cb(Fl_Widget *w) { if( NBBLOC<1 ) return; Fl_Check_Button * c = (Fl_Check_Button *)w; // printf("Bouton : '%d'\n", c->value()); if(c->value()) dijkstra(); _MAINW_->fullUpdatePanel(); } /* void input_cb(Fl_Widget *w) The callback method for the input field 'input_'. */ void input_cb(Fl_Widget *w) { if( NBBLOC<1 ) return; if(_MAINW_->getBestSeries()->isChecked()) dijkstra(); _MAINW_->fullUpdatePanel(); } MF_BestSeries::MF_BestSeries(int x, int y, int w, int h) : Fl_Widget(x, y, w, h) { int posx, posy; this->txt_ = strdup("Display the best series of segments"); fl_font(FL_COURIER, 12); this->chk_ = new Fl_Check_Button(x+5, y+3, 20, h-5, ""); //_MAINW_->add(chk_); parent()->add(chk_); chk_->callback(chk_cb); posx = posy = 0; fl_measure(txt_, posx, posy); posx_ = posx + 5; this->w( posx_ ); input_ = new Fl_Int_Input(x+posx+2, chk_->y()+5, 0, 0); //_MAINW_->add(input_); //parent()->add(input_); input_->value("0"); input_->callback(input_cb); input_->when(FL_WHEN_ENTER_KEY | FL_WHEN_RELEASE); } void MF_BestSeries::draw(void) { fl_font(FL_HELVETICA, 12); fl_color(FL_BLACK); fl_draw(txt_, (chk_->x()+chk_->w()+2), chk_->y()+(chk_->h()/2)+3 ); fl_rect(x(), y(), w(), h()); // fl_rectf(x()+posx_, y(), 20, 20, FL_RED); } int MF_BestSeries::isChecked(void) { return ( chk_->value() ); } int MF_BestSeries::getMarg(void) { return( atoi(input_->value()) ); } MF_Echelle.cxx010064400004310000036000000124671025260567600141000ustar00goutbiomol00004410000024/* MF_Echelle.cxx */ #include #include "MF_Echelle.H" #include "MF_MainWindow.H" extern MF_MainWindow * _MAINW_; FL_EXPORT MF_Echelle::MF_Echelle(int x, int y, int w, int h, int larg, int taille_inter, int taille1) : Fl_Widget(x,y,w,h+40){ this->taille_inter_ = taille_inter; this->taille1_ = taille1; this->larg_=larg; this->sizeText_= 5; this->sizeTitre_ = 20; leftBeg_ = (int)( w/2 - (taille1 + taille_inter*NBCOL)/2) + taille1; } void MF_Echelle::handle_push(void) { int choix; char buf[512]; int x, y; uchar r,g,b; r = 0xFF; g = 0xFF; b = 0xFF; x = Fl::event_x(); y = Fl::event_y(); int numCol = (int)( (w()/2 - (taille1_ + taille_inter_*NBCOL)/2) + taille1_ ); int x2 = x - numCol; if(x2<0 || x2>NBCOL*taille_inter_) return; x2 /= taille_inter_; if(y < this->y()+sizeTitre_) return; if(xx()+this->taille1_) return; numCol = NBCOL-x2-1; sprintf(buf,"%s", "Choix couleur"); choix = fl_color_chooser(buf, r, g, b); //printf("Couleur choisie : \nHexa : %x - %x - %x\nDeci : %d %d %d\n",r,g,b,r,g,b); if(choix){ fl_color(r,g,b); // fl_rectf(200,200,10,20, fl_color()); color_lg[numCol].col = fl_color(); this->redraw(); _MAINW_->redraw(); } } FL_EXPORT int MF_Echelle::handle(int e) { if(e){ switch(e){ case FL_PUSH : handle_push(); return 1; break; default : break; } } return (0); } void MF_Echelle::draw(void) { int i, leftMarg; char buf[10]; int sizeBloc = this->taille_inter_; int base = this->x(); _MAINW_->make_current(); fl_rectf(x(), y(), w(), h(), FL_WHITE); fl_color(0,0,0); fl_font(FL_COURIER,12); fl_draw("SIMILARITY SCALE\0", base+w()/2-(int)fl_width("Similarity scale\0")/2, y()+14); leftMarg = (int)( w()/2 - (taille1_ + taille_inter_*NBCOL)/2); base = leftMarg; fl_font(FL_COURIER,10); fl_draw("Nothing detected\0", base+this->taille1_/2-(int)fl_width("Nothing detected\0")/2, y()+sizeTitre_+larg_+10 ); // fl_rectf(base+1, y()+sizeTitre_, this->taille1_, this->larg_, FL_WHITE); fl_color(0,0,0); base += this->taille1_; leftBeg_ = base; for(i=NBCOL-1 ; i>=0 ; i--){ //printf("%f - %f -> %f\n", color_lg[i].sco, color_lg[i].x1, color_lg[i].x2); fl_rectf(base, y()+sizeTitre_, sizeBloc, this->larg_, color_lg[i].col); sprintf(buf,"%3.0f %c\0",color_lg[i].sco, '%'); fl_color(0,0,0); fl_font(FL_COURIER,10); fl_draw(buf , base+this->taille_inter_/2-(int)fl_width(buf)/2, y()+sizeTitre_+larg_+10); base+=sizeBloc; } base = leftMarg; fl_rect(base,y()+sizeTitre_, taille1_+taille_inter_*NBCOL, larg_); } void MF_Echelle::myResize(int xx, int yy, int ww, int hh) { this->resize(xx, yy, ww, hh); this->draw(); } /**************************************************************************************************/ /* PDF EXPORT */ /**************************************************************************************************/ void MF_Echelle::drawPDF(PDF *p, int decx, int decy) { int i, leftMarg; char buf[10]; int sizeBloc = this->taille_inter_; int base = this->x(); double larg = (double)(this->larg_/1.5); PDF_setcolor(p, "fillstroke", "rgb", (double)0.0, (double)0.0, (double)0.0, (double)0.0 ); int font = PDF_load_font(p, "Helvetica", 0, "host", ""); double fontSize = (double)10.0; PDF_setfont(p, font, fontSize); char *st = (char *)"SIMILARITY SCALE\0"; PDF_set_text_pos(p, base+w()/2-(int)PDF_stringwidth(p, st, font, fontSize)+decx, y()+decy); PDF_show(p, st); leftMarg = (int)( w()/2 - (taille1_ + taille_inter_*NBCOL)/2); base = leftMarg; fontSize = 8.0; PDF_setfont(p, font, fontSize); PDF_set_text_pos(p, base+this->taille1_/2-(int)PDF_stringwidth(p, "Nothing detected\0", font, fontSize)/2+decx, y()+sizeTitre_+larg+decy ); PDF_show(p, "Nothing detected\0"); base += this->taille1_; leftBeg_ = base; PDF_setlinewidth( p, (double)0.5 ); uchar red, green, blue; double dred, dgreen, dblue; for(i=NBCOL-1 ; i>=0 ; i--){ //printf("%f - %f -> %f\n", color_lg[i].sco, color_lg[i].x1, color_lg[i].x2); Fl::get_color(color_lg[i].col, red, green, blue); dred = (double)(red/(double)255); dgreen = (double)(green/(double)255); dblue = (double)(blue/(double)255); PDF_setcolor( p, "fill", "rgb", dred, dgreen, dblue, (double)0.0 ); PDF_rect(p, base+decx, y()+sizeTitre_+decy, sizeBloc, larg); PDF_fill(p); //fl_rectf(base, y()+sizeTitre_, sizeBloc, this->larg_, color_lg[i].col); sprintf(buf,"%3.0f %c\0",color_lg[i].sco, '%'); fl_color(0,0,0); fl_font(FL_COURIER,10); PDF_setcolor(p, "fillstroke", "rgb", (double)0.0, (double)0.0, (double)0.0, (double)0.0 ); PDF_set_text_pos(p, base+this->taille_inter_/2-(int)PDF_stringwidth(p, buf, font, fontSize)/2+decx, y()+sizeTitre_+larg+decy); PDF_show(p, buf); //fl_draw(buf , base+this->taille_inter_/2-(int)fl_width(buf)/2, y()+sizeTitre_+larg_+10); base+=sizeBloc; } base = leftMarg; PDF_setcolor(p, "stroke", "rgb", (double)0.0, (double)0.0, (double)0.0, (double)0.0 ); PDF_rect(p, base+decx, y()+sizeTitre_+decy, taille1_+taille_inter_*NBCOL, larg); PDF_stroke(p); //fl_rect(base,y()+sizeTitre_, taille1_+taille_inter_*NBCOL, larg_); } switch(e){ case FL_PUSH : handle_push(); return 1; break; default : break; } } return (0); } void MF_Echelle::draw(void) { int i, leftMarg; char buMF_FeatDisplay.cxx010064400004310000036000000023251025203700400147140ustar00goutbiomol00004410000024/* MF_FeatDisplay.cxx */ /* The MF_FeatDisplay class' goal is to display the text associated with the features on wich the user clicked. The action is performed by a 'Fl_Text_Display' widget wich is updated using the private field 'buf_'. */ #include "MF_FeatDisplay.H" #include "MF_MainWindow.H" extern MF_MainWindow * _MAINW_; MF_FeatDisplay::MF_FeatDisplay(int x, int y, int w, int h) : Fl_Text_Editor(x,y,w,h){ this->buf_ = new Fl_Text_Buffer(); } /* Displays in full text 'nb' features by reading them in 'tab' array. */ void MF_FeatDisplay::afficheFeat(int *tab, int nb) { int i; char * txt; // int len = nb * (30+18+MAXLAB+1); <-- A retablir apres debug int len = nb * (32+18+MAXLAB+1) + 1; txt = (char *)malloc(len*sizeof(char)); txt[0]='\0'; struct FEATURE f; for(i=0 ; itext(txt); free(txt); textfont(FL_COURIER); textsize(13); this->buffer(buf_); } void MF_FeatDisplay::raz(void) { buf_->text("\0"); this->buffer(buf_); } MF_MainWindow.cxx010064400004310000036000000217121025235207200145710ustar00goutbiomol00004410000024/* MF_MainWindow.cxx */ /* MF_MainWindow : Deals with the main window of the application. The menu, boxes and others objects contained in the window are declared as private fields of this class. */ #include "MF_MainWindow.H" #include "MenuCb.H" #include "MF_Values.H" #include "dijkstra.H" #include "init.H" #define GADD #define GRMV #define RADD #define RRMV MF_MainWindow::MF_MainWindow(int x, int y, int w, int h, const char * lbl) : Fl_Window(x, y, w, h, lbl) { bestFirst_ = 1; myScroll_ = NULL; zoomer_ = NULL; } /* Adds the menu, buttons and several widgets in the window */ void MF_MainWindow::addMenu(void) { static char *dirty_help_file = "lalnview.help"; #if defined( __APPLE__ ) char *help_file = getResValue("helpfile"); #elif defined( WIN32 ) char * help_file = (char *)"lalnview.help"; #else char *help_file = getSrcValue("helpfile"); if( help_file ){ FILE *nf = fopen(help_file, "r"); if( !nf ){ fclose(nf); help_file = NULL; } } if( !help_file ){ char test[8000]; char *p = getenv("HOME"); strcpy(test, p); strcat(test, "lalnview.help"); FILE *nf = fopen(test, "r"); if(nf){ fclose(nf); help_file = strdup(test); } else { help_file = strdup("lalnview.help"); } } /* if( help_file) printf("helpfile : %s\n", help_file); */ #endif Fl_Menu_Item menuitems[] = { { "&File", FL_ALT+'f', 0, 0, FL_SUBMENU }, { "&Open", FL_CTRL+'o', (Fl_Callback *)open_cb, 0 }, { "Open &Features", FL_CTRL+'f', (Fl_Callback *)open_features_cb, 0, FL_MENU_DIVIDER }, { "Export as PDF", FL_CTRL+'p', (Fl_Callback *)export_PDF_cb }, { "Capture as bmp", FL_CTRL+'b', (Fl_Callback *)save_bmp_cb, 0, FL_MENU_DIVIDER }, { "&Quit", FL_CTRL+'q', (Fl_Callback *)close_cb }, {0}, {"&Options",0, 0, 0, FL_SUBMENU }, {"&Save alignments", 0, (Fl_Callback *)save_aln_cb, 0, FL_MENU_DIVIDER }, {"S&cale", 0, 0, 0, FL_SUBMENU}, {"&Save scale", 0, (Fl_Callback *)save_scale_cb }, {"&Load Scale", 0, (Fl_Callback *)load_scale_cb }, {0}, {"F&oreground blocs", 0, 0, 0, FL_SUBMENU}, {"&Best ones", 0, (Fl_Callback *)bestScore_cb, 0, FL_MENU_RADIO}, {"&Worse ones", 0, (Fl_Callback *)worseScore_cb, 0, FL_MENU_RADIO}, {0}, {"&Green list", 0, 0, 0, FL_SUBMENU}, {"Add this segment", FL_CTRL+'a', (Fl_Callback *)greenListAdd_cb }, {"Remove this segment", FL_CTRL+'r', (Fl_Callback *)greenListRemove_cb }, {"Erase list", 0, (Fl_Callback *)greenListErase_cb }, {0}, {"&Red list", 0, 0, 0, FL_SUBMENU}, {"Add this segment", FL_CTRL+'s', (Fl_Callback *)redListAdd_cb }, {"Remove this segment", FL_CTRL+'t', (Fl_Callback *)redListRemove_cb }, {"Erase list", 0, (Fl_Callback *)redListErase_cb }, {0}, {0}, {"&?", FL_ALT+'?', 0, 0, FL_SUBMENU }, {"&Help", FL_CTRL+'h', (Fl_Callback *)help_callback, (void *)help_file}, {"&About", 0, (Fl_Callback *)about_cb, 0}, {0}, {0} }; int NAMEWIDTH = 80; // NAMEWIDTH = default width of the area in wich the names of the sequences are displayed. // This value is updated when the sequences are loaded so that it fits to the longest sequence name. int SCROLH = 220; // SCROLH = Height of the main displaying panel (the panel in wich the sequences are displayed). /* Adding the menu items into the menu bar. */ menu_ = new Fl_Menu_Bar(0, 0, this->w(), 25); menu_->copy(menuitems); this->add(menu_); /* Creates the scale on top of the main panel. */ scale_ = new MF_Echelle(NAMEWIDTH, menu_->h(), this->w()-NAMEWIDTH, 10, 12, 40, 100); this->add(scale_); /* Creates the area in wich the name of the sequences or drawn */ grpName_ = new Fl_Group( 0 , (scale_->y()) , NAMEWIDTH , SCROLH+scale_->h() ); this->add(grpName_); name_ = new MF_Name( 0 , (scale_->y()) , NAMEWIDTH , SCROLH+scale_->h(), 10, 20, 12); grpName_->add(name_); /* myScroll_ is the main panel in wich the sequences are displayed. */ myScroll_ = new MF_MyScroll( NAMEWIDTH, scale_->y()+scale_->h(), this->w()-NAMEWIDTH , SCROLH); this->add(myScroll_); myScroll_->resizable(myScroll_); /* pos1 : y position of the firsts widgets below the myScroll_ panel (buttons, minimum score chooser, ...)*/ int pos1 = myScroll_->y() + myScroll_->h() + 10; btGrp_ = new Fl_Scroll(0 , pos1, this->w(), this->h()-pos1); btGrp_->type(Fl_Scroll::HORIZONTAL); btGrp_->resizable(NULL); this->add(btGrp_); scoMinC_ = new MF_ScoMinChooser(_MF_TYPE_SCOREMIN_, 20, pos1, "Similarity Score Threshold\0", 12); btGrp_->add(scoMinC_); int pos2 = scoMinC_->y()+scoMinC_->h()+3; identityMinC_ = new MF_ScoMinChooser(_MF_TYPE_IDENTITYMIN_, 20, pos2 , "Minimum identity\0", 12); btGrp_->add(identityMinC_); int pos3 = identityMinC_->y() + identityMinC_->h() + 3; lenghtMinC_ = new MF_ScoMinChooser(_MF_TYPE_LENGHTMIN_, 20, pos3 , "Minimum length\0", 12); btGrp_->add(lenghtMinC_); int pos4 = lenghtMinC_->y() + lenghtMinC_->h() + 10; bestSeries_ = new MF_BestSeries(scoMinC_->x(), pos4, 600, 40); btGrp_->add(bestSeries_); parcBloc_ = new MF_ParcBloc(scoMinC_->x()+scoMinC_->w()+10, pos1, 100, 75); btGrp_->add(parcBloc_); zoomer_ = new MF_Zoomer(parcBloc_->x()+parcBloc_->w()+5, parcBloc_->y(), 100, 75); btGrp_->add(zoomer_); stats_ = new MF_Stats(zoomer_->x()+zoomer_->w()+15, pos1, 340, 70); btGrp_->add(stats_); pos4 = stats_->y()+stats_->h()+10; int h4 = bestSeries_->y()+bestSeries_->h()-pos4+2; featDisp_ = new MF_FeatDisplay(parcBloc_->x(), pos4, this->w()-parcBloc_->x()-10, h4); this->add(featDisp_); this->size_range(0 , h() , 2600, h() ); } /* void MF_MainWindow::about(void) Displays the about panel. */ void MF_MainWindow::about(void) { this->about_ = new MF_About(10, 10, 500, 400); this->about_->show(); } void MF_MainWindow::actuName(void){ name_->draw(); } /* updates the area in wich the names of the sequences are displayed. */ /* Redraws the main panel. */ void MF_MainWindow::updatePanel(void) { if(myScroll_) myScroll_->redraw(); } /* Performs a full update of the main panel (with new values of the thresholds). */ void MF_MainWindow::fullUpdatePanel(void) { if(myScroll_ && NBBLOC>0 && NBSEQ>0){ if(bestSeries()) dijkstra(); myScroll_->fullUpdate(); } } /* Sets the shown text inside the three boxes "Similarity score threshold", "Minimum identity" and "Minimum lenght". */ void MF_MainWindow::setMins(void) { char val[16]; sprintf(val, "%.1f\0", MF_Values::scoMin()); scoMinC_->setValue(val); sprintf(val, "%.1f\0", MF_Values::identityMin()); identityMinC_->setValue(val); sprintf(val, "%d\0", MF_Values::lenghtMin()); lenghtMinC_->setValue(val); } /* void MF_MainWindow::activerParcBloc(void) Activates the buttons used to switch from a segment to the other when the user clicks on a BLOC that belongs to several segments. */ void MF_MainWindow::activerParcBloc(void){ parcBloc_ ->activer(); } int MF_MainWindow::bestFirst(void){ return bestFirst_; }/* Return a non zero value if the radio button "Best ones" of the Option menu is checked. */ /* Sets the value of the private field 'bestFirst_' wich indicates wether the best or the worse blocs must be displayed in front. */ void MF_MainWindow::bestFirst(int val) { bestFirst_ = val; myScroll_->fullUpdate(); } int MF_MainWindow::bestSeries(void){ return bestSeries_->isChecked(); }/* Returns a non zero value if the check button "Display the best series of segments" (eg _MAINW_->bestSeries_->chk_) is checked. */ /* void MF_MainWindow::desactiverParcBloc(void) Deactivates the buttons used to switch from a segment to the other (see below). */ void MF_MainWindow::desactiverParcBloc(void){ parcBloc_->desactiver(); } void MF_MainWindow::clearAbout(void){ delete this->about_; }/* Hides the About window. */ void MF_MainWindow::listMenuItems(void) { int nb = menu_->size(); printf("Nomre d'elements dans menu : %d\n", nb); const Fl_Menu_Item * it = menu_->menu(); int i; for(i=0 ; imenu_; } MF_MyScroll * MF_MainWindow::getScroll(void){ return this->myScroll_; } MF_Name * MF_MainWindow::getName(void){ return this->name_; } MF_Zoomer * MF_MainWindow::getZoomer(void){ return this->zoomer_; } MF_ParcBloc * MF_MainWindow::getParcBloc(void){ return parcBloc_; } MF_Stats * MF_MainWindow::getStats(void){ return stats_; } const Fl_Menu_Item * MF_MainWindow::getMenuItems(void) { const Fl_Menu_Item * it = menu_->menu(); return it; } MF_FeatDisplay * MF_MainWindow::getFeatDisp(void){ return featDisp_; } MF_BestSeries * MF_MainWindow::getBestSeries(void){ return bestSeries_; } MF_Echelle * MF_MainWindow::getScale(void){ return scale_; } MF_ScoMinChooser * MF_MainWindow::getScoMinC(void){ return scoMinC_; } /*****************************************************************************************/ = 80; // NAMEWIDTH = default width of the area in wichMF_MyScroll.cxx010064400004310000036000000461661025376235100143010ustar00goutbiomol00004410000024/* MF_MyScroll.cxx */ #include "pdflib.h" #include "lalnview_utils.H" #include "MF_MyScroll.H" #include "MF_MainWindow.H" #include "MF_FeatDisplay.H" #include "MF_Values.H" extern MF_MainWindow * _MAINW_; MF_MyScroll::MF_MyScroll(int x, int y, int w, int h) : Fl_Group(x, y, w, h) { lastSeqClicked_ = -1; lastBlocClicked_ = -1; seq_[0] = seq_[1] = NULL; scrolbH_ = 15; scrolb_ = new MF_MyScrollbar(x, y+h-scrolbH_, w, scrolbH_); scrolb_->type(FL_HORIZONTAL); this->add(scrolb_); this->resizable(NULL); } void MF_MyScroll::loadSequences(void) { int seqMarg = 10; int i, imax, lg; double rapport = MF_Values::rapport(); seqLarg_ = 11; lastSeqClicked_ = -1; lastBlocClicked_ = -1; float scoMin = segm[0].sco; for(i=0 ; iscoMin) scoMin = segm[i].sco; segm[i].id = i; segm[i].myList = 0; } /* The default scoMin_ (Similarity score threshold) is 120 but if no segm has a score higer than 120, the scoMin_ is set to the score of the best segment. */ if(scoMinw(), this->h()/2-scrolbH_/2 , seqMarg, seqLarg_); this->add(seq_[0]); seq_[1] = new MF_Sequence( 1 , x() , seq_[0]->y()+seq_[0]->h(), this->w(), this->h()/2-scrolbH_/2-2 , seqMarg, seqLarg_); this->add(seq_[1]); _MAINW_->getName()->yText( seq_[0]->seqY() , seq_[1]->seqY() ); imax = 0; if( seq[0].lgslider_size( (float)( ((float)scrolb_->w()) / ((float)lg) ) ); scrolb_->step(rapport/50); scrolb_->range(0 , (lg-scrolb_->w()) + 15); scrolb_->callback(scrolb_cb); scrolb_->dessine(); scrolb_->redraw(); draw(); _MAINW_->actuName(); } void MF_MyScroll::reCalibrate(int pos) { double rapport = MF_Values::rapport(); int fullSize = getFullSize(); scrolb_->slider_size( (float)( ((float)scrolb_->w()) / ((float)fullSize) ) ); scrolb_->range(0 , (fullSize-scrolb_->w()) + 15); if(pos>-1){ Fl_Slider * slid = (Fl_Slider *)scrolb_; slid->value((double)pos); } scrolb_->redraw(); } void MF_MyScroll::zoomWhole(void) { if(NBBLOC<1 || NBSEQ<0) return; int fullSize = getFullSize(); // int r = (int)(fullSize/w()); int r, l, tot; if(lastBlocClicked_<0){ if(seq[0].lg>seq[1].lg) tot = seq[0].lg; else tot = seq[1].lg; } else { SEG curSeg = segm[seq[0].bloc[lastBlocClicked_].seg]; /*************************************/ /* Looking for the biggest left part. */ if( curSeg.beg0>curSeg.beg1 ) l = curSeg.beg0; else l = curSeg.beg1; /*************************************/ /***********************************************************/ /* Looking for the biggest right part. */ if( (seq[0].lg-curSeg.beg0)>(seq[1].lg-curSeg.beg1) ) r = seq[0].lg-curSeg.beg0; else r = seq[1].lg -curSeg.beg1; /***********************************************************/ tot = l+r; } double rp = (double)((double)tot/(double)(w()-25)); MF_Values::rapport(rp); reCalibrate(0); reAlign(); Fl_Slider * slid = ((Fl_Slider *)scrolb_); slid->value((double)0); redraw(); } void MF_MyScroll::myResize(int xx, int yy, int ww, int hh) { this->resize( xx , y() , ww , h() ); scrolb_->resize(xx, yy+hh-scrolbH_, ww, scrolbH_); scrolb_->dessine(); } double MF_MyScroll::shift(void) { return scrolb_->value(); } void MF_MyScroll::draw(void) { int i; SEG s; MF_FeatDisplay * st = _MAINW_->getFeatDisp(); st->resize( _MAINW_->getScoMinC()->x()+_MAINW_->getScoMinC()->w()+10 , st->y(), st->w() , st->h() ); if(NBBLOC<1 || NBSEQ<1){ scrolb_->dessine(); return; } uchar r, g, b; /* r,g,b : colors used to fill the segments between the sequences. */ r = 0xFF; g = 0xF0; b = 0x90; fl_rectf(x(), y(), w(), h()-scrolbH_, FL_WHITE); double scoMin = MF_Values::scoMin(); double identityMin = MF_Values::identityMin(); int lenghtMin = MF_Values::lenghtMin(); /* if the option of displaying only the best series of segments id checked bck will be non-zero */ int bck = _MAINW_->getBestSeries()->isChecked(); int onlyRed = 0; int onlyGreen = 0; /* Fisrt loop fills the segment with yellow color */ for(i=0 ; i-1 && lastBlocClicked_>-1 ){ s = segm[seq[lastSeqClicked_].bloc[lastBlocClicked_].seg]; fl_color(0xEF, 0xDF, 0x50); // if( s.sco>=scoMin && s.lgaln >= lenghtMin && s.identity >= identityMin && ( !bck || s.bestSeries) ){ if( isDrawable(s, scoMin, identityMin, lenghtMin, bck, onlyGreen, onlyRed) ){ fillSeg(s); } } /* Second loop draws the lines that delimitate the segments */ for(i=0 ; i= scoMin && s.lgaln >= lenghtMin && s.identity >= identityMin && ( !bck || s.bestSeries) ){ if( isDrawable(s, scoMin, identityMin, lenghtMin, bck, onlyGreen, onlyRed) ){ drawSegLines(s); } } /* !!!! The second loop (drawing the lines) must be done after the first one, otherwise the lines would be invisible. !!!! */ seq_[0]->draw(); seq_[1]->draw(); scrolb_->dessine(); _MAINW_->actuName(); return; } void MF_MyScroll::fillSeg(SEG s) { int px, py, px1, py1, px2, py2, px3, py3; int beg[2], end[2]; double rapport = MF_Values::rapport(); double shift[2]; shift[0] = scrolb_->value() - seq_[0]->leftMarg() - seq_[0]->x(); shift[1] = scrolb_->value() - seq_[1]->leftMarg() - seq_[1]->x(); int firstBase[2]; firstBase[0] = (int)(shift[0]*rapport); firstBase[1] = (int)(shift[1]*rapport); beg[0] = (int)((s.beg0 - firstBase[0])/rapport); beg[1] = (int)((s.beg1 - firstBase[1])/rapport); end[0] = (int)((s.end0 - firstBase[0])/rapport); end[1] = (int)((s.end1 - firstBase[1])/rapport); px = beg[0]; py = seq_[0]->seqY()+seqLarg_; px1 = beg[1]; py1 = seq_[1]->seqY(); px2 = end[1]; py2 = seq_[1]->seqY(); px3 = end[0]; py3 = seq_[0]->seqY()+seqLarg_; fl_polygon(px, py, px1, py1, px2, py2, px3, py3); } /* void MF_Bin::drawSegLines(SEG s) Draws the lines (between the two sequences) wich delimitates the segment s. */ void MF_MyScroll::drawSegLines(SEG s) { int beg[2], end[2]; double rapport = MF_Values::rapport(); double shift[2]; shift[0] = scrolb_->value() - seq_[0]->leftMarg() - seq_[0]->x(); shift[1] = scrolb_->value() - seq_[1]->leftMarg() - seq_[1]->x(); int firstBase[2]; firstBase[0] = (int)(shift[0]*rapport); firstBase[1] = (int)(shift[1]*rapport); beg[0] = (int)((s.beg0 - firstBase[0])/rapport); beg[1] = (int)((s.beg1 - firstBase[1])/rapport); end[0] = (int)((s.end0 - firstBase[0])/rapport); end[1] = (int)((s.end1 - firstBase[1])/rapport); fl_color(FL_BLACK); fl_line(beg[0], seq_[0]->seqY()+seqLarg_ , beg[1], seq_[1]->seqY()); fl_line(end[0], seq_[0]->seqY()+seqLarg_ , end[1], seq_[1]->seqY()); } void MF_MyScroll::reAlign(void) { if(lastSeqClicked_<0 || lastBlocClicked_<0) return; double rapport = MF_Values::rapport(); BLOC b[2]; b[0] = seq[0].bloc[lastBlocClicked_]; b[1] = seq[1].bloc[lastBlocClicked_]; double shift[2]; shift[0] = scrolb_->value() - seq_[0]->leftMarg() - seq_[0]->x(); shift[1] = scrolb_->value() - seq_[1]->leftMarg() - seq_[1]->x(); int firstBase[2]; firstBase[0] = (int)(shift[0]*rapport); firstBase[1] = (int)(shift[1]*rapport); int posX[2]; posX[0] = (int)( (b[0].beg - firstBase[0])/rapport ); posX[1] = (int)( (b[1].beg - firstBase[1])/rapport ); if(posX[0]==posX[1]) return; int r, l; if( posX[0]>posX[1] ){ r = 0; l = 1; } else { r = 1; l = 0; } int dec = posX[r]-posX[l]; int pos = scrolb_->value(); int leftMarg[2]; leftMarg[r] = seq_[r]->leftMarg(); leftMarg[l] = seq_[l]->leftMarg(); if( leftMarg[r] > dec){ leftMarg[r] -= dec; if( lastSeqClicked_ == r ) pos -= dec; } else { leftMarg[l] += dec; if( lastSeqClicked_ == l ) pos += dec; } while( leftMarg[r]>20 && leftMarg[l]>20 ){ leftMarg[r] -= 20; leftMarg[l] -= 20; pos -= 20; } seq_[r]->leftMarg(leftMarg[r]); seq_[l]->leftMarg(leftMarg[l]); int fullSize = getFullSize(); scrolb_->slider_size( (float)( ((float)scrolb_->w()) / ((float)fullSize) ) ); scrolb_->range(0 , (fullSize-scrolb_->w()) + 15); Fl_Slider * slid = (Fl_Slider *)scrolb_; slid->value((double)pos); // scrolb_->value(pos); seq_[r]->redraw(); seq_[l]->redraw(); } void MF_MyScroll::initSegIdentity(void) { int i, lastSeg, lgaln; float ident, gapf; float _defaultSeuil_ = 120.0; float scoMax = 0.0; BLOC b; lastSeg = -1; for(i=0 ; iscoMax) scoMax = segm[b.seg].sco; get_aln(b.seg, &ident, &gapf, &lgaln, i); segm[b.seg].identity = ident; segm[b.seg].gapf = gapf; segm[b.seg].lgaln = lgaln; lastSeg = b.seg; } } if(scoMax>_defaultSeuil_) scoMax = _defaultSeuil_; MF_Values::scoMin(scoMax); } void MF_MyScroll::setLasts(int lastSeqClicked, int lastBlocClicked) { lastSeqClicked_ = lastSeqClicked; lastBlocClicked_ = lastBlocClicked; } MF_MyScrollbar * MF_MyScroll::getScrollbar(void){ return scrolb_; } int MF_MyScroll::getFullSize(void) { double rapport = MF_Values::rapport(); int lg[2]; lg[0] = (int)(seq[0].lg/rapport) + seq_[0]->leftMarg(); lg[1] = (int)(seq[1].lg/rapport) + seq_[1]->leftMarg();; int imax; if( lg[0]>lg[1] ) imax = 0; else imax = 1; return(lg[imax]); } void MF_MyScroll::fullUpdate(void) { seq_[0]->loadTab(); seq_[1]->loadTab(); /* seq_[0]->draw(); seq_[1]->draw(); */ redraw(); } /* int MF_MyScroll::getLastSegment(void) Return the last segment clicked by the user, -1 if no segment was ever clicked. The returned integer correspond to the index of the segment in the 'segm' array declared as a global variable (see file def_globals.h for definitions). */ int MF_MyScroll::getLastSegment(void) { int segNum = -1; int lastBloc = this->getLastBloc(); int lastSeq = this->getLastSeq(); if(lastBloc>-1 && lastBloc-1 && segNumtake_focus(); _MAINW_->fullUpdatePanel(); this->take_focus(); _MAINW_->take_focus(); _MAINW_->make_current(); _MAINW_->redraw(); this->draw(); int ww = _MAINW_->getName()->w() + w(); int hh = _MAINW_->getScale()->h() + h(); uchar *mat = (uchar *)malloc(ww*hh*4*sizeof(uchar)); fl_read_image(mat, _MAINW_->getName()->x(), _MAINW_->getName()->y(), ww, hh); saveBMP(mat, ww, hh, file); } int MF_MyScroll::getLastSeq(void){ return lastSeqClicked_; } int MF_MyScroll::getLastBloc(void){ return lastBlocClicked_; } MF_Sequence * MF_MyScroll::getSequence(int num){ return seq_[num]; } /****************************************************************************************/ /****************************************************************************************/ /****************************************************************************************/ /****************************************************************************************/ /* PDF FUNCTIONS */ /****************************************************************************************/ void MF_MyScroll::exportPDF(char *fileName, int all) { PDF *p; int font; int decy = 20; int decx = 80; double fontSize = (double)10.0; int maxName, lgS, lgSMax; double sr = MF_Values::rapport(); //printf("Taille : %d\n", getFullSize()); int lg = strlen(seq[0].name); if(lg < strlen(seq[1].name) ) maxName = 1; else maxName = 0; lgSMax = 10000; lgS = getFullSize(); int a4h = 842; int a4w = 595; lgSMax = a4h; // The PDF output must nit be larger than a given width (lgSMax) to avoid crash when reading the pdf created. if( all==1 && lgS > lgSMax ){ MF_Values::rapport(sr*((double)((double)lgS/(double)lgSMax))); reAlign(); //printf("Changement rapport de %.2f a %.2f\n", sr, MF_Values::rapport()); } //MF_Values::rapport(sr*((double)((double)lgS/(double)lgSMax))); //printf("FullSize : %d\n", getFullSize()); if ((p = PDF_new()) == (PDF *) 0) { fl_alert("Couldn't create PDFlib object (out of memory)!\n"); return; } PDF_TRY(p) { if (PDF_begin_document(p, fileName, 0, "compatibility=1.3") == -1) { printf("Error: %s\n", PDF_get_errmsg(p)); return; } PDF_set_parameter(p, "topdown", "true"); PDF_set_info(p, "Creator", "lalnview"); PDF_set_info(p, "Author", "Lalnview"); PDF_set_info(p, "Title", "Export from lalnview"); if(all==1) PDF_begin_page_ext(p, lgSMax+decx, 400, ""); else PDF_begin_page_ext(p, w()+decx+10, 400, ""); font = PDF_load_font(p, "Helvetica", 0, "host", ""); PDF_setfont(p, font, fontSize); decx = (int)PDF_stringwidth(p, seq[maxName].name, font, fontSize) + 8; // Drawing successively the scale, the to sequences (with their features) and then the segments. _MAINW_->getScale()->drawPDF(p, decx, decy); seq_[0]->drawPDF(p, decx, decy, all); seq_[1]->drawPDF(p, decx, decy, all); this->drawPDF(p, decx, decy, all); /****************************************************************************************************/ /* Clean an area on the left side to draw sequence name */ PDF_setcolor(p, "fill", "rgb", (double)1.0, (double)1.0, (double)1.0, (double)0.0); PDF_rect(p, 0, 400, decx-2, 400); PDF_fill(p); PDF_setcolor(p, "fillstroke", "rgb", (double)0.0, (double)0.0, (double)0.0, (double)0.0); font = PDF_load_font(p, "Helvetica", 0, "host", ""); PDF_setfont(p, font, fontSize); PDF_set_text_pos(p, 4, seq_[0]->seqY()+decy); PDF_show(p, seq[0].name); PDF_set_text_pos(p, 4, seq_[1]->seqY()+decy); PDF_show(p, seq[1].name); /****************************************************************************************************/ PDF_end_page_ext(p, ""); PDF_end_document(p, ""); if(all==1){ MF_Values::rapport(sr); reAlign(); } } PDF_CATCH(p) { printf("PDFlib exception occurred.\n"); printf("[%d] %s: %s\n", PDF_get_errnum(p), PDF_get_apiname(p), PDF_get_errmsg(p)); PDF_delete(p); return; } PDF_delete(p); } void MF_MyScroll::drawPDF(PDF *p, int _DECX_, int _DECY_, int all) { int i; SEG s; if(NBBLOC<1 || NBSEQ<1){ return; } uchar r, g, b; /* r,g,b : colors used to fill the segments between the sequences. */ r = 0xFF; g = 0xF0; b = 0x90; // Converting uchar to double because PDFlib requires double values between 0 and 1 for colors. double red, green, blue; red = (double)(r/(double)255); green = (double)(g/(double)255); blue = (double)(b/(double)255); double scoMin = MF_Values::scoMin(); double identityMin = MF_Values::identityMin(); int lenghtMin = MF_Values::lenghtMin(); /* if the option of displaying only the best series of segments id checked bck will be non-zero */ int bck = _MAINW_->getBestSeries()->isChecked(); int onlyRed = 0; int onlyGreen = 0; /* Fisrt loop fills the segment with yellow color */ for(i=0 ; i-1 && lastBlocClicked_>-1 ){ s = segm[seq[lastSeqClicked_].bloc[lastBlocClicked_].seg]; if( isDrawable(s, scoMin, identityMin, lenghtMin, bck, onlyGreen, onlyRed) ){ r = 0xEF; g = 0xDF; b = 0x50; red = (double)(r/(double)255); green = (double)(g/(double)255); blue = (double)(b/(double)255); fillSegPDF(p, s, _DECX_, _DECY_, red, green, blue, all); } } /* Second loop draws the lines that delimitate the segments */ for(i=0 ; ivalue() - seq_[0]->leftMarg() ; shift[1] = scrolb_->value() - seq_[1]->leftMarg() ; if(all==1){ shift[0] = 0 - seq_[0]->leftMarg(); shift[1] = 0 - seq_[1]->leftMarg(); } int firstBase[2]; firstBase[0] = (int)(shift[0]*rapport); firstBase[1] = (int)(shift[1]*rapport); beg[0] = (int)((s.beg0 - firstBase[0])/rapport); beg[1] = (int)((s.beg1 - firstBase[1])/rapport); end[0] = (int)((s.end0 - firstBase[0])/rapport); end[1] = (int)((s.end1 - firstBase[1])/rapport); PDF_setcolor( p, "fill", "rgb", red, green, blue, (double)0.0 ); PDF_moveto(p, beg[0]+decx, seq_[0]->seqY()+decy); PDF_lineto(p, beg[1]+decx, seq_[1]->seqY()-seqLarg_+decy); PDF_lineto(p, end[1]+decx, seq_[1]->seqY()-seqLarg_+decy); PDF_lineto(p, end[0]+decx, seq_[0]->seqY()+decy); PDF_fill(p); } /* void MF_Bin::drawSegLines(SEG s) Draws the lines (between the two sequences) which delimitates the segment s. */ void MF_MyScroll::drawSegLinesPDF(SEG s, PDF *p, int decx, int decy, int all) { double dred, dgreen, dblue; int beg[2], end[2]; double rapport = MF_Values::rapport(); double shift[2]; shift[0] = scrolb_->value() - seq_[0]->leftMarg() ; shift[1] = scrolb_->value() - seq_[1]->leftMarg() ; // all==1 if the entire alignment must be drawn. In that case, the scrolling value does not matter, only the leftMarg must // be taken in account. if(all==1){ shift[0] = 0 - seq_[0]->leftMarg(); shift[1] = 0 - seq_[1]->leftMarg(); } int firstBase[2]; firstBase[0] = (int)(shift[0]*rapport); firstBase[1] = (int)(shift[1]*rapport); beg[0] = (int)((s.beg0 - firstBase[0])/rapport); beg[1] = (int)((s.beg1 - firstBase[1])/rapport); end[0] = (int)((s.end0 - firstBase[0])/rapport); end[1] = (int)((s.end1 - firstBase[1])/rapport); dred = dgreen = dblue = (double)0.0; PDF_setcolor(p, "stroke", "rgb", dred, dgreen, dblue, 0); PDF_setlinewidth( p, (double)0.001 ); PDF_moveto(p, beg[0]+decx, seq_[0]->seqY()+decy); PDF_lineto(p, beg[1]+decx, seq_[1]->seqY()-seqLarg_+decy); PDF_stroke(p); PDF_moveto(p, end[0]+decx, seq_[0]->seqY()+decy); PDF_lineto(p, end[1]+decx, seq_[1]->seqY()-seqLarg_+decy); PDF_stroke(p); } } } if(scoMax>_defaultSeuil_) scoMax = _defaultSeuil_; MF_Values::scoMin(scoMax); } void MF_MyScroll::setLasts(int lastSeqClicked, int lastBlocClicked) { lastSeqClicked_ = lastSeqClicked; lastBlocClicked_ = lastBlocClicked; } MF_MyScrollbar * MF_MyScroll::getScrollbar(void){ return scrolb_; } int MF_MyScroll::getFullSize(void) { double rapport = MF_Values::rapport(); MF_MyScrollbar.cxx010064400004310000036000000004171023544462400147530ustar00goutbiomol00004410000024/* MF_MyScrollbar.cxx */ #include "MF_MyScrollbar.H" MF_MyScrollbar::MF_MyScrollbar(int x, int y, int w, int h) : Fl_Scrollbar(x, y, w, h) { ; } void MF_MyScrollbar::dessine(void) { draw(); } void MF_MyScrollbar::pos(int val) { // value((double)val); ; } MF_Name.cxx010064400004310000036000000012651023616517000134010ustar00goutbiomol00004410000024/* MF_Name.cxx */ #include "MF_Name.H" #include "globals.h" MF_Name::MF_Name(int x, int y, int w, int h, int y0, int y1, int fsize) : Fl_Widget(x,y,w,h) { yText_[0] = y0; yText_[1] = y1; fsize_ = fsize; } void MF_Name::draw(void) { if(NBSEQ<1) return; fl_rectf(x(), y(), w(), h(), FL_WHITE); fl_color(FL_BLACK); fl_font(FL_COURIER, fsize_); fl_draw(seq[0].name, x()+5, yText_[0] + fsize_ - 2); fl_draw(seq[1].name, x()+5, yText_[1] + fsize_ - 2); } void MF_Name::yText(int y0, int y1) { yText_[0] = y0; yText_[1] = y1; } int MF_Name::getX(void){ return this->x(); } int MF_Name::getW(void){ return this->w(); } void MF_Name::myW(int w) { this->w(w); } MF_Next.cxx010064400004310000036000000003161024455377000134410ustar00goutbiomol00004410000024/* MF_NextBloc.cxx */ #include "MF_Next.H" MF_Next::MF_Next(int sens, int x, int y, int w, int h, char *lbl) : Fl_Button(x, y, w, h, lbl) { sens_ = sens; } int MF_Next::sens() { return sens_; } MF_ParcBloc.cxx010064400004310000036000000034411024256330400142020ustar00goutbiomol00004410000024/* MF_ParcBloc.cxx */ #include "MF_ParcBloc.H" #include "MF_MainWindow.H" extern MF_MainWindow * _MAINW_; void MF_NextBloc_cb(Fl_Widget *w) { int lb, ls; MF_MyScroll * ms = _MAINW_->getScroll(); lb = ms->getLastBloc(); ls = ms->getLastSeq(); if( ls<0 || ls>1 || lb<0) return; MF_Next * b = (MF_Next *)w; MF_Sequence * seq = ms->getSequence(ls); if(b->sens()>0){ seq->showNextBloc(); } else { seq->showPrevBloc(); } } MF_ParcBloc::MF_ParcBloc(int x, int y, int w, int h) : Fl_Widget(x,y,w,h) { curBloc_ = -1; nbBloc_ = -1; fsize_ = 12; decY_ = fsize_*2;; btPrevX_ = x+8; btPrevY_ = y + decY_; btPrevW_ = (w-16)/2; btPrevH_ = (int)(h-decY_- (0.2*decY_)); btNextX_ = btPrevX_ + btPrevW_; btNextY_ = btPrevY_; btNextW_ = btPrevW_; btNextH_ = btPrevH_; btPrev_ = new MF_Next(-1, btPrevX_, btPrevY_, btPrevW_, btPrevH_, "@<-"); btNext_ = new MF_Next(1, btNextX_, btNextY_, btNextW_, btNextH_, "@->"); //_MAINW_->add(btPrev_); //_MAINW_->add(btNext_); parent()->add(btPrev_); parent()->add(btNext_); btPrev_->callback(MF_NextBloc_cb); btNext_->callback(MF_NextBloc_cb); desactiver(); } void MF_ParcBloc::draw(void) { if(nbBloc_<0 || curBloc_<0) return; sprintf(txt_, "Bloc %d / %d\0", curBloc_, nbBloc_); fl_rectf(x(), y()+(int)(0.7*fsize_), w(), fsize_, FL_BACKGROUND_COLOR); fl_color(FL_BLACK); fl_rect(x(), y(), w(), h()); fl_font(FL_COURIER, fsize_); fl_draw(txt_, x(), y()+(int)(0.7*fsize_), w(), fsize_, FL_ALIGN_CENTER); } void MF_ParcBloc::desactiver() { btPrev_->deactivate(); btNext_->deactivate(); } void MF_ParcBloc::activer() { btPrev_->activate(); btNext_->activate(); } void MF_ParcBloc::setCurrentBloc(int curBloc, int nbBloc) { curBloc_ = curBloc; nbBloc_ = nbBloc; redraw(); } MF_Pub.cxx010064400004310000036000000005741025260567600132610ustar00goutbiomol00004410000024/* MF_Pub.cxx */ #include #include #include "MF_Pub.H" MF_Pub::MF_Pub(int x, int y, int w, int h) : Fl_Widget(x, y, w, h) { ; } void MF_Pub::draw(void) { char * txt; txt = strdup("LALNVIEW"); fl_font(FL_HELVETICA, 18); fl_rectf(x(), y(), w(), h(), FL_WHITE); fl_color(FL_BLACK); fl_draw(txt, x(), y(), w(), h(), FL_ALIGN_CENTER); } MF_ScoMinChooser.cxx010064400004310000036000000046611023770106400152360ustar00goutbiomol00004410000024/* MF_ScoMinChooser.cxx */ /* MF_ScoMinChooser provides a class that can be used to create easily boxes such as the "Similarity Score Threshold" or the "Minimum lenght" boxes. Each box is composed an input field and a text. */ #include "MF_ScoMinChooser.H" #include "MF_MainWindow.H" #include "MF_Values.H" extern MF_MainWindow * _MAINW_; /* Callback method for the "Similarity Score Threshold" box. */ void MF_ScoMinChooser_score_cb(Fl_Widget *w) { Fl_Float_Input * flip = (Fl_Float_Input *)w; // printf("Changer sco min a : %f\n", atof(flip->value())); MF_Values::scoMin(atof(flip->value())); _MAINW_->fullUpdatePanel(); } /* Callback method for the "Minimum lenght" box */ void MF_ScoMinChooser_lenght_cb(Fl_Widget *w) { int min; Fl_Float_Input * flip = (Fl_Float_Input *)w; min = (int) atof(flip->value()); // printf("Changer length min a : %d\n", min); MF_Values::lenghtMin(min); _MAINW_->fullUpdatePanel(); } /* Callback method for the "Minimum identity box" */ void MF_ScoMinChooser_identity_cb(Fl_Widget *w) { float min; Fl_Float_Input * flip = (Fl_Float_Input *)w; min = atof(flip->value()); // printf("Changer length min a : %d\n", min); MF_Values::identityMin(min); _MAINW_->fullUpdatePanel(); } MF_ScoMinChooser::MF_ScoMinChooser(int type, int x, int y, const char * txt, int fsize) : Fl_Widget(x, y, 0, 0) { int fx, fy, fw, fh, w, h; txt_ = strdup(txt); fsize_ = fsize; type_ = type; fw = 40; fh = 20; fRightMarg_ = 10; fLeftMarg_ = 10; txtLeftMarg_ = 5; topMarg_ = 12; fl_font(FL_COURIER, fsize); w = 0; h = 0; fl_measure(txt, w, h); w = txtLeftMarg_ + w + fLeftMarg_ + fw + fRightMarg_; h = fh + 2*topMarg_; this->w(w); this->h(h); fx = x + w - fw - fRightMarg_; fy = y + h/2 - fh/2; flip_ = new Fl_Float_Input(fx, fy, fw, fh); parent()->add(flip_); if(type == _MF_TYPE_SCOREMIN_) flip_->callback(MF_ScoMinChooser_score_cb); if(type == _MF_TYPE_LENGHTMIN_) flip_->callback(MF_ScoMinChooser_lenght_cb); if(type == _MF_TYPE_IDENTITYMIN_) flip_->callback(MF_ScoMinChooser_identity_cb); flip_->when(FL_WHEN_ENTER_KEY); } void MF_ScoMinChooser::setValue(char *val) { flip_->value(val); } void MF_ScoMinChooser::draw(void) { int tx, ty; tx = x() + txtLeftMarg_; ty = y() + h()/2 + topMarg_/2 - fsize_/5; fl_color(FL_BLACK); fl_rect(x(), y(), w(), h(), FL_BLACK); fl_font(FL_COURIER, fsize_); fl_draw(txt_, tx, ty); } MF_SecWindow.cxx010064400004310000036000000007331023760640400144230ustar00goutbiomol00004410000024/* MF_SecWindow.cxx */ #include "MF_SecWindow.H" #include "MenuCb.H" #include "globals.h" FL_EXPORT MF_SecWindow::MF_SecWindow(int x, int y, int w, int h, char * lbl) : Fl_Window(x,y,w,h,lbl) { t_ = new MF_Text(0,0,w,h); this->add(t_); this->resizable(this); } void MF_SecWindow::raz(void) { if(t_) t_->raz(); } void MF_SecWindow::afficheBloc(int numbloc, int numSeq){ t_->afficheBloc(numbloc, numSeq); } void MF_SecWindow::update(void){ this->draw(); } MF_Sequence.cxx010064400004310000036000000462521025261162400142740ustar00goutbiomol00004410000024/* MF_Sequence.cxx */ #include #include "MF_MainWindow.H" #include "MF_SecWindow.H" #include "MF_Sequence.H" #include "MF_Values.H" #include "lalnview_utils.H" #define _SIZEMIN_ 5 /* The minimum size (in pixel) required to draw a black rectangle around the feature. */ #define NBGRAD 20 extern MF_MainWindow * _MAINW_; extern MF_SecWindow * _SECW_; MF_Sequence::MF_Sequence(int numSeq, int x, int y, int w, int h, int leftMarg, int seqH) : Fl_Widget(x, y, w, h) { numSeq_ = numSeq; leftMarg_ = leftMarg; seqH_ = seqH; if(numSeq==0) seqY_ = y + h - MF_Values::SEQSPACE(); else seqY_ = y + MF_Values::SEQSPACE(); tabShown_ = NULL; tabBloc_ = NULL; nbBloc_ = 0; lastBloc_ = -1; topFeat_ = -1; downFeat_ = -1; loadTab(); } /* void MF_Sequence::loadTab(void) Initializes the table 'tabShown_' with the blocs that can be dsiplayed on the screen. The lenght of tabShown_ is the lenght of the sequence and for each base we can found the index of the bloc to be displayed or -1 if no bloc must be displayed at this place. */ void MF_Sequence::loadTab(void) { int i, j, lgaln, bck; BLOC b; SEG s; if(tabShown_) free(tabShown_); tabShown_ = (int *)calloc( (seq[numSeq_].lg) , sizeof(int) ); for(i=0 ; igetBestSeries()->isChecked(); if( _MAINW_->bestFirst()==0 ){ for(i=NBBLOC-1 ; i>=0 ; i--){ if(seq[numSeq_].bloc[i].sco >= scoMin){ b = seq[numSeq_].bloc[i]; s = segm[b.seg]; lgaln = s.lgaln; if( isDrawable(s, scoMin, identityMin, lenghtMin, bck, onlyGreen, onlyRed) ){ //printf("Affichage bloc %d [%d-%d] ... s.lgaln:%d\n", i, b.beg, b.end,s.lgaln); for(j=b.beg ; j<=b.end ; j++){ if(tabShown_[j]==-1) tabShown_[j]=i; } } } } } else { for(i=0 ; iparent(); double shift = ms->shift()-leftMarg_; double rapport = MF_Values::rapport(); int firstBase = (int)(shift*rapport); if(numSeq_==0) seqY_ = y()+ h() - MF_Values::SEQSPACE(); else seqY_ = y() + MF_Values::SEQSPACE();; if(NBBLOC<1 || NBSEG<1) return; int seqY = y()+seqY_; int bck = _MAINW_->getBestSeries()->isChecked(); int onlyRed = 0; int onlyGreen = 0; /* FIRST PART : displaying the blocs */ float scoMin = MF_Values::scoMin(); float identityMin = MF_Values::identityMin(); int lenghtMin = MF_Values::lenghtMin(); //for(i=0 ; i=scoMin ; i++){ for(i=0 ; inumSeq_].bloc[i]; if( !isDrawable(segm[b.seg], scoMin, identityMin, lenghtMin, bck, onlyGreen, onlyRed) ) continue; if(b.end < firstBase) continue; db = b.beg; de = b.end; rectBeg = b.beg; rectEnd = b.end; if( rectBegb.end) break; rectBeg = j; for( ; jw()){ sfin=w(); } ssize = (int)(sfin-sdeb); /* If the bloc's size is too small to occupate one pixel on the screen, the size is fixed to one pixel so that the bloc can be seen */ if(ssize<1){ ssize=1; //printf("BLOC TROP PETIT\n"); } fl_rectf(x()+sdeb, seqY_, ssize, seqH_, get_color(b.sim)); } } fl_color(FL_BLACK); sdeb = (int)((0-firstBase)/rapport); sfin = (int)((seq[numSeq_].lg - firstBase)/rapport); ssize = sfin-sdeb; fl_rect(x()+sdeb, seqY_, ssize, seqH_); /*******************************************************************************************************/ /* SECOND PART : displaying the scale. */ /* Determination of the interval between two graduations on the scale. */ int tabGrad[NBGRAD] = {1, 5, 10, 25, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000, 50000, 100000, 200000, 500000, 1000000 , 2000000, 5000000}; int bmax = seq[numSeq_].lg; char val[16]; sprintf(val, "%d\0", bmax); int tw, th; tw = th = 0; fl_measure(val, tw, th); bmax = 0; while( ((int)(tabGrad[bmax]/rapport))w() && !full){ sprintf(val, "%d\0", i); if(i>-1) fl_draw(val , x()+posx , posy); i+=pas; posx = (int)((i-firstBase)/rapport); if(i>seq[numSeq_].lg) full = true; } /* END of the Scale */ /****************************************************/ /*******************************************************************************/ /* THIRD PART : Displaying the features (if there are some features) */ if( numSeq_ == 0 ) posy = seqY_-40; else posy = seqY_+seqH_+40; if(NBFEAT>0){ fl_color(FL_BLACK); fl_line_style(FL_SOLID); sdeb = (int)((0-firstBase)/rapport); sfin = (int)((seq[numSeq_].lg - firstBase)/rapport); fl_line(x()+sdeb, posy, x()+sfin, posy); fl_line(x()+leftMarg_, posy, x()+leftMarg_+ssize, posy); topFeat_ = posy - (int)(tab_feat[0].lrg*6); downFeat_ = posy + (int)(tab_feat[0].lrg*6); } struct FEATURE f; for(i=0 ; idownFeat_) downFeat_ = posy+(int)(h/2); fl_rectf(x()+sdeb, cy, ssize, h, getColor(f.col)); if(ssize>_SIZEMIN_){ fl_color(FL_BLACK); fl_rect(x()+sdeb, cy, ssize, h); } } void MF_Sequence::showPrevBloc(void) { int i; for(i=0 ; igetParcBloc()->setCurrentBloc(i+1, nbBloc_); /* MF_MyScroll * grp = (MF_MyScroll *)this->parent(); grp->setLasts(numSeq_ , lastBloc_); this->parent()->redraw(); */ MF_MyScroll * grp = (MF_MyScroll *)this->parent(); grp->setLasts(numSeq_ , lastBloc_); grp->reAlign(); grp->redraw(); _SECW_->afficheBloc(lastBloc_, numSeq_); } void MF_Sequence::showNextBloc(void) { int i; for(i=0 ; i=nbBloc_) i = 0; lastBloc_ = tabBloc_[i]; _MAINW_->getParcBloc()->setCurrentBloc(i+1, nbBloc_); MF_MyScroll * grp = (MF_MyScroll *)this->parent(); grp->setLasts(numSeq_ , lastBloc_); grp->reAlign(); grp->redraw(); _SECW_->afficheBloc(lastBloc_, numSeq_); } void MF_Sequence::loadTabClicked(int base) { int i; BLOC b; SEG s; tabBloc_ = (int *)malloc( NBSEG * sizeof(int) ); double scoMin = MF_Values::scoMin(); double identityMin = MF_Values::identityMin(); int lenghtMin = MF_Values::lenghtMin(); int bck = _MAINW_->getBestSeries()->isChecked(); int onlyGreen = 0; int onlyRed = 0; nbBloc_ = 0; for(i=0 ; i=base ){ s = segm[b.seg]; //if( s.sco>=scoMin && s.identity>=identityMin && s.lgaln>=lenghtMin && (!bck || s.bestSeries) ){ if( isDrawable(s, scoMin, identityMin, lenghtMin, bck, onlyGreen, onlyRed) ){ tabBloc_[nbBloc_] = i; nbBloc_++; } } } } void MF_Sequence::clickOnSequence(int base) { if(tabBloc_) free(tabBloc_); loadTabClicked(base); /* Activates or Deactivates the buttons that allows user to switch from one bloc to another. */ if(nbBloc_>1) _MAINW_->activerParcBloc(); else _MAINW_->desactiverParcBloc(); showNextBloc(); } void MF_Sequence::handle_push(void) { int cx, cy; int base; double rapport = MF_Values::rapport(); MF_MyScroll * ms = (MF_MyScroll *)this->parent(); cx = Fl::event_x(); cy = Fl::event_y(); base = (int) ( ( ms->shift() + cx - leftMarg_ - x() )*rapport ); if(base<0 || base>seq[numSeq_].lg) return; /* Checks if the action to be performed on that click is a zoom or an alignment on the bloc. */ int isZoom = _MAINW_->getZoomer()->getZoom(); if(isZoom && base>0){ if(isZoom==1){ MF_Values::rapport(MF_Values::rapport()*0.7); } if(isZoom==-1){ MF_Values::rapport(MF_Values::rapport()*1.3); } if( MF_Values::rapport()<1.0 ) MF_Values::rapport( (double)1.0 ); ms->reAlign(); rapport = MF_Values::rapport(); int pos = (int)(base/rapport) + leftMarg_ - cx + x(); if(pos<0) pos = 0; ms->reCalibrate(pos); ms->redraw(); return; } if( cy>(seqY_-2) && cy<(seqY_+seqH_+2) ){ /* This part of the code deals with 'bad' clicks : if the user clicks in an empty area the program will automaticly search for the nearest bloc. */ int i = 0; int done=0; if(tabShown_[base]>-1) done = 1; while( !done && i-1 ){ base += i; done = 1; } if( (base-i)>-1 && tabShown_[base-i]>-1 ){ base -= i; done = 1; } i++; } if(!done) return; clickOnSequence(base); } if(clickOnFeat(cy)!=-1){ displayFeat(cx, base); } } void MF_Sequence::displayFeat(int cx, int numBase) { int i; double rapport = MF_Values::rapport(); int margp = (int)(3*rapport); int * tab; int nb = 0; // printf("Click sur seq:%d . base:%d\n", ns, numBase); struct FEATURE f; for(i=0 ; i(numBase-margp) ) // printf("Feature %-12s %8d .. %-8d %s\n", f.col, f.deb, f.fin, f.lab); nb++; } tab = (int *)malloc(NBFEAT*nb); nb = 0; for(i=0 ; i(numBase-margp) ){ tab[nb]=i; nb++; } } _MAINW_->getFeatDisp()->afficheFeat(tab, nb); } /* int MF_Bin::clickOnFeat(int cx, int cy) Says whether a click concerns a feature or not. Returns a feature number or -1 */ int MF_Sequence::clickOnFeat(int cy) { int i; int marg = 8; for(i=0 ; i<2 ; i++){ if( cy>(topFeat_-marg) && cy<(downFeat_+marg)) return i; } return -1; } /* FL_EXPORT int MF_Sequence::handle(int e) The virtual method given by the FLTK library and wich has to be overwrited to catch and handle events. */ FL_EXPORT int MF_Sequence::handle(int e) { if(e){ switch(e){ case FL_PUSH : handle_push(); return 1; break; default : break; } } return (0); } void MF_Sequence::leftMarg(int leftMarg){ leftMarg_ = leftMarg; } int MF_Sequence::leftMarg(void){ return this->leftMarg_; } int MF_Sequence::seqY(void){ return this->seqY_; } /********************************************************************************************************/ /********************************************************************************************************/ /********************************************************************************************************/ /********************************************************************************************************/ /********************************************************************************************************/ /* FUNCTONS THAT DEAL WITH PDF CREATION */ /********************************************************************************************************/ void MF_Sequence::drawPDF(PDF *p, int _DECX_, int _DECY_, int all) { if(NBBLOC<1 || NBSEG<1) return; int i, j; int sdeb,sfin, ssize; int de, db, rectBeg, rectEnd; uchar red, green, blue; double dred, dgreen, dblue; struct BLOC b; MF_MyScroll * ms = (MF_MyScroll *)this->parent(); double shift = ms->shift()-leftMarg_; double rapport = MF_Values::rapport(); int firstBase = (int)(shift*rapport); if(all==1) firstBase = (int)( (0-leftMarg_)*rapport); if(numSeq_==0) seqY_ = y()+ h() - MF_Values::SEQSPACE(); else seqY_ = y() + MF_Values::SEQSPACE();; int seqY = y()+seqY_; int bck = _MAINW_->getBestSeries()->isChecked(); int onlyRed = 0; int onlyGreen = 0; /* FIRST PART : displaying the blocs */ float scoMin = MF_Values::scoMin(); float identityMin = MF_Values::identityMin(); int lenghtMin = MF_Values::lenghtMin(); for(i=0 ; inumSeq_].bloc[i]; if( !isDrawable(segm[b.seg], scoMin, identityMin, lenghtMin, bck, onlyGreen, onlyRed) ) continue; if(all==0 && b.end < firstBase) continue; db = b.beg; de = b.end; rectBeg = b.beg; rectEnd = b.end; /* For each BLOC we have to check if it can be displayed on the screen by checking where the curent BLOC is visible in the previously initialized tabShown_ table. */ for(j=rectBeg ; j<=b.end ; j++){ for( ; j<=b.end && tabShown_[j]!=i ; j++ ) ; if(all==0 && j>b.end) break; rectBeg = j; for( ; jw()){ sfin=w(); } */ ssize = (int)(sfin-sdeb); /* If the bloc's size is too small to occupate one pixel on the screen, the size is fixed to one pixel so that the bloc can be seen */ if(ssize<1){ ssize=1; //printf("BLOC TROP PETIT\n"); } //fl_rectf(x()+sdeb, seqY_, ssize, seqH_, get_color(b.sim)); Fl::get_color(get_color(b.sim), red, green, blue); dred = (double)(red/(double)255); dgreen = (double)(green/(double)255); dblue = (double)(blue/(double)255); //printf("%.1f --> [%.3f.%.3f.%.3f]\n", b.sim, dred, dgreen, dblue); PDF_setcolor(p, "fill", "rgb", dred, dgreen, dblue, 0); PDF_rect(p, (float)(_DECX_+sdeb), (float)(_DECY_+seqY_), (float)ssize, (float)seqH_ ); PDF_fill(p); } } sdeb = (int)((0-firstBase)/rapport); sfin = (int)((seq[numSeq_].lg - firstBase)/rapport); ssize = sfin-sdeb; //fl_rect(x()+sdeb, seqY_, ssize, seqH_); PDF_setcolor(p, "stroke", "rgb", (double)0.0, (double)0.0, (double)0.0, (double)0.0); PDF_setlinewidth(p, (double)0.5 ); PDF_rect(p, (float)(_DECX_+sdeb), (float)(_DECY_+seqY_), (float)ssize, (float)seqH_ ); PDF_stroke(p); /*******************************************************************************************************/ /* SECOND PART : displaying the scale. */ /* Determination of the interval between two graduations on the scale. */ int tabGrad[NBGRAD] = {1, 5, 10, 25, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000, 50000, 100000, 200000, 500000, 1000000 , 2000000, 5000000}; int bmax = seq[numSeq_].lg; char val[16]; sprintf(val, "%d\0", bmax); int tw, th; tw = th = 0; fl_measure(val, tw, th); bmax = 0; while( ((int)(tabGrad[bmax]/rapport))w(); if(all==1) stop = ms->getFullSize(); while(posx-1){ PDF_set_text_pos(p, (float)(_DECX_+posx), (float)(_DECY_+posy)); PDF_show(p, val); //fl_draw(val , x()+posx , posy); } i+=pas; posx = (int)((i-firstBase)/rapport); if(i>seq[numSeq_].lg) full = true; } /* END of the Scale */ /****************************************************/ /*******************************************************************************/ /* THIRD PART : Displaying the features (if there are some features) */ if( numSeq_ == 0 ) posy = seqY_-40; else posy = seqY_+seqH_+40; struct FEATURE f; for(i=0 ; idownFeat_) downFeat_ = posy+(int)(h/2); Fl::get_color(getColor(f.col), red, green, blue); dred = (double)(red/(double)255); dgreen = (double)(green/(double)255); dblue = (double)(blue/(double)255); PDF_setcolor(p, "fill", "rgb", dred, dgreen, dblue, 0); PDF_rect(p, (float)(_DECX_+sdeb), (float)(_DECY_+cy), (float)ssize, (float)h ); PDF_fill(p); if(ssize>_SIZEMIN_){ PDF_setcolor(p, "stroke", "rgb", 0.0, 0.0, 0.0, 0.0); PDF_setlinewidth( p, (double)0.001 ); PDF_rect(p, (float)(_DECX_+sdeb), (float)(_DECY_+cy), (float)ssize, (float)h ); PDF_stroke(p); } } tabBloc_) free(tabBloc_); loadTabClicked(base); /* Activates or Deactivates the buttons that allows user to switch from one bloc to another. */ if(nbBloc_>1) _MAINW_->activerParcBloc(); else _MAINW_->desactiverParcBloc(); showNextBloc(); } void MF_Sequence::handle_push(void) { int cx, cy; int base; double rMF_Stats.cxx010064400004310000036000000014151023616374400136210ustar00goutbiomol00004410000024/* MF_Stats.cxx */ #include "MF_Stats.H" void MF_Stats::draw(void) { fl_rectf(x(), y(), w(), h(), FL_WHITE); fl_color(FL_BLACK); fl_rect(x(), y(), w(), h()); fl_font(FL_COURIER, fsize_); sprintf(l1_, "Length = %d Score = %.1f\0", lg_, score_); sprintf(l2_, "Identity = %.2f %c Gap Frequency %.1f %c\0", ident_, '%', gapf_, '%'); fl_draw(l1_, x(), y()+10, w(), fsize_, FL_ALIGN_CENTER); fl_draw(l2_, x(), y()+fsize_+30, w(), fsize_, FL_ALIGN_CENTER); } MF_Stats::MF_Stats(int x, int y, int w, int h) : Fl_Widget(x, y, w, h) { fsize_ = 12; lg_ = 0; score_ = 0.0; gapf_ = 0.0; ident_ = 0.0; } void MF_Stats::afficher(int lg, float score, float ident, float gapf) { lg_ = lg; score_ = score; ident_ = ident; gapf_ = gapf; redraw(); } MF_Text.cxx010064400004310000036000000026051023760554000134450ustar00goutbiomol00004410000024/* MF_Text.cxx */ #include "MF_Text.H" #include "MF_MainWindow.H" #ifdef __APPLE__ #define _CR_ '\r' #else #define _CR_ '\n' #endif extern MF_MainWindow * _MAINW_; MF_Text::MF_Text(int x, int y, int w, int h) : Fl_Text_Display(x,y,w,h){ this->buf_ = new Fl_Text_Buffer(); } void MF_Text::afficheBloc(int numbloc, int numSeq) { int i, j, lgaln, firstBase, numseg; float ident, gapf; char *txt; if(numbloc<0) return; numseg = seq[numSeq].bloc[numbloc].seg; BLOC b = seq[numSeq].bloc[numbloc]; get_aln(numseg, &ident, &gapf, &lgaln, numbloc); _MAINW_->getStats()->afficher(lgaln, seq[numSeq].bloc[numbloc].sco, ident, gapf); this->ident_ = ident_; this->gapf_ = gapf_; this->lgaln_ = lgaln_; txt = (char *)malloc((LINAL+1)*4*nb_ligne_aln); txt[0]= '\0'; j = 0; char *zz = txt; int k; for(i=0 ; itext(txt); free(txt); textfont(FL_COURIER); textsize(13); this->buffer(buf_); b = seq[numSeq].bloc[numbloc]; if(numSeq==0) firstBase = b.beg - segm[b.seg].beg0; else firstBase = b.beg - segm[b.seg].beg1; firstBase = firstBase/82; firstBase *= 4; firstBase += 1; this->scroll(firstBase, 0); } void MF_Text::raz(void) { buf_->text("\0"); this->buffer(buf_); } MF_Values.cxx010064400004310000036000000013761024330745000137600ustar00goutbiomol00004410000024/* MF_Values.cxx */ #include "MF_Values.H" float MF_Values::scoMin(void){ return scoMin_; } float MF_Values::identityMin(void){ return identityMin_; } int MF_Values::lenghtMin(void){ return lenghtMin_; } int MF_Values::SEQSPACE(void){ return SEQSPACE_; } double MF_Values::rapport(void){ return rapport_; } char *MF_Values::srcFile(void){ return srcFile_; } void MF_Values::scoMin(float scoMin){ scoMin_ = scoMin; } void MF_Values::identityMin(float identityMin){ identityMin_ = identityMin; } void MF_Values::lenghtMin(int lenghtMin){ lenghtMin_ = lenghtMin; } void MF_Values::SEQSPACE(int SEQSPACE){ SEQSPACE_ = SEQSPACE; } void MF_Values::rapport(double rapport){ rapport_ = rapport; } void MF_Values::srcFile(char *srcFile){ srcFile_ = strdup(srcFile); } MF_Zoomer.cxx010064400004310000036000000070421024504652400137740ustar00goutbiomol00004410000024/* MF_Zoomer.cxx */ #include #include "MF_Zoomer.H" #include "MF_MainWindow.H" #include "init.H" #include "xpms.H" extern MF_MainWindow * _MAINW_; /* void button_cb(Fl_Widget *w) The callback method wich is called when one of the button is pressed (or unpressed). */ void button_cb(Fl_Widget *w) { Fl_Button * b = (Fl_Button *)w; _MAINW_->getZoomer()->flip(b); /* flip will set the value of the buttons (pushed or relaxed) */ } void btWhole_cb(Fl_Widget *w) { if(_MAINW_->getScroll()==NULL) return; _MAINW_->getScroll()->zoomWhole(); } MF_Zoomer::MF_Zoomer(int x, int y, int w, int h) : Fl_Widget(x,y,w,h) { int wx, wy, wh, ww; /* All the stuff that deals with where to put the widgets (buttons) on the screen. */ btMoreX_ = x+5; btMoreY_ = y + 6; btMoreW_ = (w-16)/2; btMoreH_ = (int)(h - 25); btLessX_ = btMoreX_ + btMoreW_+4; btLessY_ = btMoreY_; btLessW_ = btMoreW_; btLessH_ = btMoreH_; /* matrixPLus and matrixMinus contain datas for pixmap images corresponding to the two magnifying glass. They are defined in file xpms.H */ imgPlus_ = new Fl_Pixmap((const char * const *)matrixPlus); imgMinus_ = new Fl_Pixmap((const char * const *)matrixMinus); imgPlusA_ = new Fl_Pixmap((const char * const *)loupe_plus_active); imgMinusA_ = new Fl_Pixmap((const char * const *)loupe_moins_active); btMore_ = new MF_Next(-1, btMoreX_, btMoreY_, btMoreW_, btMoreH_, NULL); btLess_ = new MF_Next(1, btLessX_, btLessY_, btLessW_, btLessH_, NULL); /* Sets the image displayed as a label for the buttons. */ btMore_->image(imgPlus_); btLess_->image(imgMinus_); parent()->add(btMore_); parent()->add(btLess_); btMore_->value(0); /* Sets the callback methods associated with the buttons. */ btMore_->callback(button_cb); btLess_->callback(button_cb); wx = btMore_->x(); wy = btMore_->y()+btMore_->h()+3; wh = 14; ww = (btLess_->x()+btLess_->w())-btMore_->x(); /* BtWhole_ is the button that makes the image fit in the screen. */ btWhole_ = new Fl_Button(wx, wy, ww, wh, "whole\0"); parent()->add(btWhole_); btWhole_->callback(btWhole_cb); } void MF_Zoomer::draw(void) { /* We simply have to draw the black rectangle that circles the area. */ fl_color(FL_BLACK); fl_rect(x(), y(), w(), h()); } /* void MF_Zoomer::desactiver() Deactivates the zoom buttons. */ void MF_Zoomer::desactiver() { btMore_->deactivate(); btLess_->deactivate(); } /* void MF_Zoomer::activer() Activates the zoom buttons. */ void MF_Zoomer::activer() { btMore_->activate(); btLess_->activate(); } /* int MF_Zoomer::getZoom(void) Returns : +1 if the zoom+ (zoom More) button is on -1 if the zoom- (zoom Less) button is on 0 if both zoom+ and zoom- are off */ int MF_Zoomer::getZoom(void) { if( btMore_->value()==1 ) return 1; if( btLess_->value()==1 ) return -1; return 0; } /* void MF_Zoomer::flip(Fl_Button * b) Inverts the value of the button 'b' (if b was on (=pressed) it is turned off (=relaxed), if b was off it is turned on) and update the status of the other button in order to prevent both zoom+ and zoom- to be ON. */ void MF_Zoomer::flip(Fl_Button * b) { int ww = b->w(); int hh = b->h(); Fl_Button * b2; if(b==btMore_) b2 = btLess_; else b2 = btMore_; if(b->value()==1){ b->value(0); } else { b->value(1); b2->value(0); } if( btMore_->value()==1 ) btMore_->image(imgPlusA_); else btMore_->image(imgPlus_); if( btLess_->value()==1 ) btLess_->image(imgMinusA_); else btLess_->image(imgMinus_); } MenuCb.cxx010064400004310000036000000256621025260567600133270ustar00goutbiomol00004410000024/* MenuCb.cxx */ #include #include #include #include #include #include #include #include #include "MenuCb.H" #include "MF_About.H" #include "MF_Values.H" extern MF_MainWindow * _MAINW_; extern int NBFEAT; #define FL_max(a,b) ( (a) > (b) ? (a):(b) ) #define FL_min(a,b) ( (a) < (b) ? (a):(b) ) typedef struct { Fl_Widget *br_item, *box; void *in; } browser_struct; void open_cb(){ char * fic = MG_input_file_chooser("Open", "", ""); if(!fic) return; charger_fichier(fic); } void export_PDF_cb(void) { if( NBBLOC<1 || NBSEQ<1 || NBSEG<1 ){ fl_alert("No sequence in memory. PDF export aborted."); return; } int choice = fl_choice("Please select what part of the alignment you want to export", "Cancel", "Current window only", "whole alignment"); //printf("Choice : %d\n", choice); if(choice==0) return; choice--; char *fic = (char *)"hello.pdf"; fic = MG_output_file_chooser("Save as", "", ""); if(!fic) return; _MAINW_->getScroll()->exportPDF((char *)fic, choice); } void save_bmp_cb(void) { char *fic = MG_output_file_chooser("Save as", "", ""); if( !fic ) return; _MAINW_->make_current(); _MAINW_->redraw(); _MAINW_->getScroll()->captToBmp(fic); } void close_cb() { exit(0); } void save_scale_cb() { int res; char *fic = MG_output_file_chooser("Save scale as", "", ""); if( !fic ) return; res = saveColorScale(fic); if(res==-1){ fl_alert("Impossible to save the scale into the file '%s'.", fic); } } void load_scale_cb() { int res; char *fic = MG_input_file_chooser("Load scale colors file", "", ""); if( !fic ) return; res = loadColorScale(fic); if(res==-1){ fl_alert("Impossible to access the file '%s'", fic); } if(res==-2){ fl_alert("Warning, the file '%s' does not seem to be in coorect format.", fic); } } void open_features_cb() { char *fic = MG_input_file_chooser("Open features file", "", ""); if(!fic) return; _MAINW_->fullUpdatePanel(); get_feature(fic); int i; struct FEATURE f; for(i=0 ; igetMenuItems(); const int val = it[_MENU_BEST_].value(); if(val){ _MAINW_->bestFirst(1); } } void worseScore_cb() { if(NBSEQ<2 || NBBLOC<1) return; const Fl_Menu_Item * it = _MAINW_->getMenuItems(); const int val = it[_MENU_WORSE_].value(); if(val){ _MAINW_->bestFirst(0); } } void save_aln_cb() { if(NBBLOC<1){ fl_alert("No sequence in memory."); return; } char *fic = MG_output_file_chooser("Save alignment in file", "", ""); if( !fic ) return; FILE * nf = fopen(fic, "w"); if(!nf){ fl_alert("Impossible to open file %s.", fic); return; } save_aln_proc(nf); } void save_aln_proc(FILE * fic) { int ii, jj, lgaln; float gapf, ident; int nbmiss = 0; float seuil_score_sim = MF_Values::scoMin(); float seuil_identity = MF_Values::identityMin(); int seuil_lenght = MF_Values::lenghtMin(); fprintf(fic, "%s\n", sim_parameter); fprintf(fic, "Sequence 1: %-20.20s %d residues\n", seq[0].name, seq[0].lg); fprintf(fic, "Sequence 2: %-20.20s %d residues\n\n", seq[1].name, seq[1].lg); fprintf(fic, "List of local alignments with score >= %.1f , identity >= %.2f%c and lenght > %d\n", seuil_score_sim, seuil_identity, '%', seuil_lenght); fprintf(fic, "----------\n"); for(ii = 0; ii < NBSEG; ii++) { if(segm[ii].sco < seuil_score_sim || segm[ii].identity < seuil_identity || segm[ii].lgaln < seuil_lenght) {nbmiss++; continue;} //printf("GET ALN, numseg : %3d - numbloc : %3d\n", ii+1, -1); get_aln(ii+1, &ident, &gapf, &lgaln, -1); fprintf(fic, "%3.1f%% identity in %d residues overlap; Score: %.1f; Gap frequency: %3.1f%%\n\n", ident, lgaln, segm[ii].sco, gapf); for(jj = 0; jj < nb_ligne_aln; jj++) { fprintf(fic, "%s\n", seq_alignee[jj]); } fprintf(fic, "----------\n"); } if(nbmiss > 0) fprintf(fic, "WARNING: %d local alignments have not been reported because of score < %.1f\n", nbmiss, seuil_score_sim); fclose(fic); } void about_cb(){ _MAINW_->about(); } char *get_next_help_line(void *in, char *line, int lline) { #ifdef WIN32 static const char match[] = "WIN32"; #elif defined(__APPLE__) static const char match[] = "__APPLE__"; #else static const char match[] = "unix"; #endif static int accept = true; static int found = false; if( read_next_help_line(line, lline, in) == NULL) { accept = true; return NULL; } while(*line != '#') { if(accept) return line; if( read_next_help_line(line, lline, in) == NULL) { accept = true; return NULL; } } if(strncmp(line, "#ifdef", 6) == 0 || strncmp(line, "#if ", 4) == 0) { accept = ( strstr(line, match) != NULL ) ; found = accept; } else if(strncmp(line, "#elif", 5) == 0) { if(found) accept = false; else if( strstr(line, match) != NULL ) { accept = true; found = true; } } else if(strncmp(line, "#else", 5) == 0) { if(found) accept = false; else { accept = true; found = true; } } else if(strncmp(line, "#endif", 6) == 0) { accept = true; } else accept = true; // should not occur return get_next_help_line(in, line, lline); } #ifdef __APPLE__ char *read_next_help_line(char *line, int lline, void *v_in) { static char *pos; char *in, *l = line; in = (char *)v_in; if(line == NULL) { pos = in; return NULL; } in = pos - 1; do *(line++) = *(++in); while(*in != 0 && *in != '\n' && *in != '\r'); if(*in == 0) return NULL; pos = ++in; *line = 0; return l; } #endif void browser_titres_callback(Fl_Widget *ob, void *data) { int reponse; static char line[200]; const char *p; browser_struct *br_data; int w; int charwidth, newwidth, maxl; Fl_Browser *browser_item; reponse = ((Fl_Browser*)ob)->value(); if(reponse == 0) return; br_data = (browser_struct *)data; p = ((Fl_Browser*)ob)->text(reponse); #ifdef __APPLE__ get_next_help_line(br_data->in, NULL, 0); #else rewind((FILE *)br_data->in); #endif br_data->box->hide(); browser_item = (Fl_Browser *)br_data->br_item; browser_item->clear(); while( get_next_help_line( br_data->in, line, sizeof(line)) != NULL) { if(strncmp(line, ">>>", 3) != 0) continue; line[ strlen(line) - 1 ] = 0; if(strcmp(line+3, p) != 0) continue; maxl = 0; while( get_next_help_line(br_data->in, line, sizeof(line)) != NULL && strncmp(line, ">>>", 3) != 0 ) { line[ strlen(line) - 1 ] = 0; if(*line == 0) strcpy(line," "); browser_item->add(line); maxl = FL_max(maxl, (int)strlen(line)); } /* agrandir fenetre si pas assez large */ w = browser_item->w(); fl_font( browser_item->textfont(), browser_item->textsize() ); charwidth = (int)fl_width('W'); maxl++; if( w < maxl * charwidth) { newwidth = ob->window()->w() + (maxl * charwidth - w); ob->window()->size(newwidth, ob->window()->h() ); } br_data->box->label(p); break; } br_data->box->show(); } void browser_ok_callback(Fl_Widget *ob, long which) { ob->window()->hide(); } void help_callback(Fl_Widget *ob, void *data) { static browser_struct browser_data; static int first = true; static Fl_Window *help_form; if(first) { char line[85]; Fl_Browser *browser_titres, *browser_item; Fl_Button *ok_button; Fl_Widget *br_item_label; int titres_width, fin_titres; #ifdef __APPLE__ get_next_help_line(data, NULL, 0); #else data = (void *)fopen( (char *)data, "r" ); #endif if(data == NULL) { fl_alert( #ifdef __APPLE__ "No help information in program resources" #else "Help file not found in PATH directories nor in current directory.\nCheck your .lalnviewrc file or put a copy of 'lalnview.help' in your HOME directory." #endif ); return; } first = false; help_form = new Fl_Window( 705, 350); help_form->label("Help"); help_form->box(FL_FLAT_BOX); fl_font(FL_HELVETICA, 12); titres_width = (int)fl_width("XXXXXX"); /* mieux ensuite */ browser_titres = new Fl_Hold_Browser(5, 20, titres_width, help_form->h() - 50, "Choose help item"); browser_titres->textsize(12); browser_titres->has_scrollbar(Fl_Browser_::VERTICAL); browser_titres->callback(browser_titres_callback, &browser_data); browser_titres->align(FL_ALIGN_TOP); browser_titres->color(FL_LIGHT1, browser_titres->selection_color()); while( get_next_help_line(data, line, sizeof(line)) != NULL) { if(strncmp(line, ">>>", 3) != 0) continue; line[ strlen(line) - 1 ] = 0; browser_titres->add(line+3); titres_width = FL_max(titres_width, (int)fl_width(line + 3) + (int)fl_width("XX") ); } ((Fl_Widget*)browser_titres)->size(titres_width, browser_titres->h() ); ok_button = new Fl_Button(5,help_form->h() - 25, titres_width,20,"OK"); ok_button->callback(browser_ok_callback, 0); fin_titres = titres_width + 10; browser_item = new Fl_Browser(fin_titres, 20, 700 - fin_titres, help_form->h() - 25, ""); browser_item->has_scrollbar(Fl_Browser_::VERTICAL); browser_item->align(FL_ALIGN_TOP); browser_item->color(FL_LIGHT1, browser_item->selection_color()); browser_item->textsize(12); browser_item->textfont(FL_COURIER); br_item_label = new Fl_Box(FL_NO_BOX, fin_titres, 0, 700 - fin_titres, 20, "Help Info"); br_item_label->align(FL_ALIGN_CENTER); browser_data.box = br_item_label; browser_data.br_item = browser_item; browser_data.in = data; help_form->add_resizable( *new Fl_Box(browser_item->x(), browser_item->y(), browser_item->w(), browser_titres->h() ) ); help_form->end(); } help_form->show(); } void greenListAdd_cb(void) { int segNum = _MAINW_->getScroll()->getLastSegment(); if( segNum>-1 ) segm[segNum].myList = _LIST_GREEN_; _MAINW_->fullUpdatePanel(); } void greenListRemove_cb(void) { int segNum = _MAINW_->getScroll()->getLastSegment(); if( segNum>-1 && segm[segNum].myList==_LIST_GREEN_ ) segm[segNum].myList = 0; _MAINW_->fullUpdatePanel(); } void greenListErase_cb(void) { int i; for(i=0 ; ifullUpdatePanel(); } void redListAdd_cb(void) { int segNum = _MAINW_->getScroll()->getLastSegment(); if( segNum>-1 ) segm[segNum].myList = _LIST_RED_; _MAINW_->fullUpdatePanel(); } void redListRemove_cb(void) { int segNum = _MAINW_->getScroll()->getLastSegment(); if( segNum>-1 && segm[segNum].myList==_LIST_RED_ ) segm[segNum].myList = 0; _MAINW_->fullUpdatePanel(); } void redListErase_cb(void) { int i; for(i=0 ; ifullUpdatePanel(); } ) ; found = accept; } else if(strncmp(line, "#elif", 5) == 0) { ifbmp.cxx010064400004310000036000000057341025260567600127320ustar00goutbiomol00004410000024/* bmp.cxx */ #include "bmp.H" static int charArray2Int(unsigned char * b, int s, int f) { int ret = 0; int i; int shift = 0; for (i = s; i <= f; i++) { ret = ret | ((b[i] & 0xff) << shift); shift += 8; } return ret; } static void int2bytes2(unsigned char * bytes, int value) { bytes[0] = (unsigned char)(value & 0xff); bytes[1] = (unsigned char)((value >> 8) & 0xff); } static void int2bytes4(unsigned char * bytes, int value) { bytes[0] = (unsigned char)(value & 0xff); bytes[1] = (unsigned char)((value >> 8) & 0xff); bytes[2] = (unsigned char)((value >> 16) & 0xff); bytes[3] = (unsigned char)((value >> 24) & 0xff); } int saveBMP(uchar * pic, int width, int height, char * filename) { FILE * bout; bmfh hdr; bmih info; int bitsInPixel = 24; // we always save in 24 bit format int i, j, k; bout = fopen(filename, "wb"); if (bout == NULL) { fprintf(stderr, "Unable to open specified file: %s\n", filename); fprintf(stderr, "Errno: %d, errstring: %s\n", errno, strerror(errno)); return -1; } int bytesPerPixel = bitsInPixel / 8; int bytesPerRow = width * bytesPerPixel; bytesPerRow = (bytesPerRow & 0x3) ? ((bytesPerRow >> 2) + 1) << 2 : bytesPerRow; int pad = bytesPerRow - (width * bytesPerPixel); int bfOffBits = sizeof(hdr) + sizeof(info); int bfSize = (bytesPerRow * height) + bfOffBits; memset((void *)&hdr, 0, sizeof(hdr)); memset((void *)&info, 0, sizeof(info)); hdr.bfType[0]='B'; hdr.bfType[1]='M'; /* fprintf(stderr, "bfSize: %d (%lx), bfOffBits: %d (%lx)\n", bfSize, (unsigned long)bfSize, bfOffBits, (unsigned long)bfOffBits); */ int2bytes4(hdr.bfSize, bfSize); int2bytes4(hdr.bfOffBits, bfOffBits); int nwrite; nwrite = fwrite(&hdr, sizeof(hdr), 1, bout); int2bytes4(info.biSize, 40); int2bytes4(info.biWidth, width); int2bytes4(info.biHeight, height); int2bytes2(info.biPlanes, 1); int2bytes2(info.biBitCount, bitsInPixel); // all rest are zero since 24 bit, no color table nwrite = fwrite(&info, sizeof(info), 1, bout); unsigned char red; unsigned char green; unsigned char blue; unsigned char rgb[3]; unsigned char padbytes[4] = {'\0', '\0', '\0', '\0'}; /* for(i=width*height*3 ; i>=0 ; i-=3){ red = (unsigned char)pic[i]; green = (unsigned char)pic[i+1]; blue = (unsigned char)pic[i+2]; rgb[0] = blue; rgb[1] = green; rgb[2] = red; nwrite = fwrite(rgb, 1, 3, bout); if (pad != 0) { nwrite = fwrite(padbytes, 1, pad, bout); } } */ for(i=height-1 ; i>=0 ; i--){ for(j=0 ; j=scoMin && S[i].lgaln>=lgMin && S[i].identity>=idMin ) return true; return false; } /* bool chevauchent(int i, int j) Returns true if the segments i and j overlap. If the function return false, we can say that there is an edge between i and j. */ bool chevauchent(int i, int j) { if( i==_a_ && !respect(j) ) return true; if( j==_z_ && !respect(i) ) return true; if( i!=_a_ && j!=_z_) if( !respect(i) || !respect(j) ) return true; if( (S[j].beg0 > S[i].beg0 && S[j].beg1 > S[i].beg1) && (S[j].beg0+marg >= S[i].end0 && S[j].beg1+marg >= S[i].end1) ) return false; if( S[i].beg0<=S[j].beg0 && S[i].beg1<=S[j].beg1 && S[i].end0<=(S[j].beg0-marg) && S[i].end1<=(S[j].beg1-marg) ) return false; return true; } int fcmp1(const void *s1, const void *s2) { if( ((struct SEG *)s1)->beg0 > ((struct SEG *)s2)->beg0 ) return 1; return -1; } void relacher(int f, int g) { float p = W[f] + S[g].sco; if( (W[f] != _INF_ && W[g]getBestSeries()->getMarg(); //printf("marg : %d\n", marg); S = (SEG *)malloc(NBSOM*sizeof(SEG)); memcpy(S, segm, (NBSEG*sizeof(SEG))); qsort(S, NBSEG, sizeof(SEG), fcmp1); if(seq[0].lg>seq[1].lg) emax = seq[0].lg+1; else emax = seq[1].lg+1; SEG s1, s2; s1.id = _a_; s1.sco = 0.0; s1.beg0 = s1.beg1 = s1.end0 = s1.end1 = -1; s2.id = _z_; s2.sco = 0.0; s2.beg0 = s2.beg1 = emax; s2.end0 = s2.end1 = emax; S[_a_] = s1; S[_z_] = s2; int *ENTR = (int *)malloc(NBSEG*sizeof(int)); int *SORT = (int *)malloc(NBSEG*sizeof(int)); W = (float *)malloc(NBSOM*sizeof(float)); PREDEC = (int *)malloc(NBSOM*sizeof(int)); for(i=0 ; i there is an incoming edge in segm[i] if SORT[i]!=0 --> there is an edge outgoing from segm[i]*/ for(i=0 ; i bestSeries\n", segm[j].id); } sp = S[PREDEC[cur]]; // printf("(%d . %d) sco:%.2f\n", sp.beg0, sp.end0, sp.sco); cur = PREDEC[cur]; i++; } free(S); free(SORT); free(ENTR); free(PREDEC); } extras.cxx010064400004310000036000000223541025212546000134430ustar00goutbiomol00004410000024#include #include char *my_fgets(char *s, int n, FILE *f) { int next_char, ahead; char *p; p = s; while(--n > 0) { next_char = getc(f); if( next_char == '\r' || next_char == '\n' ) { *(p++) = '\n'; ahead = getc(f); if(ahead == EOF) break; if( (next_char == '\r' && ahead != '\n') || (next_char == '\n' && ahead != '\r') ) { ungetc(ahead, f); } break; } else if (next_char == EOF) break; *(p++) = next_char; } *p = 0; return (p == s ? NULL : s); } #ifdef WIN32 #include #include #include #include #include #include char *MG_input_file_chooser(const char* message, const char* pat, const char* fname); char *MG_output_file_chooser(const char* message, const char* pat, const char* fname); char *MG_win32_file_chooser(const char* message, const char* pattern, const char* fname, const char* deftext, bool save, int* ptfilterindex); char *MG_win32_file_chooser(const char* message, // title of dialog window const char* pattern, // optional "mase format\0*.mase\0MSF format\0*.msf\0" const char* fname, // default file name const char* defext, // default filename extension or NULL bool save, // TRUE iff output file selection int *pfilterindex) // (inout) pointer to index (from 1) in series of file types in pattern { static char filenamebuffer[MAX_PATH]; static OPENFILENAME wreq; bool retval; memset(&wreq, 0, sizeof(wreq)); wreq.lStructSize = sizeof(OPENFILENAME); wreq.lpstrFilter = pattern; if(pattern == NULL) wreq.nFilterIndex = 0; else if(pfilterindex != NULL) wreq.nFilterIndex = *pfilterindex; else wreq.nFilterIndex = 1; if(defext != NULL) wreq.lpstrDefExt = defext; wreq.lpstrFile = filenamebuffer; wreq.nMaxFile = MAX_PATH; wreq.lpstrTitle = message ? message : "Select the filename"; if(fname) { memset(filenamebuffer, 0, MAX_PATH); if((filenamebuffer[1] == ':') && (_getdrive() + 'A' - 1 == filenamebuffer[0])) strncpy(filenamebuffer, fname + 2, MAX_PATH); else strncpy(filenamebuffer, fname, MAX_PATH); } wreq.Flags = OFN_NOCHANGEDIR | OFN_HIDEREADONLY; retval = (save ? GetSaveFileName(&wreq) : GetOpenFileName(&wreq)); if(save && (pfilterindex != NULL) ) *pfilterindex = wreq.nFilterIndex; return retval == 0 ? NULL : wreq.lpstrFile; } char *MG_input_file_chooser(const char* message, const char* pat, const char* fname) { char *outfname; outfname = MG_win32_file_chooser(message, NULL, fname, memcmp(pat, "*.", 2) == 0 ? pat+2 : NULL, FALSE, NULL); return outfname; } char *MG_output_file_chooser(const char* message, const char* pat, const char* fname) { char *outfname; outfname = MG_win32_file_chooser(message, NULL, fname, memcmp(pat, "*.", 2) == 0 ? pat+2 : NULL, TRUE, NULL); return outfname; } #elif defined(__APPLE__) #include extern "C" { void CtoP(const void *in, void *out); void PtoC(const void *in, void *out); void MG_FSSpecToPathname (FSSpec *myFSS, char *fname, int maxl); } static pascal void MyNavEventProc (NavEventCallbackMessage callBackSelector, NavCBRecPtr callBackParms, NavCallBackUserData callBackUD); int MG_GetInputFName(char *fname, int maxl, char *title); int MG_GetOutputFName(const char *message, char *fname, int maxl, const char *dfault); char *MG_output_file_chooser(const char* message, const char* pat, const char* fname); char *MG_input_file_chooser(const char* message, const char* pat, const char* fname); void PtoC(const void *in, void *out) { char *vin = (char *)in; char *vout = (char *)out; int l = *vin; if(l > 0) memcpy(vout, vin + 1, l); vout[l] = 0; } void CtoP(const void *in, void *out) { char *vout = (char *)out; int l; if(in == NULL) l = 0; else { l = strlen( (char *)in ); memcpy(vout + 1, in, l); } vout[0] = l; } void MG_FSSpecToPathname (FSSpec *myFSS, char *fname, int maxl) { FSRef myFSRef, pFSRef; FSCatalogInfo myinfo; static int anErr = noErr; char *p, *q; static char buffer[1000], name[256]; FSSpec fsspec; p = buffer; anErr = FSpMakeFSRef(myFSS, &myFSRef); while(1) { anErr = FSGetCatalogInfo(&myFSRef, kFSCatInfoParentDirID, &myinfo, NULL, &fsspec, &pFSRef); PtoC(fsspec.name, name); /* add the file or dir name to the end of buffer in reverse orientation */ q = name + strlen(name) - 1; while(q >= name) { *p = *q; q--; p++; } if(myinfo.parentDirID == fsRtParID) break; /* detect when top level is reached */ *p = ':'; p++; myFSRef = pFSRef; } *p = 0; /* invert buffer into fname */ maxl--; if(maxl > strlen(buffer)) maxl = strlen(buffer); q = buffer + maxl - 1; p = fname; while(q >= buffer) { *p = *q; q--; p++; } fname[maxl] = 0; } static pascal void MyNavEventProc (NavEventCallbackMessage callBackSelector, NavCBRecPtr callBackParms, NavCallBackUserData callBackUD) { return; } int MG_GetInputFName(char *fname, int maxl, char *title) { NavEventUPP eventProc = NewNavEventUPP(MyNavEventProc); OSErr anErr = noErr; FSSpec fss; int rsult = FALSE; NavReplyRecord reply; NavDialogOptions options; NavGetDefaultDialogOptions(&options); CtoP(title, options.windowTitle); options.dialogOptionFlags &= ~ kNavAllowPreviews; options.dialogOptionFlags &= ~ kNavAllowMultipleFiles; options.dialogOptionFlags |= kNavNoTypePopup; anErr = NavChooseFile (NULL , &reply, &options, eventProc, NULL, NULL, NULL , 0); if (anErr == noErr && reply.validRecord){ AEKeyword theKeyword; DescType actualType; Size actualSize; FSSpec documentFSSpec; anErr = AEGetNthPtr(&(reply.selection), 1, typeFSS, &theKeyword, &actualType,&documentFSSpec, sizeof(documentFSSpec), &actualSize); if (anErr == noErr){ MG_FSSpecToPathname (&documentFSSpec, fname, maxl); rsult = TRUE; } // Dispose of NavReplyRecord, resources, descriptors anErr = NavDisposeReply(&reply); } DisposeNavEventUPP(eventProc); return rsult; } int MG_GetOutputFName(const char *message, char *fname, int maxl, const char *dfault) { OSErr anErr = noErr; NavReplyRecord reply; NavDialogOptions dialogOptions; FSSpec fss; OSType fileTypeToSave = 'TEXT'; OSType creatorType; NavEventUPP eventProc = NewNavEventUPP(MyNavEventProc); char filename [256]; NavMenuItemSpec *p; int i, rsult = FALSE; reply.translationNeeded = false; NavGetDefaultDialogOptions(&dialogOptions); CtoP(message, dialogOptions.windowTitle); CtoP(dfault, dialogOptions.savedFileName); creatorType = kNavGenericSignature; anErr = NavPutFile(NULL, &reply, &dialogOptions, eventProc, fileTypeToSave, creatorType, NULL); if (anErr == noErr && reply.validRecord) { AEKeyword theKeyword; DescType actualType; Size actualSize; FSSpec documentFSSpec; anErr = AEGetNthPtr(&(reply.selection), 1, typeFSS, &theKeyword, &actualType, &documentFSSpec, sizeof(documentFSSpec), &actualSize ); if (anErr == noErr) { if (reply.replacing) { /* compute the pathname of the pre-existing file */ MG_FSSpecToPathname (&documentFSSpec, fname, maxl); rsult = TRUE; } else { /* the chosen file is new, compute pathname to its directory and append new filename */ char empty[256]; FSSpec pfss; empty[0] = 0; /* make an FSSpec from volume + parentID of documentFSSpec */ FSMakeFSSpec(documentFSSpec.vRefNum, documentFSSpec.parID, (StringPtr) empty, &pfss); /* compute pathname for this FSSpec */ MG_FSSpecToPathname (&pfss, fname, maxl); /* append : new filename to this path */ #if TARGET_RT_MAC_MACHO strcat(fname, "/"); #else strcat(fname, ":"); #endif PtoC(documentFSSpec.name, fname + strlen(fname) ); anErr = FSpCreate(&documentFSSpec, 'ttxt', 'TEXT', smSystemScript); rsult = TRUE; } anErr = NavCompleteSave(&reply, kNavTranslateInPlace); } } NavDisposeReply(&reply); return rsult; } char *MG_input_file_chooser(const char* message, const char* pat, const char* fname) { static char pathname[FL_PATH_MAX]; int ok; ok = MG_GetInputFName(pathname, FL_PATH_MAX, (char *)message); if( ok ) return pathname; else return NULL; } char *MG_output_file_chooser(const char* message, const char* pat, const char* fname) { static char pathname[FL_PATH_MAX]; if( MG_GetOutputFName(message, pathname, FL_PATH_MAX, fname) ) return pathname; else return NULL; } #else /* for the X11 GUI */ extern char *fl_file_chooser(const char* message, const char* pat, const char* fname, int relative=0); char *MG_input_file_chooser(const char* message, const char* pat, const char* fname) { return fl_file_chooser(message, pat, fname, 0); } char *MG_output_file_chooser(const char* message, const char* pat, const char* fname); char *MG_output_file_chooser(const char* message, const char* pat, const char* fname) { return fl_file_chooser(message, pat, fname, 0); } #endif get_aln.cxx010064400004310000036000000117341025212362000135420ustar00goutbiomol00004410000024#include "lalnview.h" #include "lalnview_utils.H" #include "globals.h" void get_aln(int numseg, float *ident, float *gapf, int *lgaln, int numbloc) { int ii, jj0, jj1, jj2, kk, jj; int debseg, endseg, lgbloc, lggap1, lggap2; char *aln1, *aln2, *aln3, *aln4; char fragseg[4][LINAL]; int deb0, fin0, deb1, fin1, numl; int lgfrag; /* longueur du fragment qui apparait dans l'alignement */ int nbid = 0, nbgap = 0; *lgaln = 0; /* repere debut et fin du segment */ for(ii = 0; ii < NBBLOC; ii++) if(seq[0].bloc[ii].seg == numseg) { debseg = ii; break; } endseg = debseg; for(ii = debseg; ii <= NBBLOC; ii++) { if(ii == NBBLOC) endseg = NBBLOC; else if(seq[0].bloc[ii].seg != numseg) { endseg = ii; break; } } if(numbloc != -1) lgfrag = LINAL - 40; else lgfrag = 60; /* libere la memoire */ if(seq_alignee != NULL) { for(ii = 0; ii < nb_ligne_aln; ii++) free(seq_alignee[ii]); free((char *)seq_alignee); } /* calcule la taille de l'alignement */ for(ii = debseg; ii < endseg; ii++) { lgbloc = seq[0].bloc[ii].end - seq[0].bloc[ii].beg + 1; if(ii != (endseg - 1)) lggap1 = max_((seq[0].bloc[ii+1].beg - seq[0].bloc[ii].end - 1), (seq[1].bloc[ii+1].beg - seq[1].bloc[ii].end - 1)); else lggap1 = 0; *lgaln+= (lgbloc + lggap1); } nb_ligne_aln = ceil((double) *lgaln / lgfrag) * 4; //nb_ligne_aln = (int)ceil( (*lgaln) / lgfrag) * 4; /* alloue la memoire */ seq_alignee = (char **) calloc(nb_ligne_aln, sizeof(char *)); for(ii = 0; iilgName ) lgName = strlen(seq[1].name); lgName+=2; if(numbloc != -1) { sprintf(seq_alignee[numl], "%-*s %8.5s %s %8.5s", lgName, "", "", fragseg[3], ""); sprintf(seq_alignee[numl+1], "%-*s %8d %s %8d", lgName, seq[0].name, deb0, fragseg[0], fin0); sprintf(seq_alignee[numl+2], "%-*s %8d %s %8d", lgName, seq[1].name, deb1, fragseg[1], fin1); sprintf(seq_alignee[numl+3], "%-*s %8.5s %s %8.5s", lgName, "", "", fragseg[2], ""); } else { sprintf(seq_alignee[numl], "%-10.10s %8.5s %s", "", "", fragseg[3]); sprintf(seq_alignee[numl+1], "%-10.10s %8d %s", seq[0].name, deb0, fragseg[0]); sprintf(seq_alignee[numl+2], "%-10.10s %8d %s", seq[1].name, deb1, fragseg[1]); sprintf(seq_alignee[numl+3], "%-10.10s %8.5s %s", "", "", fragseg[2]); } if(lgfrag > lggap1) deb0 = fin0 + 1; else deb0 = fin0; if(lgfrag > lggap2) deb1 = fin1 + 1; else deb1 = fin1; } free((char *)aln1); free((char *)aln2); free((char *)aln3); free((char *)aln4); } int max_(int a, int b) { if (a > b) return(a); return(b); } ii < NBBLOC; ii++) if(seq[0].bloc[get_feature.cxx010064400004310000036000000121421023765342400144320ustar00goutbiomol00004410000024#include #include "lalnview.h" #include "lalnview_utils.H" #include "globals.h" #define TRUE true #define FALSE false void get_numc(char *, int *, char *); int tri_tab_feat(const void * ,const void *); void get_feature(char * nomfic) { char *pname, ficname[400]; FILE *fic; char string[300]; char bufdeb[10], buffin[10], cdeb[2], cfin[2]; int nseq, deb, fin, ii, jj; float lrg; char color[30]; char *label; int test_error = 0; /*GP_color test_color;*/ NBFEAT = 0; if (NBSEQ == 0) { // printf("Impossible de charger des features sans une sequence.\n"); return; } if (has_features == TRUE && GET_FEAT_FROM_SIM != TRUE) { if(tab_feat != NULL) free((char *) tab_feat); feat_decal = 0.0; has_features = FALSE; return; } else if (GET_FEAT_FROM_SIM == TRUE) { feat_decal = 0.0; has_features = FALSE; if(tab_feat != NULL) free((char *) tab_feat); } if(GET_FEAT_FROM_SIM == TRUE) strcpy(ficname, aln_fic_name); else { pname=strdup(nomfic); if(pname == NULL) return; strcpy(ficname, pname); } if((fic = fopen(ficname, "r")) == NULL) { //printf("Impossible to open this file"); fl_alert("Impossible to open this file"); return; } /* se place en debut des features */ while(fgets(string, 300, fic) != NULL) if(strncmp(string, "# FEATURES BEGIN", 16) == 0) break; /* compte le nombre de features */ while(fgets(string, 300, fic) != NULL) { if(strncmp(string, "# FEATURES END", 14) == 0) break; if(sscanf(string, "%d %s %s %f %s", &nseq, bufdeb, buffin, &lrg, color) == 5) NBFEAT++; } rewind(fic); /* alloue la memoire */ tab_feat = (struct FEATURE *)check_alloc(NBFEAT,sizeof(struct FEATURE)); /* initialise */ for(ii=0; ii 0) while(fgets(string, 300, fic) != NULL) { if(strncmp(string, "# FEATURES END", 14) == 0) break; if(sscanf(string, "%d %s %s %f %s", &nseq, bufdeb, buffin, &lrg, color) != 5) continue; nseq = nseq -1; get_numc(bufdeb, &deb, cdeb); get_numc(buffin, &fin, cfin); if(nseq != 0 && nseq != 1) test_error++; else if(deb < 0) test_error++; else if(deb > seq[nseq].lg) test_error++; else if(fin < 0) test_error++; else if(fin > seq[nseq].lg) test_error++; else if(lrg < 0) test_error++; else { if(lrg > MAXFEATLRG) lrg = MAXFEATLRG; tab_feat[ii].nseq = nseq; if(cdeb[0]== '?') { deb = fin; } else if(cfin[0]== '?') { fin =deb; } tab_feat[ii].lrg = lrg; if(fin >= deb) { tab_feat[ii].fin = fin; tab_feat[ii].deb = deb; strcpy(tab_feat[ii].cdeb, cdeb); strcpy(tab_feat[ii].cfin, cfin); } else { tab_feat[ii].fin = deb; tab_feat[ii].deb = fin; strcpy(tab_feat[ii].cdeb, cfin); strcpy(tab_feat[ii].cfin, cdeb); } /* recupere le label */ label = strtok(string, " \t\n"); for(jj = 2; jj < 6; jj++) label = strtok(NULL, " \t\n"); label = strtok(NULL, "\n"); strcpy(tab_feat[ii].col, color); if(label != NULL) strncpy(tab_feat[ii].lab, label, MAXLAB); else strcpy(tab_feat[ii].lab, ""); tab_feat[ii].lab[MAXLAB-1] = '\0'; ii++; } } if(NBFEAT == 0) { if (GET_FEAT_FROM_SIM != TRUE) fl_alert("Parsing problem in feature file. \nNo feature read."); fclose(fic); return; } /* if(test_error > 0 && GET_FEAT_FROM_SIM != TRUE) printf("Parsing problem in feature file. \nSome features may have been lost."); */ has_features = TRUE; feat_decal = 1.5; qsort(tab_feat, NBFEAT, sizeof(tab_feat[0]), tri_tab_feat); /*for(ii=0; ii' || string[ii] == '<' || string[ii] == '?') c[0] = string[ii]; else buf[jj++] = string[ii]; } buf[jj] = '\0'; *num = atoi(buf); } int tri_tab_feat(const void *a ,const void *b) { struct FEATURE *aa, *bb; aa = (struct FEATURE *) a; bb = (struct FEATURE *) b; /* 1er critere de tri: hauteur de la feature */ if(bb->lrg != aa->lrg) { if (bb->lrg > aa->lrg) return(1); else return(-1); } /* 2eme critere de tri: longueur de la feature */ return((bb->fin - bb->deb) - (aa->fin - aa->deb)); } init.cxx010064400004310000036000000043731025235157000131040ustar00goutbiomol00004410000024/* init.cxx */ #include #include #include #include #include #include #include "MF_Values.H" #include "init.H" #define MAX_SRC_PARAM_LG 8000 #ifdef __APPLE__ extern "C" { extern void PtoC(const void *in, void *out); extern void CtoP(const void *in, void *out); } void initSrc(void) { ; } char * getResValue(char *name) { char *p; p = load1res(name); if(p != NULL) return p; else return NULL; } char *load1res(char *resname) { char **h, *p, pname[256]; int l; CtoP(resname, pname); h = GetNamedResource('TEXT', (ConstStr255Param)pname ); if(h == NULL) return NULL; else { l = GetHandleSize(h); p = (char *)malloc(l + 1); } if(p != NULL) { HLock(h); memcpy(p, *h, l); HUnlock(h); p[l] = 0; if(p[--l] == '\r') p[l] = 0; } ReleaseResource(h); return p; } #else void initSrc(void) { MF_Values::srcFile(configFile()); } char * configFile(void) { #ifdef WIN32 char *fullName = (char *)"lalnview.ini"; #else char *p = getenv("HOME"); char * configFile = (char *)"/.lalnviewrc"; int lg = strlen(p) + strlen(configFile) + 1; char *fullName = (char *)malloc( lg * sizeof(char) ); sprintf(fullName,"%s%s\0", p, configFile); #endif return fullName; } /* Returns the value of the given var parameter in the configuration ($HOME/.lalnviewsrc) file */ char * getSrcValue(char *var) { using namespace std; std::ifstream file(MF_Values::srcFile()); if( !file ) return NULL; std::string line; std::string val; std::string svar = var; int pos; while( std::getline(file, line) ){ //printf("\n\nAnalyse de la ligne : %s\n", line.c_str()); if( line.substr(0,1) != "#" ){ pos = line.find("=", 0); if( pos==string::npos ){ //printf("Pas de egal\n"); continue; } if( line.substr(0, pos) != svar ){ //printf("!=%s\n", svar.c_str()); continue; } pos++; if(pos==line.size()){ //printf("Pas de valeur associee\n"); continue; } val = line.substr(pos, line.size()-pos); //printf("Val trouvee : %s\n", val.c_str()); //return val.c_str(); if( val.c_str() ) return strdup(val.c_str()); else return NULL; } } return NULL; } #endif lalnview.cxx010064400004310000036000000056261025235545000137650ustar00goutbiomol00004410000024#include #include #include #include #include "lalnview.h" #include "def_globals.h" #include "lalnview_utils.H" #include "MF_MainWindow.H" #include "MF_SecWindow.H" #include "MF_Values.H" #include "dijkstra.H" #include "init.H" /**************************************************/ float MF_Values::scoMin_ = 10.0; float MF_Values::identityMin_ = 0.0; int MF_Values::lenghtMin_ = 0; int MF_Values::SEQSPACE_ = 33; double MF_Values::rapport_ = 0.8; char * MF_Values::srcFile_ = NULL; /**************************************************/ MF_MainWindow * _MAINW_; MF_SecWindow * _SECW_; int main(int argc, char **argv) { _MAINW_ = NULL; _SECW_ = NULL; nb_ligne_aln = 0; NBFEAT = 0; seq_alignee = NULL; initSrc(); _MAINW_ = new MF_MainWindow(10,30,950,530,"_lalnview_"); _MAINW_->addMenu(); _MAINW_->resizable(_MAINW_->getScroll()); load_color_lg(); #if defined( __APPLE__ ) char *defaultScale = getResValue("scale"); #else char *defaultScale = getSrcValue("scale"); #endif if(defaultScale){ int scaleOk = loadColorScale(defaultScale); if(scaleOk==-1) fl_alert("Warning : unable to load default scale '%s' from ressource file.", defaultScale); } _MAINW_->show(); _MAINW_->make_current(); _MAINW_->redraw(); if(argc>1){ charger_fichier(argv[1]); if(argc>2) get_feature(argv[2]); } while(Fl::wait()){ ; } return 0; } void charger_fichier(char *fic) { int ret, pg, nw, nh; int S_NBBLOC, S_NBSEQ, S_NBFEAT; S_NBBLOC = NBBLOC; S_NBSEQ = NBSEQ; S_NBFEAT = NBFEAT; NBBLOC = 0; NBSEQ = 0; NBFEAT = 0; strcpy(aln_fic_name, fic); ret = load_data(fic); if(ret) { /* NBBLOC = S_NBBLOC; NBSEQ = S_NBSEQ; NBFEAT = S_NBFEAT; */ NBBLOC = NBSEQ = NBFEAT = 0; if(ret!=9 && ret !=11) fl_alert("Unrecognized file format."); return; } if( strlen(seq[0].name) > strlen(seq[1].name) ){ pg = 0; } else { pg = 1; } nw = 0; nh = 0; fl_font(FL_COURIER, 12); fl_measure(seq[pg].name, nw, nh); MF_MyScroll * ms = _MAINW_->getScroll(); MF_Name * name = _MAINW_->getName(); MF_Echelle * echelle = _MAINW_->getScale(); nw+=10; ms->myResize( name->x()+nw , ms->y() , _MAINW_->w()-(name->x()+nw) , ms->h() ); echelle->myResize( ms->x() , echelle->y() , ms->w() , echelle->h() ); name->myW(nw); if(seq[0].lg>seq[1].lg) pg = 0; else pg = 1; double rapport = (double)((double)seq[pg].lg/(double)(_MAINW_->getScroll()->w()-25)); MF_Values::rapport(rapport); if(_MAINW_->bestSeries()){ dijkstra(); } ms->loadSequences(); _MAINW_->setMins(); _MAINW_->getFeatDisp()->raz(); if(_SECW_ == NULL){ Fl_Group::current(0); _SECW_ = new MF_SecWindow(10,500,900,400, "Full text sequences"); _SECW_->show(); Fl_Group::current(_MAINW_); } else { _SECW_->raz(); } _MAINW_->fullUpdatePanel(); } lalnview_utils.cxx010064400004310000036000000675171025260567600152240ustar00goutbiomol00004410000024#include "lalnview_utils.H" /* These color are the avaible color for the features. */ #define NBFCOL 496 /* char * stab[NBFCOL] = {"black", "yellow", "red", "blue", "green", "brown"}; Fl_Color ftab[NBFCOL] = {FL_BLACK, FL_YELLOW, FL_RED, FL_BLUE, FL_GREEN, fl_rgb_color(0x9a,0x38,0x22) }; */ char * stab[NBFCOL] = { "red", "green", "blue", "yellow", "AliceBlue","AntiqueWhite","AntiqueWhite1","AntiqueWhite2", "AntiqueWhite3","AntiqueWhite4","aquamarine","aquamarine1","aquamarine2","aquamarine3","aquamarine4","azure","azure1","azure2","azure3","azure4","beige","bisque","bisque1","bisque2","bisque3","bisque4","black","BlanchedAlmond","blue","blue1","blue2","blue3","blue4","BlueViolet","brown","burlywood","burlywood1","burlywood2","burlywood3","burlywood4","CadetBlue","CadetBlue1","CadetBlue2","CadetBlue3","CadetBlue4","chartreuse","chartreuse1","chartreuse2","chartreuse3","chartreuse4","chocolate","coral","coral1","coral2","coral3","coral4","CornflowerBlue","cornsilk","cornsilk1","cornsilk2","cornsilk3","cornsilk4","cyan","cyan1","cyan2","cyan3","cyan4","DarkBlue","DarkCyan","DarkGoldenrod","DarkGoldenrod1","DarkGoldenrod2","DarkGoldenrod3","DarkGoldenrod4","DarkGray","DarkGreen","DarkKhaki","DarkMagenta","DarkOliveGreen","DarkOliveGreen1","DarkOliveGreen2","DarkOliveGreen3","DarkOliveGreen4","DarkOrange","DarkOrange1","DarkOrange2","DarkOrange3","DarkOrange4","DarkOrchid","DarkOrchid1","DarkOrchid2","DarkOrchid3","DarkOrchid4","DarkRed","DarkSalmon","DarkSeaGreen","DarkSeaGreen1","DarkSeaGreen2","DarkSeaGreen3","DarkSeaGreen4","DarkSlateBlue","DarkSlateGray","DarkSlateGray1","DarkSlateGray2","DarkSlateGray3","DarkSlateGray4","DarkTurquoise","DarkViolet","DeepPink","DeepPink1","DeepPink2","DeepPink3","DeepPink4","DeepSkyBlue","DeepSkyBlue1","DeepSkyBlue2","DeepSkyBlue3","DeepSkyBlue4","DimGray","DodgerBlue","DodgerBlue1","DodgerBlue2","DodgerBlue3","DodgerBlue4","firebrick","FloralWhite","ForestGreen","gainsboro","ghostwhite","gold","gold1","gold2","gold3","gold4","goldenrod","goldenrod1","goldenrod2","goldenrod3","goldenrod4","gray","gray0","gray1","gray10","gray100","gray11","gray2","gray3","gray4","gray41","gray49","gray5","gray54","gray55","gray56","gray57","gray58","gray59","gray6","gray60","gray61","gray62","gray63","gray64","gray65","gray66","gray67","gray68","gray69","gray7","gray70","gray71","gray72","gray73","gray74","gray75","gray76","gray77", "gray78" ,"gray79","gray8","gray80","gray81","gray82","gray83","gray84","gray85","gray86","gray87","gray88","gray89","gray9","gray90","gray91","gray92","gray93","gray94","gray95","gray96","gray97","gray98","gray99","green","green1","green2","green3","green4","GreenYellow","honeydew","honeydew1","honeydew2","honeydew3","honeydew4","HotPink","HotPink1","HotPink2","HotPink3","HotPink4","IndianRed","IndianRed1","IndianRed2","IndianRed3","IndianRed4","ivory","ivory1","ivory2","ivory3","ivory4","khaki","khaki1","khaki2","khaki3","khaki4","lavender","LavenderBlush","LavenderBlush1","LavenderBlush2","LavenderBlush3","LavenderBlush4","LawnGreen","LemonChiffon","LemonChiffon1","LemonChiffon2","LemonChiffon3","LemonChiffon4","LightBlue","LightBlue1","LightBlue2","LightBlue3","LightBlue4","LightCoral","LightCyan","LightCyan1","LightCyan2","LightCyan3","LightCyan4","LightGoldenrod","LightGoldenrod1","LightGoldenrod2","LightGoldenrod3","LightGoldenrod4","LightGoldenrodYellow","LightGray","LightGreen","LightPink","LightPink1","LightPink2","LightPink3","LightPink4","LightSalmon","LightSalmon1","LightSalmon2","LightSalmon3","LightSalmon4","LightSeaGreen","LightSkyBlue","LightSkyBlue1","LightSkyBlue2","LightSkyBlue3","LightSkyBlue4","LightSlateBlue","LightSlateGray","LightSteelBlue","LightSteelBlue1","LightSteelBlue2","LightSteelBlue3","LightSteelBlue4","LightYellow","LightYellow1","LightYellow2","LightYellow3","LightYellow4","LimeGreen","linen","magenta","magenta1","magenta2","magenta3","magenta4","maroon","maroon1","maroon2","maroon3","maroon4","MediumAquamarine","MediumBlue","MediumOrchid","MediumOrchid1","MediumOrchid2","MediumOrchid3","MediumOrchid4","MediumPurple","MediumPurple1","MediumPurple2","MediumPurple3","MediumPurple4","MediumSeaGreen","MediumSlateBlue","MediumSpringGreen","MediumTurquoise","MediumVioletRed","MidnightBlue","MintCream","MistyRose","MistyRose1","MistyRose2","MistyRose3","MistyRose4","moccasin","NavajoWhite","NavajoWhite1","NavajoWhite2","NavajoWhite3","NavajoWhite4","navy", "NavyBlue","OldLace","OliveDrab","OliveDrab1","OliveDrab2","OliveDrab3","OliveDrab4","orange","orange1","orange2","orange3","orange4","OrangeRed","OrangeRed1","OrangeRed2","OrangeRed3","OrangeRed4","orchid","orchid1","orchid2","orchid3","orchid4","PaleGoldenrod","PaleGreen","PaleGreen1","PaleGreen2","PaleGreen3","PaleGreen4","PaleTurquoise","PaleTurquoise1","PaleTurquoise2","PaleTurquoise3","PaleTurquoise4","PaleVioletRed","PaleVioletRed1","PaleVioletRed2","PaleVioletRed3","PaleVioletRed4","PapayaWhip","PeachPuff","PeachPuff1","PeachPuff2","PeachPuff3","PeachPuff4","peru","pink","pink1","pink2","pink3","pink4","plum","plum1","plum2","plum3","plum4","PowderBlue","purple","purple1","purple2","purple3","purple4","red1","red2","red3","red4","RosyBrown","RosyBrown1","RosyBrown2","RosyBrown3","RosyBrown4","RoyalBlue","RoyalBlue1","RoyalBlue2","RoyalBlue3","RoyalBlue4","SaddleBrown","salmon","salmon3","salmon4","SandyBrown","SeaGreen","SeaGreen1","SeaGreen2","SeaGreen3","SeaGreen4","seashell","seashell1","seashell2","seashell3","seashell4","sienna","sienna1","sienna2","sienna3","sienna4","SkyBlue","SkyBlue1","SkyBlue2","SkyBlue3","SkyBlue4","SlateBlue","SlateBlue1","SlateBlue2","SlateBlue3","SlateBlue4","SlateGray","SlateGray1","SlateGray2","SlateGray3","SlateGray4","snow","snow1","snow2","snow3","snow4","SpringGreen","SpringGreen1","SpringGreen2","SpringGreen3","SpringGreen4","SteelBlue","SteelBlue1","SteelBlue2","SteelBlue3","SteelBlue4","tan","tan1","tan2","thistle","thistle1","thistle2","thistle3","thistle4","tomato","tomato1","tomato2","tomato3","tomato4","turquoise","turquoise1","turquoise2","turquoise3","turquoise4","violet","VioletRed","VioletRed1","VioletRed2","VioletRed3","VioletRed4","wheat","wheat1","wheat2","wheat3","wheat4","white","whitesmoke","yellow", "yellow1","yellow2","yellow3","yellow4","YellowGreen"}; Fl_Color ftab[NBFCOL] = { FL_RED, FL_GREEN, FL_BLUE, FL_YELLOW, fl_rgb_color(0xf0,0xe6,0xfa),fl_rgb_color(0xfa,0xeb,0xd7),fl_rgb_color(0xff,0xef,0xdb),fl_rgb_color(0xee,0xdf,0xcc),fl_rgb_color(0xcd,0xc0,0xb0),fl_rgb_color(0x8b,0x83,0x78),fl_rgb_color(0x7f,0xff,0xd4),fl_rgb_color(0x7f,0xff,0xd4),fl_rgb_color(0x76,0xcd,0xaa),fl_rgb_color(0x66,0xcd,0xaa),fl_rgb_color(0x45,0x8b,0x74),fl_rgb_color(0xf0,0xff,0xff),fl_rgb_color(0xf0,0xff,0xff),fl_rgb_color(0xe0,0xcd,0xcd),fl_rgb_color(0xc1,0xcd,0xcd),fl_rgb_color(0x83,0x8b,0x8b),fl_rgb_color(0xf5,0xf5,0xdc),fl_rgb_color(0xff,0xe4,0xc4),fl_rgb_color(0xff,0xe4,0xc4),fl_rgb_color(0xee,0xd5,0xb7),fl_rgb_color(0xcd,0xb7,0x9e),fl_rgb_color(0x8b,0x7d,0x6b),fl_rgb_color(0x00,0x00,0x00),fl_rgb_color(0xff,0xeb,0xcd),fl_rgb_color(0x00,0x00,0xff),fl_rgb_color(0x00,0x00,0xff),fl_rgb_color(0x00,0x00,0xee),fl_rgb_color(0x00,0x00,0xcd),fl_rgb_color(0x00,0x00,0x8b),fl_rgb_color(0x8a,0x2b,0xe2),fl_rgb_color(0xa5,0x2a,0x2a),fl_rgb_color(0xde,0xb8,0x87),fl_rgb_color(0xff,0xd3,0x9b),fl_rgb_color(0xee,0xc5,0x9e),fl_rgb_color(0xcd,0xaa,0x7d),fl_rgb_color(0x8b,0x73,0x55),fl_rgb_color(0x5f,0x9e,0xa0),fl_rgb_color(0x98,0xf5,0xff),fl_rgb_color(0x8e,0xe5,0xee),fl_rgb_color(0x7a,0xc5,0xcd),fl_rgb_color(0x53,0x86,0x8b),fl_rgb_color(0x7f,0xff,0x00),fl_rgb_color(0x7f,0xff,0x00),fl_rgb_color(0x76,0xee,0x00),fl_rgb_color(0x66,0xcd,0x00),fl_rgb_color(0x45,0x8b,0x00),fl_rgb_color(0xd2,0x69,0x1e),fl_rgb_color(0xff,0x7f,0x50),fl_rgb_color(0xff,0x72,0x56),fl_rgb_color(0xee,0x6a,0x50),fl_rgb_color(0xcd,0x5b,0x45),fl_rgb_color(0x8b,0x3e,0x2f),fl_rgb_color(0x64,0x95,0xed),fl_rgb_color(0xff,0xf8,0xdc),fl_rgb_color(0xff,0xf8,0xdc),fl_rgb_color(0xee,0xe8,0xcd),fl_rgb_color(0xcd,0xc8,0xb1),fl_rgb_color(0x8b,0x88,0x78),fl_rgb_color(0x00,0xff,0xff),fl_rgb_color(0x00,0xff,0xff),fl_rgb_color(0x00,0xee,0xee),fl_rgb_color(0x00,0xcd,0xcd),fl_rgb_color(0x00,0x8b,0x8b),fl_rgb_color(0x00,0x00,0x8b),fl_rgb_color(0x00,0x8b,0x8b),fl_rgb_color(0xb8,0x86,0x0b),fl_rgb_color(0xff,0xb9,0x0f),fl_rgb_color(0xee,0xad,0x0e),fl_rgb_color(0xcd,0x95,0x0c),fl_rgb_color(0x8b,0x65,0x08), fl_rgb_color(0xa9, 0xa9,0xa9),fl_rgb_color(0x64,0x00,0x00),fl_rgb_color(0xbd,0xb7,0x6b),fl_rgb_color(0x8b,0x00,0x8b),fl_rgb_color(0x55,0x6b,0x2f),fl_rgb_color(0xca,0xff,0x70),fl_rgb_color(0xbc,0xee,0x68),fl_rgb_color(0xa2,0xcd,0x5a),fl_rgb_color(0x6e,0x8b,0x3d),fl_rgb_color(0xff,0x8c,0x00),fl_rgb_color(0xff,0x7f,0x00),fl_rgb_color(0xee,0x76,0x00),fl_rgb_color(0xcd,0x66,0x00),fl_rgb_color(0x8b,0x45,0x00),fl_rgb_color(0x99,0x32,0xcc),fl_rgb_color(0xbf,0x3e,0xff),fl_rgb_color(0xb2,0x3a,0xee),fl_rgb_color(0x9a,0x32,0xcd),fl_rgb_color(0x68,0x22,0x8b),fl_rgb_color(0x8b,0x00,0x00),fl_rgb_color(0xe9,0x96,0x7a),fl_rgb_color(0x8f,0xbc,0x8f),fl_rgb_color(0xc1,0xff,0xc1),fl_rgb_color(0xb4,0xee,0xb4),fl_rgb_color(0x9b,0xcd,0x9b),fl_rgb_color(0x69,0x8b,0x69),fl_rgb_color(0x48,0x3d,0x8b),fl_rgb_color(0x2f,0x4f,0x4f),fl_rgb_color(0x9b,0xff,0xff),fl_rgb_color(0x8d,0xee,0xee),fl_rgb_color(0x79,0xcd,0xcd),fl_rgb_color(0x52,0x8b,0x8b),fl_rgb_color(0x00,0xce,0xd1),fl_rgb_color(0x94,0x00,0xd3),fl_rgb_color(0xff,0x14,0x93),fl_rgb_color(0xff,0x14,0x93),fl_rgb_color(0xee,0x12,0x89),fl_rgb_color(0xcd,0x10,0x76),fl_rgb_color(0xcd,0x10,0x76),fl_rgb_color(0x00,0xbf,0xff),fl_rgb_color(0x00,0xbf,0xff),fl_rgb_color(0x00,0xb2,0xee),fl_rgb_color(0x00,0x9a,0xcd),fl_rgb_color(0x00,0x68,0x8b),fl_rgb_color(0x69,0x69,0x69),fl_rgb_color(0x1e,0x90,0xff),fl_rgb_color(0x1e,0x90,0xff),fl_rgb_color(0x1c,0x86,0xee),fl_rgb_color(0x18,0x74,0xcd),fl_rgb_color(0x10,0x4e,0x8b),fl_rgb_color(0xb2,0x22,0x22),fl_rgb_color(0xff,0xfa,0xf0),fl_rgb_color(0x22,0x8b,0x22),fl_rgb_color(0xdc,0xdc,0xdc),fl_rgb_color(0xF8,0xF8,0xFF),fl_rgb_color(0xff,0xd7,0x00),fl_rgb_color(0xff,0xd7,0x00),fl_rgb_color(0xee,0xc9,0x00),fl_rgb_color(0xcd,0xad,0x00),fl_rgb_color(0x8b,0x75,0x00),fl_rgb_color(0xda,0xa5,0x20),fl_rgb_color(0x8b,0x75,0x00),fl_rgb_color(0xee,0xb4,0x22),fl_rgb_color(0xcd,0x9b,0x1d),fl_rgb_color(0x8b,0x69,0x14),fl_rgb_color(0xbe,0xbe,0xbe),fl_rgb_color(0x00,0x00,0x00),fl_rgb_color(0x30,0x30,0x30),fl_rgb_color(0x1a,0x1a,0x1a),fl_rgb_color(0xff,0xff,0xff),fl_rgb_color(0x1c,0x1c,0x1c), fl_rgb_color(0x50,0x50,0x50),fl_rgb_color(0x80,0x80,0x80),fl_rgb_color(0x0a,0x0a,0x0a),fl_rgb_color(0x69,0x69,0x69),fl_rgb_color(0x7d,0x7d,0x7d),fl_rgb_color(0x0d,0x0d,0x0d),fl_rgb_color(0x8a,0x8a,0x8a),fl_rgb_color(0x8c,0x8c,0x8c),fl_rgb_color(0x8f,0x8f,0x8f),fl_rgb_color(0x91,0x91,0x91),fl_rgb_color(0x94,0x94,0x94),fl_rgb_color(0x96,0x96,0x96),fl_rgb_color(0x0f,0x0f,0x0f),fl_rgb_color(0x99,0x99,0x99),fl_rgb_color(0x9c,0x9c,0x9c),fl_rgb_color(0x9e,0x9e,0x9e),fl_rgb_color(0xa1,0xa1,0xa1),fl_rgb_color(0xa3,0xa3,0xa3),fl_rgb_color(0xa6,0xa6,0xa6),fl_rgb_color(0xa8,0xa8,0xa8),fl_rgb_color(0xab,0xab,0xab),fl_rgb_color(0xad,0xad,0xad),fl_rgb_color(0xb0,0xb0,0xb0),fl_rgb_color(0x12,0x12,0x12),fl_rgb_color(0xb3,0xb3,0xb3),fl_rgb_color(0xb5,0xb5,0xb5),fl_rgb_color(0xb8,0xb8,0xb8),fl_rgb_color(0xba,0xba,0xba),fl_rgb_color(0xbd,0xbd,0xbd),fl_rgb_color(0xbf,0xbf,0xbf),fl_rgb_color(0xc2,0xc2,0xc2),fl_rgb_color(0xc4,0xc4,0xc4),fl_rgb_color(0xc7,0xc7,0xc7),fl_rgb_color(0xc9,0xc9,0xc9),fl_rgb_color(0x14,0x14,0x14),fl_rgb_color(0xcc,0xcc,0xcc),fl_rgb_color(0xcf,0xcf,0xcf),fl_rgb_color(0xd1,0xd1,0xd1),fl_rgb_color(0xd4,0xd4,0xd4),fl_rgb_color(0xd6,0xd6,0xd6),fl_rgb_color(0xd9,0xd9,0xd9),fl_rgb_color(0xdb,0xdb,0xdb),fl_rgb_color(0xde,0xde,0xde),fl_rgb_color(0xe0,0xe0,0xe0),fl_rgb_color(0xe3,0xe3,0xe3),fl_rgb_color(0x17,0x17,0x17),fl_rgb_color(0xe5,0xe5,0xe5),fl_rgb_color(0xe8,0xe8,0xe8),fl_rgb_color(0xeb,0xeb,0xeb),fl_rgb_color(0xed,0xed,0xed),fl_rgb_color(0xf0,0xf0,0xf0),fl_rgb_color(0xf2,0xf2,0xf2),fl_rgb_color(0xf5,0xf5,0xf5),fl_rgb_color(0xf7,0xf7,0xf7),fl_rgb_color(0xfa,0xfa,0xfa),fl_rgb_color(0xfc,0xfc,0xfc),fl_rgb_color(0x00,0xff,0x00),fl_rgb_color(0x00,0xff,0x00),fl_rgb_color(0x00,0xee,0x00),fl_rgb_color(0x00,0xcd,0x00),fl_rgb_color(0x00,0x8b,0x00),fl_rgb_color(0xad,0xff,0x2f),fl_rgb_color(0xf0,0xff,0xf0),fl_rgb_color(0xf0,0xff,0xf0),fl_rgb_color(0xe0,0xee,0xe0),fl_rgb_color(0xc1,0xcd,0xc1),fl_rgb_color(0x83,0x8b,0x83),fl_rgb_color(0xff,0x69,0xb4),fl_rgb_color(0xff,0x6e,0xb4), fl_rgb_color(0xee,0x6a,0xa7),fl_rgb_color(0xcd,0x60,0x90),fl_rgb_color(0x8b,0x3a,0x62),fl_rgb_color(0xcd,0x5c,0x5c),fl_rgb_color(0xff,0x6a,0x6a),fl_rgb_color(0xee,0x63,0x63),fl_rgb_color(0xcd,0x55,0x55),fl_rgb_color(0x8b,0x3a,0x3a),fl_rgb_color(0xff,0xff,0xf0),fl_rgb_color(0xff,0xff,0xf0),fl_rgb_color(0xee,0xee,0xe0),fl_rgb_color(0xcd,0xcd,0xc1),fl_rgb_color(0x8b,0x8b,0x83),fl_rgb_color(0xf0,0xe6,0x8c),fl_rgb_color(0xff,0xf6,0x8f),fl_rgb_color(0xee,0xe6,0x85),fl_rgb_color(0xcd,0xc6,0x73),fl_rgb_color(0x8b,0x86,0x4e),fl_rgb_color(0xe6,0xe6,0xfa),fl_rgb_color(0xff,0xf0,0xf5),fl_rgb_color(0xff,0xf0,0xf5),fl_rgb_color(0xee,0xe0,0xe5),fl_rgb_color(0xcd,0xc1,0xc5),fl_rgb_color(0x8b,0x83,0x86),fl_rgb_color(0x7c,0xfc,0x7f),fl_rgb_color(0xe1,0xfa,0xcd),fl_rgb_color(0xff,0xfa,0xcd),fl_rgb_color(0xee,0xc9,0xa5),fl_rgb_color(0xcd,0xc9,0xa5),fl_rgb_color(0x8b,0x89,0x70),fl_rgb_color(0xad,0xd8,0xe6),fl_rgb_color(0xbf,0xef,0xff),fl_rgb_color(0xb2,0xdf,0xee),fl_rgb_color(0x9a,0xc0,0xcd),fl_rgb_color(0x68,0x83,0x8b),fl_rgb_color(0xf0,0x80,0x80),fl_rgb_color(0xe1,0xff,0xff),fl_rgb_color(0xe0,0xff,0xff),fl_rgb_color(0x68,0x83,0x8b),fl_rgb_color(0xb4,0xcd,0xcd),fl_rgb_color(0x7a,0x8b,0x82),fl_rgb_color(0xee,0xdd,0x82),fl_rgb_color(0xff,0xec,0x8b),fl_rgb_color(0xee,0xdc,0x82),fl_rgb_color(0xcd,0xbe,0x70),fl_rgb_color(0x8b,0x81,0x4c),fl_rgb_color(0xfa,0xfa,0xd2),fl_rgb_color(0xd3,0xd3,0xd3),fl_rgb_color(0x90,0xee,0x90),fl_rgb_color(0xff,0xb6,0xc1),fl_rgb_color(0xff,0xae,0xb9),fl_rgb_color(0xee,0xa2,0xad),fl_rgb_color(0xcd,0x8c,0x95),fl_rgb_color(0x8b,0x5f,0x65),fl_rgb_color(0xff,0xa0,0x7a),fl_rgb_color(0xff,0xa0,0x7a),fl_rgb_color(0xee,0x95,0x72),fl_rgb_color(0xcd,0x81,0x62),fl_rgb_color(0x8b,0x57,0x42),fl_rgb_color(0x20,0xb2,0xaa),fl_rgb_color(0x87,0xce,0xfa),fl_rgb_color(0xb0,0xe2,0xff),fl_rgb_color(0xa4,0xd3,0xee),fl_rgb_color(0x8d,0xb6,0xcd),fl_rgb_color(0x60,0x7b,0x8b),fl_rgb_color(0x84,0x70,0xff),fl_rgb_color(0x77,0x88,0x99),fl_rgb_color(0xb0,0xc4,0xde),fl_rgb_color(0xca,0xe1,0xff), fl_rgb_color(0xbc,0xd2,0xee),fl_rgb_color(0xa2,0xb5,0xcd), fl_rgb_color(0x6e,0x7b,0x8b),fl_rgb_color(0xff,0xff,0xe0),fl_rgb_color(0xff,0xff,0xe0),fl_rgb_color(0xee,0xee,0xd1),fl_rgb_color(0xcd,0xcd,0xb4),fl_rgb_color(0x8b,0x8b,0x6a),fl_rgb_color(0x32,0xcd,0x32),fl_rgb_color(0xfa,0xf0,0xe6),fl_rgb_color(0xff,0x00,0xff),fl_rgb_color(0xff,0x00,0xff),fl_rgb_color(0xee,0x00,0xee),fl_rgb_color(0xcd,0x00,0xcd),fl_rgb_color(0x8b,0x00,0x8b),fl_rgb_color(0xb0,0x2e,0x60),fl_rgb_color(0xff,0x34,0xb3),fl_rgb_color(0xee,0x30,0xa7),fl_rgb_color(0xcd,0x29,0x90),fl_rgb_color(0x8b,0x1c,0x62),fl_rgb_color(0x66,0xcd,0xaa),fl_rgb_color(0x00,0x00,0xcd),fl_rgb_color(0xba,0x55,0xd3),fl_rgb_color(0xd1,0x5f,0xee),fl_rgb_color(0xd1,0x5f,0xee),fl_rgb_color(0xb4,0x52,0xcd),fl_rgb_color(0x7a,0x37,0x8b),fl_rgb_color(0xa0,0x20,0xf0),fl_rgb_color(0xab,0x82,0xff),fl_rgb_color(0x9f,0x79,0xee),fl_rgb_color(0x89,0x68,0xcd),fl_rgb_color(0x5d,0x47,0x8b),fl_rgb_color(0x3c,0xb3,0x71),fl_rgb_color(0x7b,0x68,0xee),fl_rgb_color(0x00,0xfa,0x9a),fl_rgb_color(0x48,0xd1,0xcc),fl_rgb_color(0xc7,0x15,0x85),fl_rgb_color(0x19,0x19,0x70),fl_rgb_color(0xf5,0xff,0xfa),fl_rgb_color(0xff,0xe4,0xe1),fl_rgb_color(0xff,0xe4,0xe1),fl_rgb_color(0xee,0xd5,0xd2),fl_rgb_color(0xcd,0xb7,0xb5),fl_rgb_color(0x8b,0x7d,0x7b),fl_rgb_color(0xff,0xe4,0xb5),fl_rgb_color(0xff,0xda,0xb9),fl_rgb_color(0xff,0xde,0xad),fl_rgb_color(0xee,0xcf,0xa1),fl_rgb_color(0xcd,0xb3,0x8b),fl_rgb_color(0x8b,0x79,0x5e),fl_rgb_color(0x80,0x00,0x00),fl_rgb_color(0x80,0x00,0x00),fl_rgb_color(0xfa,0xf5,0xe6),fl_rgb_color(0x6b,0x8e,0x23),fl_rgb_color(0xc0,0xff,0x3e),fl_rgb_color(0xb3,0xee,0x3a),fl_rgb_color(0x9a,0xcd,0x32),fl_rgb_color(0x69,0x8b,0x22),fl_rgb_color(0xff,0xa5,0x00),fl_rgb_color(0xff,0xa5,0x00),fl_rgb_color(0xee,0x9a,0x00),fl_rgb_color(0xcd,0x85,0x00),fl_rgb_color(0x8b,0x5a,0x00),fl_rgb_color(0xff,0x41,0x00),fl_rgb_color(0xff,0x45,0x00),fl_rgb_color(0xee,0x40,0x00),fl_rgb_color(0xcd,0x37,0x00),fl_rgb_color(0x8b,0x25,0x00),fl_rgb_color(0xda,0x70,0xd6),fl_rgb_color(0x8b,0x00,0x8b),fl_rgb_color(0xee,0x7a,0xe9), fl_rgb_color(0xcd,0x69,0xc9),fl_rgb_color(0x8b,0x47,0x89),fl_rgb_color(0xee,0xe8,0xaa), fl_rgb_color(0x98,0xfb,0x98),fl_rgb_color(0x9a,0xff,0x9a),fl_rgb_color(0x90,0xee,0x90),fl_rgb_color(0x7c,0xcd,0x7c),fl_rgb_color(0x54,0x8b,0x54),fl_rgb_color(0xaf,0xee,0xee),fl_rgb_color(0xbb,0xff,0xff),fl_rgb_color(0xae,0xee,0xee),fl_rgb_color(0x96,0xcd,0xcd),fl_rgb_color(0x66,0x8b,0x8b),fl_rgb_color(0xdb,0x70,0x93),fl_rgb_color(0xff,0x82,0xab),fl_rgb_color(0xee,0x79,0x9f),fl_rgb_color(0xcd,0x68,0x89),fl_rgb_color(0x8b,0x47,0x5d),fl_rgb_color(0xff,0xef,0xd5),fl_rgb_color(0xff,0xda,0xb9),fl_rgb_color(0xff,0xda,0xb9),fl_rgb_color(0xee,0xcb,0xad),fl_rgb_color(0xcd,0xaf,0x95),fl_rgb_color(0x8b,0x77,0x65),fl_rgb_color(0xcd,0x85,0x3f),fl_rgb_color(0xff,0xc0,0xcb),fl_rgb_color(0xff,0xb5,0xc5),fl_rgb_color(0xee,0xa9,0xb8),fl_rgb_color(0xcd,0x91,0x9e),fl_rgb_color(0x8b,0x63,0x6c),fl_rgb_color(0xdd,0xa0,0xdd),fl_rgb_color(0xff,0xbb,0xff),fl_rgb_color(0xee,0xae,0xee),fl_rgb_color(0xcd,0x96,0xcd),fl_rgb_color(0x8b,0x66,0x8b),fl_rgb_color(0xb0,0xe0,0xe6),fl_rgb_color(0xa0,0x20,0xf0),fl_rgb_color(0x9b,0x30,0xff),fl_rgb_color(0x91,0x2c,0xee),fl_rgb_color(0x7d,0x26,0xcd),fl_rgb_color(0x55,0x1a,0x8b),fl_rgb_color(0xff,0x00,0x00),fl_rgb_color(0xee,0x00,0x00),fl_rgb_color(0xcd,0x00,0x00),fl_rgb_color(0x8b,0x00,0x00),fl_rgb_color(0xbc,0x8f,0x8f),fl_rgb_color(0xff,0xb6,0xb6),fl_rgb_color(0xee,0xb4,0xb4),fl_rgb_color(0xcd,0x9b,0x9b),fl_rgb_color(0x8b,0x69,0x69),fl_rgb_color(0x41,0x69,0xe1),fl_rgb_color(0x48,0x76,0xff),fl_rgb_color(0x43,0x6e,0xee),fl_rgb_color(0x3a,0x5f,0xcd),fl_rgb_color(0x27,0x40,0x8b),fl_rgb_color(0x8b,0x45,0x13),fl_rgb_color(0xfa,0x80,0x72),fl_rgb_color(0xcd,0x70,0x54),fl_rgb_color(0x8b,0x4c,0x39),fl_rgb_color(0xf4,0xa4,0x60),fl_rgb_color(0x2e,0x8b,0x57),fl_rgb_color(0x54,0xff,0x9f),fl_rgb_color(0x4e,0xee,0x94),fl_rgb_color(0x43,0xcd,0x80),fl_rgb_color(0x2e,0x8b,0x57),fl_rgb_color(0xff,0xf5,0xee),fl_rgb_color(0xff,0xf5,0xee),fl_rgb_color(0xee,0xe5,0xde),fl_rgb_color(0xcd,0xc5,0xbf),fl_rgb_color(0x8b,0x86,0x82), fl_rgb_color(0xa0,0x52,0x2d),fl_rgb_color(0xff,0x82,0x47), fl_rgb_color(0xee,0x79,0x42),fl_rgb_color(0xcd,0x68,0x39),fl_rgb_color(0x8b,0x47,0x36),fl_rgb_color(0x87,0xce,0xeb),fl_rgb_color(0x87,0xce,0xff),fl_rgb_color(0x7e,0xc0,0xee),fl_rgb_color(0x6c,0xa6,0xcd),fl_rgb_color(0x4a,0x70,0x8b),fl_rgb_color(0x6a,0x5a,0xcd),fl_rgb_color(0x83,0x6f,0xff),fl_rgb_color(0x7a,0x67,0xee),fl_rgb_color(0x69,0x59,0xcd),fl_rgb_color(0x47,0x3c,0x8b),fl_rgb_color(0x70,0x80,0x90),fl_rgb_color(0xc6,0xe2,0xff),fl_rgb_color(0xb9,0xd3,0xee),fl_rgb_color(0x9f,0xb6,0xcd),fl_rgb_color(0x6c,0x7b,0x8b),fl_rgb_color(0xFF,0xFA,0xFA),fl_rgb_color(0x8b,0x89,0x89),fl_rgb_color(0xee,0xe9,0xe9),fl_rgb_color(0xcd,0xc9,0xc9),fl_rgb_color(0x8b,0x89,0x89),fl_rgb_color(0x00,0xff,0x7f),fl_rgb_color(0x00,0xff,0x7f),fl_rgb_color(0x00,0xee,0x76),fl_rgb_color(0x00,0xcd,0x66),fl_rgb_color(0x00,0x8b,0x45),fl_rgb_color(0x46,0x82,0xb4),fl_rgb_color(0x63,0xb8,0x8b),fl_rgb_color(0x5c,0xac,0xee),fl_rgb_color(0x4f,0x94,0xcd),fl_rgb_color(0x36,0x64,0x8b),fl_rgb_color(0xd2,0xb4,0x8c),fl_rgb_color(0xff,0xa5,0x4f),fl_rgb_color(0xee,0x9a,0x49),fl_rgb_color(0x8b,0x89,0x89),fl_rgb_color(0xff,0xe1,0xff),fl_rgb_color(0xee,0xd2,0xee),fl_rgb_color(0xcd,0xb5,0xcd),fl_rgb_color(0x8b,0x7b,0x8b),fl_rgb_color(0xff,0x63,0x47),fl_rgb_color(0xff,0x63,0x47),fl_rgb_color(0xee,0x5c,0x42),fl_rgb_color(0xcd,0x4f,0x39),fl_rgb_color(0x8b,0x36,0x26),fl_rgb_color(0x40,0xe0,0xd0),fl_rgb_color(0x00,0xf5,0xff),fl_rgb_color(0x00,0xef,0xee),fl_rgb_color(0x00,0xc5,0xcd),fl_rgb_color(0x00,0x86,0x8b),fl_rgb_color(0xee,0x82,0xee),fl_rgb_color(0xd0,0x20,0x90),fl_rgb_color(0xff,0x3e,0x96),fl_rgb_color(0xee,0x3a,0x8c),fl_rgb_color(0xcd,0x32,0x78),fl_rgb_color(0x8b,0x22,0x52),fl_rgb_color(0xf5,0xde,0xb3),fl_rgb_color(0xff,0xe7,0xba),fl_rgb_color(0xee,0x8e,0xae),fl_rgb_color(0xcd,0xba,0x96),fl_rgb_color(0x8b,0x7e,0x66),fl_rgb_color(0xFF,0xFF,0xFF),fl_rgb_color(0xf5,0xf5,0xf5),fl_rgb_color(0xff,0xff,0x00),fl_rgb_color(0xff,0xff,0x00), fl_rgb_color(0xee,0xee,0x00),fl_rgb_color(0xcd,0xcd,0x00), fl_rgb_color(0x8b,0x8b,0x00),fl_rgb_color(0x9a,0xcd,0x32) }; Fl_Color getColor(char *col) { int i; for(i=0 ; i= color_lg[ii].sco) return(color_lg[ii].col); return(FL_WHITE); } void load_color_lg(void) { Fl_Color liscol[]={FL_BLACK, fl_rgb_color(0x85, 0x11, 0x49), fl_rgb_color(0xd8, 0x17, 0x9b), FL_RED, fl_rgb_color(0xe8, 0x7a, 0x3b), fl_rgb_color(0xff, 0xcc, 0x6c), fl_rgb_color(0xfa, 0xff, 0xb), fl_rgb_color(0xda, 0xda, 0xdf), fl_rgb_color(0xef, 0xef, 0xdd) }; float lissco[]={100.0, 90.0, 80.0, 70.0, 60.0, 50.0, 40.0, 30.0, 20.0}; char * labels[]={"100","90","80","70","60","50","40","30","20"}; int ii; for(ii = 0; ii < NBCOL; ii++) { //strcpy(color_lg[ii].col, liscol[ii]); color_lg[ii].col = liscol[ii]; color_lg[ii].sco = lissco[ii]; } } int saveColorScale(char *fic) { int i; FILE * nf; nf = fopen(fic, "w+"); if( !nf ) return -1; for(i=0 ; isco > ((struct SEG *)s2)->sco ) return -1; if( ((struct SEG *)s1)->sco == ((struct SEG *)s2)->sco ){ if( ((struct SEG *)s1)->beg0 > ((struct SEG *)s2)->beg0 ) return 1; else return -1; } return 0; return 1; } /* int fcmpBloc(const void *b1, const void *b2) Used to sort the blocs. */ int fcmpBloc(const void *b1, const void *b2) { if( ((struct BLOC *)b1)->seg > ((struct BLOC *)b2)->seg ) return 1; if( ((struct BLOC *)b1)->seg == ((struct BLOC *)b2)->seg ){ if(((struct BLOC *)b1)->beg > ((struct BLOC *)b2)->beg ) return 1; else return -1; } return -1; } void scrolb_cb(Fl_Widget * w) { Fl_Scrollbar * scrolb = (Fl_Scrollbar *)w; MF_MyScroll * grp = (MF_MyScroll *)scrolb->parent(); grp->redraw(); } /* void echange(SEG *tab, int i, int j) swaps two segments. */ void echange(SEG *tab, int i, int j) { SEG s = tab[i]; tab[i] = tab[j]; tab[j] = s; } /* void tribulle(SEG *tab, int n) A sort function used to sort the segments. */ void tribulle(SEG *tab, int n) { int ok, i; do { ok = 1; for(i=1 ; i=scoMin && s.identity>=identityMin && s.lgaln>=lenghtMin && (!bck || s.bestSeries)) return true; return false; } or(0x2e,0x8b,0x57),fl_rgb_color(0x54,0xff,0x9f),fl_rgb_color(0x4e,0xee,0x94),fl_rgb_color(0x43,0xcd,0x80),fl_rgb_color(0x2e,0x8b,0x57),fl_rgb_color(0xff,0xf5,0xee),fl_rgb_color(load_data.cxx010064400004310000036000000473671025260567600140740ustar00goutbiomol00004410000024#include #include "lalnview.h" #include "globals.h" #define TRUE true #define FALSE false /* char aln_fic_name[300]; char aln_fic_name_short[300]; */ /* charge l'alignement. Retourne 0 si Ok, sinon numero d'erreur */ void complement(char *seq); char *_ficname_; char *_dirname_; int load_data(char *ficname) { char _DIRSEP_ = '/'; #ifdef WIN32 _DIRSEP_ = '\\'; #elif defined( __APPLE__ ) _DIRSEP_ = ':'; #endif FILE *fic; char string[100]; int test = 0; int i, j; _ficname_ = strdup(ficname); j = 0; for(i=0 ; i seq[1].lg) maxscroll = (double) seq[0].lg; else maxscroll = (double) seq[1].lg; /* alloue memoire pour les seq. */ if(seq[0].seq != NULL) free(seq[0].seq); if(seq[1].seq != NULL) free(seq[1].seq); if((seq[0].seq = (char *)calloc(seq[0].lg + 1,sizeof(char))) == NULL ) return(13); if((seq[1].seq = (char *)calloc(seq[1].lg + 1,sizeof(char))) == NULL ) { free(seq[0].seq); return(13); } /* counts number of blocks */ GET_SEQ_FROM_SIM = false; GET_FEAT_FROM_SIM = false; while(fgets(string, 100, fic)!=NULL) { if(strncmp(string, "a {", 3) == 0) NBSEG++; if(strncmp(string, " l ", 4) == 0) NBBLOC++; if(strncmp(string, "# SEQUENCES BEGIN", 17) == 0) GET_SEQ_FROM_SIM = true; if(strncmp(string, "# FEATURES BEGIN", 16) == 0) GET_FEAT_FROM_SIM = true; } ii = get_seq_fasta(fic_name[0], 0); if(ii != 0) return(ii); ii = get_seq_fasta(fic_name[1], 1); if(ii != 0) return(ii); if(GET_FEAT_FROM_SIM == TRUE){ // printf("get_feature(%s);\n", _ficname_); get_feature(_ficname_); } rewind(fic); if(seq[0].bloc != NULL) free((char *) seq[0].bloc); if(seq[1].bloc != NULL) free((char *) seq[1].bloc); if(segm != NULL) free((char *) segm); seq[0].bloc = (struct BLOC *)check_alloc(NBBLOC+1,sizeof(struct BLOC)); seq[1].bloc = (struct BLOC *)check_alloc(NBBLOC+1,sizeof(struct BLOC)); segm = (struct SEG *)check_alloc(NBSEG+1,sizeof(struct SEG)); /* get blocks info */ segnum = 0; ii = 0; COMPLEMENT = 0; while(fgets(string, 100, fic)!=NULL) { /* in SIM4 if R!0 requires that shorter sequence be reverse complemented. */ if(strncmp(string, "(complement)", 12) == 0) { COMPLEMENT = 1; if(seq[0].lg < seq[1].lg) { sprintf(buf, "C_%s", seq[0].name); strcpy(seq[0].name, buf); complement(seq[0].seq); } else { sprintf(buf, "C_%s", seq[1].name); strcpy(seq[1].name, buf); complement(seq[1].seq); } } if(strncmp(string, " s ", 4) == 0) { if(sscanf(string, "%*s %f", &score) != 1) return(4); segm[segnum].sco = score; if(score > bestscore) bestscore = score; continue; } if(strncmp(string, " b ", 4) == 0) { if(sscanf(string, "%*s %d %d", &segm[segnum].beg0, &segm[segnum].beg1) != 2) return(5); continue; } if(strncmp(string, " e ", 4) == 0) { if(sscanf(string, "%*s %d %d", &segm[segnum].end0, &segm[segnum].end1) != 2) return(6); segnum++; continue; } if(strncmp(string, " l ", 4) != 0) continue; if(sscanf(string, "%*s %d %d %d %d %f", &seq[0].bloc[ii].beg, &seq[1].bloc[ii].beg, &seq[0].bloc[ii].end, &seq[1].bloc[ii].end, &seq[0].bloc[ii].sim ) != 5) return(7); seq[1].bloc[ii].sim = seq[0].bloc[ii].sim; seq[1].bloc[ii].seg = seq[0].bloc[ii].seg = segnum; seq[1].bloc[ii].sco = seq[0].bloc[ii].sco = score; ii++; } if(seq[0].lg > seq[1].lg) LGSEQMAX = seq[0].lg; else LGSEQMAX = seq[1].lg; if(bestscore < seuil_score_sim) seuil_score_sim = bestscore; cur_seq_view = LGSEQMAX; return(0); } void Nieme_mot(char *string, int n, char *separat, char *result) { int ii; char *mot; char *phrase; if((phrase = (char*) malloc((1+strlen(string)) * sizeof(char))) == NULL){ fprintf(stderr,"ERROR: not enough memory in function: Nieme_mot \n"); exit(3); } strcpy(phrase,string); mot = strtok(phrase, separat); for(ii = 1; ii < n; ii++) if(mot != NULL) mot = strtok(NULL, separat); if(mot != NULL) strcpy(result, mot); else strcpy(result, "\0"); free(phrase); return; } int get_seq_fasta(char *fic_name, int num) { FILE *fic; char string[300], buf[300]; unsigned char c; long ii; char repere[100]; int lg; char *absName; absName = (char *)malloc( sizeof(char)*(strlen(_dirname_)+strlen(fic_name)+1) ); if( strlen(_dirname_)>1 ){ sprintf(absName, "%s%s\0", _dirname_, fic_name); sprintf(fic_name, "%s", absName); } // DEBUG !!!!!!!!!! // GET_SEQ_FROM_SIM = true; if(GET_SEQ_FROM_SIM == TRUE) strcpy(fic_name, aln_fic_name); //printf("fic : %s\n", fic_name); if((fic = fopen(fic_name, "r"))==NULL) { ii = strlen(fic_name) - 1; if(fic_name[ii] == '-') fic_name[ii] = 0; if((fic = fopen(fic_name, "r"))==NULL) { /* #ifdef MACINTOSH sprintf(buf, "ERROR: impossible to open %s\n", fic_name); ShowMessage(c2pstr(buf),FALSE); #else fl_alert(stderr, "ERROR: impossible to open %s\n", fic_name); #endif */ NBBLOC = NBSEQ = 0; fl_alert("ERROR: impossible to open %s\n", fic_name); return(9); } } if(GET_SEQ_FROM_SIM == TRUE) { sprintf(repere, "# SEQUENCES BEGIN %d", num+1); lg = (int) strlen(repere); while(fgets(string, 300, fic)!= NULL) { if(strncmp(string, repere, lg) == 0) break; if(strncmp(string, "# SEQUENCES END", 15) == 0) return(12); } } fgets(string, 300, fic); if(string[0] != '>') { #ifdef MACINTOSH sprintf(buf, "ERROR: %s not in FASTA format\n", fic_name); ShowMessage(c2pstr(buf),FALSE); #else fprintf(stderr, "ERROR: %s not in FASTA format\n", fic_name); #endif return(10); } Nieme_mot(string+1, 1, " \t\n", seq[num].name); ii = 0; while( (c = (char) fgetc(fic)) != EOF) { if(c == ' ') continue; if(c == '\t') continue; if(c == '\n' || c == '\r') continue; if(c == '*') continue; if(c == '#') break; if(feof(fic) != 0) break; seq[num].seq[ii++] = c; if(ii > seq[num].lg ) { fl_alert("ERROR: sequence longer than expected"); /* #ifdef MACINTOSH sprintf(buf, "ERROR: sequence longer than expected\n"); ShowMessage(c2pstr(buf),FALSE); #else fprintf(stderr, "ERROR: sequence longer than expected\n"); #endif */ return(11); } } seq[num].seq[ii] = '\0'; fclose(fic); return(0); } /* reads alignment from LFASTA or LALIGN */ int load_data_lfasta(FILE *fic) { int ii, jj, lg, num; char string[100], fic_name[2][400]; int numbloc; float bestscore; char *aln1, *aln0; long *lis_pos, pos; bestscore = 0.0; /* get seq. info */ while(fgets(string, 100, fic)!=NULL) { num = -1; if (strncmp(string, "(A) ", 4) == 0) num = 0; else if(strncmp(string, "(B) ", 4) == 0) num = 1; if(num != -1) { Nieme_mot(string, 2, " ", fic_name[num]); ii= strlen(string) - 4; string[ii] = '\0'; for(;ii>=0; ii--) if(string[ii] == ' ') break; ii++; seq[num].lg = atoi(string+ii); } if(num == 1) break; } /* get alignment parameters */ while(fgets(string, 100, fic)!=NULL) { if(strncmp(string, " using", 6) == 0) { strcpy(sim_parameter, string); break; } } if(seq[0].lg > seq[1].lg) maxscroll = (double) seq[0].lg; else maxscroll = (double) seq[1].lg; /* alloue memoire pour les seq. */ if(seq[0].seq != NULL) free(seq[0].seq); if(seq[1].seq != NULL) free(seq[1].seq); if((seq[0].seq = (char *)calloc(seq[0].lg + 1,sizeof(char))) == NULL ) return(13); if((seq[1].seq = (char *)calloc(seq[1].lg + 1,sizeof(char))) == NULL ) { free(seq[0].seq); return(13); } /* counts number of segments */ GET_SEQ_FROM_SIM = FALSE; GET_FEAT_FROM_SIM = FALSE; while(fgets(string, 100, fic)!=NULL) { if(strstr(string, " overlap; ") != NULL) NBSEG++; if(strncmp(string, "# SEQUENCES BEGIN", 17) == 0) GET_SEQ_FROM_SIM = TRUE; if(strncmp(string, "# FEATURES BEGIN", 16) == 0) GET_FEAT_FROM_SIM = TRUE; } ii = get_seq_fasta(fic_name[0], 0); if(ii != 0) return(ii); ii = get_seq_fasta(fic_name[1], 1); if(ii != 0) return(ii); if(GET_FEAT_FROM_SIM == TRUE){ //printf("get_feature(%s);\n", _ficname_); get_feature(_ficname_); } /* recupere les positions des fragments dans le fichier */ lis_pos = (long *) check_alloc(NBSEG,sizeof(long)); rewind(fic); ii = 0; pos = ftell(fic); while(fgets(string, 100, fic)!=NULL) { if(strstr(string, " overlap; ") != NULL) lis_pos[ii++] = pos; pos = ftell(fic); } /* compte les blocs */ for(ii = 0; ii < NBSEG; ii++) { jj = compte_bloc_lfasta(ii, fic, lis_pos[ii]); if(jj < 0) {free((char *) lis_pos); return(abs(jj));} NBBLOC+= jj; } if(seq[0].bloc != NULL) free((char *) seq[0].bloc); if(seq[1].bloc != NULL) free((char *) seq[1].bloc); if(segm != NULL) free((char *) segm); seq[0].bloc = (struct BLOC *)check_alloc(NBBLOC+1,sizeof(struct BLOC)); seq[1].bloc = (struct BLOC *)check_alloc(NBBLOC+1,sizeof(struct BLOC)); segm = (struct SEG *)check_alloc(NBSEG+1,sizeof(struct SEG)); /* get blocks info */ numbloc = 0; for(ii = 0; ii < NBSEG; ii++) { jj = get_bloc_info_lfasta(ii, fic, &bestscore, &numbloc, lis_pos[ii]); if(jj < 0) {free((char *) lis_pos); return(abs(jj));} } if(seq[0].lg > seq[1].lg) LGSEQMAX = seq[0].lg; else LGSEQMAX = seq[1].lg; if(bestscore < seuil_score_sim) seuil_score_sim = bestscore; cur_seq_view = LGSEQMAX; free((char *) lis_pos); return(0); } /* fin de load_data_lfasta */ int compte_bloc_lfasta(int numseg, FILE *fic, long pos) { char string[100], buf[100]; char *aln0; char *aln1; int lgaln, nbbloc = 0, ii; /* alloue les seq. alignees: au plus, lg aln = somme des seq */ if((aln0 = (char *)calloc((seq[0].lg + seq[1].lg + 1), sizeof(char))) == NULL ) return(-13); if((aln1 = (char *)calloc((seq[0].lg + seq[1].lg + 1), sizeof(char))) == NULL ) { free(aln0); return(-13); } /* positionne en debut de fragment */ fseek(fic, pos, 0); fgets(string, 100, fic); /* recupere les seq alignees */ aln0[0] = '\0'; aln1[0] = '\0'; for(;;) { fgets(string, 100, fic); /* vide */ fgets(string, 100, fic); /* numerotation 1 */ if(strncmp(string, "----------", 10) == 0) break; fgets(string, 100, fic); /* aln0 */ Nieme_mot(string+7, 1, "\n", buf); if((int)(strlen(buf) + strlen(aln0)) > (seq[0].lg + seq[1].lg)) { free(aln0); free(aln1); return(-14); } strcat(aln0, buf); fgets(string, 100, fic); /* inter-aln */ fgets(string, 100, fic); /* aln1 */ Nieme_mot(string+7, 1, "\n", buf); if((int)(strlen(buf) + strlen(aln1)) > (seq[0].lg + seq[1].lg)) { free(aln0); free(aln1); return(-14); } strcat(aln1, buf); fgets(string, 100, fic); /* numerotation 2 */ } lgaln = strlen(aln0); for(ii = 1; ii < lgaln; ii++) { if(aln0[ii] == '-' && aln0[ii-1] != '-') nbbloc++; if(aln1[ii] == '-' && aln1[ii-1] != '-') nbbloc++; } if(aln0[lgaln-1] != '-' && aln1[lgaln-1] != '-') nbbloc++; free(aln0); free(aln1); return(nbbloc); } /* fin de compte_bloc_lfasta */ int get_bloc_info_lfasta(int segnum, FILE *fic, float *bestscore, int *numbloc, long pos) { char string[100], buf[100]; char *aln0; char *aln1; int lgaln, nbbloc = 0, ii, jj; float score; int pos_seq; long posfic; int blocnum; int deb0, deb1, cur0, cur1, nbid; int nbgap1, nbgap2, debaln; blocnum = *numbloc; /* alloue les seq. alignees: au plus, lg aln = somme des seq */ if((aln0 = (char *)calloc((seq[0].lg + seq[1].lg + 1), sizeof(char))) == NULL ) return(-13); if((aln1 = (char *)calloc((seq[0].lg + seq[1].lg + 1), sizeof(char))) == NULL ) { free(aln0); return(-13); } /* positionne en debut de fragment */ fseek(fic, pos, 0); fgets(string, 100, fic); posfic = ftell(fic); /* recupere le score */ if(strstr(string, " init:") != NULL) { if(sscanf(string, "%*s %*s %*s %*s %*s %*s %*s %*s %*s %f", &score) != 1) {free(aln0); free(aln1); return(-4);}; segm[segnum].sco = score; } else if(strstr(string, " score:") != NULL) { if(sscanf(string, "%*s %*s %*s %*s %*s %*s %*s %f", &score) != 1) {free(aln0); free(aln1); return(-4);}; segm[segnum].sco = score; } if(*bestscore < score) *bestscore = score; /* recupere les seq alignees */ aln0[0] = '\0'; aln1[0] = '\0'; segm[segnum].beg0 = seq[0].lg; segm[segnum].beg1 = seq[1].lg; for(;;) { fgets(string, 100, fic); /* vide */ fgets(string, 100, fic); /* numerotation 1 */ if(strncmp(string, "----------", 10) == 0) break; fgets(string, 100, fic); /* aln0 */ Nieme_mot(string+7, 1, "\n", buf); if((int)(strlen(buf) + strlen(aln0)) > (seq[0].lg + seq[1].lg)) { free(aln0); free(aln1); return(-14); } strcat(aln0, buf); fgets(string, 100, fic); /* inter-aln */ fgets(string, 100, fic); /* aln1 */ Nieme_mot(string+7, 1, "\n", buf); if((int)(strlen(buf) + strlen(aln1)) > (seq[0].lg + seq[1].lg)) { free(aln0); free(aln1); return(-14); } strcat(aln1, buf); fgets(string, 100, fic); /* numerotation 2 */ } /* recupere les positions de debut de segment */ fseek(fic, posfic, 0); fgets(string, 100, fic); /* vide */ fgets(string, 100, fic); /* numerotation 1 */ if((pos_seq = get_pos_seq(string, aln0)) < segm[segnum].beg0){ #ifdef DEBUG if(pos_seq<0) printf("NEGATIF : %d\n", segnum); #endif segm[segnum].beg0 = pos_seq; } fgets(string, 100, fic); /* aln0 */ fgets(string, 100, fic); /* inter-aln */ fgets(string, 100, fic); /* aln1 */ fgets(string, 100, fic); /* numerotation 2 */ if((pos_seq = get_pos_seq(string, aln1)) < segm[segnum].beg1) segm[segnum].beg1 = pos_seq; lgaln = strlen(aln0); /* recupere les positions de fin de segment */ segm[segnum].end0 = segm[segnum].beg0; for(ii=1; ii < lgaln; ii++) if(aln0[ii] != '-') segm[segnum].end0++; segm[segnum].end1 = segm[segnum].beg1; for(ii=1; ii < lgaln; ii++) if(aln1[ii] != '-') segm[segnum].end1++; deb0 = segm[segnum].beg0; deb1 = segm[segnum].beg1; cur0 = deb0; cur1 = deb1; nbid = 0; nbgap1 = nbgap2 = 0; debaln = 1; /* cherche debut du 1er bloc (cas ou l'aln debute par des gaps) */ for(jj =0; jj < lgaln; jj++) { if(aln0[jj] != '-' && aln1[jj] != '-') break; else if(aln0[jj] != '-') cur0++; else if(aln1[jj] != '-') cur1++; deb0 = cur0; deb1 = cur1; } ii = jj; if(ii == 0 ) ii = 1; /* traite le 1er residu aligne */ if(aln0[ii-1] == aln1[ii-1] && aln0[ii-1] != '-') nbid++; for(; ii < lgaln; ii++) { if(aln0[ii] != '-') cur0++; else nbgap1++; if(aln1[ii] != '-') cur1++; else nbgap2++; if(aln0[ii] == aln1[ii]) nbid++; if((aln0[ii] == '-' && aln0[ii-1] != '-') || (aln1[ii] == '-' && aln1[ii-1] != '-')) { cur0 = cur0-nbgap2; cur1 = cur1-nbgap1; seq[0].bloc[blocnum].beg = deb0; seq[1].bloc[blocnum].beg = deb1; seq[0].bloc[blocnum].end = cur0; seq[1].bloc[blocnum].end = cur1; seq[0].bloc[blocnum].sim = 100. * (float) nbid / (float)(ii - debaln - nbgap1 - nbgap2 +1); seq[1].bloc[blocnum].sim = seq[0].bloc[blocnum].sim; seq[1].bloc[blocnum].seg = seq[0].bloc[blocnum].seg = segnum+1; seq[1].bloc[blocnum].sco = seq[0].bloc[blocnum].sco = score; blocnum++; nbid = 0; nbgap1 = nbgap2 = 0; debaln = ii; /* cherche debut du bloc suivant */ for(jj = ii; jj < lgaln; jj++) { deb0 = cur0+1; deb1 = cur1+1; if(aln0[jj] != '-' && aln1[jj] != '-') break; else if(aln0[jj] != '-') cur0++; else if(aln1[jj] != '-') cur1++; } } } /* traite le dernier bloc - sauf si aln se termine par des gap*/ if(aln0[lgaln -1] != '-' && aln1[lgaln -1] != '-' ) { seq[0].bloc[blocnum].beg = deb0; seq[1].bloc[blocnum].beg = deb1; seq[0].bloc[blocnum].end = cur0-nbgap2; seq[1].bloc[blocnum].end = cur1-nbgap1; seq[0].bloc[blocnum].sim = 100. * (float) nbid / (float)(ii - debaln - nbgap1 - nbgap2 +1); seq[1].bloc[blocnum].sim = seq[0].bloc[blocnum].sim; seq[1].bloc[blocnum].seg = seq[0].bloc[blocnum].seg = segnum+1; seq[1].bloc[blocnum].sco = seq[0].bloc[blocnum].sco = score; blocnum++; } free(aln0); free(aln1); *numbloc = blocnum; return(nbbloc); } /* fin de get_bloc_info_lfasta */ int get_pos_seq(char *string, char *aln) { char buf[20]; int ii, jj, firstnum, nbgap=0; for(ii=0; ii < 80; ii++) if(string[ii] != ' ') break; for(; ii < 80; ii++) if(string[ii] == ' ') break; Nieme_mot(string, 1, " \n", buf); firstnum = atoi(buf); ii-= 8; for(jj=0; jj= 0; lg--) { if (seq[lg] == 'A' || seq[lg]== 'a') c = 'T'; else if(seq[lg] == 'T' || seq[lg]== 't') c = 'A'; else if(seq[lg] == 'U' || seq[lg]== 'u') c = 'A'; else if(seq[lg] == 'C' || seq[lg]== 'c') c = 'G'; else if(seq[lg] == 'G' || seq[lg]== 'g') c = 'C'; else c = 'N'; buf[ii++] = c; } buf[ii] = 0; strcpy(seq, buf); free(buf); } urn(13); if((seq[1].seq = (char *)calloc(seq[1].lg + 1,sizeof(char))) == NULL ) { free(seq[0].seq); return(13); } /* counts number of segments */ GET_SEQ_FROM_SIM = FALSE; GET_FEAT_FROM_SIM = FALSE; while(fgets(string, 100, fic)!=NULL) mac_pc_extras.cxx010064400004310000036000000323211024434204000147340ustar00goutbiomol00004410000024#ifdef __APPLE__ #include "seaview.h" #include #include #include // included functions extern "C" { void *memccpy(void *s1, const void *s2, int c, size_t n); char *get_prog_dir(void); void MG_FSSpecToPathname (FSSpec *myFSS, char *fname, int maxl); void PtoC(const void *in, void *out); void CtoP(const void *in, void *out); void MGinit_apple_events(SEA_VIEW *); void add_apropos(char *progname, void *data); void show_apropos(Fl_Widget *, void *); Boolean AppleEventsInstalled (); pascal OSErr MyHandleODoc (const AppleEvent *theAppleEvent, AppleEvent* reply, long handlerRefCon); pascal OSErr MyHandlePDoc (const AppleEvent *theAppleEvent, AppleEvent *reply, long handlerRefCon); pascal OSErr MyHandleOApp (const AppleEvent *theAppleEvent, AppleEvent *reply, long handlerRefCon); pascal OSErr MyHandleQApp (const AppleEvent *theAppleEvent, AppleEvent *reply, long handlerRefCon); OSErr MyGotRequiredParams (const AppleEvent *theAppleEvent); } static SEA_VIEW *view; extern void use_initial_file(SEA_VIEW *view, char *masename); extern char *get_next_help_line(void *in, char *line, int lline); #elif defined(WIN32) #include #include #include #include #include #include /* included functions */ extern "C" { void my_bell(void); void *memccpy(void *s1, const void *s2, int c, size_t n); int mysystem(const char *command); char *get_prog_dir(void); void add_to_path(char *dir); } char *MG_win32_file_chooser(const char* message, // title of dialog window const char* pattern, // optional "mase format\0*.mase\0MSF format\0*.msf\0" const char* fname, // default file name const char* defext, // default filename extension or NULL bool save, // TRUE iff output file selection int *pfilterindex); // (inout) pointer to index (from 1) in series of file types in pattern #endif void *memccpy(void *s1, const void *s2, int c, size_t n) { char *p, *q; p = (char *)s1; q = (char *)s2; while(n-- > 0) { *p = *(q++); if( *(p++) == c) return p; } return 0; } #ifdef __APPLE__ char *get_prog_dir(void) /* returns the pathname of the directory containing the running program */ { FSSpec fspec; ProcessInfoRec info; ProcessSerialNumber psn; OSErr err; static char myname[300]; char *p; info.processInfoLength = sizeof(ProcessInfoRec); info.processName = NULL; info.processAppSpec = &fspec; err = GetCurrentProcess(&psn); if(err != noErr) return NULL; err = GetProcessInformation(&psn, &info); if(err != noErr) return NULL; MG_FSSpecToPathname(&fspec, myname, sizeof(myname) ); p = strrchr(myname, ':'); if(p == NULL) return NULL; *p = 0; return myname; } void MG_FSSpecToPathname (FSSpec *myFSS, char *fname, int maxl) { FSRef myFSRef, pFSRef; FSCatalogInfo myinfo; static int anErr = noErr; char *p, *q; static char buffer[1000], name[256]; FSSpec fsspec; p = buffer; anErr = FSpMakeFSRef(myFSS, &myFSRef); while(1) { anErr = FSGetCatalogInfo(&myFSRef, kFSCatInfoParentDirID, &myinfo, NULL, &fsspec, &pFSRef); PtoC(fsspec.name, name); /* add the file or dir name to the end of buffer in reverse orientation */ q = name + strlen(name) - 1; while(q >= name) { *p = *q; q--; p++; } if(myinfo.parentDirID == fsRtParID) break; /* detect when top level is reached */ *p = ':'; p++; myFSRef = pFSRef; } *p = 0; /* invert buffer into fname */ maxl--; if(maxl > strlen(buffer)) maxl = strlen(buffer); q = buffer + maxl - 1; p = fname; while(q >= buffer) { *p = *q; q--; p++; } fname[maxl] = 0; } void PtoC(const void *in, void *out) { char *vin = (char *)in; char *vout = (char *)out; int l = *vin; if(l > 0) memcpy(vout, vin + 1, l); vout[l] = 0; } void CtoP(const void *in, void *out) { char *vout = (char *)out; int l; if(in == NULL) l = 0; else { l = strlen( (char *)in ); memcpy(vout + 1, in, l); } vout[0] = l; } void MGinit_apple_events(SEA_VIEW *v) { // long gestaltAnswer; OSErr gestaltErr, theResult; OSErr err; AEEventHandlerUPP gAEEventHandlerUPPODoc; AEEventHandlerUPP gAEEventHandlerUPPOApp; AEEventHandlerUPP gAEEventHandlerUPPPDoc; AEEventHandlerUPP gAEEventHandlerUPPQApp; Boolean aEvents; aEvents = AppleEventsInstalled(); if (aEvents) { gAEEventHandlerUPPODoc = NewAEEventHandlerUPP(MyHandleODoc); gAEEventHandlerUPPOApp = NewAEEventHandlerUPP(MyHandleOApp); gAEEventHandlerUPPPDoc = NewAEEventHandlerUPP(MyHandlePDoc); gAEEventHandlerUPPQApp = NewAEEventHandlerUPP(MyHandleQApp); err = AEInstallEventHandler (kCoreEventClass, kAEOpenDocuments, gAEEventHandlerUPPODoc,0, 0); err = AEInstallEventHandler (kCoreEventClass, kAEOpenApplication, gAEEventHandlerUPPOApp,0, 0); err = AEInstallEventHandler (kCoreEventClass, kAEPrintDocuments, gAEEventHandlerUPPPDoc,0, 0); err = AEInstallEventHandler (kCoreEventClass, kAEQuitApplication, gAEEventHandlerUPPQApp,0, 0); } view = v; } void add_apropos(char *progname, void *data) { static Fl_Menu_Item item = {"", 0, show_apropos, 0, 0}; OSStatus err; MenuRef mr; char title[256]; Str255 ptitle; const unsigned char apple_glyph[2] = "\p\024"; Fl_Sys_Menu_Bar *smb = new Fl_Sys_Menu_Bar(0,0,0,0); Fl_Menu_Item empty = {0, 0, NULL, 0, 0}; smb->menu( &empty ); // indispensable pour initialiser fl_sys_menu_bar mr = NewMenu(1, apple_glyph); InsertMenu(mr, 0); sprintf(title, "About %s", progname); CtoP(title, ptitle); err = InsertMenuItemText(mr, ptitle, 0); err = SetMenuItemRefCon(mr, 1, (UInt32) (&item)); item.user_data_ = data; } void show_apropos(Fl_Widget *w, void *data) { static Fl_Window *about = NULL; char line[100], *p; if(about == NULL) { about = new Fl_Window(600, 400, "About seaview"); Fl_Browser *br = new Fl_Browser(1, 1, about->w() - 2, about->h() - 2); about->end(); br->add(""); get_next_help_line(data, NULL, 0); get_next_help_line(data, line, sizeof(line)); if(strncmp(line, ">>>", 3) != 0) br->add(line); while(TRUE) { get_next_help_line(data, line, sizeof(line)); if(strncmp(line, ">>>", 3) == 0) break; while( (p=strchr(line,'\r')) != NULL) *p = 0; while( (p=strchr(line,'\n')) != NULL) *p = 0; br->add(line); } get_next_help_line(data, NULL, 0); } about->show(); } /***********************************************************************/ Boolean AppleEventsInstalled () { OSErr err; long result; err = Gestalt (gestaltAppleEventsAttr, &result); return (!err && ((result >> gestaltAppleEventsPresent) & 0x0001)); // return TRUE if there is no // error and the proper bit of // result is set } /***********************************************************************/ pascal OSErr MyHandleODoc (const AppleEvent *theAppleEvent, AppleEvent* reply, long handlerRefCon) { FSSpec myFSS; AEDescList docList; OSErr err; long index, itemsInList; Size actualSize; AEKeyword keywd; DescType returnedType; FSRef myFSRef; FSCatalogInfo myinfo; char masename[300]; known_format defaultformat; err = AEGetParamDesc (theAppleEvent, keyDirectObject, typeAEList, &docList); if (err) return err; err = MyGotRequiredParams (theAppleEvent); if (err) return err; err = AECountItems (&docList, &itemsInList); index = 1; err = AEGetNthPtr (&docList, index, typeFSS, &keywd, &returnedType, (Ptr) &myFSS, sizeof(myFSS), &actualSize); if (err) return err; MG_FSSpecToPathname(&myFSS, masename, sizeof(masename) ); use_initial_file(view, masename); err = AEDisposeDesc (&docList); return noErr; } /***********************************************************************/ pascal OSErr MyHandlePDoc (const AppleEvent *theAppleEvent, AppleEvent *reply, long handlerRefCon) { FSSpec myFSS; AEDescList docList; OSErr err; long index, itemsInList; Size actualSize; AEKeyword keywd; DescType returnedType; char fname[256], dirname[256]; // get the direct parameter--a descriptor list--and put it into a docList err = AEGetParamDesc (theAppleEvent, keyDirectObject, typeAEList, &docList); if (err) return err; // check for missing parameters err = MyGotRequiredParams (theAppleEvent); if (err) return err; // count the number of descriptor records in the list err = AECountItems (&docList, &itemsInList); // now get each descriptor record from the list, coerce the returned // data to an FSSpec record, and open the associated file return noErr; } /***********************************************************************/ pascal OSErr MyHandleOApp (const AppleEvent *theAppleEvent, AppleEvent *reply, long handlerRefCon) { // Ouverture de l'appli return noErr; } /***********************************************************************/ pascal OSErr MyHandleQApp (const AppleEvent *theAppleEvent, AppleEvent *reply, long handlerRefCon) { // Quitte l'appli // quitAEReceived = 1; ExitToShell(); return noErr; } /***********************************************************************/ OSErr MyGotRequiredParams (const AppleEvent *theAppleEvent) { DescType returnedType; Size actualSize; OSErr err; err = AEGetAttributePtr (theAppleEvent, keyMissedKeywordAttr, typeWildCard, &returnedType, nil, 0, &actualSize); if (err == errAEDescNotFound) // you got all the required parameters return noErr; else if (!err) // you missed a required parameter return errAEEventNotHandled; else // the call to AEGetAttributePtr failed return err; } #endif #ifdef WIN32 void add_to_path(char *dir) /* ajoute a la variable PATH la directory dir teste si deja dedans ou si vide */ { char *buffer; int l; if(dir == NULL || strlen(dir) == 0) return; buffer = (char *)malloc(10000); l = GetEnvironmentVariable("PATH", buffer, 10000); if(l == 0) *buffer = 0; //fprintf(OUT,"l=%d PATH=%s\n",l,buffer);fflush(OUT); if(strstr(buffer, dir) != NULL) return; if(*buffer != 0) strcat(buffer, ";"); strcat(buffer, dir); SetEnvironmentVariable("PATH", buffer); //GetEnvironmentVariable("PATH", buffer, sizeof(buffer)); //fprintf(OUT,"PATH=%s\n",buffer);fflush(OUT); free(buffer); } int mysystem(const char *command) /* command contains "prog.exe args" prog is searched in dir where calling program was launched, current dir, windows system dir, windows dir, dirs in PATH. */ { static char buf[100]; STARTUPINFO info; PROCESS_INFORMATION pi; int retval; GetStartupInfo(&info); //fprintf(OUT,"retour GetStartupInfo \n");fflush(OUT); retval = CreateProcess(NULL, (char *)command,0,0,0,0,0,_getcwd(buf,sizeof(buf)),&info,&pi); //fprintf(OUT,"retour CreateProcess bool retval=%d\n",retval);fflush(OUT); retval = WaitForSingleObject(pi.hProcess, INFINITE); //fprintf(OUT,"retour WaitForSingleObject retval=%d WAIT_FAILED=%d\n",retval,WAIT_FAILED);fflush(OUT); return (retval == WAIT_FAILED); } char *get_prog_dir(void) /* returns path of dir where calling program was launched */ { static char dir[100]; char *line, *p; int l; line = GetCommandLine(); //fprintf(OUT,"retour GetCommandLine line=%s\n",line);fflush(OUT); /* extract 1st word of line or first group delimited by " " */ if(*line == '"') { line++; p = strchr(line, '"'); } else p = strchr(line, ' '); if(p == NULL) p = line + strlen(line); l = p - line; while( l > 0 && line[l - 1] != '\\' ) l--; if(l <= 0) return NULL; memcpy(dir, line, l); dir[l] = 0; return dir; } void my_bell(void) { Beep(0,0); } char *MG_win32_file_chooser(const char* message, // title of dialog window const char* pattern, // optional "mase format\0*.mase\0MSF format\0*.msf\0" const char* fname, // default file name const char* defext, // default filename extension or NULL bool save, // TRUE iff output file selection int *pfilterindex) // (inout) pointer to index (from 1) in series of file types in pattern { static char filenamebuffer[MAX_PATH]; static OPENFILENAME wreq; bool retval; memset(&wreq, 0, sizeof(wreq)); wreq.lStructSize = sizeof(OPENFILENAME); wreq.lpstrFilter = pattern; if(pattern == NULL) wreq.nFilterIndex = 0; else if(pfilterindex != NULL) wreq.nFilterIndex = *pfilterindex; else wreq.nFilterIndex = 1; if(defext != NULL) wreq.lpstrDefExt = defext; wreq.lpstrFile = filenamebuffer; wreq.nMaxFile = MAX_PATH; wreq.lpstrTitle = message ? message : "Select the filename"; if(fname) { memset(filenamebuffer, 0, MAX_PATH); if((filenamebuffer[1] == ':') && (_getdrive() + 'A' - 1 == filenamebuffer[0])) strncpy(filenamebuffer, fname + 2, MAX_PATH); else strncpy(filenamebuffer, fname, MAX_PATH); } wreq.Flags = OFN_NOCHANGEDIR | OFN_HIDEREADONLY; retval = (save ? GetSaveFileName(&wreq) : GetOpenFileName(&wreq)); if(save && (pfilterindex != NULL) ) *pfilterindex = wreq.nFilterIndex; return retval == 0 ? NULL : wreq.lpstrFile; } /* char **split_args(char *all, int *pargc) { char *p, *q, **argv; int l, argc = 0; // compter les arguments p = all; while(*p != 0) { argc++; if(*p == '"') p = strchr(p+1, '"'); else p = strchr(p, ' '); if(p == NULL) break; p++; while(*p == ' ') p++; } argv = (char **)malloc(argc * sizeof(char *)); *pargc = argc; // separer les arguments, enlever les "" encadrantes si presentes p = all; argc = 0; while(*p != 0) { if(*p == '"') { p++; q = strchr(p, '"'); } else q = strchr(p, ' '); if(q == NULL) q = p + strlen(p); l = q - p; argv[argc] = (char *)malloc(l + 1); memcpy(argv[argc], p, l); argv[argc][l] = 0; if(*q == 0) break; p = q + 1; while(*p == ' ') p++; argc++; } return argv; } */ #endif zeof(line)); if(strncmp(line, ">>>", 3) != 0) br->add(line); while(TRUE) { get_next_help_line(data, line, sizeof(line)); if(strncmp(line, ">>>", 3) == 0) break; while( (p=strchr(line,'\r')) != NULL) *p = 0; while( (p=strchr(line,'\n')) != NULL) *p = 0; br->add(line); } get_next_help_linemacextras.cxx010064400004310000036000000062011024245160200141140ustar00goutbiomol00004410000024#ifdef __APPLE__ #include extern "C" { void CtoP(const void *in, void *out); void PtoC(const void *in, void *out); void MG_FSSpecToPathname (FSSpec *myFSS, char *fname, int maxl); } int MG_GetInputFName(char *fname, int maxl, char *title); char* fl_file_chooser(const char* message, const char* pat, const char* fname, int relative=0); void PtoC(const void *in, void *out) { char *vin = (char *)in; char *vout = (char *)out; int l = *vin; if(l > 0) memcpy(vout, vin + 1, l); vout[l] = 0; } void CtoP(const void *in, void *out) { char *vout = (char *)out; int l; if(in == NULL) l = 0; else { l = strlen( (char *)in ); memcpy(vout + 1, in, l); } vout[0] = l; } void MG_FSSpecToPathname (FSSpec *myFSS, char *fname, int maxl) { FSRef myFSRef, pFSRef; FSCatalogInfo myinfo; static int anErr = noErr; char *p, *q; static char buffer[1000], name[256]; FSSpec fsspec; p = buffer; anErr = FSpMakeFSRef(myFSS, &myFSRef); while(1) { anErr = FSGetCatalogInfo(&myFSRef, kFSCatInfoParentDirID, &myinfo, NULL, &fsspec, &pFSRef); PtoC(fsspec.name, name); /* add the file or dir name to the end of buffer in reverse orientation */ q = name + strlen(name) - 1; while(q >= name) { *p = *q; q--; p++; } if(myinfo.parentDirID == fsRtParID) break; /* detect when top level is reached */ *p = ':'; p++; myFSRef = pFSRef; } *p = 0; /* invert buffer into fname */ maxl--; if(maxl > strlen(buffer)) maxl = strlen(buffer); q = buffer + maxl - 1; p = fname; while(q >= buffer) { *p = *q; q--; p++; } fname[maxl] = 0; } static pascal void MyNavEventProc (NavEventCallbackMessage callBackSelector, NavCBRecPtr callBackParms, NavCallBackUserData callBackUD) { return; } int MG_GetInputFName(char *fname, int maxl, char *title) { NavEventUPP eventProc = NewNavEventUPP(MyNavEventProc); OSErr anErr = noErr; FSSpec fss; int rsult = FALSE; NavReplyRecord reply; NavDialogOptions options; NavGetDefaultDialogOptions(&options); CtoP(title, options.windowTitle); options.dialogOptionFlags &= ~ kNavAllowPreviews; options.dialogOptionFlags &= ~ kNavAllowMultipleFiles; options.dialogOptionFlags |= kNavNoTypePopup; anErr = NavChooseFile (NULL , &reply, &options, eventProc, NULL, NULL, NULL , 0); if (anErr == noErr && reply.validRecord) { AEKeyword theKeyword; DescType actualType; Size actualSize; FSSpec documentFSSpec; anErr = AEGetNthPtr(&(reply.selection), 1, typeFSS, &theKeyword, &actualType,&documentFSSpec, sizeof(documentFSSpec), &actualSize); if (anErr == noErr) { MG_FSSpecToPathname (&documentFSSpec, fname, maxl); rsult = TRUE; } // Dispose of NavReplyRecord, resources, descriptors anErr = NavDisposeReply(&reply); } DisposeNavEventUPP(eventProc); return rsult; } char* fl_file_chooser(const char* message, const char* pat, const char* fname, int relative) { static char pathname[FL_PATH_MAX]; int ok; ok = MG_GetInputFName(pathname, FL_PATH_MAX, (char *)message); if( ok ) return pathname; else return NULL; } #endif resource.cxx010064400004310000036000000114021025153265400137620ustar00goutbiomol00004410000024#include #include #include #include #include "resources.H" #if defined(__APPLE__) extern "C" { extern void PtoC(const void *in, void *out); extern void CtoP(const void *in, void *out); } char *load1res(char *resname) { char **h, *p, pname[256]; int l; CtoP(resname, pname); h = GetNamedResource('TEXT', (ConstStr255Param)pname ); if(h == NULL) return NULL; else { l = GetHandleSize(h); p = (char *)malloc(l + 1); } if(p != NULL) { HLock(h); memcpy(p, *h, l); HUnlock(h); p[l] = 0; if(p[--l] == '\r') p[l] = 0; } ReleaseResource(h); return p; } void *load_resources(char *progname) { return NULL; } char *get_res_value(char *name, char *def_value, void *v_db) { char *p; p = load1res(name); if(p != NULL) return p; else return def_value; } int set_res_value(const char *name, const char *value) /* returns 0 iff no error */ { Str255 pname; Handle h; short id; OSErr err; int l; CtoP(name, pname); l = strlen(value); h = GetNamedResource('TEXT', pname); if(h == NULL) { // resource not yet exists if(ResError() != resNotFound) return 1; id = Unique1ID('TEXT'); h = NewHandle(l); if(h == NULL) return 1; HLock(h); memcpy(*h, value, l); HUnlock(h); AddResource(h, 'TEXT', id, pname); if( ResError() != noErr) return 1; } else {// resource already exists if(l == GetHandleSize(h)) { HLock(h); err = memcmp(*h, value, l); HUnlock(h); if(err == 0) return 0; // same value already, stop here } SetHandleSize(h, l); if( MemError() != noErr) return 1; HLock(h); memcpy(*h, value, l); HUnlock(h); ChangedResource(h); if( ResError() != noErr) return 1; } ReleaseResource(h); err = ResError(); return err != noErr ; } int save_resources(void) { // nothing to do, taken care of by the system } #else /* for X11 and win32 */ typedef struct _item { struct _item *before; char *name; char *value; struct _item *next; } item; static item *firstitem = NULL; extern "C" { char *get_prog_dir(void); } char *res_filename(void) { static char fname[FILENAME_MAX]; char *p; #ifdef WIN32 p = get_prog_dir(); if(p == NULL) return NULL; strcpy(fname, p); strcat(fname, "\\lalnview.ini"); #else p = getenv("HOME"); if(p == NULL) return NULL; strcpy(fname, p); strcat(fname, "/.lalnviewrc"); FILE * nf = fopen(fname, "r"); if(nf){ fclose(nf); return fname; } char test1[FILENAME_MAX]; strcpy(test1, p); strcat(test1, "lalnview.help"); nf = fopen(test1, "r"); if(nf){ fclose(nf); return test1; } char test2[FILENAME_MAX]; strcpy(test2, "lalnview.help"); nf = fopen(test2, "r"); if(nf){ fclose(nf); return test2; } #endif return fname; } void *load_resources(char *progname) { FILE *in; char *fname, *p, line[500]; item *elt, *last = NULL; fname = res_filename(); if(fname == NULL) return NULL; in = fopen(fname, "r"); if(in == NULL) return NULL; while((p = fgets(line, sizeof(line), in)) != NULL) { p = strchr(line, '\n'); if(p != NULL) *p = 0; p = strchr(line, '='); if(p == NULL) continue; *(p++) = 0; while(isspace(*p)) p++; if(*p == 0) continue; elt = (item *)malloc(sizeof(item)); if(elt == NULL) break; elt->name = strdup(line); elt->value = strdup(p); if(elt->name == NULL || elt->value == NULL) break; if(last != NULL) last->next = elt; else firstitem = elt; elt->before = last; last = elt; elt->next = NULL; } fclose(in); return firstitem; } char *get_res_value(char *name, char *def_value, void *v_db) { if(v_db == NULL) return def_value; item *elt = (item *)v_db; while(elt != NULL) { if(strcmp(name, elt->name) == 0) return elt->value; elt = elt->next; } return def_value; } int set_res_value(const char *name, const char *value) { item *elt, *last = NULL; elt = firstitem; while(elt != NULL) { if(strcmp(elt->name, name) == 0) { free(elt->value); elt->value = strdup(value); return 0; } last = elt; elt = elt->next; } elt = (item *)malloc(sizeof(item)); if(elt == NULL) return 1; elt->name = strdup(name); elt->value = strdup(value); if(elt->name == NULL || elt->value == NULL) return 1; if(last != NULL) last->next = elt; else firstitem = elt; elt->before = last; elt->next = NULL; return 0; } int save_resources(void) { char *fname; item *elt; FILE *out; fname = res_filename(); if(fname == NULL) return 1; out = fopen(fname, "w"); if(out == NULL) return 1; elt = firstitem; while(elt != NULL) { fprintf(out, "%s=%s\n", elt->name, elt->value); elt = elt->next; } fclose(out); return 0; } #endif int int_res_value(char *name, int def_value, void *v_db) { int val = def_value; char *p = get_res_value(name, NULL, v_db); if( p != NULL ) sscanf(p, "%d", &val); return val; } int bool_res_value(char *name, int def_value, void *v_db) { char *p = get_res_value(name, NULL, v_db); if( p == NULL ) return def_value; return (*p == 'T' || *p == 't'); } MF_About.H010064400004310000036000000011101023340313000131310ustar00goutbiomol00004410000024/* MF_About.H */ #ifndef _MFABOUTH_ #define _MFABOUTH_ #include #include #include #include /* The MF_About class displays a window containing the information of the 'about' menu. */ class MF_AboutText : public Fl_Widget { public: MF_AboutText(int x, int y, int w, int h); void draw(void); private: Fl_Button * bt_; }; class MF_About : public Fl_Window { public: MF_About(int x, int y, int w, int h); private: MF_AboutText * tin_; }; void ok_cb(Fl_Widget *w); #endif MF_BestSeries.H010064400004310000036000000011151023340303400141370ustar00goutbiomol00004410000024/* MF_BestSeries.H */ #ifndef _MF_BESTSERIESH_ #define _MF_BESTSERIESH_ #include "stdio.h" #include "stdlib.h" #include "string.h" #include #include #include #include class MF_BestSeries : public Fl_Widget { public: MF_BestSeries(int x, int y, int w, int h); void draw(void); int isChecked(void); int getMarg(void); private: int posx_; char * txt_; Fl_Check_Button * chk_; Fl_Int_Input * input_; }; void chk_cb(Fl_Widget *w); void input_cb(Fl_Widget *w); #endif MF_Echelle.H010064400004310000036000000015561025132404400134440ustar00goutbiomol00004410000024/* MF_Echelle.H */ #ifndef _MF_ECHELLEH_ #define _MF_ECHELLEH_ #include #include #include #include #include #include #include #include #include #include #include "pdflib.h" #include "globals.h" #include "lalnview.h" class MF_Echelle : public Fl_Widget{ void draw(void); int handle(int event); public : FL_EXPORT MF_Echelle(int x, int y, int w, int h, int larg, int taille_inter, int taille1); void handle_push(void); void myResize(int xx, int yy, int ww, int hh); void drawPDF(PDF *p, int _DECX_, int _DECY_); private : int larg_; int sizeText_; int sizeTitre_; int taille_inter_; int taille1_; int leftBeg_; }; #endif MF_FeatDisplay.H010064400004310000036000000012721024012204000142710ustar00goutbiomol00004410000024/* MF_FeatDisplay.H */ #ifndef _MF_FEATDISPLAH_ #define _MF_FEATDISPLAH_ #include #include #include #include #include #include #include #include #include #include #include #include #include "globals.h" #include "lalnview.h" class MF_FeatDisplay : public Fl_Text_Editor { public : FL_EXPORT MF_FeatDisplay(int x, int y, int w, int h); void afficheFeat(int *tab, int nb); void raz(void); private : Fl_Text_Buffer * buf_; }; #endif MF_Globals.H010064400004310000036000000004011022075046000134530ustar00goutbiomol00004410000024/* MF_Globals.H */ #ifndef _MF_GLOBALS_H_ #define _MF_GLOBALS_H_ static class MF_Globals { public: static float getRapport(){return rapport_;} static void setRapport(float r){rapport_=r;}; private : static float rapport_; }; #endif MF_MainWindow.H010064400004310000036000000033041024340260400141500ustar00goutbiomol00004410000024#ifndef _MF_MAINWINDOW_H_ #define _MF_MAINWINDOW_H_ #include #include #include #include "MF_MyScroll.H" #include "MF_Echelle.H" #include "MF_Name.H" #include "MF_About.H" #include "MF_Zoomer.H" #include "MF_ScoMinChooser.H" #include "MF_ParcBloc.H" #include "MF_Stats.H" #include "MF_FeatDisplay.H" #include "MF_BestSeries.H" class MF_MainWindow : public Fl_Window { public : MF_MainWindow(int x, int y, int w, int h, const char * lbl); void addMenu(void); void about(void); void clearAbout(void); void actuName(void); void updatePanel(void); void fullUpdatePanel(void); void activerParcBloc(void); void desactiverParcBloc(void); void bestFirst(int); int bestFirst(void); int bestSeries(void); void setMins(void); void listMenuItems(void); Fl_Menu_Bar * getMenuBar(void); const Fl_Menu_Item * getMenuItems(void); MF_MyScroll * getScroll(void); MF_Name * getName(void); MF_Zoomer * getZoomer(void); MF_ParcBloc * getParcBloc(void); MF_Stats * getStats(void); MF_FeatDisplay * getFeatDisp(void); MF_BestSeries * getBestSeries(void); MF_Echelle * getScale(void); MF_ScoMinChooser * getScoMinC(void); private : Fl_Menu_Bar * menu_; MF_About * about_; MF_Echelle * scale_; MF_Name * name_; MF_MyScroll * myScroll_; MF_ScoMinChooser * scoMinC_; MF_ScoMinChooser * identityMinC_; MF_ScoMinChooser * lenghtMinC_; MF_ParcBloc * parcBloc_; MF_Zoomer * zoomer_; MF_Stats * stats_; MF_FeatDisplay * featDisp_; MF_BestSeries * bestSeries_; Fl_Scroll * btGrp_; Fl_Group * grpName_; int bestFirst_; }; #endif MF_MyScroll.H010064400004310000036000000024411025130343000136350ustar00goutbiomol00004410000024/* MF_MyScroll.H */ #ifndef _MF_MYSCROLLH_ #define _MF_MYSCROLLH_ #include #include "MF_Sequence.H" #include "MF_MyScrollbar.H" #include "bmp.H" class MF_MyScroll : public Fl_Group { public : MF_MyScroll(int x, int y, int w , int h); void draw(void); void fillSeg(SEG s); void drawSegLines(SEG s); void myResize(int x, int y, int w, int h); void loadSequences(void); void initSegIdentity(void); void reAlign(void); void reCalibrate(int pos); void zoomWhole(void); int getFullSize(void); double shift(void); void fullUpdate(void); void setLasts(int lastSeqClicked, int lastBlocClicked); int getLastSegment(void); int getLastSeq(void); int getLastBloc(void); void captToBmp(char *file); void exportPDF(char *fileName, int all); void drawPDF(PDF *p, int _DECX_, int _DECY_, int all); void fillSegPDF(PDF *p, SEG s, int _DECX_, int _DECY_, double red, double green, double blue, int all); void drawSegLinesPDF(SEG s, PDF *p, int decx, int decy, int all); MF_MyScrollbar * getScrollbar(void); MF_Sequence * getSequence(int numSeq); private : MF_Sequence * seq_[2]; MF_MyScrollbar * scrolb_; int scrolbH_; int seqLarg_; int lastSeqClicked_; int lastBlocClicked_; }; #endif MF_MyScrollbar.H010064400004310000036000000004401023544443400143330ustar00goutbiomol00004410000024/* MF_MyScrollbar.H */ #ifndef _MF_MYSCROLLBARH_ #define _MF_MYSCROLLBARH_ #include class MF_MyScrollbar : public Fl_Scrollbar { public : MF_MyScrollbar(int x, int y, int w, int h); void dessine(void); void pos(int val); private: }; #endif MF_Name.H010064400004310000036000000007401023544614400127650ustar00goutbiomol00004410000024/* MF_Name.H */ #ifndef _MF_NAMEH_ #define _MF_NAMEH_ #include #include #include #include "globals.h" #include "lalnview.h" class MF_Name : public Fl_Widget { public: FL_EXPORT MF_Name(int x, int y, int w, int h, int y0, int y1, int fsize); void draw(void); void yText(int y0, int y1); int getX(void); int getW(void); void myW(int w); private: int yText_[2]; int fsize_; }; #endif MF_Next.H010064400004310000036000000005601024455406400130240ustar00goutbiomol00004410000024/* MF_NextBloc.H */ #ifndef _MF_NEXT_BLOCH_ #define _MF_NEXT_BLOCH_ #include #include #include "globals.h" #include "lalnview.h" #include "MF_Text.H" class MF_Next : public Fl_Button { public : FL_EXPORT MF_Next(int sens, int x, int y, int w, int h, char *lbl); int sens(); private : int sens_; }; #endif MF_ParcBloc.H010064400004310000036000000012571023566010000135640ustar00goutbiomol00004410000024/* MF_ParcBloc.H */ #ifndef _MF_PARC_BLOCH_ #define _MF_PARC_BLOCH_ #include #include "globals.h" #include "lalnview.h" //#include "MF_Text.H" #include "MF_Next.H" class MF_ParcBloc : public Fl_Widget { public : FL_EXPORT void draw(void); MF_ParcBloc(int x, int y, int w, int h); void setCurrentBloc(int curBloc, int nbBloc); void desactiver(); void activer(); private : MF_Next * btPrev_; MF_Next * btNext_; int btNextX_, btNextY_, btNextW_, btNextH_; int btPrevX_, btPrevY_, btPrevW_, btPrevH_; int decY_; int fsize_; int curBloc_; int nbBloc_; char txt_[32]; }; void MF_NextBloc_cb(Fl_Widget *w); #endif MF_Preferences.H010064400004310000036000000000301024336531400143340ustar00goutbiomol00004410000024/* MF_Preferences */ MF_Pub.H010064400004310000036000000006301023316347400126310ustar00goutbiomol00004410000024/* MF_Pub.H */ /* MF_Pub is a very small class wich is simply used to display the text "LALNVIEW" in the main pannel while no sequence is loaded. */ #ifndef _MF_PUBH_ #define _MF_PUBH_ #include #include #include class MF_Pub : public Fl_Widget { public: MF_Pub(int x, int y, int w, int h); void draw(void); private: }; #endif MF_ScoMinChooser.H010064400004310000036000000012471023340236000146110ustar00goutbiomol00004410000024/* MF_ScoMinChooser.H */ #ifndef _MF_SCO_MIN_CHOOSER_ #define _MF_SCO_MIN_CHOOSER_ #include #include #include "lalnview.h" #include "globals.h" class MF_ScoMinChooser : public Fl_Widget { FL_EXPORT void draw(void); public: MF_ScoMinChooser(int type, int x, int y, const char * txt, int fsize); void setValue(char *val); private: Fl_Float_Input * flip_; char * txt_; int fsize_; int txtLeftMarg_, fLeftMarg_, fRightMarg_, topMarg_; int type_; }; void MF_ScoMinChooser_score_cb(Fl_Widget *w); void MF_ScoMinChooser_lenght_cb(Fl_Widget *w); void MF_ScoMinChooser_identity_cb(Fl_Widget *w); #endif MF_SecWindow.H010064400004310000036000000007301023760631000140010ustar00goutbiomol00004410000024/* MF_SecWindow.H */ #ifndef _MF_SECWINDOWH_ #define _MF_SECWINDOWH_ #include #include #include #include "globals.h" #include "lalnview.h" #include "MF_Text.H" class MF_SecWindow : public Fl_Window { public: FL_EXPORT MF_SecWindow(int x, int y, int w, int h, char * lbl); void raz(void); void update(void); void afficheBloc(int numbloc, int numSeq); private: MF_Text * t_; }; #endif MF_Sequence.H010064400004310000036000000022041025125731000136430ustar00goutbiomol00004410000024/* MF_Sequence.H */ #ifndef _MF_SEQUENCEH_ #define _MF_SEQUENCEH_ #include #include #include "pdflib.h" #include "globals.h" #include "lalnview.h" class MF_Sequence : public Fl_Widget { public : FL_EXPORT MF_Sequence(int id, int x, int y, int w, int h, int leftMarg, int seqH); FL_EXPORT void draw(void); void drawFeat(struct FEATURE f, int posy, int firstBase, double rapport); void drawPDF(PDF *p, int decx, int decy, int all); void drawFeatPDF(PDF *p, struct FEATURE f, int posy, int firstBase, double rapport, int _DECX_, int _DEXY_); int handle(int e); void handle_push(void); int clickOnFeat(int cy); void displayFeat(int cx, int numBase); void clickOnSequence(int cx); void loadTabClicked(int base); void showNextBloc(void); void showPrevBloc(void); void loadTab(void); int leftMarg(void); int seqY(void); void leftMarg(int leftMarg); private : int numSeq_; int seqY_; int seqH_; int leftMarg_; int topFeat_; int downFeat_; int * tabBloc_; int nbBloc_; int lastBloc_; int * tabShown_; }; #endif MF_Stats.H010064400004310000036000000010231023566370000131750ustar00goutbiomol00004410000024/* MF_Stats.H */ #ifndef _MF_STATSH_ #define _MF_STATSH_ #include #include #include #include "globals.h" #include "lalnview.h" #include "MF_Text.H" class MF_Stats : public Fl_Widget { void draw(void); public : MF_Stats(int x, int y, int w, int h); void afficher(int lg, float score, float ident, float gapf); private : int lg_; int fsize_; float score_; float ident_; float gapf_; char l1_[512]; char l2_[512]; }; #endif MF_Text.H010064400004310000036000000015031023760554000130260ustar00goutbiomol00004410000024/* MF_Text.H */ /* The MF_Text class deals with the displaying of the sequences in full text in the second window. */ #ifndef _MF_TEXTH_ #define _MF_TEXTH_ #include #include #include #include #include #include #include #include #include #include #include #include "globals.h" #include "lalnview.h" class MF_Text : public Fl_Text_Display { public : FL_EXPORT MF_Text(int x, int y, int w, int h); void raz(void); void afficheBloc(int numbloc, int numSeq); Fl_Text_Buffer * buf_; private : float ident_; float gapf_; int lgaln_; int numbloc_; int numseg_; }; #endif MF_Values.H010064400004310000036000000013521024330716400133410ustar00goutbiomol00004410000024/* MF_Values.H */ #ifndef _VALUES_H_ #define _VALUES_H_ #include class MF_Values { private : static float scoMin_; static float identityMin_; static int lenghtMin_; static double rapport_; static int SEQSPACE_; static char * srcFile_; public : static float scoMin(void); static float identityMin(void); static int lenghtMin(void); static double rapport(void); static int SEQSPACE(void); static char *srcFile(void); static void scoMin(float scoMin); static void identityMin(float identityMin); static void lenghtMin(int lenghtMin); static void rapport(double rapport); static void SEQSPACE(int SEQSPACE); static void srcFile(char *srcFile); }; #endif MF_Zoomer.H010064400004310000036000000016441024464400000133530ustar00goutbiomol00004410000024/* MF_Zoomer.H */ #ifndef _MF_ZOOMERH_ #define _MF_ZOOMERH_ #include #include #include "globals.h" #include "lalnview.h" #include "MF_Text.H" #include "MF_Next.H" #define IMAGESIZE 6301 /* class MF_Zoomer Displays a box containing the two buttons used for the zoom. */ class MF_Zoomer : public Fl_Widget { public : FL_EXPORT void draw(void); MF_Zoomer(int x, int y, int w, int h); void desactiver(); void activer(); int getZoom(void); void flip(Fl_Button * b); Fl_Pixmap *imgPlus_; Fl_Pixmap * imgMinus_; Fl_Pixmap * imgPlusA_; Fl_Pixmap * imgMinusA_; private : MF_Next * btMore_; MF_Next * btLess_; Fl_Button * btWhole_; int btLessX_, btLessY_, btLessW_, btLessH_; int btMoreX_, btMoreY_, btMoreW_, btMoreH_; int decY_; int fsize_; }; void button_cb(Fl_Widget *w); void btWhole_cb(Fl_Widget *w); #endif MenuCb.H010064400004310000036000000021711024554001400126640ustar00goutbiomol00004410000024/* MenuCb.H */ #ifndef _MENUCBH_ #define _MENUCBH_ #include "lalnview_utils.H" #include "lalnview.h" #include "globals.h" #include "MF_MainWindow.H" #define _MENU_BEST_ 14 #define _MENU_WORSE_ 15 #define GREEN_ADD 18 #define GREEM_RMV 19 #define RED_ADD 23 #define RED_RMV 24 void open_cb(); void close_cb(); void open_features_cb(); void save_bmp_cb(void); void export_PDF_cb(void); void save_scale_cb(); void load_scale_cb(); void bestScore_cb(); void worseScore_cb(); void save_aln_cb(); void save_aln_proc(FILE * fic); void greenListAdd_cb(void); void greenListRemove_cb(void); void greenListErase_cb(void); void redListAdd_cb(void); void redListRemove_cb(void); void redListErase_cb(void); void about_cb(); void help_callback(Fl_Widget *ob, void *data); void browser_ok_callback(Fl_Widget *ob, long which); void browser_titres_callback(Fl_Widget *ob, void *data); char *get_next_help_line(void *in, char *line, int lline); #ifdef __APPLE__ char *read_next_help_line(char *line, int lline, void *v_in); #else #define read_next_help_line(a,b,c) fgets(a,b,(FILE *)c) #endif #endif bmp.H010064400004310000036000000015171024534277000123050ustar00goutbiomol00004410000024#ifndef _BMP_H_ #define _BMP_H_ #include #include #include #include #include typedef struct { char bfType[2]; unsigned char bfSize[4]; unsigned char bfReserved1[2]; unsigned char bfReserved2[2]; unsigned char bfOffBits[4]; } bmfh; typedef struct { unsigned char biSize[4]; unsigned char biWidth[4]; unsigned char biHeight[4]; unsigned char biPlanes[2]; unsigned char biBitCount[2]; unsigned char stuff1[16]; unsigned char biClrUsed[4]; unsigned char biClrImportant[4]; } bmih; static int charArray2Int(unsigned char * b, int s, int f); static void int2bytes2(unsigned char * bytes, int value); static void int2bytes4(unsigned char * bytes, int value); int saveBMP( uchar * pic, int width, int height, char * filename); #endif dijkstra.H010064400004310000036000000004471023340332000133250ustar00goutbiomol00004410000024/* disjkstra.H */ #ifndef _DIJKSTRAH_ #define _DIJKSTRAH_ #include "lalnview.h" #include "globals.h" bool chevauchent(int i, int j); int fcmp1(const void *s1, const void *s2); void relacher(int f, int g); void dijkstra(); bool respect(int i); void afficheSegm(int i); #endif init.H010064400004310000036000000004161025236170600124650ustar00goutbiomol00004410000024/* init.H */ #ifndef _INIT_H_ #define _INIT_H_ #ifdef __APPLE__ void initSrc(void); char * getResValue(char *name); char *load1res(char *resname); #else void initSrc(void); char * configFile(void); char * getSrcValue(char *var); #endif #endif lalnview_utils.H010064400004310000036000000013451024435600400145610ustar00goutbiomol00004410000024/* lalnview_utils.H */ #ifndef _LALNVIEW_UTILSH_ #define _LALNVIEW_UTILSH_ #include "lalnview.h" #include "globals.h" #include "MF_MyScroll.H" Fl_Color getColor(char *col); int saveColorScale(char *fic); int loadColorScale(char *fic); char *check_alloc(int nbrelt, int sizelt); int fcmpSeg(const void * s1, const void *s2); int fcmpBloc(const void *b1, const void *b2); void scrolb_cb(Fl_Widget * w); void trier(void); void afficherSegm(int i); void displayBloc(BLOC b); void listeBloc(int ns); void listeSegm(void); void tribulle(SEG *tab, int n); void echange(SEG *tab, int i, int j); bool isDrawable(SEG s, float scoMin, float identityMin, int lenghtMin, int bck, int onlyGreen, int onlyRed); #endif resources.H010064400004310000036000000006331024303115000135200ustar00goutbiomol00004410000024/* resources.H */ #ifndef _RESOURCES_H_ #define _RESOURCES_H_ // included functions void *load_resources(char *progname); char *get_res_value(char *name, char *def_value, void *v_db); int int_res_value(char *name, int def_value, void *v_db); int bool_res_value(char *name, int def_value, void *v_db); int set_res_value(const char *name, const char *value); int save_resources(void); #endif xpms.H010064400004310000036000000211621024464370400125140ustar00goutbiomol00004410000024/* Images in the xpm format */ #ifndef _XPMS_H_ #define _XPMS_H_ static char * matrixPlus[] = { "40 35 25 1\0", " c None\0", ". c #000000\0", "+ c #DEDEDE\0", "@ c #F7F7F7\0", "# c #EFEFEF\0", "$ c #CECECE\0", "% c #848484\0", "& c #ADADAD\0", "* c #C6C6C6\0", "= c #E7E7E7\0", "- c #9C9C9C\0", "; c #8CADAD\0", "> c #D6D6D6\0", ", c #949494\0", "' c #E7F7F7\0", ") c #A5A5A5\0", "! c #7B7B7B\0", "~ c #8C8C8C\0", "{ c #B5B5B5\0", "] c #4AD694\0", "^ c #ADE7CE\0", "/ c #29A563\0", "( c #CEBDA5\0", "_ c #7B6B52\0", ": c #B59C84\0", " \0", " \0", " .... \0", " ..++++.. \0", " @# ..++++++++.. \0", " @#+$%.++++....++++. \0", " #$&%%.++..****..+++. \0", " =-%%.++.;;....**.++. \0", " #>%%..++.;;;;;;..*.++. \0", " @>,%%.++.;;;;;;;;.*.++. \0", " =&%%%.++.''';;;;;;.*.++. \0", " @>)%%..++.'''';;;;;.*.++. \0", " #*,%%..++.''''';;;;.*.++. \0", " =&%%%.*.++.'''';;;;.*.++. \0", " +-%%%.*.++.'''';;;;;.++. \0", " +-%%!%.*.++.''';;;;;.++. \0", " #&~%%%.*.+++..'';;..++. \0", " @$-%%!%.*.++++....++++. \0", " ={,%%%%.*..++++++++..+. \0", " @=+....%%.**..++++...*++. \0", " @>&.]^^^.%%..**.....% .*++.. \0", " =&%./]]^.%%%%....%%%%% .*.((. \0", " +-%./]]^.%%%%!!~>>-%%%%%._::(. \0", " +-%./]]^.&)&{*>=@@>)%%%%._:::(. \0", "+...../]]^.....#@ #*-%%%%._:::(. \0", ".]^^^^]]]]^^^^^. @+{~%%%%._:::(. \0", "./]]]]]]]]]]]]^. #>)%%%%%._:::(. \0", "./]]]]]]]]]]]]^. #>)%%%%%._:::(. \0", "./////]]]]////]. #>)%%%%%._:::(. \0", "%...../]]^..... @>-%%%%%._::(. \0", "--,%%./]]^.-&>@ #>)%%%%%.__. \0", "++*,%./]]^.+=@ @>-%%%%%.. \0", " +-%./]]^. #>-~%-# \0", " +-%.///]. #$&{>@ \0", " =&%%.... #==@ \0" }; static char * matrixMinus[] = { "41 34 25 1", " c None", ". c #000000", "+ c #DEDEDE", "@ c #EFEFEF", "# c #F7F7F7", "$ c #848484", "% c #CECECE", "& c #C6C6C6", "* c #ADADAD", "= c #8CADAD", "- c #9C9C9C", "; c #E7E7E7", "> c #D6D6D6", ", c #949494", "' c #E7F7F7", ") c #A5A5A5", "! c #7B7B7B", "~ c #8C8C8C", "{ c #B5B5B5", "] c #CEBDA5", "^ c #B59C84", "/ c #7B6B52", "( c #ADE7CE", "_ c #4AD694", ": c #29A563", " ", " .... ", " ..++++.. ", " ..++++++++.. @# ", " .++++....++++.$%+@# ", " .+++..&&&&..++.$$*%@ ", " .++.&&....==.++.$$-; ", " .++.&..======.++..$$>@ ", " .++.&.========.++.$$,># ", " .++.&.======'''.++.$$$*; ", " .++.&.=====''''.++..$$)># ", " .++.&.===='''''.++..$$,&@ ", " .++.&.====''''.++.&.$$$*; ", " .++.=====''''.++.&.$$$-+ ", " .++.====='''.++.&.$!$$-+ ", " .++..==''..+++.&.$$$~*@ ", " .++++....++++.&.$!$$-%# ", " .+..++++++++..&.$$$$,{; ", " .++&...++++..&&.$$$$~*># ", " ..++&. $.....&&..$$$$$)># ", " .]].&. $$$$$....$$$$$$)># ", " .]^^/.$$$$$->>~!!$$$$~*># ", " .]^^^/.$$$$)>##;>&{*)*>;# ", " .]^^^/.$$$$-&@ #@..............+;# ", " .]^^^/.$$$$~{+# .(((((((((((((_.*> ", " .]^^^/.$$$$$)>@ .(____________:.$* ", ".]^^^/.$$$$$)>@ .(____________:.$- ", "]^^^/.$$$$$)>@ ._:::::::::::::.$- ", "]^^/.$$$$$-># ..............$$* ", ".//.$$$$$)>@ #>*------------*> ", " ..$$$$$-># #;++++++++++++;# ", " @-$~->@ ", " #>{*%@ ", " #;;@ " }; static char * loupe_plus_active[] = { "40 35 26 1", " c None", ". c #000000", "+ c #DEDEDE", "@ c #F7F7F7", "# c #EFEFEF", "$ c #CECECE", "% c #848484", "& c #ADADAD", "* c #C6C6C6", "= c #E7E7E7", "- c #9C9C9C", "; c #8CADAD", "> c #D6D6D6", ", c #949494", "' c #E7F7F7", ") c #A5A5A5", "! c #7B7B7B", "~ c #8C8C8C", "{ c #B5B5B5", "] c #4AD694", "^ c #ADE7CE", "/ c #29A563", "( c #F4071B", "_ c #CEBDA5", ": c #7B6B52", "< c #B59C84", " ", " ", " .... ", " ..++++.. ", " @# ..++++++++.. ", " @#+$%.++++....++++. ", " #$&%%.++..****..+++. ", " =-%%.++.;;....**.++. ", " #>%%..++.;;;;;;..*.++. ", " @>,%%.++.;;;;;;;;.*.++. ", " =&%%%.++.''';;;;;;.*.++. ", " @>)%%..++.'''';;;;;.*.++. ", " #*,%%..++.''''';;;;.*.++. ", " =&%%%.*.++.'''';;;;.*.++. ", " +-%%%.*.++.'''';;;;;.++. ", " +-%%!%.*.++.''';;;;;.++. ", " #&~%%%.*.+++..'';;..++. ", " @$-%%!%.*.++++....++++. ", " ={,%%%%.*..++++++++..+. ", " @=+....%%.**..++++...*++. ", " @>&.]^^^.%%..**.....% .*++.. ", " =&%./((^.%%%%....%%%%% .*.__. ", " +-%./((^.%%%%!!~>>-%%%%%.:<<_. ", " +-%./((^.&)&{*>=@@>)%%%%.:<<<_. ", "+...../((^.....#@ #*-%%%%.:<<<_. ", ".]^^^^((((^^^^^. @+{~%%%%.:<<<_. ", "./((((((((((((^. #>)%%%%%.:<<<_. ", "./((((((((((((^. #>)%%%%%.:<<<_. ", "./////((((////]. #>)%%%%%.:<<<_. ", "%...../((^..... @>-%%%%%.:<<_. ", "--,%%./((^.-&>@ #>)%%%%%.::. ", "++*,%./((^.+=@ @>-%%%%%.. ", " +-%./((^. #>-~%-# ", " +-%.///]. #$&{>@ ", " =&%%.... #==@ "}; static char * loupe_moins_active[] = { "41 34 26 1", " c None", ". c #000000", "+ c #DEDEDE", "@ c #EFEFEF", "# c #F7F7F7", "$ c #848484", "% c #CECECE", "& c #C6C6C6", "* c #ADADAD", "= c #8CADAD", "- c #9C9C9C", "; c #E7E7E7", "> c #D6D6D6", ", c #949494", "' c #E7F7F7", ") c #A5A5A5", "! c #7B7B7B", "~ c #8C8C8C", "{ c #B5B5B5", "] c #CEBDA5", "^ c #B59C84", "/ c #7B6B52", "( c #ADE7CE", "_ c #4AD694", ": c #F4071B", "< c #29A563", " ", " .... ", " ..++++.. ", " ..++++++++.. @# ", " .++++....++++.$%+@# ", " .+++..&&&&..++.$$*%@ ", " .++.&&....==.++.$$-; ", " .++.&..======.++..$$>@ ", " .++.&.========.++.$$,># ", " .++.&.======'''.++.$$$*; ", " .++.&.=====''''.++..$$)># ", " .++.&.===='''''.++..$$,&@ ", " .++.&.====''''.++.&.$$$*; ", " .++.=====''''.++.&.$$$-+ ", " .++.====='''.++.&.$!$$-+ ", " .++..==''..+++.&.$$$~*@ ", " .++++....++++.&.$!$$-%# ", " .+..++++++++..&.$$$$,{; ", " .++&...++++..&&.$$$$~*># ", " ..++&. $.....&&..$$$$$)># ", " .]].&. $$$$$....$$$$$$)># ", " .]^^/.$$$$$->>~!!$$$$~*># ", " .]^^^/.$$$$)>##;>&{*)*>;# ", " .]^^^/.$$$$-&@ #@..............+;# ", " .]^^^/.$$$$~{+# .(((((((((((((_.*> ", " .]^^^/.$$$$$)>@ .(::::::::::::<.$* ", ".]^^^/.$$$$$)>@ .(::::::::::::<.$- ", "]^^^/.$$$$$)>@ ._<<<<<<<<<<<<<.$- ", "]^^/.$$$$$-># ..............$$* ", ".//.$$$$$)>@ #>*------------*> ", " ..$$$$$-># #;++++++++++++;# ", " @-$~->@ ", " #>{*%@ ", " #;;@ "}; #endif @>,%%.++.;;;;;;;;.*.++. \0", " =&%%%.++.''';;;;;;.*.++. \0", " @>)%%..++.'''';;;;;.*.++. \0", " #*,%%..++.''''';;;;.*.++. \0", " =&%%%.*.++.'''';;;;.*.++. \0", " +-%%%.*.++.'''';;;;;.++. \0", " +-%%!%.*.++.''';;;;;.++. \0", " #&~%%%.*.+++..'';;..++. \def_globals.h010064400004310000036000000026531023445461000140250ustar00goutbiomol00004410000024#ifndef _GLOBALS_H_ #define _GLOBALS_H_ #include "lalnview.h" int _MENU_OPENFEAT_; int NBSEQ; int LGSEQMAX; int NBBLOC; int NBSEG; int NEWSEQ; int COMPLEMENT; int GET_SEQ_FROM_SIM; int GET_FEAT_FROM_SIM; struct COLOR color_lg[NBCOL]; double y_color; char cur_color[30]; struct FEATURE *tab_feat; int has_features; /* = TRUE or FALSE */ int NBFEAT; /* = nombre de features a decrire */ double yfeat[2]; /* position du milieu des features sur axe y */ double dist12; /* distance between the 2 seq. on the screen */ struct SEG *segm; struct SEQ seq[2]; int cur_seq_view; /* Nb of residues visible on the screen */ double left_margin, right_margin; double feat_decal; /* decalage des features par rapport au sequences */ double lrg_box; /* largeur des boites representant les blocs de similitude */ int scale_pas; /* graduation pour representation de l'echelle */ char aln_fic_name[300]; char aln_fic_name_short[300]; double scale_factor; double char_width, char_height; char error_mess[500]; float seuil_score_sim; /* score mini de similitude pour reporter les blocs */ char **seq_alignee; /* vecteur de sequences alignees lg = LINAL */ int nb_ligne_aln; /* nb de ligne dans alignement */ char **empty_aln; int cur_num_line; /* numero de la ligne selectionnee */ /* scroller des sequences */ double maxscroll; char lis_error_mess[20][80]; char sim_parameter[500]; #endif globals.h010064400004310000036000000032531022722055400132040ustar00goutbiomol00004410000024#ifndef _GLOBALS_H_ #define _GLOBALS_H_ #include "lalnview.h" extern int _MENU_OPENFEAT_; extern int NBSEQ; extern int LGSEQMAX; extern int NBBLOC; extern int NBSEG; extern int NEWSEQ; extern int COMPLEMENT; extern int GET_SEQ_FROM_SIM; extern int GET_FEAT_FROM_SIM; extern struct COLOR color_lg[NBCOL]; extern double y_color; extern char cur_color[30]; extern struct FEATURE *tab_feat; extern int has_features; /* = TRUE or FALSE */ extern int NBFEAT; /* = nombre de features a decrire */ extern double yfeat[2]; /* position du milieu des features sur axe y */ extern double dist12; /* distance between the 2 seq. on the screen */ extern struct SEG *segm; extern struct SEQ seq[2]; extern int cur_seq_view; /* Nb of residues visible on the screen */ extern double left_margin, right_margin; extern double feat_decal; /* decalage des features par rapport au sequences */ extern double lrg_box; /* largeur des boites representant les blocs de similitude */ extern int scale_pas; /* graduation pour representation de l'echelle */ extern char aln_fic_name[300]; extern char aln_fic_name_short[300]; extern double scale_factor; extern double char_width, char_height; extern char error_mess[500]; extern float seuil_score_sim; /* score mini de similitude pour reporter les blocs */ extern char **seq_alignee; /* vecteur de sequences alignees lg = LINAL */ extern int nb_ligne_aln; /* nb de ligne dans alignement */ extern char **empty_aln; extern int cur_num_line; /* numero de la ligne selectionnee */ /* scroller des sequences */ extern double maxscroll; extern char lis_error_mess[20][80]; extern char sim_parameter[500]; #endif lalnview.h010064400004310000036000000053011025236157200134020ustar00goutbiomol00004410000024#ifndef _LALNVIEWH_ #define _LALNVIEWH_ #include #include #include #include #include #define _MAX_PIX_HELP_ 20 /* */ #define LINAL 123 /* length of line in alignment */ #define MAXMN 50 /* max seq. name length */ #define NBCOL 9 /* nombre de couleurs pour similitude */ #define MAXLAB 4096 /* taille maxi d'un label pour feature */ #define MAXFEATLRG 2.0 /* largeur maxi d'une boite pour feature */ #define DEFAULT_THRESHOLD 120.0 /* valeur par defaut pour seuil_score_sim */ #define _MF_TYPE_SCOREMIN_ 0 #define _MF_TYPE_LENGHTMIN_ 1 #define _MF_TYPE_IDENTITYMIN_ 2 #define _LIST_GREEN_ 1 #define _LIST_RED_ -1 #ifdef MACINTOSH #define LALN_VERSION "lalnview 3 - Mac" #else #define LALN_VERSION "lalnview 3" #endif #define FIRST_SHOWN "first shown" struct COLOR { float sco; Fl_Color col; double x1; double x2; }; struct FEATURE { int nseq; /* numero de la seq */ int deb; int fin; char cdeb[2]; char cfin[2]; float lrg; char col[30]; char lab[MAXLAB]; }; struct BLOC { int beg; int end; float sim; /* pourcentage identite entre les 2 blocs */ float sco; /* score du segment auquel le bloc appartient */ int seg; /* numero du segment auquel le bloc appartient */ int idb; }; struct SEQ { char *seq; char name[MAXMN]; struct BLOC *bloc; int lg; int id; int ori; double y; }; struct SEG { int id; float sco; int beg0; int end0; int beg1; int end1; int lgaln; float identity; float gapf; int bestSeries; int myList; }; void load_error_mess(void); void get_feature(char * nomfic); void get_aln(int, float *, float *, int *, int); int load_data(char *); char *check_alloc(int ,int); Fl_Color get_color(float); int load_data_sim(FILE *fic); int load_data_lfasta(FILE *fic); int compte_bloc_lfasta(int, FILE *, long); int get_bloc_info_lfasta(int , FILE *, float *, int *, long); int get_pos_seq(char *string, char * aln); void draw_scale(struct SEQ); void draw_seq(struct SEQ); void draw_link_seg(void); void draw_color_leg(void); void draw_features(void); void get_scale_pas(void); int get_seq_fasta(char *, int); void Nieme_mot(char *string, int n, char *separat, char *result); int max_(int, int); void load_color_lg(void); void init_glob(void); void get_short_name(void); void charger_fichier(char *fic); char *my_fgets(char *s, int n, FILE *f); char *MG_input_file_chooser(const char* message, const char* pat, const char* fname); char *MG_output_file_chooser(const char* message, const char* pat, const char* fname); #define fgets my_fgets #define GLOBDEFINE #endif pdflib.h010064400004310000036000001442261015160374000130250ustar00goutbiomol00004410000024/*---------------------------------------------------------------------------* | PDFlib - A library for generating PDF on the fly | +---------------------------------------------------------------------------+ | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | +---------------------------------------------------------------------------+ | | | This software is subject to the PDFlib license. It is NOT in the | | public domain. Extended versions and commercial licenses are | | available, please check http://www.pdflib.com. | | | *---------------------------------------------------------------------------*/ /* $Id: pdflib.h,v 1.244.2.9 2004/11/22 22:20:19 rjs Exp $ * * PDFlib public function declarations * */ #ifndef PDFLIB_H #define PDFLIB_H /* Make our declarations C++ compatible */ #ifdef __cplusplus extern "C" { #endif #include #include /* * The version defines below can be used to check the version of the * include file against the library. */ #define PDFLIB_MAJORVERSION 6 /* PDFlib major version number */ #define PDFLIB_MINORVERSION 0 /* PDFlib minor version number */ #define PDFLIB_REVISION 1 /* PDFlib revision number */ #define PDFLIB_VERSIONSTRING "6.0.1" /* The whole bunch */ /* * ---------------------------------------------------------------------- * Setup, mostly Windows calling conventions and DLL stuff * ---------------------------------------------------------------------- */ #if defined(WIN32) && !defined(PDFLIB_CALL) #define PDFLIB_CALL __cdecl #endif #if defined(WIN32) #ifdef PDFLIB_EXPORTS #define PDFLIB_API __declspec(dllexport) /* prepare a DLL (internal use) */ #elif defined(PDFLIB_DLL) #define PDFLIB_API __declspec(dllimport) /* PDFlib clients: import DLL */ #endif /* PDFLIB_DLL */ #endif /* WIN32 */ #if !defined(WIN32) && \ ((defined __IBMC__ || defined __IBMCPP__) && defined __DLL__ && defined OS2) #define PDFLIB_CALL _Export #define PDFLIB_API #endif /* IBM VisualAge C++ DLL */ #ifndef PDFLIB_CALL #define PDFLIB_CALL /* */ /* default: no special calling conventions */ #endif #ifndef PDFLIB_API #define PDFLIB_API /* */ /* default: generate or use static library */ #endif /* Define the basic PDF type. This is used opaquely at the API level. */ #if !defined(PDF) || defined(ACTIVEX) typedef struct PDF_s PDF; #endif /* !PDF */ /* Export the API functions when creating a shared library on the Mac with CW */ #if defined(__MWERKS__) && defined(PDFLIB_EXPORTS) #pragma export on #endif /* The API structure with function pointers. */ typedef struct PDFlib_api_s PDFlib_api; /* * ---------------------------------------------------------------------- * Function prototypes for all supported API functions * ---------------------------------------------------------------------- */ /* Activate a previously created structure element or other content item. */ PDFLIB_API void PDFLIB_CALL PDF_activate_item(PDF *p, int id); /* Deprecated, use PDF_create_bookmark(). */ PDFLIB_API int PDFLIB_CALL PDF_add_bookmark(PDF *p, const char *text, int parent, int open); /* Deprecated, use PDF_create_bookmark(). */ PDFLIB_API int PDFLIB_CALL PDF_add_bookmark2(PDF *p, const char *text, int len, int parent, int open); /* Deprecated, use PDF_create_action() and PDF_create_annotation(). */ PDFLIB_API void PDFLIB_CALL PDF_add_launchlink(PDF *p, double llx, double lly, double urx, double ury, const char *filename); /* Deprecated, use PDF_create_action() and PDF_create_annotation(). */ PDFLIB_API void PDFLIB_CALL PDF_add_locallink(PDF *p, double llx, double lly, double urx, double ury, int page, const char *optlist); /* Create a named destination on an arbitrary page in the current document. */ PDFLIB_API void PDFLIB_CALL PDF_add_nameddest(PDF *p, const char *name, int len, const char *optlist); /* Deprecated, use PDF_create_annotation() instead. */ PDFLIB_API void PDFLIB_CALL PDF_add_note(PDF *p, double llx, double lly, double urx, double ury, const char *contents, const char *title, const char *icon, int open); /* Deprecated, use PDF_create_annotation() instead. */ PDFLIB_API void PDFLIB_CALL PDF_add_note2(PDF *p, double llx, double lly, double urx, double ury, const char *contents, int len_cont, const char *title, int len_title, const char *icon, int open); /* Deprecated, use PDF_create_action() and PDF_create_annotation(). */ PDFLIB_API void PDFLIB_CALL PDF_add_pdflink(PDF *p, double llx, double lly, double urx, double ury, const char *filename, int page, const char *optlist); /* Add an existing image as thumbnail for the current page. */ PDFLIB_API void PDFLIB_CALL PDF_add_thumbnail(PDF *p, int image); /* Deprecated, use PDF_create_action() and PDF_create_annotation(). */ PDFLIB_API void PDFLIB_CALL PDF_add_weblink(PDF *p, double llx, double lly, double urx, double ury, const char *url); /* Draw a counterclockwise circular arc segment. */ PDFLIB_API void PDFLIB_CALL PDF_arc(PDF *p, double x, double y, double r, double alpha, double beta); /* Draw a clockwise circular arc segment. */ PDFLIB_API void PDFLIB_CALL PDF_arcn(PDF *p, double x, double y, double r, double alpha, double beta); /* Deprecated, use PDF_create_annotation() instead. */ PDFLIB_API void PDFLIB_CALL PDF_attach_file(PDF *p, double llx, double lly, double urx, double ury, const char *filename, const char *description, const char *author, const char *mimetype, const char *icon); /* Deprecated, use PDF_create_annotation() instead. */ PDFLIB_API void PDFLIB_CALL PDF_attach_file2(PDF *p, double llx, double lly, double urx, double ury, const char *filename, int len_filename, const char *description, int len_descr, const char *author, int len_auth, const char *mimetype, const char *icon); /* Create a new PDF file subject to various options. */ PDFLIB_API int PDFLIB_CALL PDF_begin_document(PDF *p, const char *filename, int len, const char *optlist); /* Create a new PDF file subject to various options. */ typedef size_t (*writeproc_t)(PDF *p1, void *data, size_t size); PDFLIB_API void PDFLIB_CALL PDF_begin_document_callback(PDF *p, writeproc_t writeproc, const char *optlist); /* Start a Type 3 font definition. */ PDFLIB_API void PDFLIB_CALL PDF_begin_font(PDF *p, const char *fontname, int len, double a, double b, double c, double d, double e, double f, const char *optlist); /* Start a glyph definition for a Type 3 font. */ PDFLIB_API void PDFLIB_CALL PDF_begin_glyph(PDF *p, const char *glyphname, double wx, double llx, double lly, double urx, double ury); /* Open a structure element or other content item with attributes supplied as options. */ PDFLIB_API int PDFLIB_CALL PDF_begin_item(PDF *p, const char *tag, const char *optlist); /* Start a layer for subsequent output on the page (requires PDF 1.5). */ PDFLIB_API void PDFLIB_CALL PDF_begin_layer(PDF *p, int layer); /* Begin a marked content sequence with or without properties (unsupported). */ PDFLIB_API void PDFLIB_CALL PDF_begin_mc(PDF *p, const char *tag, const char *optlist); /* Deprecated, use PDF_begin_page_ext(). */ PDFLIB_API void PDFLIB_CALL PDF_begin_page(PDF *p, double width, double height); /* Add a new page to the document, and specify various options. */ PDFLIB_API void PDFLIB_CALL PDF_begin_page_ext(PDF *p, double width, double height, const char *optlist); /* Start a pattern definition. */ PDFLIB_API int PDFLIB_CALL PDF_begin_pattern(PDF *p, double width, double height, double xstep, double ystep, int painttype); /* Start a template definition. */ PDFLIB_API int PDFLIB_CALL PDF_begin_template(PDF *p, double width, double height); /* Start a template definition with option list (unsupported). */ PDFLIB_API int PDFLIB_CALL PDF_begin_template2(PDF *p, double width, double height, const char *optlist); /* Boot PDFlib (recommended although currently not required). */ PDFLIB_API void PDFLIB_CALL PDF_boot(void); /* Draw a circle. */ PDFLIB_API void PDFLIB_CALL PDF_circle(PDF *p, double x, double y, double r); /* Use the current path as clipping path, and terminate the path. */ PDFLIB_API void PDFLIB_CALL PDF_clip(PDF *p); /* Deprecated, use PDF_end_document(). */ PDFLIB_API void PDFLIB_CALL PDF_close(PDF *p); /* Close an image. */ PDFLIB_API void PDFLIB_CALL PDF_close_image(PDF *p, int image); /* Close all open page handles, and close the input PDF document. */ PDFLIB_API void PDFLIB_CALL PDF_close_pdi(PDF *p, int doc); /* Close the page handle, and free all page-related resources. */ PDFLIB_API void PDFLIB_CALL PDF_close_pdi_page(PDF *p, int page); /* Close the current path. */ PDFLIB_API void PDFLIB_CALL PDF_closepath(PDF *p); /* Close the path, fill, and stroke it. */ PDFLIB_API void PDFLIB_CALL PDF_closepath_fill_stroke(PDF *p); /* Close the path, and stroke it. */ PDFLIB_API void PDFLIB_CALL PDF_closepath_stroke(PDF *p); /* Concatenate a matrix to the current transformation matrix. */ PDFLIB_API void PDFLIB_CALL PDF_concat(PDF *p, double a, double b, double c, double d, double e, double f); /* Print text at the next line. */ PDFLIB_API void PDFLIB_CALL PDF_continue_text(PDF *p, const char *text); /* Same as PDF_continue_text but with explicit string length. */ PDFLIB_API void PDFLIB_CALL PDF_continue_text2(PDF *p, const char *text, int len); /* Create an action which can be applied to various objects and events. */ PDFLIB_API int PDFLIB_CALL PDF_create_action(PDF *p, const char *type, const char *optlist); /* Create a rectangular annotation on the current page. */ PDFLIB_API void PDFLIB_CALL PDF_create_annotation(PDF *p, double llx, double lly, double urx, double ury, const char *type, const char *optlist); /* Create a bookmark subject to various options. */ PDFLIB_API int PDFLIB_CALL PDF_create_bookmark(PDF *p, const char *text, int len, const char *optlist); /* Create a form field on the current page subject to various options. */ PDFLIB_API void PDFLIB_CALL PDF_create_field(PDF *p, double llx, double lly, double urx, double ury, const char *name, int len, const char *type, const char *optlist); /* Create a form field group subject to various options. */ PDFLIB_API void PDFLIB_CALL PDF_create_fieldgroup(PDF *p, const char *name, int len, const char *optlist); /* Create a graphics state object subject to various options. */ PDFLIB_API int PDFLIB_CALL PDF_create_gstate(PDF *p, const char *optlist); /* Create a named virtual read-only file from data provided in memory. */ PDFLIB_API void PDFLIB_CALL PDF_create_pvf(PDF *p, const char *filename, int len, const void *data, size_t size, const char *optlist); /* Preprocess text for later formatting and create a textflow object. */ PDFLIB_API int PDFLIB_CALL PDF_create_textflow(PDF *p, const char *text, int len, const char *optlist); /* Draw a Bezier curve from the current point, using 3 more control points. */ PDFLIB_API void PDFLIB_CALL PDF_curveto(PDF *p, double x_1, double y_1, double x_2, double y_2, double x_3, double y_3); /* Create a new layer definition (requires PDF 1.5). */ PDFLIB_API int PDFLIB_CALL PDF_define_layer(PDF *p, const char *name, int len, const char *optlist); /* Delete a PDFlib object and free all internal resources. */ PDFLIB_API void PDFLIB_CALL PDF_delete(PDF *p); /* Delete a named virtual file and free its data structures (but not the contents). */ PDFLIB_API int PDFLIB_CALL PDF_delete_pvf(PDF *p, const char *filename, int len); /* Delete a textflow and the associated data structures. */ PDFLIB_API void PDFLIB_CALL PDF_delete_textflow(PDF *p, int textflow); /* Request a glyph name from a custom encoding (unsupported). */ PDFLIB_API const char * PDFLIB_CALL PDF_encoding_get_glyphname(PDF *p, const char *encoding, int slot); /* Request a slot's unicode value from a custom encoding (unsupported). */ PDFLIB_API int PDFLIB_CALL PDF_encoding_get_unicode(PDF *p, const char *encoding, int slot); /* Add a glyph name and/or Unicode value to a custom encoding. */ PDFLIB_API void PDFLIB_CALL PDF_encoding_set_char(PDF *p, const char *encoding, int slot, const char *glyphname, int uv); /* Close the generated PDF file and apply various options. */ PDFLIB_API void PDFLIB_CALL PDF_end_document(PDF *p, const char *optlist); /* Terminate a Type 3 font definition. */ PDFLIB_API void PDFLIB_CALL PDF_end_font(PDF *p); /* Terminate a glyph definition for a Type 3 font. */ PDFLIB_API void PDFLIB_CALL PDF_end_glyph(PDF *p); /* Close a structure element or other content item. */ PDFLIB_API void PDFLIB_CALL PDF_end_item(PDF *p, int id); /* Deactivate all active layers (requires PDF 1.5). */ PDFLIB_API void PDFLIB_CALL PDF_end_layer(PDF *p); /* End the least recently opened marked content sequence (unsupported). */ PDFLIB_API void PDFLIB_CALL PDF_end_mc(PDF *p); /* Deprecated, use PDF_end_page_ext(). */ PDFLIB_API void PDFLIB_CALL PDF_end_page(PDF *p); /* Finish a page, and apply various options. */ PDFLIB_API void PDFLIB_CALL PDF_end_page_ext(PDF *p, const char *optlist); /* Finish a pattern definition. */ PDFLIB_API void PDFLIB_CALL PDF_end_pattern(PDF *p); /* Finish a template definition. */ PDFLIB_API void PDFLIB_CALL PDF_end_template(PDF *p); /* End the current path without filling or stroking it. */ PDFLIB_API void PDFLIB_CALL PDF_endpath(PDF *p); /* Fill the interior of the path with the current fill color. */ PDFLIB_API void PDFLIB_CALL PDF_fill(PDF *p); /* Fill an image block with variable data according to its properties. */ PDFLIB_API int PDFLIB_CALL PDF_fill_imageblock(PDF *p, int page, const char *blockname, int image, const char *optlist); /* Fill a PDF block with variable data according to its properties. */ PDFLIB_API int PDFLIB_CALL PDF_fill_pdfblock(PDF *p, int page, const char *blockname, int contents, const char *optlist); /* Fill and stroke the path with the current fill and stroke color. */ PDFLIB_API void PDFLIB_CALL PDF_fill_stroke(PDF *p); /* Fill a text block with variable data according to its properties. */ PDFLIB_API int PDFLIB_CALL PDF_fill_textblock(PDF *p, int page, const char *blockname, const char *text, int len, const char *optlist); /* Deprecated, use PDF_load_font(). */ PDFLIB_API int PDFLIB_CALL PDF_findfont(PDF *p, const char *fontname, const char *encoding, int embed); /* Place an image or template at on the page, subject to various options. */ PDFLIB_API void PDFLIB_CALL PDF_fit_image(PDF *p, int image, double x, double y, const char *optlist); /* Place an imported PDF page on the page subject to various options. */ PDFLIB_API void PDFLIB_CALL PDF_fit_pdi_page(PDF *p, int page, double x, double y, const char *optlist); /* Format the next portion of a textflow into a rectangular area. */ PDFLIB_API const char * PDFLIB_CALL PDF_fit_textflow(PDF *p, int textflow, double llx, double lly, double urx, double ury, const char *optlist); /* Place a single line of text at position (x, y) subject to various options. */ PDFLIB_API void PDFLIB_CALL PDF_fit_textline(PDF *p, const char *text, int len, double x, double y, const char *optlist); /* * Retrieve a structure with PDFlib API function pointers (mainly for DLLs). * Although this function is published here, it is not supposed to be used * directly by clients. Use PDF_new_dl() (in pdflibdl.c) instead. */ PDFLIB_API const PDFlib_api * PDFLIB_CALL PDF_get_api(void); /* Get the name of the API function which threw the last exception or failed. */ PDFLIB_API const char * PDFLIB_CALL PDF_get_apiname(PDF *p); /* Get the contents of the PDF output buffer. */ PDFLIB_API const char * PDFLIB_CALL PDF_get_buffer(PDF *p, long *size); /* Get the descriptive text of the last thrown exception or the reason of a failed function call. */ PDFLIB_API const char * PDFLIB_CALL PDF_get_errmsg(PDF *p); /* Get the number of the last thrown exception or the reason of a failed function call. */ PDFLIB_API int PDFLIB_CALL PDF_get_errnum(PDF *p); /* Request a glyph ID value from a font (unsupported). */ PDFLIB_API int PDFLIB_CALL PDF_get_glyphid(PDF *p, int font, int code); /* Request the amount of kerning between two characters (unsupported). */ PDFLIB_API double PDFLIB_CALL PDF_get_kern_amount(PDF *p, int font, int firstchar, int secondchar); /* Depreceated, use PDF_get_value(). */ PDFLIB_API int PDFLIB_CALL PDF_get_majorversion(void); /* Depreceated, use PDF_get_value(). */ PDFLIB_API int PDFLIB_CALL PDF_get_minorversion(void); /* Fetch the opaque application pointer stored in PDFlib. */ PDFLIB_API void * PDFLIB_CALL PDF_get_opaque(PDF *p); /* Get the contents of some PDFlib parameter with string type. */ PDFLIB_API const char * PDFLIB_CALL PDF_get_parameter(PDF *p, const char *key, double modifier); /* Get some PDI document parameter with string type. */ PDFLIB_API const char *PDFLIB_CALL PDF_get_pdi_parameter(PDF *p, const char *key, int doc, int page, int reserved, int *len); /* Get some PDI document parameter with numerical type. */ PDFLIB_API double PDFLIB_CALL PDF_get_pdi_value(PDF *p, const char *key, int doc, int page, int reserved); /* Get the value of some PDFlib parameter with numerical type. */ PDFLIB_API double PDFLIB_CALL PDF_get_value(PDF *p, const char *key, double modifier); /* Query the current state of a textflow. */ PDFLIB_API double PDFLIB_CALL PDF_info_textflow(PDF *p, int textflow, const char *keyword); /* Reset all color and graphics state parameters to their defaults. */ PDFLIB_API void PDFLIB_CALL PDF_initgraphics(PDF *p); /* Draw a line from the current point to another point. */ PDFLIB_API void PDFLIB_CALL PDF_lineto(PDF *p, double x, double y); /* Search for a font and prepare it for later use. */ PDFLIB_API int PDFLIB_CALL PDF_load_font(PDF *p, const char *fontname, int len, const char *encoding, const char *optlist); /* Search for an ICC profile, and prepare it for later use. */ PDFLIB_API int PDFLIB_CALL PDF_load_iccprofile(PDF *p, const char *profilename, int len, const char *optlist); /* Open a disk-based or virtual image file subject to various options. */ PDFLIB_API int PDFLIB_CALL PDF_load_image(PDF *p, const char *imagetype, const char *filename, int len, const char *optlist); /* Find a built-in spot color name, or make a named spot color from the current fill color. */ PDFLIB_API int PDFLIB_CALL PDF_makespotcolor(PDF *p, const char *spotname, int reserved); /* Add a marked content point with or without properties (unsupported). */ PDFLIB_API void PDFLIB_CALL PDF_mc_point(PDF *p, const char *tag, const char *optlist); /* Set the current point. */ PDFLIB_API void PDFLIB_CALL PDF_moveto(PDF *p, double x, double y); /* Create a new PDFlib object with default settings. */ PDFLIB_API PDF * PDFLIB_CALL PDF_new(void); /* Create a new PDFlib object with client-supplied error handling and memory allocation routines. */ typedef void (*errorproc_t)(PDF *p1, int errortype, const char *msg); typedef void* (*allocproc_t)(PDF *p2, size_t size, const char *caller); typedef void* (*reallocproc_t)(PDF *p3, void *mem, size_t size, const char *caller); typedef void (*freeproc_t)(PDF *p4, void *mem); PDFLIB_API PDF * PDFLIB_CALL PDF_new2(errorproc_t errorhandler, allocproc_t allocproc, reallocproc_t reallocproc, freeproc_t freeproc, void *opaque); /* Deprecated, use PDF_load_image(). */ PDFLIB_API int PDFLIB_CALL PDF_open_CCITT(PDF *p, const char *filename, int width, int height, int BitReverse, int K, int BlackIs1); /* Deprecated, use PDF_begin_document(). */ PDFLIB_API int PDFLIB_CALL PDF_open_file(PDF *p, const char *filename); /* Deprecated, use PDF_load_image() with virtual files. */ PDFLIB_API int PDFLIB_CALL PDF_open_image(PDF *p, const char *imagetype, const char *source, const char *data, long length, int width, int height, int components, int bpc, const char *params); /* Deprecated, use PDF_load_image(). */ PDFLIB_API int PDFLIB_CALL PDF_open_image_file(PDF *p, const char *imagetype, const char *filename, const char *stringparam, int intparam); /* Deprecated, use PDF_begin_document_callback(). */ PDFLIB_API void PDFLIB_CALL PDF_open_mem(PDF *p, writeproc_t writeproc); /* Open a disk-based or virtual PDF document and prepare it for later use. */ PDFLIB_API int PDFLIB_CALL PDF_open_pdi(PDF *p, const char *filename, const char *optlist, int len); /* Open an existing PDF document from a custom data source and prepare it for later use. */ PDFLIB_API int PDFLIB_CALL PDF_open_pdi_callback(PDF *p, void *opaque, size_t filesize, size_t (*readproc)(void *opaque, void *buffer, size_t size), int (*seekproc)(void *opaque, long offset), const char *optlist); /* Prepare a page for later use with PDF_fit_pdi_page(). */ PDFLIB_API int PDFLIB_CALL PDF_open_pdi_page(PDF *p, int doc, int pagenumber, const char *optlist); /* Deprecated, use PDF_fit_image(). */ PDFLIB_API void PDFLIB_CALL PDF_place_image(PDF *p, int image, double x, double y, double scale); /* Deprecated, use PDF_fit_pdi_page(). */ PDFLIB_API void PDFLIB_CALL PDF_place_pdi_page(PDF *p, int page, double x, double y, double sx, double sy); /* Process certain elements of an imported PDF document. */ PDFLIB_API int PDFLIB_CALL PDF_process_pdi(PDF *p, int doc, int page, const char *optlist); /* Draw a Bezier curve using relative coordinates (unsupported). */ PDFLIB_API void PDFLIB_CALL PDF_rcurveto(PDF *p, double x_1, double y_1, double x_2, double y_2, double x_3, double y_3); /* Draw a rectangle. */ PDFLIB_API void PDFLIB_CALL PDF_rect(PDF *p, double x, double y, double width, double height); /* Restore the most recently saved graphics state from the stack. */ PDFLIB_API void PDFLIB_CALL PDF_restore(PDF *p); /* Resume a page to add more content to it. */ PDFLIB_API void PDFLIB_CALL PDF_resume_page(PDF *p, const char *optlist); /* Draw a line from the current point to (cp + (x, y)) (unsupported). */ PDFLIB_API void PDFLIB_CALL PDF_rlineto(PDF *p, double x, double y); /* Set the new current point relative the old current point (unsupported). */ PDFLIB_API void PDFLIB_CALL PDF_rmoveto(PDF *p, double x, double y); /* Rotate the coordinate system. */ PDFLIB_API void PDFLIB_CALL PDF_rotate(PDF *p, double phi); /* Save the current graphics state to a stack. */ PDFLIB_API void PDFLIB_CALL PDF_save(PDF *p); /* Scale the coordinate system. */ PDFLIB_API void PDFLIB_CALL PDF_scale(PDF *p, double sx, double sy); /* Deprecated, use PDF_create_annotation(). */ PDFLIB_API void PDFLIB_CALL PDF_set_border_color(PDF *p, double red, double green, double blue); /* Deprecated, use PDF_create_annotation(). */ PDFLIB_API void PDFLIB_CALL PDF_set_border_dash(PDF *p, double b, double w); /* Deprecated, use PDF_create_annotation(). */ PDFLIB_API void PDFLIB_CALL PDF_set_border_style(PDF *p, const char *style, double width); /* Activate a gstate object. */ PDFLIB_API void PDFLIB_CALL PDF_set_gstate(PDF *p, int gstate); /* Fill document information field key with value. */ PDFLIB_API void PDFLIB_CALL PDF_set_info(PDF *p, const char *key, const char *value); /* Like PDF_set_info(), but with explicit string length. */ PDFLIB_API void PDFLIB_CALL PDF_set_info2(PDF *p, const char *key, const char *value, int len); /* Define hierarchical and group relationships among layers (requires PDF 1.5). */ PDFLIB_API void PDFLIB_CALL PDF_set_layer_dependency(PDF *p, const char *type, const char *optlist); /* Set some PDFlib parameter with string type. */ PDFLIB_API void PDFLIB_CALL PDF_set_parameter(PDF *p, const char *key, const char *value); /* Set the position for text output on the page. */ PDFLIB_API void PDFLIB_CALL PDF_set_text_pos(PDF *p, double x, double y); /* Set the value of some PDFlib parameter with numerical type. */ PDFLIB_API void PDFLIB_CALL PDF_set_value(PDF *p, const char *key, double value); /* Set the current color space and color. */ PDFLIB_API void PDFLIB_CALL PDF_setcolor(PDF *p, const char *fstype, const char *colorspace, double c1, double c2, double c3, double c4); /* Set the current dash pattern. */ PDFLIB_API void PDFLIB_CALL PDF_setdash(PDF *p, double b, double w); /* Set a dash pattern defined by an option list. */ PDFLIB_API void PDFLIB_CALL PDF_setdashpattern(PDF *p, const char *optlist); /* Set the flatness parameter. */ PDFLIB_API void PDFLIB_CALL PDF_setflat(PDF *p, double flatness); /* Set the current font in the specified size. */ PDFLIB_API void PDFLIB_CALL PDF_setfont(PDF *p, int font, double fontsize); /* Deprecated, use PDF_setcolor(). */ PDFLIB_API void PDFLIB_CALL PDF_setgray(PDF *p, double gray); /* Deprecated, use PDF_setcolor(). */ PDFLIB_API void PDFLIB_CALL PDF_setgray_fill(PDF *p, double gray); /* Deprecated, use PDF_setcolor(). */ PDFLIB_API void PDFLIB_CALL PDF_setgray_stroke(PDF *p, double gray); /* Set the linecap parameter. */ PDFLIB_API void PDFLIB_CALL PDF_setlinecap(PDF *p, int linecap); /* Set the linejoin parameter. */ PDFLIB_API void PDFLIB_CALL PDF_setlinejoin(PDF *p, int linejoin); /* Set the current linewidth. */ PDFLIB_API void PDFLIB_CALL PDF_setlinewidth(PDF *p, double width); /* Explicitly set the current transformation matrix. */ PDFLIB_API void PDFLIB_CALL PDF_setmatrix(PDF *p, double a, double b, double c, double d, double e, double f); /* Set the miter limit. */ PDFLIB_API void PDFLIB_CALL PDF_setmiterlimit(PDF *p, double miter); /* Deprecated, use PDF_setdashpattern(). */ PDFLIB_API void PDFLIB_CALL PDF_setpolydash(PDF *p, float *dasharray, int length); /* Deprecated, use PDF_setcolor(). */ PDFLIB_API void PDFLIB_CALL PDF_setrgbcolor(PDF *p, double red, double green, double blue); /* Deprecated, use PDF_setcolor(). */ PDFLIB_API void PDFLIB_CALL PDF_setrgbcolor_fill(PDF *p, double red, double green, double blue); /* Deprecated, use PDF_setcolor(). */ PDFLIB_API void PDFLIB_CALL PDF_setrgbcolor_stroke(PDF *p, double red, double green, double blue); /* Define a blend from the current fill color to another color (requires PDF 1.4 or above). */ PDFLIB_API int PDFLIB_CALL PDF_shading(PDF *p, const char *shtype, double x_0, double y_0, double x_1, double y_1, double c_1, double c_2, double c_3, double c_4, const char *optlist); /* Define a shading pattern using a shading object (requires PDF 1.4 or above). */ PDFLIB_API int PDFLIB_CALL PDF_shading_pattern(PDF *p, int shading, const char *optlist); /* Fill an area with a shading, based on a shading object (requires PDF 1.4 or above). */ PDFLIB_API void PDFLIB_CALL PDF_shfill(PDF *p, int shading); /* Print text in the current font and size at the current position. */ PDFLIB_API void PDFLIB_CALL PDF_show(PDF *p, const char *text); /* Same as PDF_show() but with explicit string length. */ PDFLIB_API void PDFLIB_CALL PDF_show2(PDF *p, const char *text, int len); /* Deprecated, use PDF_fit_textline() or PDF_fit_textflow(). */ PDFLIB_API int PDFLIB_CALL PDF_show_boxed(PDF *p, const char *text, double left, double top, double width, double height, const char *hmode, const char *feature); /* Deprecated, use PDF_fit_textline() or PDF_fit_textflow(). */ PDFLIB_API int PDFLIB_CALL PDF_show_boxed2(PDF *p, const char *text, int len, double left, double top, double width, double height, const char *hmode, const char *feature); /* Print text in the current font. */ PDFLIB_API void PDFLIB_CALL PDF_show_xy(PDF *p, const char *text, double x, double y); /* Same as PDF_show_xy() but with explicit string length. */ PDFLIB_API void PDFLIB_CALL PDF_show_xy2(PDF *p, const char *text, int len, double x, double y); /* Shut down PDFlib (recommended although currently not required). */ PDFLIB_API void PDFLIB_CALL PDF_shutdown(void); /* Skew the coordinate system. */ PDFLIB_API void PDFLIB_CALL PDF_skew(PDF *p, double alpha, double beta); /* Return the width of text in an arbitrary font. */ PDFLIB_API double PDFLIB_CALL PDF_stringwidth(PDF *p, const char *text, int font, double fontsize); /* Same as PDF_stringwidth() but with explicit string length. */ PDFLIB_API double PDFLIB_CALL PDF_stringwidth2(PDF *p, const char *text, int len, int font, double fontsize); /* Stroke the path with the current color and line width, and clear it. */ PDFLIB_API void PDFLIB_CALL PDF_stroke(PDF *p); /* Suspend the current page so that it can later be resumed. */ PDFLIB_API void PDFLIB_CALL PDF_suspend_page(PDF *p, const char *optlist); /* Translate the origin of the coordinate system. */ PDFLIB_API void PDFLIB_CALL PDF_translate(PDF *p, double tx, double ty); /* Convert a string from UTF-16 format to UTF-8. */ PDFLIB_API const char * PDFLIB_CALL PDF_utf16_to_utf8(PDF *p, const char *utf16string, int len, int *size); /* Convert a string from UTF-8 format to UTF-16. */ PDFLIB_API const char * PDFLIB_CALL PDF_utf8_to_utf16(PDF *p, const char *utf8string, const char *ordering, int *size); /* Print text in the current font and size, using individual horizontal positions (unsupported). */ PDFLIB_API void PDFLIB_CALL PDF_xshow(PDF *p, const char *text, int len, const double *xadvancelist); /* * ---------------------------------------------------------------------- * PDFlib API structure with function pointers to all API functions * ---------------------------------------------------------------------- */ /* Auxiliary structure for try/catch */ typedef struct { jmp_buf jbuf; } pdf_jmpbuf; /* The API structure with pointers to all PDFlib API functions */ struct PDFlib_api_s { /* version numbers for checking the DLL against client code */ size_t sizeof_PDFlib_api; /* size of this structure */ int major; /* PDFlib major version number */ int minor; /* PDFlib minor version number */ int revision; /* PDFlib revision number */ int reserved; /* reserved */ void (PDFLIB_CALL * PDF_activate_item)(PDF *p, int id); int (PDFLIB_CALL * PDF_add_bookmark)(PDF *p, const char *text, int parent, int open); int (PDFLIB_CALL * PDF_add_bookmark2) (PDF *p, const char *text, int len, int parent, int open); void (PDFLIB_CALL * PDF_add_launchlink)(PDF *p, double llx, double lly, double urx, double ury, const char *filename); void (PDFLIB_CALL * PDF_add_locallink)(PDF *p, double llx, double lly, double urx, double ury, int page, const char *optlist); void (PDFLIB_CALL * PDF_add_nameddest) (PDF *p, const char *name, int len, const char *optlist); void (PDFLIB_CALL * PDF_add_note)(PDF *p, double llx, double lly, double urx, double ury, const char *contents, const char *title, const char *icon, int open); void (PDFLIB_CALL * PDF_add_note2) (PDF *p, double llx, double lly, double urx, double ury, const char *contents, int len_cont, const char *title, int len_title, const char *icon, int open); void (PDFLIB_CALL * PDF_add_pdflink)(PDF *p, double llx, double lly, double urx, double ury, const char *filename, int page, const char *optlist); void (PDFLIB_CALL * PDF_add_thumbnail)(PDF *p, int image); void (PDFLIB_CALL * PDF_add_weblink)(PDF *p, double llx, double lly, double urx, double ury, const char *url); void (PDFLIB_CALL * PDF_arc)(PDF *p, double x, double y, double r, double alpha, double beta); void (PDFLIB_CALL * PDF_arcn)(PDF *p, double x, double y, double r, double alpha, double beta); void (PDFLIB_CALL * PDF_attach_file)(PDF *p, double llx, double lly, double urx, double ury, const char *filename, const char *description, const char *author, const char *mimetype, const char *icon); void (PDFLIB_CALL * PDF_attach_file2) (PDF *p, double llx, double lly, double urx, double ury, const char *filename, int len_filename, const char *description, int len_descr, const char *author, int len_auth, const char *mimetype, const char *icon); int (PDFLIB_CALL * PDF_begin_document)(PDF *p, const char *filename, int len, const char *optlist); void (PDFLIB_CALL * PDF_begin_document_callback)(PDF *p, writeproc_t writeproc, const char *optlist); void (PDFLIB_CALL * PDF_begin_font)(PDF *p, const char *fontname, int len, double a, double b, double c, double d, double e, double f, const char *optlist); void (PDFLIB_CALL * PDF_begin_glyph)(PDF *p, const char *glyphname, double wx, double llx, double lly, double urx, double ury); int (PDFLIB_CALL * PDF_begin_item)(PDF *p, const char *tag, const char *optlist); void (PDFLIB_CALL * PDF_begin_layer)(PDF *p, int layer); void (PDFLIB_CALL * PDF_begin_mc)(PDF *p, const char *tag, const char *optlist); void (PDFLIB_CALL * PDF_begin_page)(PDF *p, double width, double height); void (PDFLIB_CALL * PDF_begin_page_ext)(PDF *p, double width, double height, const char *optlist); int (PDFLIB_CALL * PDF_begin_pattern)(PDF *p, double width, double height, double xstep, double ystep, int painttype); int (PDFLIB_CALL * PDF_begin_template)(PDF *p, double width, double height); void (PDFLIB_CALL * PDF_boot)(void); void (PDFLIB_CALL * PDF_circle)(PDF *p, double x, double y, double r); void (PDFLIB_CALL * PDF_clip)(PDF *p); void (PDFLIB_CALL * PDF_close)(PDF *p); void (PDFLIB_CALL * PDF_close_image)(PDF *p, int image); void (PDFLIB_CALL * PDF_close_pdi)(PDF *p, int doc); void (PDFLIB_CALL * PDF_close_pdi_page)(PDF *p, int page); void (PDFLIB_CALL * PDF_closepath)(PDF *p); void (PDFLIB_CALL * PDF_closepath_fill_stroke)(PDF *p); void (PDFLIB_CALL * PDF_closepath_stroke)(PDF *p); void (PDFLIB_CALL * PDF_concat)(PDF *p, double a, double b, double c, double d, double e, double f); void (PDFLIB_CALL * PDF_continue_text)(PDF *p, const char *text); void (PDFLIB_CALL * PDF_continue_text2)(PDF *p, const char *text, int len); int (PDFLIB_CALL * PDF_create_action)(PDF *p, const char *type, const char *optlist); void (PDFLIB_CALL * PDF_create_annotation)(PDF *p, double llx, double lly, double urx, double ury, const char *type, const char *optlist); int (PDFLIB_CALL * PDF_create_bookmark)(PDF *p, const char *text, int len, const char *optlist); void (PDFLIB_CALL * PDF_create_field) (PDF *p, double llx, double lly, double urx, double ury, const char *name, int len, const char *type, const char *optlist); void (PDFLIB_CALL * PDF_create_fieldgroup) (PDF *p, const char *name, int len, const char *optlist); int (PDFLIB_CALL * PDF_create_gstate) (PDF *p, const char *optlist); void (PDFLIB_CALL * PDF_create_pvf)(PDF *p, const char *filename, int len, const void *data, size_t size, const char *optlist); int (PDFLIB_CALL * PDF_create_textflow)(PDF *p, const char *text, int len, const char *optlist); void (PDFLIB_CALL * PDF_curveto)(PDF *p, double x_1, double y_1, double x_2, double y_2, double x_3, double y_3); int (PDFLIB_CALL * PDF_define_layer)(PDF *p, const char *name, int len, const char *optlist); void (PDFLIB_CALL * PDF_delete)(PDF *); int (PDFLIB_CALL * PDF_delete_pvf)(PDF *p, const char *filename, int len); void (PDFLIB_CALL * PDF_delete_textflow)(PDF *p, int textflow); void (PDFLIB_CALL * PDF_encoding_set_char) (PDF *p, const char *encoding, int slot, const char *glyphname, int uv); void (PDFLIB_CALL * PDF_end_document)(PDF *p, const char *optlist); void (PDFLIB_CALL * PDF_end_font)(PDF *p); void (PDFLIB_CALL * PDF_end_glyph)(PDF *p); void (PDFLIB_CALL * PDF_end_item)(PDF *p, int id); void (PDFLIB_CALL * PDF_end_layer)(PDF *p); void (PDFLIB_CALL * PDF_end_mc)(PDF *p); void (PDFLIB_CALL * PDF_end_page)(PDF *p); void (PDFLIB_CALL * PDF_end_page_ext)(PDF *p, const char *optlist); void (PDFLIB_CALL * PDF_end_pattern)(PDF *p); void (PDFLIB_CALL * PDF_end_template)(PDF *p); void (PDFLIB_CALL * PDF_endpath)(PDF *p); void (PDFLIB_CALL * PDF_fill)(PDF *p); int (PDFLIB_CALL * PDF_fill_imageblock) (PDF *p, int page, const char *blockname, int image, const char *optlist); int (PDFLIB_CALL * PDF_fill_pdfblock) (PDF *p, int page, const char *blockname, int contents, const char *optlist); void (PDFLIB_CALL * PDF_fill_stroke)(PDF *p); int (PDFLIB_CALL * PDF_fill_textblock) (PDF *p, int page, const char *blockname, const char *text, int len, const char *optlist); int (PDFLIB_CALL * PDF_findfont)(PDF *p, const char *fontname, const char *encoding, int embed); void (PDFLIB_CALL * PDF_fit_image) (PDF *p, int image, double x, double y, const char *optlist); void (PDFLIB_CALL * PDF_fit_pdi_page) (PDF *p, int page, double x, double y, const char *optlist); const char * (PDFLIB_CALL * PDF_fit_textflow)(PDF *p, int textflow, double llx, double lly, double urx, double ury, const char *optlist); void (PDFLIB_CALL * PDF_fit_textline)(PDF *p, const char *text, int len, double x, double y, const char *optlist); const PDFlib_api * (PDFLIB_CALL * PDF_get_api)(void); const char * (PDFLIB_CALL * PDF_get_apiname) (PDF *p); const char * (PDFLIB_CALL * PDF_get_buffer)(PDF *p, long *size); const char * (PDFLIB_CALL * PDF_get_errmsg) (PDF *p); int (PDFLIB_CALL * PDF_get_errnum) (PDF *p); int (PDFLIB_CALL * PDF_get_minorversion)(void); int (PDFLIB_CALL * PDF_get_majorversion)(void); void * (PDFLIB_CALL * PDF_get_opaque)(PDF *p); const char * (PDFLIB_CALL * PDF_get_parameter)(PDF *p, const char *key, double modifier); const char * (PDFLIB_CALL * PDF_get_pdi_parameter)(PDF *p, const char *key, int doc, int page, int reserved, int *len); double (PDFLIB_CALL * PDF_get_pdi_value)(PDF *p, const char *key, int doc, int page, int reserved); double (PDFLIB_CALL * PDF_get_value)(PDF *p, const char *key, double modifier); double (PDFLIB_CALL * PDF_info_textflow)(PDF *p, int textflow, const char *keyword); void (PDFLIB_CALL * PDF_initgraphics)(PDF *p); void (PDFLIB_CALL * PDF_lineto)(PDF *p, double x, double y); int (PDFLIB_CALL * PDF_load_font)(PDF *p, const char *fontname, int len, const char *encoding, const char *optlist); int (PDFLIB_CALL * PDF_load_iccprofile)(PDF *p, const char *profilename, int len, const char *optlist); int (PDFLIB_CALL * PDF_load_image) (PDF *p, const char *imagetype, const char *filename, int len, const char *optlist); int (PDFLIB_CALL * PDF_makespotcolor)(PDF *p, const char *spotname, int len); void (PDFLIB_CALL * PDF_mc_point)(PDF *p, const char *tag, const char *optlist); void (PDFLIB_CALL * PDF_moveto)(PDF *p, double x, double y); PDF* (PDFLIB_CALL * PDF_new)(void); PDF* (PDFLIB_CALL * PDF_new2)(errorproc_t errorhandler, allocproc_t allocproc, reallocproc_t reallocproc, freeproc_t freeproc, void *opaque); int (PDFLIB_CALL * PDF_open_CCITT)(PDF *p, const char *filename, int width, int height, int BitReverse, int K, int BlackIs1); int (PDFLIB_CALL * PDF_open_file)(PDF *p, const char *filename); int (PDFLIB_CALL * PDF_open_image)(PDF *p, const char *imagetype, const char *source, const char *data, long length, int width, int height, int components, int bpc, const char *params); int (PDFLIB_CALL * PDF_open_image_file)(PDF *p, const char *imagetype, const char *filename, const char *stringparam, int intparam); void (PDFLIB_CALL * PDF_open_mem)(PDF *p, writeproc_t writeproc); int (PDFLIB_CALL * PDF_open_pdi)(PDF *p, const char *filename, const char *optlist, int len); int (PDFLIB_CALL * PDF_open_pdi_callback) (PDF *p, void *opaque, size_t filesize, size_t (*readproc)(void *opaque, void *buffer, size_t size), int (*seekproc)(void *opaque, long offset), const char *optlist); int (PDFLIB_CALL * PDF_open_pdi_page)(PDF *p, int doc, int pagenumber, const char *optlist); void (PDFLIB_CALL * PDF_place_image)(PDF *p, int image, double x, double y, double scale); void (PDFLIB_CALL * PDF_place_pdi_page)(PDF *p, int page, double x, double y, double sx, double sy); int (PDFLIB_CALL * PDF_process_pdi)(PDF *p, int doc, int page, const char *optlist); void (PDFLIB_CALL * PDF_rect)(PDF *p, double x, double y, double width, double height); void (PDFLIB_CALL * PDF_restore)(PDF *p); void (PDFLIB_CALL * PDF_resume_page)(PDF *p, const char *optlist); void (PDFLIB_CALL * PDF_rotate)(PDF *p, double phi); void (PDFLIB_CALL * PDF_save)(PDF *p); void (PDFLIB_CALL * PDF_scale)(PDF *p, double sx, double sy); void (PDFLIB_CALL * PDF_set_border_color)(PDF *p, double red, double green, double blue); void (PDFLIB_CALL * PDF_set_border_dash)(PDF *p, double b, double w); void (PDFLIB_CALL * PDF_set_border_style)(PDF *p, const char *style, double width); void (PDFLIB_CALL * PDF_set_gstate) (PDF *p, int gstate); void (PDFLIB_CALL * PDF_set_info)(PDF *p, const char *key, const char *value); void (PDFLIB_CALL * PDF_set_info2) (PDF *p, const char *key, const char *value, int len); void (PDFLIB_CALL * PDF_set_layer_dependency)(PDF *p, const char *type, const char *optlist); void (PDFLIB_CALL * PDF_set_parameter)(PDF *p, const char *key, const char *value); void (PDFLIB_CALL * PDF_set_text_pos)(PDF *p, double x, double y); void (PDFLIB_CALL * PDF_set_value)(PDF *p, const char *key, double value); void (PDFLIB_CALL * PDF_setcolor)(PDF *p, const char *fstype, const char *colorspace, double c1, double c2, double c3, double c4); void (PDFLIB_CALL * PDF_setdash)(PDF *p, double b, double w); void (PDFLIB_CALL * PDF_setdashpattern) (PDF *p, const char *optlist); void (PDFLIB_CALL * PDF_setflat)(PDF *p, double flatness); void (PDFLIB_CALL * PDF_setfont)(PDF *p, int font, double fontsize); void (PDFLIB_CALL * PDF_setgray)(PDF *p, double gray); void (PDFLIB_CALL * PDF_setgray_stroke)(PDF *p, double gray); void (PDFLIB_CALL * PDF_setgray_fill)(PDF *p, double gray); void (PDFLIB_CALL * PDF_setlinecap)(PDF *p, int linecap); void (PDFLIB_CALL * PDF_setlinejoin)(PDF *p, int linejoin); void (PDFLIB_CALL * PDF_setlinewidth)(PDF *p, double width); void (PDFLIB_CALL * PDF_setmatrix)(PDF *p, double a, double b, double c, double d, double e, double f); void (PDFLIB_CALL * PDF_setmiterlimit)(PDF *p, double miter); void (PDFLIB_CALL * PDF_setpolydash)(PDF *p, float *dasharray, int length); void (PDFLIB_CALL * PDF_setrgbcolor)(PDF *p, double red, double green, double blue); void (PDFLIB_CALL * PDF_setrgbcolor_fill)(PDF *p, double red, double green, double blue); void (PDFLIB_CALL * PDF_setrgbcolor_stroke)(PDF *p, double red, double green, double blue); int (PDFLIB_CALL * PDF_shading) (PDF *p, const char *shtype, double x_0, double y_0, double x_1, double y_1, double c_1, double c_2, double c_3, double c_4, const char *optlist); int (PDFLIB_CALL * PDF_shading_pattern) (PDF *p, int shading, const char *optlist); void (PDFLIB_CALL * PDF_shfill) (PDF *p, int shading); void (PDFLIB_CALL * PDF_show)(PDF *p, const char *text); void (PDFLIB_CALL * PDF_show2)(PDF *p, const char *text, int len); int (PDFLIB_CALL * PDF_show_boxed)(PDF *p, const char *text, double left, double top, double width, double height, const char *hmode, const char *feature); int (PDFLIB_CALL * PDF_show_boxed2)(PDF *p, const char *text, int len, double left, double top, double width, double height, const char *hmode, const char *feature); void (PDFLIB_CALL * PDF_show_xy)(PDF *p, const char *text, double x, double y); void (PDFLIB_CALL * PDF_show_xy2)(PDF *p, const char *text, int len, double x, double y); void (PDFLIB_CALL * PDF_shutdown)(void); void (PDFLIB_CALL * PDF_skew)(PDF *p, double alpha, double beta); double (PDFLIB_CALL * PDF_stringwidth)(PDF *p, const char *text, int font, double fontsize); double (PDFLIB_CALL * PDF_stringwidth2)(PDF *p, const char *text, int len, int font, double fontsize); void (PDFLIB_CALL * PDF_stroke)(PDF *p); void (PDFLIB_CALL * PDF_suspend_page)(PDF *p, const char *optlist); void (PDFLIB_CALL * PDF_translate)(PDF *p, double tx, double ty); const char * (PDFLIB_CALL * PDF_utf16_to_utf8) (PDF *p, const char *utf16string, int len, int *size); const char * (PDFLIB_CALL * PDF_utf8_to_utf16) (PDF *p, const char *utf8string, const char *format, int *size); void (PDFLIB_CALL * PDF_xshow)(PDF *p, const char *text, int len, const double *xadvancelist); int (PDFLIB_CALL * pdf_catch)(PDF *p); void (PDFLIB_CALL * pdf_exit_try)(PDF *p); pdf_jmpbuf * (PDFLIB_CALL * pdf_jbuf)(PDF *p); void (PDFLIB_CALL * pdf_rethrow)(PDF *p); }; /* * ---------------------------------------------------------------------- * exception handling with try/catch implementation * ---------------------------------------------------------------------- */ /* Set up an exception handling frame; must always be paired with PDF_CATCH().*/ #define PDF_TRY(p) if (p) { if (setjmp(pdf_jbuf(p)->jbuf) == 0) /* Inform the exception machinery that a PDF_TRY() will be left without entering the corresponding PDF_CATCH( ) clause. */ #define PDF_EXIT_TRY(p) pdf_exit_try(p) /* Catch an exception; must always be paired with PDF_TRY(). */ #define PDF_CATCH(p) } if (pdf_catch(p)) /* Re-throw an exception to another handler. */ #define PDF_RETHROW(p) pdf_rethrow(p) /* * ---------------------------------------------------------------------- * End of supported public declarations * ---------------------------------------------------------------------- */ /* * ------------------------------------------------------------------------ * Deprecated: macros for page size formats * ------------------------------------------------------------------------ */ /* * The page sizes are only available to the C and C++ bindings. * These are deprecated; corresponding options are supported in * PDF_begin_page_ext(). */ #define a0_width 2380.0 #define a0_height 3368.0 #define a1_width 1684.0 #define a1_height 2380.0 #define a2_width 1190.0 #define a2_height 1684.0 #define a3_width 842.0 #define a3_height 1190.0 #define a4_width 595.0 #define a4_height 842.0 #define a5_width 421.0 #define a5_height 595.0 #define a6_width 297.0 #define a6_height 421.0 #define b5_width 501.0 #define b5_height 709.0 #define letter_width 612.0 #define letter_height 792.0 #define legal_width 612.0 #define legal_height 1008.0 #define ledger_width 1224.0 #define ledger_height 792.0 #define p11x17_width 792.0 #define p11x17_height 1224.0 /* * ---------------------------------------------------------------------- * Deprecated: Error classes * ---------------------------------------------------------------------- */ /* * Error classes are deprecated; use PDF_TRY/PDF_CATCH instead. * Note that old-style error handlers are still supported, but * they will always receive type PDF_NonfatalError (for warnings) * or PDF_UnknownError (for other exceptions). */ #define PDF_MemoryError 1 #define PDF_IOError 2 #define PDF_RuntimeError 3 #define PDF_IndexError 4 #define PDF_TypeError 5 #define PDF_DivisionByZero 6 #define PDF_OverflowError 7 #define PDF_SyntaxError 8 #define PDF_ValueError 9 #define PDF_SystemError 10 #define PDF_NonfatalError 11 #define PDF_UnknownError 12 /* * ---------------------------------------------------------------------- * Private stuff, do not use explicitly but only via the macros above! * ---------------------------------------------------------------------- */ PDFLIB_API pdf_jmpbuf * PDFLIB_CALL pdf_jbuf(PDF *p); PDFLIB_API void PDFLIB_CALL pdf_exit_try(PDF *p); PDFLIB_API int PDFLIB_CALL pdf_catch(PDF *p); PDFLIB_API void PDFLIB_CALL pdf_rethrow(PDF *p); PDFLIB_API void PDFLIB_CALL pdf_throw(PDF *p, const char *binding, const char *apiname, const char *errmsg); /* * ---------------------------------------------------------------------- * End of useful stuff * ---------------------------------------------------------------------- */ #if defined(__MWERKS__) && defined(PDFLIB_EXPORTS) #pragma export off #endif #ifdef __cplusplus } /* extern "C" */ #endif #endif /* PDFLIB_H */ /* * vim600: sw=4 fdm=marker */ ackIs1); int (PDFLIB_CALL * PDF_open_file)(PDF *p, const char *filename); int (PDFLIB_CALL * PDF_open_image)(PDF *p, const char *imagetype, const char *source, const char *data, long length, int width, int height, int components, int bpc, const char *params); int (PDFLIB_CALL * PDF_open_image_file)(PDF *p, const char *imagetype, const makefile010064400004310000036000000017461025177747500131350ustar00goutbiomol00004410000024FLTK = /bge/mgouy/fltk-1.1.6 PDF = /bge/mgouy/PDFlib-Lite-6.0.1/libs/pdflib OBJECTS = lalnview.o lalnview_utils.o load_data.o get_feature.o MF_Echelle.o get_aln.o MenuCb.o MF_Name.o MF_MainWindow.o MF_About.o MF_MyScroll.o extras.o MF_Values.o MF_Sequence.o MF_MyScrollbar.o MF_Zoomer.o MF_Next.o MF_ScoMinChooser.o MF_ParcBloc.o MF_Stats.o MF_SecWindow.o MF_Text.o MF_FeatDisplay.o MF_BestSeries.o dijkstra.o init.o bmp.o ifdef ISDEBUG DEBUG = -ggdb EXEC = debug3lalnview else DEBUG = -ggdb DEBUG= EXEC = lalnview endif CFLAGS = -c $(OPT) $(DEBUG) -I$(FLTK) -I$(PDF) #EXEC=3lalnview #DEBUG = -ggdb CXX=g++ exec : $(OBJECTS) $(CXX) $(DEBUG) -o $(EXEC) $(OBJECTS) -L $(FLTK)/lib -lfltk -lfltk_images \ -L$(PDF) -lpdf \ -lX11 -lm # $(CC) -o $(EXEC) $(SOURCES) -I $(FLTK) -L $(FLTK)/lib -lfltk -lX11 -lm .SUFFIXES: .cxx .h .o .cxx.o : $(CXX) $(CFLAGS) $< clean : rm -rf *.o superclean : rm -rf *.o *~ core 3lalnview ultraclean : rm -rf *.o *~ *.cxx *.c *.H *.h core 2lalnviewlalnview.help010064400004310000036000000307361025203730000141020ustar00goutbiomol00004410000024>>>About lalnview Program lalnview was published in : Duret, L., Gasteiger, E. and Perrie`re, G. (1996) LalnView: a graphical viewer for pairwise sequence alignments. Comput. Applic. Biosci., 12, 507-510 Binaries and full source code available from http://pbil.univ-lyon1.fr/software/lalniew.html Version 3 released on may 2005. Laurent Duret & Jean-Francois Gout Laurent Duret Pole BioInformatique Lyonnais Laboratoire BBE - UMR CNRS 5558 Phone : +33 (0) 4 72 44 62 97 Université Claude Bernard - Lyon 1 FAX : +33 (0) 4 72 43 13 88 16 rue Raphaël Dubois F-69622 Villeurbanne Cedex e-mail : duret@biomserv.univ-lyon1.fr France http://pbil.univ-lyon1.fr/ Jean-Francois Gout e-mail : gout@biomserv.univ-lyon1.fr Lalnview uses the FLTK project (http://www.fltk.org) for its user interface. Lalnview uses the PDFlib lite library (http://www.pdflib.org) for pdf output under the "Open Source Developer Exemption" of the PDFlib Lite License Agreement. >>>Introduction LALNVIEW is a graphical program for visualizing local alignments between two sequences (protein or nucleic acids). Sequences are represented by colored rectangles to give an overall picture of the similarities between the two sequences. Blocs of similarity between the two sequences are colored according to the degree of identity between the two segments. By clicking on a bloc, the user can visualize the corresponding local alignment. A bloc can be repeated in a sequence: iterative clicking on one block will successively display all the similar blocks that occur in the other sequence. It is also possible to display all the overlaping blocks by using the arrows on the main panel (first buttons on the left side of the magnifying glass). The number of overlaping blocks is displayed on top of the arrows. >>>Running LALNVIEW LALNVIEW does not calculate the alignments itself: it uses the output of local alignment programs. LALNVIEW is able to read alignments from three widely used softwares: LFASTA, LALIGN and SIM. LFASTA uses the FASTA heuristic to quickly find local regions of similarity between two sequences [Pearson & Lipman 1988]. SIM and LALIGN are two different implementations of the rigourous algorithm of Huang and Miller [Huang and Miller 1991]. The Huang and Miller algorithm guarentees to find the N-best local alignments between two sequences. Its main drawback is that it is much slower than LFASTA (more than 100-fold slower for the comparison of two sequences of 3000 residues each). If sequences are relatively short (less than 1000 residues) or if calculation time is not limiting, then the Huang and Miller algorithm should be prefered to LFASTA. SIM sources, executables and documentation are distributed along with LALNVIEW. LFASTA and LALIGN are available by anonymous FTP at ftp.virginia.edu Directory /pub/fasta Or ftp.bio.indiana.edu Directory /molbio/search The first step is to run a local alignment software (SIM, LALIGN or LFASTA). The three programs read sequences in FASTA format : >seq-name annotation of any sort ATCGGAGTCGATGGTCACCGNTGGCAC GTACGTACCGTTGTCCAAACTGTGCAY ... For example, to find with SIM 7 best local alignments of segments from two sequences in files A and B, and using the default values, use the command sim 7 A B > search.out Or with LALIGN: lalign A B 7 > search.out Or with LFASTA: lfasta -b 7 A B > search.out Then run LALNVIEW : lalnview search.out & NB : lalnview needs the two sequence files "A" and "B" to be located in the same directory as "search.out". NB: Mac users simply have to drag and drop the search output file on the LALNVIEW icon. NB: SIM software has not been compiled for Macintosh or PC. To run the alignments, use the ExPaSy WWW server (protein sequences): http://expasy.hcuge.ch/sprot/sim-prot.html or http://expasy.hcuge.ch/sprot/sim-nucl.html or the ACNUC WWW server (nucleic acid sequences): http://pbil.univ-lyon1.fr/lfasta.html and declare LALNVIEW as helper application on your WWW browser. >>>Changing thresholds LALNVIEW displays all the local alignments with : - a similarity score greater than a given threshold value. Change the value in the "Similarity Score Threshold" box and type to validate this new value. Increase this value to display only the most significant blocks of similarity. - an identity percentage greater than the minimum percentage shown in the "Minumum identity" box. - a lenght greater than the minimum lenght shown in the "Minimum lenght" box. Change the value in any of these three boxes and type to validate this new value. >>>Displaying the best series of segments Sometimes, the alignments produced by SIM or LFASTA contain so many segments that the area between the two sequences in the main window looks like a very thick spider web and becomes nearly unworkable. Im such a case, it can be very usefull to display only the series of non-overlaping segments that gives the best cumulated score. This can be achieved by tiking the "Display the best series of segments" check button. In any other case, it can still be usefull to use this option, considering the fact that the best series of non-overlaping segments generaly reveals biologicals realities. >>>Adding "Features" The item "Open Features" (in the 'File' menu) allows you to read in a list of segment coordinates from a file. These segments are then displayed on the screen as coloured boxes. Your file with feature segments should be in this format: SeqNumber Begin End Width Color Label SeqNumber: 1 for the bottom sequence, 2 for the upper Begin: beginning of the feature End: end of the feature If "Begin" and "End" are equal, then only a line is displayed. Height: Height of the box representing the feature. any value between 0.0 and 2.2 Color: color of the box representing the feature. 135 colors are available (see at the end of this file). Label: any annotation < 4096 characters The file should contain a line "# FEATURES BEGIN" and a line "# FEATURES END". Only the lines between these two ones are considered. Example: # FEATURES BEGIN 1 1 149 1.0 blue Exon 1 1 1 1.0 blue Transcription start site 2 700 800 1.0 green Exon 2 800 1000 0.2 blue Intron 2 850 950 1.0 yellow Alu repeat 2 1000 1100 1.0 green Exon 2 1100 1500 0.2 blue Intron 2 1500 1600 1.0 green Exon # FEATURES END Click on any "feature" box in the picture to see the corresponding annotation. Annotations are displayed in the main window, under the magnifying glass buttons. WHEN USING LALNVIEW THROUGH THE EXPASY OR ACNUC WWW SERVERS, SEQUENCE FEATURES ARE AUTOMATICALLY EXTRACTED FROM DATABASE ANNOTATIONS. ExPaSy WWW server (protein sequences): http://expasy.hcuge.ch/sprot/sim-prot.html or http://expasy.hcuge.ch/sprot/sim-nucl.html ACNUC WWW server (nucleic acid sequences): http://pbil.univ-lyon1.fr/lfasta.html >>>Reading alignment and features from a single file LALNVIEW reads data from 3 files: - SIM (or LFASTA or LALIGN) output file - first sequence file - second sequence file - features description file [optional] In some cases, it may be convenient to compile all these data in a single file. It is possible to concatenate these 3 (or 4) files in a single file: - this file must begin with SIM (or LFASTA or LALIGN) output data - the first sequence must be preceded by the line: "# SEQUENCES BEGIN 1" - the second sequence must be preceded by the line: "# SEQUENCES BEGIN 2" - the second sequence must be followed by the line: "# SEQUENCES END" In UNIX language, this would be done with the following commands: cat sim_output_file > my_new_file echo "# SEQUENCES BEGIN 1" >> my_new_file cat first_seq_file >> my_new_file echo "# SEQUENCES BEGIN 2" >> my_new_file cat second_seq_file >> my_new_file echo "# SEQUENCES END" >> my_new_file cat feature_file >> my_new_file Then run LALNVIEW with: lalnview my_new_file & Exemple: --------------- begin of file ------------------------------------ #:lav d { "SIM output with parameters: Used PAM200 matrix O = 12, E = 4" } s { "seq_file1" 1 110 "seq_file2" 1 115 } k { "% match" } a { s 168.0 b 11 13 e 110 115 l 11 13 52 54 52.4 l 53 56 64 67 25.0 l 65 69 87 91 4.3 l 88 93 110 115 78.3 } a { s 24.0 b 1 1 e 24 24 l 1 1 24 24 33.3 } # SEQUENCES BEGIN 1 >INS_HUMAN MALWMRLLPLLALLALWGPDPAAAFVNQHLCGSHLVEALYLVCGERGFFY TPKTRREAEDLQVGQVELGGGPGAGSLQPLALEGSLQKRGIVEQCCTSIC SLYQLENYCN # SEQUENCES BEGIN 2 >INS_MYXGL MALSPFLAAVIPLVLLLSRAPPSADTRTTGHLCGKDLVNALYIACGVRGF FYDPTKMKRDTGALAAFLPLAYAEDNESQDDESIGINEVLKSKRGIVEQC CHKRCSIYDLENYCN # SEQUENCES END # FEATURES BEGIN 1 1 24 0.50 yellow SIGNAL 1 25 54 0.50 yellow CHAIN B CHAIN. 1 57 87 0.50 yellow PROPEP C PEPTIDE. 2 96 97 0.10 black TURN 2 102 108 0.50 blue HELIX 2 109 109 0.50 pink STRAND # FEATURES END --------------- end of file ------------------------------------ >>>Changing the colors of the similarity scale Click on any colored rectangle in the similarity scale to change the color affected to the corresponding value. The new scale can be saved and then loaded each time you use lalnview (see help item "Options menu"). >>>File Menu File menu --------- Shortcut key : ALT+f pulls down the menu. Open loads a file in a suported format : SIM, LFASTA or compiled file (see help topic : 'Reading alignment and features from a single file'). Shortcut keys : CTRL+o. ************************************************************************************** Open Features opens a features file associated with the currently displayed alignments. Read section 'Adding features' of this help to get all informations you need about features. Shortcut keys : CTRL+f. ************************************************************************************** Export as PDF creates a PDF capture of the alignment currently displayed in lalnview. You will be asked whether you want to capture the whole alignment (eg including parts of the alignments that are beyond the scrolling area) or the currently visible window. Shortcut keys : CTRL+p. ************************************************************************************** Export as BMP sames as PDF export, creates an image of the currently visible window in bitmap format. Only the current window can be exported, if you wish to export the whole alignment use the 'PDF export' option. WARNING : If the file chooser box or an other window is placed in front of the alignment window it will be visible in the bmp file. It is then strongly recommended that you make sure lalnview is in foreground when using the 'Export as BMP' option. Shortcut keys : CTRL+b. ************************************************************************************** Quit guess what? Shortcut keys : CTRL+q. >>>Options menu Option menu ----------- Shortcut key : ALT+o pulls down the menu. Save alignments Click on "Save Alignments" menu item to write the alignments in a file (by default, this file is named according to the input filename + the extension ".aln". For example "search.aln" ). WARNING : Only the local alignments with a similarity score greater than the current threshold value will be reported. Shortcut key : CTRL+s ************************************************************************************** Scale - Save scale Saves the current colors of the scale in a file of your choice. - Load scale Loads a previously saved scale. ************************************************************************************** Foregroung blocs Sets wether LALNVIEW displays the blocs that belongs to the best or to the worse segment in front when several blocs overlap. >>>Informations displayed in the main window The white rectangle on the left of the zoom buttons contains the main informations about the currently selected segments (lenght, score, identity and gap frequency). The rectangle area below displays informations about the features on wich you clicked. It is updated each time you click on a new feature. so many segments that the area .lalnviewrc010064400004310000036000000004451025203731100135520ustar00goutbiomol00004410000024# # lalnview configuration file # #helpfile : access path to the help file 'lalnview.help' provided with the programm helpfile=/ftp/ftpdir/pub/logiciel/lalnview/lalnview.help # scale : default scale file (previously saved by the Option menu) scale=/bge/gout/lalnview/ressources/echelle.scal