[med-svn] r111 - in trunk/packages: . seaview seaview/branches
seaview/branches/upstream seaview/branches/upstream/current
Charles Plessy
charles-guest at costa.debian.org
Tue Sep 19 14:20:15 UTC 2006
Author: charles-guest
Date: 2006-09-19 14:20:14 +0000 (Tue, 19 Sep 2006)
New Revision: 111
Added:
trunk/packages/seaview/
trunk/packages/seaview/branches/
trunk/packages/seaview/branches/upstream/
trunk/packages/seaview/branches/upstream/current/
trunk/packages/seaview/branches/upstream/current/align.cxx
trunk/packages/seaview/branches/upstream/current/chooser_plus.cxx
trunk/packages/seaview/branches/upstream/current/comlines.cxx
trunk/packages/seaview/branches/upstream/current/load_seq.cxx
trunk/packages/seaview/branches/upstream/current/mac_pc_extras.cxx
trunk/packages/seaview/branches/upstream/current/makefile
trunk/packages/seaview/branches/upstream/current/matpt.h
trunk/packages/seaview/branches/upstream/current/nexus.cxx
trunk/packages/seaview/branches/upstream/current/old_file_chooser.cxx
trunk/packages/seaview/branches/upstream/current/protein.mase
trunk/packages/seaview/branches/upstream/current/regions.cxx
trunk/packages/seaview/branches/upstream/current/resource.cxx
trunk/packages/seaview/branches/upstream/current/seaview.cxx
trunk/packages/seaview/branches/upstream/current/seaview.h
trunk/packages/seaview/branches/upstream/current/seaview.help
trunk/packages/seaview/branches/upstream/current/seaview_align.sh
trunk/packages/seaview/branches/upstream/current/use_mase_files.cxx
trunk/packages/seaview/branches/upstream/current/xfmatpt.cxx
trunk/packages/seaview/tags/
Log:
[svn-inject] Installing original source of seaview
Added: trunk/packages/seaview/branches/upstream/current/align.cxx
===================================================================
--- trunk/packages/seaview/branches/upstream/current/align.cxx (rev 0)
+++ trunk/packages/seaview/branches/upstream/current/align.cxx 2006-09-19 14:20:14 UTC (rev 111)
@@ -0,0 +1,612 @@
+#include "seaview.h"
+#include <stdlib.h>
+#include <ctype.h>
+#ifndef WIN32
+#include <FL/x.H>
+#endif
+
+
+/* local prototypes */
+int save_part_as_pir(int debut, int fin, char **sequence, char **seqname,
+ int *sel_seqs, int tot_seqs, char *fname, int *withU, int *empty_seq,
+ int *num_longest, int protein);
+int replace_align_part(SEA_VIEW *view, int debut, int fin, char *fname, int withU, int num_longest);
+void align_selected_parts(SEA_VIEW *view);
+int calc_gap_sites(char *old_seq, char *new_seq, int lold, int lnew,
+ gap_site *gap_sites, int maxsites);
+int insert_gaps_new_align(char **seq, int site, int number, int numseqs,
+ int lseqs);
+int reset_stars(SEA_VIEW *view, int debut, int lpart, char **seq, int lfrag);
+int confirm_refer_seq(int num_longest, SEA_VIEW *view);
+
+/* extern proto */
+extern int insert_gaps_at(SEA_VIEW *view, int seq, int site, int total);
+extern int insert_gap_all_comments(int numgaps, int pos, SEA_VIEW *view);
+#ifdef WIN32
+extern "C" {
+int mysystem(const char *command);
+}
+#elif defined(__APPLE__)
+void *my_run_program(char *prog, char *arguments, int flavor);
+void loop_till_program_ends(void *psn);
+extern "C" {
+ void MG_FSSpecToPathname (FSSpec *myFSS, char *fname, int maxl);
+ char *get_prog_dir(void);
+ }
+#else
+void change_attr(Fl_Window *w);
+#endif
+
+
+/* extern variables */
+extern gap_site gap_sites[];
+
+int save_part_as_pir(int debut, int fin, char **sequence, char **seqname,
+ int *sel_seqs, int tot_seqs, char *fname, int *withU, int *empty_seq,
+ int *num_longest, int protein)
+/* returns TRUE iff error */
+{
+FILE *out;
+int num, pos, l_line, retval, maxlen, seqlen, current;
+char line[90];
+
+out = fopen(fname,"w");
+if( out == NULL ) return TRUE;
+retval = TRUE;
+*withU = FALSE;
+maxlen = 0; current = 0;
+for(num = 0; num < tot_seqs; num++) {
+ if( ! sel_seqs[num] ) continue;
+ sprintf(line, "%d_%s", ++current, seqname[num]);
+ fprintf(out, ">%.10s\n", line);
+ if(ferror(out)) goto fin;
+ *empty_seq = TRUE;
+ l_line = 0;
+ seqlen = 0;
+ for ( pos = debut - 1 ; pos < fin; pos++) {
+ if( sequence[num][pos] == 0 ) break;
+ if( sequence[num][pos] == '-' ) continue;
+ if(l_line >= 70) {
+ line[l_line] = 0;
+ if(!*withU) *withU = (strchr(line, 'U') != NULL);
+ fprintf(out, "%s\n", line);
+ if(ferror(out)) goto fin;
+ seqlen += l_line;
+ l_line = 0;
+ }
+ line[l_line++] = sequence[num][pos];
+ if(protein && sequence[num][pos] == '*') line[l_line - 1] = 'X';
+ *empty_seq = FALSE;
+ }
+ line[l_line] = 0;
+ seqlen += l_line;
+ if(seqlen > maxlen) {
+ maxlen = seqlen; *num_longest = num;
+ }
+ if(!*withU) *withU = (strchr(line, 'U') != NULL);
+ fprintf(out, "%s\n", line);
+ if( *empty_seq ) strcpy(fname, seqname[num]);
+ if(ferror(out) || *empty_seq) goto fin;
+ }
+retval = FALSE;
+fin:
+if( fclose(out) != 0) return TRUE;
+return retval;
+}
+
+void align_selected_parts(SEA_VIEW *view)
+{
+int debut, fin, status, withU, empty_seq, num_longest, l;
+char *p, *q;
+static char base_fname[100], commande[300];
+FILE *in;
+static int first = TRUE;
+static char *prog_path;
+
+if(first) { /* check for presence of xterm + clustalw + seaview_align.sh */
+ first = FALSE;
+#ifdef WIN32
+ status = check_path("clustalw.exe");
+#elif defined(__APPLE__) // need clustalw in same directory as seaview
+ p = get_prog_dir();
+ if(p == NULL) status = 1;
+ else {
+ strcpy(commande, p); strcat(commande, ":clustalw");
+ in = fopen(commande, "r");
+ status = (in == NULL);
+ fclose(in);
+ prog_path = (char *)malloc(strlen(commande) + 1);
+ strcpy(prog_path, commande);
+ }
+#else
+ status = check_path("clustalw");
+ if(status == 0) {
+ status = check_path("xterm");
+ }
+ if(status == 0) {
+ status = check_path("seaview_align.sh");
+ }
+#endif
+ if(status != 0) {
+ fl_message("Alignment operation is impossible because\n"
+#ifdef WIN32
+ "program clustalw.exe\n"
+#elif defined(__APPLE__)
+ "program clustalw\n"
+#else
+ "one of the programs xterm, clustalw, seaview_align.sh\n"
+#endif
+ "is missing");
+ ((Fl_Menu_ *)view->menu_edit)->mode(ALIGN_SEQS,
+ FL_MENU_INACTIVE);
+ return;
+ }
+ }
+if(view->active_region == NULL || view->active_region->list == NULL ||
+ view->active_region->list->next != NULL || view->tot_sel_seqs <= 1) {
+ fl_message("Need to have exactly one block of selected sites\n"
+ "and some selected sequences");
+ return;
+ }
+#if !( defined(WIN32) || defined(__APPLE__) )
+// mettre fenetres en Backing Store State: WhenMapped
+change_attr( view->DNA_obj->window() );
+change_attr( view->dnawin );
+#endif
+debut = view->active_region->list->debut;
+fin = view->active_region->list->fin;
+tmpnam(base_fname);
+/*
+convertir en minuscules car clustalw n'accepte pas les majuscules ds filenames
+*/
+p = base_fname - 1; while( *(++p) != 0) *p = tolower( *p);
+#ifdef WIN32 /* pas de . et pas plus de 8 car */
+p = base_fname; while( ( q = strchr(p, '\\')) != NULL ) p = q + 1;
+p[8] = 0;
+if( (q = strchr(p + 1,'.')) != NULL ) *q = 0;
+#endif
+sprintf(commande, "%s.pir", base_fname);
+/* allonger les seqs plus courtes que la region traitee */
+for(l = 0; l < view->tot_seqs; l++) {
+ if(!view->sel_seqs[l]) continue;
+ if(fin > view->each_length[l]) insert_gaps_at(view, l + 1,
+ view->each_length[l] + 1, fin - view->each_length[l]);
+ }
+status = save_part_as_pir(debut, fin, view->sequence, view->seqname,
+ view->sel_seqs, view->tot_seqs, commande, &withU, &empty_seq,
+ &num_longest, view->protein);
+if(view->protein) withU = FALSE;
+if(empty_seq) {
+ fl_alert("Cannot process sequence(s)\n%s\n"
+ "containing only gaps", commande);
+ }
+if( (!empty_seq) && status) {
+ fl_alert("Cannot write sequences to filename\n%s", commande);
+ return;
+ }
+if(!empty_seq) num_longest = confirm_refer_seq(num_longest, view);
+if(num_longest == -1 || empty_seq) {
+ sprintf(commande, "%s.pir", base_fname);
+ remove(commande);
+ return;
+ }
+my_watch_cursor(view->dnawin);
+
+/* pour memoire: clustalw retourne 1 ou -1 si erreur, autre chose = succes */
+#ifdef WIN32
+sprintf(commande,
+ "clustalw.exe /align /infile=%s.pir /outfile=%s.phy /output=phylip /outorder=input ",
+ base_fname, base_fname);
+#elif defined(__APPLE__)
+
+sprintf(commande,
+ "/align /infile=%s.pir /outfile=%s.phy /output=phylip /outorder=input ",
+ base_fname, base_fname);
+
+#else
+strcpy(commande, "xterm -T \"clustalw alignment\" -n clustalw -sb -sl 2000 "
+ "-e seaview_align.sh " );
+l = strlen(commande);
+sprintf(commande + l,
+ " %s -infile=%s.pir -outfile=%s.phy -output=phylip -outorder=input ",
+ base_fname, base_fname, base_fname);
+#endif
+Fl_Menu_Button *menu_props = (Fl_Menu_Button *)view->bouton_props;
+props_menu_parts *props_parts =
+ (props_menu_parts *)menu_props->user_data();
+status = menu_props->mode(props_parts->clustalopt) & FL_MENU_VALUE;
+if(view->clustal_options != NULL && status )
+ sprintf(commande + strlen(commande), "%s", view->clustal_options);
+#ifdef WIN32
+status = mysystem(commande);
+#elif defined(__APPLE__)
+void *psn = my_run_program(prog_path, commande, 'SvCw');
+if(psn != NULL) loop_till_program_ends(psn);
+status = 0;
+sprintf(commande, "%s.status", base_fname);
+in = fopen(commande, "r");
+if(in == NULL) status = 1;
+else fclose(in);
+#else
+status = system(commande);
+if( status == 0 ) {
+ sprintf(commande, "%s.status", base_fname);
+ in = fopen(commande, "r");
+ if(in != NULL) {
+ fgets(commande, sizeof(commande), in);
+ if( strcmp(commande, "success\n") != 0) status = 1;
+ fclose(in);
+ }
+ else status = 1;
+ }
+#endif
+sprintf(commande, "%s.phy", base_fname);
+if( status == 0 ) {
+ in = fopen(commande, "r");
+ if(in != NULL) {
+ fseek(in, 0, SEEK_END);
+ status = (ftell(in) < 10);
+ fclose(in);
+ }
+ else status = 1;
+ }
+if( status != 0 )
+ fl_message("Alignment operation ignored");
+else {
+ status = replace_align_part(view, debut, fin, commande, withU, num_longest);
+ if(status) fl_alert("Not enough memory\nor\n"
+ "max sequence length reached");
+ }
+sprintf(commande, "%s.pir", base_fname);
+remove(commande);
+sprintf(commande, "%s.phy", base_fname);
+remove(commande);
+sprintf(commande, "%s.dnd", base_fname);
+remove(commande);
+#ifndef WIN32
+sprintf(commande, "%s.status", base_fname);
+remove(commande);
+#endif
+}
+
+
+int calc_gap_sites(char *old_seq, char *new_seq, int lold, int lnew,
+ gap_site *gap_sites, int maxsites)
+{
+char *fin_old, *fin_new;
+int tot_sites = 0, posalign = 0;
+fin_old = old_seq + lold - 1; fin_new = new_seq + lnew - 1;
+while( old_seq <= fin_old || new_seq <= fin_new ) {
+ if(old_seq <= fin_old && new_seq <= fin_new &&
+ ( ( *old_seq != '-' && *new_seq != '-') ||
+ ( *old_seq == '-' && *new_seq == '-') ) ){
+ old_seq++; new_seq++;
+ posalign++;
+ continue;
+ }
+ if(tot_sites >= maxsites) return -1;
+ gap_sites[tot_sites].l[1] = 0;
+ gap_sites[tot_sites].l[0] = 0;
+ if(old_seq <= fin_old && *old_seq == '-') {
+ gap_sites[tot_sites].pos = posalign;
+ do { old_seq++; ++(gap_sites[tot_sites].l[1]); }
+ while( *old_seq == '-' && old_seq < fin_old);
+ posalign += gap_sites[tot_sites].l[1];
+ }
+ else {
+ gap_sites[tot_sites].pos = posalign;
+ do { new_seq++; ++(gap_sites[tot_sites].l[0]); }
+ while( *new_seq == '-' && new_seq < fin_new);
+ posalign += gap_sites[tot_sites].l[0];
+ }
+ tot_sites++;
+ }
+return tot_sites;
+}
+
+
+int replace_align_part(SEA_VIEW *view, int debut, int fin, char *fname,
+ int withU, int num_longest)
+/* returns TRUE if error, FALSE if ok */
+{
+int num, lfrag, lpart, i, col, rang, retval, newlength, lfrag2;
+char **seq, **comments, **seqname, *pheader, *err_message;
+int (*calc_color_function)(int);
+int totgapsites, num1, site, l_copy, res;
+char *tmp;
+
+view->cursor_in_comment = FALSE;
+view->cursor_seq = view->first_seq;
+/* lecture de l'alignement multiple produit par clustalw */
+num = read_phylip_align(fname, &seq, &seqname, &comments, &pheader, &err_message);
+for(i = 0; i < num; i++) free(seqname[i]);
+if(num > 0) { free(seqname); free(comments); }
+if(num != view->tot_sel_seqs) { if(num > 0) free(seq); return TRUE; }
+
+retval = TRUE;
+if(withU) {
+/* si seq avec U au depart, les remettre car ont ete changes en T par clustalw */
+ char *p, *q;
+ for(num = 0; num < view->tot_sel_seqs; num++) {
+ p = seq[num];
+ while( (q = strchr(p, 'T')) != NULL) { *q = 'U'; p = q; }
+ }
+ }
+lfrag = strlen(seq[0]); /* long alignement de clustalw */
+lpart = fin - debut + 1; /*long region traitee de l'ancien alignement multiple*/
+if(view->protein) {
+ if( reset_stars(view, debut, lpart, seq, lfrag) ) return TRUE;
+ }
+/* num1 = rang dans align clustalw de num_longest dans align multiple */
+num1 = -1;
+for(i = 0; i < view->tot_seqs; i++) {
+ if( !view->sel_seqs[i]) continue;
+ num1++;
+ if( i == num_longest) break;
+ }
+/* calcul des pos et longs de gaps a inserer:
+gap_sites[x].pos = position a droite du gap a inserer (from 0)
+gap_sites[x].l[0] = longueur a inserer dans alignement multiple
+gap_sites[x].l[1] = longueur a inserer dans alignement produit par clustalw
+*/
+totgapsites = calc_gap_sites(view->sequence[num_longest] + debut - 1, seq[num1],
+ FL_min(lpart, view->each_length[num_longest] - debut + 1),
+ lfrag, gap_sites, MAX_GAP_SITES);
+if(totgapsites == -1) goto fin;
+/* calcul long region traitee apres ajout des gaps */
+for(site=0; site<totgapsites; site++)
+ lpart += gap_sites[site].l[0];
+/* l'alignement multiple serait-il trop long en fin d'operation? */
+if( view->seq_length + lpart - (fin - debut + 1) > view->max_seq_length )
+ goto fin;
+/* calcul long alignement de clustalw apres ajout des gaps */
+lfrag2 = lfrag;
+for(site = 0; site < totgapsites; site++)
+ lfrag2 += gap_sites[site].l[1];
+/* allongement memoire pour seqs de l'alignement de clustalw */
+for(num=0; num<view->tot_sel_seqs; num++) {
+ tmp = (char *)malloc(lfrag2+1);
+ if(tmp == NULL) goto fin;
+ memcpy(tmp, seq[num], lfrag+1);
+ free(seq[num]);
+ seq[num] = tmp;
+ }
+/* allongement des seqs de l'alignement de clustalw */
+for(site = 0; site < totgapsites; site++) {
+ if(gap_sites[site].l[1] == 0) continue;
+ lfrag = insert_gaps_new_align(seq, gap_sites[site].pos,
+ gap_sites[site].l[1],
+ view->tot_sel_seqs, lfrag);
+ }
+if(view->numb_gc > 1) {
+ calc_color_function = ( view->protein ?
+ get_color_for_aa : get_color_for_base );
+ }
+newlength = view->seq_length;
+/* allongement des seqs de l'alignement multiple */
+for(site = 0; site < totgapsites; site++) {
+ if(gap_sites[site].l[0] == 0) continue;
+ for(num = 0; num < view->tot_seqs; num++) {
+ insert_gaps_at(view, num + 1,
+ debut + gap_sites[site].pos, gap_sites[site].l[0]);
+ }
+ newlength += gap_sites[site].l[0];
+ insert_region_part(view, debut + gap_sites[site].pos,
+ gap_sites[site].l[0]);
+ if(view->tot_comment_lines > 0) insert_gap_all_comments(
+ gap_sites[site].l[0], debut + gap_sites[site].pos, view);
+ }
+
+/* copie des sequences de clustalw vers alignement multiple */
+rang = -1;
+for(num = 0; num < view->tot_seqs; num++) {
+ if( ! view->sel_seqs[num] ) continue;
+ rang++;
+/* on met les nouvelles seqs */
+ l_copy = FL_min(lpart, lfrag);
+ memcpy( view->sequence[num] + debut - 1, seq[rang], l_copy);
+ if(debut + l_copy - 1 > view->each_length[num])
+ view->each_length[num] = debut + l_copy - 1;
+ newlength = FL_max(newlength, view->each_length[num]);
+ if(view->each_length[num] == debut + l_copy - 1)
+ view->sequence[num][debut + l_copy - 1] = 0;
+ if(view->numb_gc == 1) continue;
+ for(i = 0; i < view->numb_gc; i++) {
+ memset( view->col_seq[num][i] + debut - 1, ' ', l_copy);
+ }
+ for(i = debut - 1; i < debut + l_copy - 1; i++) {
+ res = view->sequence[num][i];
+ col = calc_color_function( res );
+ view->col_seq[num][col][i] =
+ (view->allow_lower ? res : toupper(res) );
+ }
+ if(view->each_length[num] == debut + l_copy - 1) {
+ for(col = 0; col < view->numb_gc; col++)
+ view->col_seq[num][col][debut + l_copy - 1] = 0;
+ }
+ }
+/* mettre a jour horsli */
+update_current_seq_length(newlength, view);
+view->modif_but_not_saved = TRUE;
+retval = FALSE;
+
+fin:
+for(num = 0; num < view->tot_sel_seqs; num++)
+ free(seq[num]);
+free(seq);
+return retval;
+}
+
+
+int insert_gaps_new_align(char **seq, int site, int number, int numseqs,
+ int lseqs)
+{
+int num;
+char *pos;
+for(num=0; num < numseqs; num++) {
+ pos = seq[num] + site;
+ memmove(pos + number, pos, lseqs - site + 1);
+ memset(pos, '-', number);
+ }
+return lseqs + number;
+}
+
+
+int reset_stars(SEA_VIEW *view, int debut, int lpart, char **seq, int lfrag)
+{
+int oldseq, newseq;
+char *p, *q;
+
+newseq = -1;
+for(oldseq = 0; oldseq < view->tot_seqs; oldseq++) {
+ if(!view->sel_seqs[oldseq]) continue;
+ newseq++;
+ p = view->sequence[oldseq] + debut - 2;
+ q = seq[newseq] - 1;
+ while(TRUE) {
+ p++; q++;
+ while (*p == '-') p++;
+ while (*q == '-') q++;
+ if(*p == 0 || *q == 0) break;
+ if( *p == '*' && *q == 'X') *q = '*';
+ if( toupper(*p) != toupper(*q) ) return TRUE;
+ if( islower(*p) ) *q = *p;
+ }
+ }
+return FALSE;
+}
+
+
+int confirm_refer_seq(int num_longest, SEA_VIEW *view)
+{
+static Fl_Window *form;
+static int first = TRUE;
+static Fl_Browser *browser_noms;
+static Fl_Button *ok_button, *cancel_button;
+int lnum, i;
+if(first) {
+ first = FALSE;
+ form = new Fl_Window( 300, 400);
+ form->label("Reference Sequence");
+ form->box(FL_FLAT_BOX);
+ fl_font(FL_HELVETICA, FL_NORMAL_SIZE);
+ browser_noms = new Fl_Browser(5, 5 + fl_height(), form->w() - 10,
+ form->h() - 35 - fl_height(), "Choose one seq.");
+ browser_noms->type(FL_HOLD_BROWSER);
+ browser_noms->textsize(FL_NORMAL_SIZE);
+ browser_noms->has_scrollbar(Fl_Browser_::VERTICAL);
+ browser_noms->align(FL_ALIGN_TOP);
+ browser_noms->color(FL_LIGHT1, browser_noms->selection_color());
+ ok_button = new Fl_Return_Button(5, form->h() - 25,
+ browser_noms->w() / 2, 20, "OK");
+ cancel_button = new Fl_Button(ok_button->x() + ok_button->w(),
+ ok_button->y(), ok_button->w(), ok_button->h(), "Cancel");
+ form->resizable(browser_noms);
+ form->end();
+ form->set_modal();
+ }
+browser_noms->clear();
+lnum = 0;
+for(i = 0; i < view->tot_seqs; i++) {
+ if(!view->sel_seqs[i]) continue;
+ lnum++;
+ browser_noms->add(view->seqname[i]);
+ if(i == num_longest) browser_noms->value(lnum);
+ }
+form->show();
+for (;;) {
+ Fl_Widget *o = Fl::readqueue();
+ if (!o) Fl::wait();
+ else if(o == cancel_button ) { num_longest = -1; break; }
+ else if(o == ok_button && browser_noms->value() != 0) break;
+ }
+form->hide();
+if(num_longest == -1) return -1;
+Fl::flush();
+
+lnum = browser_noms->value();
+for(i = 0; i < view->tot_seqs; i++) {
+ if(!view->sel_seqs[i]) continue;
+ if(strcmp(view->seqname[i], browser_noms->text(lnum)) == 0) {
+ num_longest = i;
+ break;
+ }
+ }
+return num_longest;
+}
+
+
+
+#if defined(__APPLE__)
+
+void loop_till_program_ends(void *psn)
+{
+ProcessInfoRec pinfo;
+OSErr err;
+
+while(1) {
+ Fl::wait();
+ pinfo.processInfoLength = sizeof(ProcessInfoRec);
+ pinfo.processName = NULL;
+ pinfo.processAppSpec = NULL;
+ err = GetProcessInformation((ProcessSerialNumber *)psn, &pinfo);
+ if(err == procNotFound) break;
+ }
+}
+
+
+void *my_run_program(char *prog, char *arguments, int flavor)
+{
+LaunchParamBlockRec pbloc;
+FSSpec fspec;
+OSErr err;
+char pfname[256];
+ProcessSerialNumber *pinfo;
+ScrapRef scrapref;
+OSStatus etat;
+Size l;
+UInt32 count;
+
+if(arguments != NULL) { // put arguments in the scrap under the specified flavor
+ etat = ClearCurrentScrap(); // indispensable !
+ etat = GetCurrentScrap(&scrapref);
+ l = strlen(arguments);
+ etat = PutScrapFlavor(scrapref, flavor, kScrapFlavorMaskNone, l, arguments);
+ }
+strcpy(pfname + 1, prog );
+pfname[0] = strlen(pfname+1);
+err = FSMakeFSSpec(0, 0, (ConstStr255Param)pfname, &fspec);
+if(err != noErr) return NULL;
+
+pbloc.launchControlFlags = launchContinue | launchNoFileFlags ;
+pbloc.launchBlockID = extendedBlock;
+pbloc.launchEPBLength = extendedBlockLen;
+pbloc.launchAppParameters = NULL;
+pbloc.launchAppSpec = &fspec;
+err = LaunchApplication(&pbloc);
+pinfo = (ProcessSerialNumber *)malloc(sizeof(ProcessSerialNumber));
+*pinfo = pbloc.launchProcessSN;
+return ( err == noErr ? pinfo : NULL) ;
+}
+
+
+#elif !defined(WIN32)
+
+void change_attr(Fl_Window *w)
+{
+XSetWindowAttributes attr;
+XWindowAttributes current;
+
+XGetWindowAttributes(fl_display, fl_xid(w), ¤t);
+if(current.backing_store != NotUseful) return;
+attr.backing_store = WhenMapped;
+XChangeWindowAttributes(fl_display, fl_xid(w), CWBackingStore, &attr);
+// il faut la redessiner pour que ca fasse effet
+w->redraw();
+Fl::flush();
+}
+
+#endif
+
+
+
Added: trunk/packages/seaview/branches/upstream/current/chooser_plus.cxx
===================================================================
--- trunk/packages/seaview/branches/upstream/current/chooser_plus.cxx (rev 0)
+++ trunk/packages/seaview/branches/upstream/current/chooser_plus.cxx 2006-09-19 14:20:14 UTC (rev 111)
@@ -0,0 +1,600 @@
+#include "seaview.h"
+#include "FL/Fl_Group.H"
+#include "FL/Fl_Menu.H"
+#include "FL/Fl_Menu_.H"
+#include "FL/Fl_Browser_.H"
+#include "FL/filename.H"
+#include "FL/Fl_Button.H"
+#include "FL/Fl_Check_Button.H"
+
+
+/* included functions */
+char* fl_file_chooser_plus(const char* message, const char* pat,
+ const char* fname, int use_only_button);
+char* fl_file_chooser_save_as(const char* message, const char* pat,
+ const char* fname, void *view);
+#ifdef __APPLE__
+int MG_GetOutputFName_Popup(char *fname, int maxl, char *dfault, void *data, int defaultformat);
+int MG_GetOutputFName_Plus(char *fname, int maxl, char *dfault, char *message);
+#else
+int change_bouton_label(Fl_Widget *obj, char *message);
+void change_block(Fl_Widget *obj, void *data);
+void change_cpl(Fl_Widget *obj, void *data);
+void change_lpp(Fl_Widget *obj, void *data);
+void change_vary(Fl_Widget *obj, void *data);
+#endif
+
+
+
+// needed functions
+#ifdef __APPLE__
+extern "C" {
+ void MG_FSSpecToPathname (FSSpec *myFSS, char *fname, int maxl);
+ void PtoC(const void *in, void *out);
+ void CtoP(const void *in, void *out);
+ }
+extern void set_save_format(SEA_VIEW *view, int val);
+#else
+extern void change_format(Fl_Widget *obj, void *data);
+#endif
+
+extern int nbr_formats;
+extern char *f_format_names[];
+extern int printout_block, printout_cpl, printout_lpp;
+extern int printout_vary;
+
+
+#ifdef __APPLE__
+
+
+static pascal void MyNavEventProc_popup (NavEventCallbackMessage callBackSelector,
+ NavCBRecPtr callBackParms,
+ NavCallBackUserData callBackUD)
+{
+NavMenuItemSpec *p;
+SEA_VIEW *view;
+int num;
+char f_name[20];
+OSErr err;
+
+view = (SEA_VIEW *)callBackUD;
+if(callBackSelector == kNavCBStart) {
+/* il faut beaucoup d'imagination pour arriver à faire marcher ce call */
+ NavMenuItemSpec item;
+ CtoP(f_format_names[view->format_for_save], item.menuItemName);
+ item.version = kNavMenuItemSpecVersion;
+ item.menuCreator = 'extn'; // nécessaire
+ item.menuType = view->format_for_save ;
+ err = NavCustomControl(callBackParms->context, kNavCtlSelectCustomType, &item );
+ }
+else if(callBackSelector == kNavCBPopupMenuSelect) {
+ p = (NavMenuItemSpec *)(callBackParms->eventData.eventDataParms.param);
+ PtoC(p->menuItemName, f_name);
+ for(num = 0; num < nbr_formats; num++ ) {
+ if(strcmp(f_format_names[num], f_name) == 0) break;
+ }
+ set_save_format(view, num);
+ }
+return;
+}
+
+
+int MG_GetOutputFName_Popup(char *fname, int maxl, char *dfault, void *data, int defaultformat)
+{
+ OSErr anErr = noErr;
+ NavReplyRecord reply;
+ NavDialogOptions dialogOptions;
+ FSSpec fss;
+ OSType fileTypeToSave = 'TEXT';
+ OSType creatorType;
+ NavEventUPP eventProc = NewNavEventUPP (MyNavEventProc_popup);
+ char filename [256];
+ Handle h;
+ NavMenuItemSpec *p;
+ int i, rsult = FALSE;
+
+ anErr = NavGetDefaultDialogOptions (&dialogOptions);
+ if (anErr == noErr)
+ {
+ CtoP("seaview : save", dialogOptions.windowTitle);
+ dialogOptions.dialogOptionFlags &= ~ kNavNoTypePopup;
+ dialogOptions.dialogOptionFlags &= ~ kNavAllowStationery;
+ h = NewHandle(nbr_formats * sizeof(NavMenuItemSpec));
+ HLock(h); p = (NavMenuItemSpec *)*h;
+ for(i = 0; i < nbr_formats; i++) {
+ p->version = kNavMenuItemSpecVersion;
+ CtoP(f_format_names[i], p->menuItemName);
+ p->menuCreator = 'extn'; // nécessaire
+ p->menuType = i ; // nécessaire
+ p++;
+ }
+ HUnlock(h);
+ dialogOptions.popupExtension = (NavMenuItemSpecArrayHandle)h;
+ reply.translationNeeded = false;
+
+
+ // One way to get the name for the file to be saved.
+ CtoP(dfault, dialogOptions.savedFileName);
+
+ creatorType = kNavGenericSignature;
+ anErr = NavPutFile( NULL, &reply, &dialogOptions, eventProc,
+ fileTypeToSave, creatorType, data );
+ 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
+ */
+ strcat(fname, ":");
+ PtoC(documentFSSpec.name, fname + strlen(fname) );
+
+ rsult = TRUE;
+ }
+
+ // DO NOT call NavCompleteSave() to complete
+ anErr = NavCompleteSave(&reply,
+ kNavTranslateInPlace);
+ }
+ (void) NavDisposeReply(&reply);
+ }
+ DisposeNavEventUPP(eventProc);
+ }
+ return rsult;
+}
+
+
+char* fl_file_chooser_save_as(const char* message, const char* pat,
+ const char* fname, void *data)
+{
+ static char pathname[FL_PATH_MAX];
+ SEA_VIEW *view = (SEA_VIEW *)data;
+ if( MG_GetOutputFName_Popup(pathname, FL_PATH_MAX, (char *)fname, data,
+ view->format_for_save) ) return pathname;
+ else return NULL;
+}
+
+
+static pascal void MyNavEventProc_Plus (NavEventCallbackMessage callBackSelector,
+ NavCBRecPtr callBackParms,
+ NavCallBackUserData callBackUD)
+{
+OSErr err;
+static Handle gDitlList;
+static DialogItemIndex index;
+static DialogRef ref;
+Rect rect; Handle h; DialogItemType dtype; Str255 text;
+char text2[256];
+
+if(callBackSelector == kNavCBCustomize) {
+ if(callBackParms->customRect.bottom == 0)
+ callBackParms->customRect.bottom = callBackParms->customRect.top + 35;
+ if(callBackParms->customRect.right == 0)
+ callBackParms->customRect.right = callBackParms->customRect.left + 400;
+ }
+else if(callBackSelector == kNavCBStart) {
+ gDitlList = GetResource ('DITL', 128);
+ if(gDitlList != NULL) err = NavCustomControl(callBackParms->context,
+ kNavCtlAddControlList, gDitlList);
+ err = NavCustomControl(callBackParms->context, kNavCtlGetFirstControlID, &index);
+ index++;
+ ref = GetDialogFromWindow(callBackParms->window);
+ sprintf(text2,"%3d", printout_block);
+ CtoP(text2, text);
+ GetDialogItem(ref, index + 1, &dtype, &h, &rect);
+ SetDialogItemText(h, text);
+ sprintf(text2,"%3d", printout_cpl);
+ CtoP(text2, text);
+ GetDialogItem(ref, index + 3, &dtype, &h, &rect);
+ SetDialogItemText(h, text);
+ sprintf(text2,"%3d", printout_lpp);
+ CtoP(text2, text);
+ GetDialogItem(ref, index + 5, &dtype, &h, &rect);
+ SetDialogItemText(h, text);
+ }
+else if(callBackSelector == kNavCBTerminate) {
+ GetDialogItem(ref, index + 1, &dtype, &h, &rect);
+ GetDialogItemText(h, text);
+ PtoC(text, text2);
+ sscanf(text2,"%d", &printout_block);
+ GetDialogItem(ref, index + 3, &dtype, &h, &rect);
+ GetDialogItemText(h, text);
+ PtoC(text, text2);
+ sscanf(text2,"%d", &printout_cpl);
+ GetDialogItem(ref, index + 5, &dtype, &h, &rect);
+ GetDialogItemText(h, text);
+ PtoC(text, text2);
+ sscanf(text2,"%d", &printout_lpp);
+ if(gDitlList != NULL) ReleaseResource( gDitlList );
+ }
+return;
+}
+
+
+int MG_GetOutputFName_Plus(char *fname, int maxl, char *dfault, char *message)
+{
+ OSErr anErr = noErr;
+ NavReplyRecord reply;
+ NavDialogOptions dialogOptions;
+ FSSpec fss;
+ OSType fileTypeToSave = 'TEXT';
+ OSType creatorType;
+ NavEventUPP eventProc = NewNavEventUPP (MyNavEventProc_Plus);
+ char filename [256];
+ NavMenuItemSpec *p;
+ int i, rsult = FALSE;
+
+ anErr = NavGetDefaultDialogOptions (&dialogOptions);
+ if (anErr == noErr)
+ {
+ CtoP(message, dialogOptions.windowTitle);
+ dialogOptions.dialogOptionFlags |= kNavNoTypePopup;
+ dialogOptions.dialogOptionFlags &= ~ kNavAllowStationery;
+ reply.translationNeeded = false;
+
+
+ // One way to get the name for the file to be saved.
+ 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
+ */
+ strcat(fname, ":");
+ PtoC(documentFSSpec.name, fname + strlen(fname) );
+
+ rsult = TRUE;
+ }
+
+ // DO NOT call NavCompleteSave() to complete
+ anErr = NavCompleteSave(&reply,
+ kNavTranslateInPlace);
+ }
+ (void) NavDisposeReply(&reply);
+ }
+ DisposeNavEventUPP(eventProc);
+ }
+ return rsult;
+}
+
+
+char* fl_file_chooser_plus(const char* message, const char* pat,
+ const char* fname, int use_only_button)
+{
+ static char pathname[FL_PATH_MAX];
+ if( MG_GetOutputFName_Plus(pathname, FL_PATH_MAX, (char *)fname, (char *)message ) ) return pathname;
+ else return NULL;
+}
+
+
+#else
+
+
+
+class FCB : public Fl_Browser_ {
+ void* item_first() const ;
+ void* item_next(void*) const ;
+ void* item_prev(void*) const ;
+ int item_height(const dirent*, int) const ;
+ int item_height(void*) const ;
+ int item_width(const dirent*) const ;
+ int item_width(void*) const ;
+ int item_quick_height(void*) const ;
+ int incr_height() const ;
+ void item_draw(void*, int, int, int, int) const ;
+ int checkdir(const dirent*, char*) const ;
+ void draw();
+ void clear_prev();
+public:
+ char listed[FL_PATH_MAX];// current dir & starname
+ int dirend; // points after last / before starname
+ int nameend; // length to trailing '*' or '\0'
+ const char* pattern; // default pattern
+ dirent** list; // the file names
+ dirent** last; // pointer after end of list
+ const char* message; // message if no file names
+ char preved[FL_PATH_MAX];// directory listed in prev
+ dirent** prev; // cached list of another directory
+ dirent** prev_last; // end of that list
+ int prev_count;
+ FCB(int x, int y, int w, int h) : Fl_Browser_(x, y, w, h, 0) {
+ type(FL_HOLD_BROWSER);
+ listed[0] = 0;
+ dirend = nameend = 1;
+ pattern = 0;
+ list = prev = 0;
+ message = 0;
+ }
+ // ~FCB nyi
+ void clear();
+ void set(const char*);
+ int get(char*);
+};
+
+class FCW : public Fl_Window {
+public:
+ int handle(int);
+ Fl_Input input;
+ Fl_Button* ok_button;
+ Fl_Button* cancel_button;
+ Fl_Button* normal_button;
+ Fl_Button* cwd_button;
+ FCB browser;
+ FCW() ;
+};
+
+#define PRINTOUT_LABEL_SIZE 30
+static char printout_label_block[PRINTOUT_LABEL_SIZE] = "block size=";
+static char printout_label_cpl[PRINTOUT_LABEL_SIZE] = "chars/line=";
+static char printout_label_lpp[PRINTOUT_LABEL_SIZE] = "lines/page=";
+static char printout_label_vary[PRINTOUT_LABEL_SIZE] = "variable sites only";
+
+
+int change_bouton_label(Fl_Widget *obj, char *message)
+{
+char *p, defaut[PRINTOUT_LABEL_SIZE], *b_label;
+int old_val, new_val;
+p = (char *)obj->label();
+p = strchr(p, '=') + 1;
+sscanf(p, "%d", &old_val);
+sprintf(defaut, "%d", old_val);
+p = (char *)fl_input(message, defaut);
+if(p == NULL) return old_val;
+new_val = -1; sscanf(p, "%d", &new_val);
+if( new_val == old_val || new_val <= 0) return old_val;
+b_label = (char *)malloc(PRINTOUT_LABEL_SIZE);
+strcpy(b_label, obj->label());
+p = strchr(b_label, '=') + 1;
+sprintf(p, "%d", new_val);
+free( (void *)obj->label() );
+obj->label(b_label);
+return new_val;
+}
+
+void change_block(Fl_Widget *obj, void *data)
+{
+printout_block = change_bouton_label(obj, "Enter desired printout block size");
+}
+
+void change_cpl(Fl_Widget *obj, void *data)
+{
+printout_cpl = change_bouton_label(obj,
+ "Enter desired number of residues per line");
+}
+
+void change_lpp(Fl_Widget *obj, void *data)
+{
+printout_lpp = change_bouton_label(obj,
+ "Enter desired number of lines per page");
+}
+
+
+void change_vary(Fl_Widget *obj, void *data)
+{
+Fl_Button *b = (Fl_Button *)obj;
+int etat = b->value();
+printout_vary = etat;
+}
+
+
+#define labelSize 10
+#define calc_width(nom) \
+ (fl_font(FL_HELVETICA, labelSize), (int)fl_width(nom) + 20)
+
+
+char* fl_file_chooser_save_as(const char* message, const char* pat,
+ const char* fname, void *view)
+{
+ static FCW* f; if (!f) f = new FCW();
+ f->ok_button->label(fl_ok);
+ f->cancel_button->label(fl_cancel);
+
+ if (pat && !*pat) pat = 0;
+ if (fname && *fname) {
+ f->input.value(fname);
+ } else if (f->browser.pattern != pat && (!pat || !f->browser.pattern ||
+ strcmp(pat,f->browser.pattern))) {
+ // if pattern is different, remove name but leave old directory:
+ const char* p = f->input.value();
+ const char* q = fl_filename_name(p);
+ f->input.value(p, q-p);
+ }
+ f->browser.pattern = pat;
+ f->normal_button->label(pat ? pat : "visible files");
+ f->browser.set(f->input.value());
+ f->input.position(10000, f->browser.dirend);
+
+ f->label(message);
+ f->hotspot(f);
+
+Fl_Button *bouton;
+
+bouton = new Fl_Button(2, f->ok_button->y(), 5, f->ok_button->h());
+char b_label[] = "change file format";
+fl_font(f->ok_button->labelfont(), f->ok_button->labelsize());
+bouton->size( (int)fl_width(b_label) + 10 , bouton->h() );
+bouton->label(b_label);
+bouton->callback(change_format, view);
+f->add(bouton);
+
+
+ f->show();
+ int ok = 0;
+ for (;;) {
+ Fl::wait();
+ Fl_Widget* o = Fl::readqueue();
+ if (o == f->ok_button) {ok = 1; break;}
+ else if (o == f->cancel_button || o == f) break;
+ }
+ f->hide();
+ f->browser.clear();
+
+ if (!ok) return 0;
+ const char* r = f->input.value();
+ const char *p;
+ for (p=r+f->browser.dirend; *p; p++)
+ if (*p=='*' || *p=='?' || *p=='[' || *p=='{') return 0;
+ static char final[FL_PATH_MAX];
+ strcpy(final, r);
+ return final;
+}
+
+
+char* fl_file_chooser_plus(const char* message, const char* pat,
+ const char* fname, int use_only_button)
+{
+static int first = TRUE;
+static Fl_Button *b_vary;
+ static FCW* f; if (!f) f = new FCW();
+ f->ok_button->label(fl_ok);
+ f->cancel_button->label(fl_cancel);
+
+ if (pat && !*pat) pat = 0;
+ if (fname && *fname) {
+ f->input.value(fname);
+ } else if (f->browser.pattern != pat && (!pat || !f->browser.pattern ||
+ strcmp(pat,f->browser.pattern))) {
+ // if pattern is different, remove name but leave old directory:
+ const char* p = f->input.value();
+ const char* q = fl_filename_name(p);
+ f->input.value(p, q-p);
+ }
+ f->browser.pattern = pat;
+ f->normal_button->label(pat ? pat : "visible files");
+ f->browser.set(f->input.value());
+ f->input.position(10000, f->browser.dirend);
+
+ f->label(message);
+ f->hotspot(f);
+
+if(first) {
+ first = FALSE;
+ int gauche = 2; char *q; Fl_Button *bouton; char *b_label;
+
+ bouton = new Fl_Button(gauche, f->ok_button->y(), 5, f->ok_button->h());
+ b_label = (char *)malloc(50);
+ strcpy(b_label, printout_label_block);
+ q = strchr(b_label,'=');
+ sprintf(q+1, "%d", printout_block);
+ bouton->size( calc_width(b_label) , bouton->h() );
+ bouton->label(b_label);
+ bouton->callback(change_block, NULL);
+ bouton->labelsize(labelSize);
+ f->add(bouton);
+ gauche += bouton->w() + 2;
+
+ bouton = new Fl_Button(gauche, f->ok_button->y(), 5, f->ok_button->h());
+ b_label = (char *)malloc(50);
+ strcpy(b_label, printout_label_cpl);
+ q = strchr(b_label,'=');
+ sprintf(q+1, "%d", printout_cpl);
+ bouton->size( calc_width(b_label) , bouton->h() );
+ bouton->label(b_label);
+ bouton->callback(change_cpl, NULL);
+ bouton->labelsize(labelSize);
+ f->add(bouton);
+ gauche += bouton->w() + 2;
+
+ bouton = new Fl_Button(gauche, f->ok_button->y(), 5, f->ok_button->h());
+ b_label = (char *)malloc(50);
+ strcpy(b_label, printout_label_lpp);
+ q = strchr(b_label,'=');
+ sprintf(q+1, "%d", printout_lpp);
+ bouton->size( calc_width(b_label) , bouton->h() );
+ bouton->label(b_label);
+ bouton->callback(change_lpp, NULL);
+ bouton->labelsize(labelSize);
+ f->add(bouton);
+ gauche += bouton->w() + 2;
+
+ b_vary = new Fl_Check_Button(gauche, f->ok_button->y(), 5,
+ f->ok_button->h());
+ b_vary->size( calc_width(printout_label_vary) , bouton->h() );
+ b_vary->label(printout_label_vary);
+ b_vary->callback(change_vary, NULL);
+ b_vary->labelsize(labelSize);
+ b_vary->value(printout_vary);
+ f->add(b_vary);
+}
+
+f->show();
+if(use_only_button) b_vary->show();
+else b_vary->hide();
+
+ int ok = 0;
+ for (;;) {
+ Fl::wait();
+ Fl_Widget* o = Fl::readqueue();
+ if (o == f->ok_button) {ok = 1; break;}
+ else if (o == f->cancel_button || o == f) break;
+ }
+ f->hide();
+ f->browser.clear();
+
+ if (!ok) return 0;
+ const char* r = f->input.value();
+ const char *p;
+ for (p=r+f->browser.dirend; *p; p++)
+ if (*p=='*' || *p=='?' || *p=='[' || *p=='{') return 0;
+ return (char*)r;
+}
+
+#endif
Added: trunk/packages/seaview/branches/upstream/current/comlines.cxx
===================================================================
--- trunk/packages/seaview/branches/upstream/current/comlines.cxx (rev 0)
+++ trunk/packages/seaview/branches/upstream/current/comlines.cxx 2006-09-19 14:20:14 UTC (rev 111)
@@ -0,0 +1,331 @@
+#include "seaview.h"
+#include <string.h>
+#include <stdlib.h>
+
+void draw_comment_lines(Fl_Widget *ob, SEA_VIEW *view);
+int parse_comment_lines_from_header(char *header, char ***plines,
+ char ***pnames, int **plengths, int *pmax_seq_length);
+int insert_char_in_comment(int key, int num, SEA_VIEW *view);
+int insert_gap_all_comments(int numgaps, int pos, SEA_VIEW *view);
+int delete_char_in_comment(SEA_VIEW *view, int count, int comnum, int depart,
+ int protect);
+int delete_in_all_comments(int numdels, int pos, SEA_VIEW *view);
+void update_menu_footers(SEA_VIEW *view);
+void footers_menu_callback(Fl_Widget *ob, long which);
+
+/* used prototypes */
+void set_and_show_new_cursor_site(SEA_VIEW *view, int new_pos, int center,
+ int force_redraw);
+int compute_size_params(SEA_VIEW *view, int force_recompute);
+
+
+void draw_comment_lines(Fl_Widget *ob, SEA_VIEW *view)
+{
+int offset, x, y, l_line, nline;
+int couleur, background;
+
+if( !view->show_comment_lines ) return;
+x = view->x_seq;
+y = view->y_seq + (view->pos_first_comment_line - 1) * view->line_height;
+/* write lines */
+x = view->x_seq;
+offset= view->first_site - 1;
+for(nline = 0;
+ nline < view->tot_comment_lines ; nline++, y += view->line_height ) {
+ if(view->mod_comment_line == 0 || view->mod_comment_line == nline+1 ) {
+ if(view->active_comment_line == nline + 1) {
+ couleur = FL_WHITE;
+ background = FL_BLACK;
+ }
+ else {
+ couleur = FL_BLACK;
+ background = ob->selection_color();
+ }
+ fl_font(FL_COURIER_ITALIC, ob->labelsize() );
+ fl_color(background);
+ fl_rectf( view->x_name,
+ y - view->line_height + fl_descent(),
+ (view->wid_names+1) * view->char_width,
+ view->line_height);
+ fl_color(couleur);
+ fl_draw(view->comment_name[nline],
+ FL_min(view->wid_names,
+ strlen(view->comment_name[nline]) ),
+ view->x_name, y);
+ l_line = (
+ offset + view->tot_sites < view->comment_length[nline] ?
+ view->tot_sites : view->comment_length[nline] - offset);
+ if(l_line <= 0) continue;
+ fl_font(ob->labelfont(), ob->labelsize() );
+ fl_color(ob->color());
+ fl_rectf(x, y - view->line_height + fl_descent(),
+ (view->tot_sites + 1) * view->char_width,
+ view->line_height);
+ fl_color(FL_BLACK);
+ fl_draw(view->comment_line[nline] + offset, l_line, x, y);
+ }
+ }
+}
+
+
+int parse_comment_lines_from_header(char *header, char ***plines,
+ char ***pnames, int **plengths, int *pmax_seq_length)
+{
+char *new_header, *fin_new_header, *old_header, *j, *p, *q;
+int l_header, num, total, max_seq_length;
+char **lines, **names;
+int *lengths;
+
+if(header == NULL) return 0;
+old_header = header;
+l_header = strlen(header);
+total = 0;
+while (*header!= 0) {
+ if(strncmp(header,";;|",3) == 0) {
+ total++;
+ do header = strchr(header,'\n') + 1;
+ while(strncmp(header, ";;||", 4) != 0);
+ }
+ header = strchr(header,'\n') + 1;
+ }
+if(total == 0) return 0;
+names = (char **)malloc(total * sizeof(char *));
+lines = (char **)malloc(total * sizeof(char *));
+lengths = (int *)malloc(total * sizeof(int));
+if( names == NULL || lines == NULL || lengths == NULL) out_of_memory();
+header = old_header;
+if( (new_header = (char *)malloc(l_header+1)) == NULL) out_of_memory();
+fin_new_header = new_header;
+*new_header = 0;
+num = -1;
+max_seq_length = *pmax_seq_length;
+while (*header!= 0) {
+ if(strncmp(header,";;|",3) == 0) {
+ num++;
+ p = header + 3; while(*p == ' ') p++;
+ q = strchr(p, '\n');
+ names[num] = (char *)malloc(q - p + 1);
+ if( names[num] == NULL ) out_of_memory();
+ memcpy( names[num], p, q - p );
+ names[num][q - p] = 0;
+ header = q + 1;
+ p = header;
+ do p = strchr(p,'\n') + 1;
+ while(strncmp(p, ";;||", 4) != 0);
+ if(p - header > max_seq_length) max_seq_length = p - header;
+ lines[num] = (char *)malloc(p - header + 1);
+ if( lines[num] == NULL ) out_of_memory();
+ q = lines[num];
+ do {
+ p = strchr(header,'\n') + 1;
+ memcpy(q, header + 2, p - header - 3);
+ q += p - header - 3;
+ header = p;
+ }
+ while(strncmp(p, ";;||", 4) != 0);
+ *q = 0;
+ lengths[num] = strlen(lines[num]);
+ }
+ else {
+ j=(char *)memccpy(fin_new_header, header, '\n', l_header);
+ fin_new_header += (j - fin_new_header);
+ }
+ header = strchr(header,'\n') + 1;
+ }
+*fin_new_header = 0;
+strcpy(old_header, new_header);
+free(new_header);
+*pnames = names; *plines = lines; *plengths = lengths;
+*pmax_seq_length = max_seq_length;
+return num + 1;
+}
+
+
+int insert_char_in_comment(int key, int num, SEA_VIEW *view)
+{
+char *pos;
+int l;
+
+if(num + view->comment_length[view->active_comment_line - 1] >
+ view->max_seq_length)
+ num = view->max_seq_length -
+ view->comment_length[view->active_comment_line - 1];
+pos = view->comment_line[view->active_comment_line - 1] + view->cursor_site - 1;
+l = view->comment_length[view->active_comment_line - 1] - view->cursor_site + 1;
+memmove(pos + num, pos, l + 1);
+memset(pos, key, num);
+view->mod_comment_line = view->cursor_seq;
+view->comment_length[view->active_comment_line - 1] += num;
+set_and_show_new_cursor_site(view, view->cursor_site + num, FALSE, TRUE);
+view->modif_but_not_saved = TRUE;
+return num;
+}
+
+
+int insert_gap_all_comments(int numgaps, int pos, SEA_VIEW *view)
+{
+int num, l, total = 0;
+char *debut;
+for(num = 0; num < view->tot_comment_lines; num++) {
+ if(pos > view->comment_length[num] + 1) continue; /* beyond end */
+ total = numgaps;
+ if(total + view->comment_length[num] > view->max_seq_length) {
+ total = view->max_seq_length - view->comment_length[num];
+ fl_ringbell(0);
+ }
+ debut = view->comment_line[num] + pos - 1;
+ l = view->comment_length[num] - pos + 1;
+ memmove(debut + total, debut, l + 1);
+ memset(debut, '-', total);
+ view->comment_length[num] += total;
+ }
+return total;
+}
+
+
+int delete_char_in_comment(SEA_VIEW *view, int count, int comnum, int depart,
+ int protect)
+{
+char *pos;
+int l, total;
+
+if(count >= depart) count = depart - 1;
+pos = view->comment_line[comnum - 1] + depart - 1;
+l = view->comment_length[comnum - 1] - depart + 1;
+if(protect) {
+ for(total = 1; total <= count ; total++)
+ if( *(pos - total) != '-' ) break;
+ count = total - 1;
+ if(count == 0) return 0;
+ }
+memmove(pos - count, pos, l + 1);
+view->mod_comment_line = comnum;
+view->comment_length[comnum - 1] -= count;
+set_and_show_new_cursor_site(view, depart - count, FALSE, TRUE);
+view->modif_but_not_saved = TRUE;
+return count;
+}
+
+
+int delete_in_all_comments(int numdels, int pos, SEA_VIEW *view)
+{
+int num, l;
+char *debut;
+numdels = FL_min(numdels, pos);
+for(num = 0; num < view->tot_comment_lines; num++) {
+ if(pos > view->comment_length[num] + 1) continue; /* beyond end */
+ debut = view->comment_line[num] + pos - 1;
+ l = view->comment_length[num] - pos + 1;
+ memmove(debut - numdels, debut, l + 1);
+ view->comment_length[num] -= numdels;
+ }
+return numdels;
+}
+
+
+void update_menu_footers(SEA_VIEW *view)
+{
+Fl_Menu_ *menu = (Fl_Menu_ *)view->menu_footers;
+Fl_Menu_Item *items = (Fl_Menu_Item *)menu->menu();
+if(view->tot_comment_lines > 0)
+ items[SHOW_HIDE_FOOTERS].activate();
+else
+ items[SHOW_HIDE_FOOTERS].deactivate();
+if(view->show_comment_lines)
+ menu->replace(SHOW_HIDE_FOOTERS,"Hide footers");
+else
+ menu->replace(SHOW_HIDE_FOOTERS,"Show footers");
+if(view->show_comment_lines && view->active_comment_line > 0)
+ items[DELETE_FOOTER].activate();
+else
+ items[DELETE_FOOTER].deactivate();
+if(view->tot_seqs > 0 )
+ items[CREATE_FOOTER].activate();
+else
+ items[CREATE_FOOTER].deactivate();
+}
+
+
+void footers_menu_callback(Fl_Widget *ob, long which)
+{
+SEA_VIEW *view;
+int num, reponse = ((Fl_Menu_ *)ob)->value();
+view = (SEA_VIEW *) ob->user_data();
+if(reponse == SHOW_HIDE_FOOTERS && view->tot_comment_lines > 0) {
+ view->show_comment_lines = !view->show_comment_lines;
+ view->active_comment_line = 0;
+ view->cursor_in_comment = FALSE;
+ compute_size_params(view, TRUE);
+ view->DNA_obj->redraw();
+ }
+else if(reponse == CREATE_FOOTER) {
+ char **pline, **pname, *texte, *name;
+ const char *c_name;
+ int *plength;
+ c_name = fl_input("Name of new footer line?", "Comments" );
+ if(c_name == NULL || strlen(c_name) == 0) return;
+ num = view->tot_comment_lines;
+ pline = (char **)malloc((view->tot_comment_lines + 1) *sizeof(char *));
+ if(pline == NULL) return;
+ pname = (char **)malloc((view->tot_comment_lines + 1) *sizeof(char *));
+ if(pname == NULL) return;
+ plength = (int *)malloc((view->tot_comment_lines + 1) *sizeof(int ));
+ if(plength == NULL) return;
+ texte = (char *)malloc((view->max_seq_length + 1) *sizeof(char));
+ if(texte == NULL) return;
+ name = (char *)malloc(strlen(c_name) + 1);
+ if(name == NULL) return;
+ memset(texte, '-', view->seq_length);
+ texte[view->seq_length] = 0;
+ strcpy(name, c_name);
+ if(view->tot_comment_lines > 0) {
+ memcpy(pline, view->comment_line,
+ view->tot_comment_lines * sizeof(char *));
+ free(view->comment_line);
+ }
+ pline[view->tot_comment_lines] = texte;
+ view->comment_line = pline;
+ if(view->tot_comment_lines > 0) {
+ memcpy(pname, view->comment_name,
+ view->tot_comment_lines * sizeof(char *));
+ free(view->comment_name);
+ }
+ pname[view->tot_comment_lines] = name;
+ view->comment_name = pname;
+ if(view->tot_comment_lines > 0) {
+ memcpy(plength, view->comment_length,
+ view->tot_comment_lines * sizeof(int));
+ free(view->comment_length);
+ }
+ plength[view->tot_comment_lines] = view->seq_length;
+ view->comment_length = plength;
+ ++(view->tot_comment_lines);
+ view->show_comment_lines = TRUE;
+ view->active_comment_line = 0;
+ view->cursor_in_comment = FALSE;
+ view->modif_but_not_saved = TRUE;
+ compute_size_params(view, TRUE);
+ view->DNA_obj->redraw();
+ }
+else if(reponse == DELETE_FOOTER) {
+ if(view->tot_comment_lines == 0 || view->active_comment_line == 0)
+ return;
+ if(! fl_ask("Confirm deletion?") ) return;
+ free(view->comment_line[view->active_comment_line - 1]);
+ free(view->comment_name[view->active_comment_line - 1]);
+ for(num = view->active_comment_line; num < view->tot_comment_lines;
+ num++) {
+ view->comment_line[num - 1] = view->comment_line[num];
+ view->comment_name[num - 1] = view->comment_name[num];
+ view->comment_length[num - 1] = view->comment_length[num];
+ }
+ (view->tot_comment_lines)--;
+ if(view->tot_comment_lines == 0) view->show_comment_lines = FALSE;
+ view->active_comment_line = 0;
+ view->cursor_in_comment = FALSE;
+ view->modif_but_not_saved = TRUE;
+ compute_size_params(view, TRUE);
+ view->DNA_obj->redraw();
+ }
+update_menu_footers(view);
+}
Added: trunk/packages/seaview/branches/upstream/current/load_seq.cxx
===================================================================
--- trunk/packages/seaview/branches/upstream/current/load_seq.cxx (rev 0)
+++ trunk/packages/seaview/branches/upstream/current/load_seq.cxx 2006-09-19 14:20:14 UTC (rev 111)
@@ -0,0 +1,570 @@
+#include "seaview.h"
+#include <ctype.h>
+
+
+typedef struct {
+ SEA_VIEW *view;
+ Fl_Input *seq_name_field;
+ Fl_Input *seq_field;
+ } view_name_struct;
+
+/* included prototypes */
+void clear_callback(Fl_Widget *ob, void *data);
+void refresh_callback(Fl_Widget *ob, void *data);
+void remove_gaps_callback(Fl_Widget *ob, void *data);
+void remove_numbers_callback(Fl_Widget *ob, void *data);
+void to_upcase_callback(Fl_Widget *ob, void *data);
+void load_seq_callback(Fl_Widget *ob, void *data);
+void cancel_seq_callback(Fl_Widget *ob, long val);
+void load_seq_dialog(SEA_VIEW *view);
+void add_seq_to_align(SEA_VIEW *view, char *newname, char *newseq,
+ int lenseq);
+char complement_base(char old);
+void edit_comments_dialog(SEA_VIEW *view);
+void update_comments_callback(Fl_Widget *ob, void *data);
+int load_comments(SEA_VIEW *view, Fl_Input *input, Fl_Widget *name);
+char *cre_consensus(SEA_VIEW *view, char *newname);
+Fl_Widget *cre_adjusted_button(int x, int y, int *w, int h,
+ char *label);
+
+
+void clear_callback(Fl_Widget *ob, void *data)
+{
+Fl_Input *seq_input, *seq_name_input;
+seq_name_input = ((view_name_struct *)data)->seq_name_field;
+seq_input = ((view_name_struct *)data)->seq_field;
+seq_input->value("");
+if(seq_name_input != NULL) seq_name_input->value("");
+}
+
+
+void refresh_callback(Fl_Widget *ob, void *data)
+{
+Fl_Input *seq_input;
+seq_input = ((view_name_struct *)data)->seq_field;
+seq_input->redraw();
+}
+
+
+void remove_gaps_callback(Fl_Widget *ob, void *data)
+{
+Fl_Input *seq_input;
+char *old_seq, *new_seq, *p, *q;
+size_t lseq;
+
+seq_input = (Fl_Input *)data;
+old_seq = (char *)seq_input->value();
+lseq = strlen(old_seq);
+new_seq = (char *)malloc(lseq+1);
+if(new_seq == NULL) return;
+p = old_seq; q = new_seq;
+while(*p != 0) {
+ if(*p != '-' ) *(q++) = *p;
+ p++;
+ }
+*q = 0;
+seq_input->value(new_seq);
+}
+
+
+void remove_numbers_callback(Fl_Widget *ob, void *data)
+{
+Fl_Input *seq_input;
+char *old_seq, *new_seq, *p, *q;
+size_t lseq;
+
+seq_input = (Fl_Input *)data;
+old_seq = (char *)seq_input->value();
+lseq = strlen(old_seq);
+new_seq = (char *)malloc(lseq+1);
+if(new_seq == NULL) return;
+p = old_seq; q = new_seq;
+while(*p != 0) {
+ if( ! isdigit(*p) ) *(q++) = *p;
+ p++;
+ }
+*q = 0;
+seq_input->value(new_seq);
+}
+
+
+void to_upcase_callback(Fl_Widget *ob, void *data)
+{
+Fl_Input *seq_input = (Fl_Input *)data;
+char *old_seq = (char *)seq_input->value();
+int lseq = strlen(old_seq);
+char *new_seq = (char *)malloc(lseq+1);
+if(new_seq == NULL) return;
+char *p = old_seq;
+char *q = new_seq - 1;
+do *(++q) = toupper(*(p++)); while(*q != 0);
+seq_input->value(new_seq);
+}
+
+
+void load_seq_callback(Fl_Widget *ob, void *data)
+{
+Fl_Input *seq_name_input, *seq_input;
+SEA_VIEW *view;
+char *name, *newseq, *tmp, *p, *q;
+int lenseq;
+
+seq_name_input = ((view_name_struct *)data)->seq_name_field;
+view = ((view_name_struct *)data)->view;
+seq_input = ((view_name_struct *)data)->seq_field;
+name = (char *)seq_name_input->value();
+if(strlen(name) == 0) {
+ fl_alert(
+ "`Seq. name' field is empty\nPlease enter a sequence name");
+ return;
+ }
+tmp = (char *)seq_input->value();
+lenseq = (int)strlen(tmp);
+newseq = (char *)malloc(lenseq+1);
+if(newseq == NULL) {
+ fl_alert("Not enough memory");
+ return;
+ }
+ob->window()->hide();
+p = tmp; q = newseq; lenseq = 0;
+while(*p != 0) {
+ if(*p != ' ' && *p != '\n' && *p != '\t') {
+ if(view->allow_lower) *(q++) = (*p);
+ else *(q++) = toupper(*p);
+ lenseq++;
+ }
+ p++;
+ }
+*q = 0;
+add_seq_to_align(view, name, newseq, lenseq);
+free(newseq);
+}
+
+
+void cancel_seq_callback(Fl_Widget *ob, long val)
+{
+ob->window()->hide();
+}
+
+
+Fl_Widget *cre_adjusted_button(int x, int y, int *w, int h,
+ char *label)
+{
+Fl_Button *obj;
+const int lsize = FL_NORMAL_SIZE;
+fl_font(FL_HELVETICA, lsize);
+// *w = (int) ( fl_width(label) + 2 * fl_width("R") + 0.5 );
+*w = (int) ( fl_width(label) + 10 + 0.5 );
+obj = new Fl_Button(x, y, *w, h, label);
+obj->labelsize(lsize);
+obj->labelfont(FL_HELVETICA);
+return (Fl_Widget *)obj;
+}
+
+
+void load_seq_dialog(SEA_VIEW *view)
+{
+static Fl_Window *load_form;
+static int first = TRUE;
+static Fl_Input *seq_input, *seq_name_input;
+
+if(first) {
+ Fl_Widget *obj;
+ int fin, width;
+ static view_name_struct view_name;
+ first = FALSE;
+ load_form = new Fl_Window(490,530);
+ load_form->box(FL_FLAT_BOX);
+ load_form->label("Sequence Loading");
+
+ int curr_y = 5;
+ fin = 5;
+ Fl_Group *top = new Fl_Group(fin,curr_y,load_form->w() - 2 * fin, 25);
+ static char label[] = "Seq. name:";
+ fl_font(FL_HELVETICA, FL_NORMAL_SIZE);
+ width = (int)fl_width(label) + 4 * 2;
+ Fl_Box *name_box = new Fl_Box(FL_UP_BOX,
+ fin, top->y(), width, top->h(), label);
+ name_box->labelsize(FL_NORMAL_SIZE);
+ name_box->box(FL_NO_BOX);
+ fin += width + 5;
+
+ seq_name_input = new Fl_Input(fin,top->y(),100,top->h(),"");
+ seq_name_input->type(FL_NORMAL_INPUT);
+ fin += seq_name_input->w() + 5;
+
+ obj = cre_adjusted_button(fin,top->y(),&width,top->h(),
+ "Add to alignment");
+ obj->callback(load_seq_callback, &view_name);
+ fin += width + 5;
+
+ obj = cre_adjusted_button(fin,top->y(),&width,top->h(),
+ "Cancel");
+ obj->callback(cancel_seq_callback, 0);
+ fin += width;
+
+ top->resizable(NULL);
+ top->size(fin - top->x(), top->h());
+ top->end();
+
+ curr_y += top->h() + 15;
+ seq_input = new
+ Fl_Input(top->x(), curr_y, load_form->w() - 2 * top->x(), 450,
+#if defined(WIN32) || defined(__APPLE__)
+ "Type sequence or paste it with CRTL-v in panel below"
+#else
+ "Type or paste sequence with middle mouse button in panel below"
+#endif
+ );
+ seq_input->type(FL_MULTILINE_INPUT);
+ seq_input->align(FL_ALIGN_TOP);
+ seq_input->textfont(FL_COURIER);
+ seq_input->textsize(12);
+
+ fin = top->x();
+ curr_y += seq_input->h() + 5;
+ Fl_Group *bottom = new Fl_Group(fin, curr_y, top->w(), top->h() );
+ obj = cre_adjusted_button(fin, curr_y, &width, bottom->h(), "Refresh");
+ obj->callback(refresh_callback, &view_name);
+ fin += width + 5;
+
+ obj = cre_adjusted_button(fin, curr_y, &width, bottom->h(), "Clear");
+ obj->callback(clear_callback, &view_name);
+ fin += width + 5;
+
+ obj = cre_adjusted_button(fin, curr_y, &width, bottom->h(),
+ "Remove gaps");
+ obj->callback(remove_gaps_callback, seq_input);
+ fin += width + 5;
+
+ obj = cre_adjusted_button(fin,curr_y,&width,bottom->h(),
+ "Remove numbers");
+ obj->callback(remove_numbers_callback, seq_input);
+ fin += width + 5;
+
+ obj = cre_adjusted_button(fin, curr_y, &width, bottom->h(),
+ "to UPPER");
+ obj->callback(to_upcase_callback, seq_input);
+ fin += width;
+
+ bottom->resizable(NULL);
+ bottom->size(fin - bottom->x(), bottom->h());
+ bottom->end();
+
+ load_form->resizable(seq_input);
+
+ view_name.view = view;
+ view_name.seq_name_field = seq_name_input;
+ view_name.seq_field = seq_input;
+ load_form->end();
+ load_form->position((Fl::w() - load_form->w())/2,
+ (Fl::h() - load_form->h())/2);
+ }
+seq_name_input->value("");
+seq_input->value("");
+seq_input->take_focus();
+load_form->show();
+}
+
+
+void add_seq_to_align(SEA_VIEW *view, char *newname, char *newseq,
+ int lenseq)
+{
+int num, *newsel, numset;
+void *newcol;
+static char defname[]="newfile";
+char **new_s, **new_n, **new_c;
+
+num = view->tot_seqs + 1;
+new_s = (char **)realloc(view->sequence, num * sizeof(char *));
+if(new_s != NULL) view->sequence = new_s;
+new_c = (char **)realloc(view->comments, num * sizeof(char *));
+if(new_c != NULL) view->comments = new_c;
+new_n = (char **)realloc(view->seqname, num * sizeof(char *));
+if(new_n != NULL) view->seqname = new_n;
+
+if(new_s == NULL || new_n == NULL || new_c == NULL) goto nomem;
+if(lenseq > view->max_seq_length) {
+ lenseq = view->max_seq_length;
+ newseq[lenseq] = 0;
+ fl_alert("Warning: sequence was truncated to current max length %d", lenseq);
+ }
+if( (view->seqname[num-1] = (char *)malloc(strlen(newname)+1)) == NULL)
+ goto nomem;
+strcpy(view->seqname[num-1], newname);
+if( (view->comments[num-1] = (char *)malloc(3)) == NULL) goto nomem;
+strcpy(view->comments[num-1], ";\n");
+if( (view->sequence[num-1] = (char *)malloc(view->max_seq_length + 1)) == NULL)
+ goto nomem;
+memcpy(view->sequence[num-1], newseq, lenseq+1);
+if(view->tot_seqs == 0) {
+ newname = (char *) fl_input("Name of the new file?", "");
+ if(newname == NULL) newname = defname;
+ init_dna_scroller(view, 1, newname, FALSE, NULL);
+ view->modif_but_not_saved = TRUE;
+ { char *q, *p = newname;
+ while ( (q = strchr(p, '/')) != NULL ) p = q + 1;
+ view->dnawin->label(p);
+ }
+ view->DNA_obj->redraw();
+ Fl_Menu_Item *items =
+ (Fl_Menu_Item *)((Fl_Menu_ *)view->menu_file)->menu();
+ items[SAVE].activate();
+ items[SAVE_AS].activate();
+ return;
+ }
+if( (newsel = (int *)malloc(num*sizeof(int))) == NULL) goto nomem;
+memcpy(newsel, view->each_length, (num-1)*sizeof(int) );
+free(view->each_length);
+view->each_length = newsel;
+view->each_length[num-1] = lenseq;
+if(lenseq > view->seq_length) {
+ double x; int l;
+ view->seq_length = lenseq;
+ x = ( (double) view->tot_sites ) / ( view->seq_length + 3 );
+ if(x>1) x=1;
+ ((Fl_Slider*)view->horsli)->slider_size(x);
+ l = view->seq_length - view->tot_sites+3;
+ if(l<1) l=1;
+ ((Fl_Slider*)view->horsli)->bounds(1,l);
+ }
+if(view->numb_dnacolors > 1) {
+ if( (newcol = (void *)malloc(num*sizeof(void *))) == NULL)
+ goto nomem;
+ memcpy(newcol, view->col_seq, (num-1)*sizeof(void *) );
+ free(view->col_seq);
+ view->col_seq = (char ***)newcol;
+ view->col_seq[num-1] = * prepcolseqs(view->sequence+num-1, 1,
+ view->max_seq_length,
+ view->each_length+num-1,
+ ( view->protein ? get_color_for_aa : get_color_for_base ),
+ view->numb_gc, view->allow_lower);
+ }
+if( (newsel = (int *)malloc(num*sizeof(int))) == NULL) goto nomem;
+memcpy(newsel, view->sel_seqs, (num-1)*sizeof(int) );
+free(view->sel_seqs);
+view->sel_seqs = newsel;
+view->sel_seqs[num-1] = FALSE;
+for(numset = 0; numset < view->numb_species_sets; numset++) {
+ if( (newsel = (int *)malloc(num*sizeof(int))) == NULL) goto nomem;
+ memcpy(newsel, view->list_species_sets[numset], (num-1)*sizeof(int) );
+ free(view->list_species_sets[numset]);
+ view->list_species_sets[numset] = newsel;
+ view->list_species_sets[numset][num-1] = FALSE;
+ }
+view->tot_seqs = num;
+view->cursor_seq = num;
+view->cursor_site = 1;
+view->first_site = 1;
+view->modif_but_not_saved = TRUE;
+((Fl_Slider*)view->horsli)->value(1);
+set_tot_lines(view, view->tot_lines);
+view->first_seq = FL_max(num - view->tot_lines + 1, 1);
+((Fl_Slider*)view->vertsli)->value(view->first_seq);
+view->DNA_obj->redraw();
+view->vertsli->redraw();
+view->horsli->redraw();
+return;
+nomem:
+fl_alert("Not enough memory\nto create the new sequence %s",
+ newname);
+}
+
+
+char complement_base(char old)
+{
+static char bases[] = "ACGTURYMWSKVHDB";
+static char complement[] = "TGCAAYRKWSMBDHV";
+char *p;
+if( (p = strchr(bases, old)) != NULL )
+ return complement[ p - bases ];
+else
+ return old;
+}
+
+
+void edit_comments_dialog(SEA_VIEW *view)
+{
+static Fl_Window *comments_form;
+static int first = TRUE;
+static Fl_Input *comments_input;
+static Fl_Widget *comments_name;
+
+if(first) {
+ Fl_Widget *obj;
+ int fin, width;
+ static view_name_struct comments_data;
+ first = FALSE;
+ comments_form = new Fl_Window(490,530);
+ comments_form->label("Comments Editing");
+ comments_form->box(FL_FLAT_BOX);
+
+ Fl_Group *top_group = new Fl_Group(5,5,comments_form->w() - 10, 25);
+ fin = 5;
+ obj = cre_adjusted_button(fin,5,&width,25, "Apply");
+ obj->callback(update_comments_callback, &comments_data);
+ fin += width + 5;
+
+ obj = cre_adjusted_button(fin,5,&width,25,"Cancel");
+ obj->callback(cancel_seq_callback, 0);
+ fin += width + 5;
+
+ obj = cre_adjusted_button(fin,5,&width,25,"Refresh");
+ obj->callback(refresh_callback, &comments_data);
+ fin += width + 5;
+
+ comments_name = new Fl_Box(FL_DOWN_BOX, fin, 5,
+ top_group->x() +top_group->w() - fin, 25, "");
+ comments_name->align(FL_ALIGN_CENTER);
+ comments_name->labelfont(FL_COURIER);
+ comments_name->labelsize(FL_NORMAL_SIZE);
+
+ top_group->resizable(comments_name);
+ top_group->end();
+
+ comments_input = new Fl_Input(5,35,top_group->w(),
+ comments_form->h() - 5 - 35, "");
+ comments_input->type(FL_MULTILINE_INPUT);
+ comments_input->textfont(FL_COURIER);
+ comments_input->textsize(12);
+ comments_data.view = view;
+ comments_data.seq_field = comments_input;
+ comments_form->resizable(comments_input);
+ comments_form->end();
+ comments_form->position( (Fl::w() - comments_form->w())/2,
+ (Fl::h() - comments_form->h())/2 );
+ }
+if(load_comments(view, comments_input, comments_name)) {
+ fl_alert("Not enough memory");
+ return;
+ }
+comments_input->take_focus();
+comments_form->show();
+}
+
+
+void update_comments_callback(Fl_Widget *ob, void *data)
+{
+Fl_Input *comments_input;
+SEA_VIEW *view;
+int num, l, num_l;
+char *temp, *p, *q, *r;
+
+ob->window()->hide();
+view = ((view_name_struct *)data)->view;
+comments_input = ((view_name_struct *)data)->seq_field;
+num = comments_input->argument();
+num_l = 0;
+p = (char *)comments_input->value(); l =strlen(p);
+q = p;
+while( (q = strchr(q, '\n')) != NULL) {
+ q++; num_l++;
+ }
+if(p[l - 1] != '\n') num_l++;
+temp = (char *)malloc(l + num_l + 1);
+if(temp == NULL) {
+ fl_alert("Not enough memory");
+ return;
+ }
+r = temp;
+do {
+ q = strchr(p, '\n'); if(q == NULL) q = strchr(p, 0) - 1;
+ *(r++) = ';';
+ memcpy(r, p, q - p + 1); r += q - p + 1;
+ p = q + 1;
+ }
+while( *p != 0);
+if( *(r - 1) != '\n') *(r++) = '\n';
+*r = 0;
+if(view->comments[num] != NULL) free(view->comments[num]);
+view->comments[num] = temp;
+view->modif_but_not_saved = TRUE;
+}
+
+
+int load_comments(SEA_VIEW *view, Fl_Input *input, Fl_Widget *name)
+{
+int num;
+char *temp, *p, *q, *r;
+
+for(num = 0; num <view->tot_seqs; num++)
+ if(view->sel_seqs[num]) break;
+input->argument( num);
+name->label(view->seqname[num]);
+name->redraw();
+if( view->comments[num] == NULL) {
+ input->value("");
+ return FALSE;
+ }
+temp = (char *)malloc(strlen(view->comments[num]) + 1);
+if( temp == NULL) return TRUE;
+r = temp; p = view->comments[num];
+do {
+ q = strchr(p, '\n');
+ memcpy(r, p + 1, q - p); r += q - p;
+ p = q + 1;
+ }
+while( *p != 0);
+*r = 0;
+input->value(temp);
+free(temp);
+input->position(0);
+return FALSE;
+}
+
+
+char *cre_consensus(SEA_VIEW *view, char *newname)
+{
+char *newseq, *p, *residues, unknown;
+int pos, num, total, kind, dernier, maxi, vu;
+static char dna_residues[]="ACGTU";
+static const char prot_residues[] = "EDQNHRKILMVAPSGTFYWC";
+static int freqs[30];
+
+newseq = (char *)malloc(view->seq_length + 1);
+if(newseq == NULL) return NULL;
+if(view->protein) {
+ residues = (char *)prot_residues;
+ unknown = 'X';
+ }
+else {
+ residues = (char *)dna_residues;
+ unknown = 'N';
+ }
+dernier = strlen(residues) + 1;
+
+for (pos = 0; pos < view->seq_length; pos++) {
+ vu = total = 0; memset(freqs, 0, dernier * sizeof(int));
+ for(num = 0; num < view->tot_seqs; num++) {
+ if( !view->sel_seqs[num] ) continue;
+ if(pos >= view->each_length[num]) continue;
+ vu++;
+ if(view->sequence[num][pos] == '-') continue;
+ total++;
+ p = strchr(residues, toupper(view->sequence[num][pos]));
+ if(p == NULL) kind = 0;
+ else kind = p - residues + 1;
+ ++(freqs[kind]);
+ }
+ if(vu == 0) break;
+ if(total == 0)
+ newseq[pos] = '-';
+ else {
+ maxi = 0;
+ for(num = 0; num < dernier; num++) {
+ if(freqs[num] > maxi) {
+ maxi = freqs[num]; kind = num;
+ }
+ }
+ if(kind == 0)
+ newseq[pos] = unknown;
+ else if( maxi >= total * (view->consensus_threshold / 100.) )
+ newseq[pos] = residues[kind - 1];
+ else
+ newseq[pos] = unknown;
+ }
+ newseq[pos + 1] = 0;
+ }
+strcpy(newname, "Consensus");
+return newseq;
+}
Added: trunk/packages/seaview/branches/upstream/current/mac_pc_extras.cxx
===================================================================
--- trunk/packages/seaview/branches/upstream/current/mac_pc_extras.cxx (rev 0)
+++ trunk/packages/seaview/branches/upstream/current/mac_pc_extras.cxx 2006-09-19 14:20:14 UTC (rev 111)
@@ -0,0 +1,485 @@
+#ifdef __APPLE__
+
+#include "seaview.h"
+#include <string.h>
+#include <stdio.h>
+#include <FL/Fl_Sys_Menu_Bar.H>
+
+// included functions
+extern "C" {
+char *my_fgets(char *s, int n, FILE *f);
+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 show_apropos(Fl_Widget *, void *);
+pascal Boolean myfilter(DialogRef dptr, EventRecord *event, DialogItemIndex *item);
+Boolean AppleEventsInstalled ();
+pascal OSErr MyHandleODoc (const AppleEvent *theAppleEvent, AppleEvent* reply, UInt32 handlerRefCon);
+pascal OSErr MyHandlePDoc (const AppleEvent *theAppleEvent, AppleEvent *reply, UInt32 handlerRefCon);
+pascal OSErr MyHandleOApp (const AppleEvent *theAppleEvent, AppleEvent *reply, UInt32 handlerRefCon);
+pascal OSErr MyHandleQApp (const AppleEvent *theAppleEvent, AppleEvent *reply, UInt32 handlerRefCon);
+OSErr MyGotRequiredParams (const AppleEvent *theAppleEvent);
+}
+
+static SEA_VIEW *view;
+extern void use_initial_file(SEA_VIEW *view, char *masename);
+
+#elif defined(WIN32)
+
+#include <stdarg.h>
+#include <windef.h>
+#include <winbase.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+/* 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);
+}
+#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__
+/* version de fgets qui accepte les formats CR, LF, ou CR+LF sur Mac.
+!!!!!!!!!!! sur Mac, fgets échange les \r et \n lus dans les fichiers !!!!!!!!!!!!!
+!!!!!!!!!!! donc le format PC des fichiers apparait comme LF+CR !!!!!!!!!!!!!!
+!!!!!!!!!!! et le format unix comme CR !!!!!!!!!!!!!
+*/
+
+char *my_fgets(char *s, int n, FILE *f)
+{
+int next_char;
+char *p;
+
+p = s;
+while(--n > 0) {
+ next_char = getc(f);
+ if( next_char == '\r' ) {
+ *(p++) = '\n';
+ break;
+ }
+ else if( next_char == '\n' ) {
+ *(p++) = '\n';
+ next_char = getc(f);
+ if(next_char != '\r' && next_char != EOF) {
+ ungetc(next_char, f);
+ }
+ break;
+ }
+ else if (next_char == EOF)
+ break;
+ *(p++) = next_char;
+ }
+*p = 0;
+return (p == s ? NULL : s);
+}
+
+
+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)
+{
+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));
+}
+
+
+void show_apropos(Fl_Widget *w, void *data)
+{
+DialogItemIndex tmp;
+DialogRef dptr;
+
+dptr = GetNewDialog(129, NULL, (WindowPtr)-1L);
+ModalDialog( NewModalFilterUPP(myfilter), &tmp);
+DisposeDialog(dptr);
+}
+
+
+pascal Boolean myfilter(DialogPtr dptr, EventRecord *event, DialogItemIndex *item)
+{
+if(event->what == mouseDown) {
+ *item = 1;
+ return TRUE;
+ }
+else
+ return FALSE;
+}
+
+
+/***********************************************************************/
+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, UInt32 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, UInt32 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, UInt32 handlerRefCon)
+{
+ // Ouverture de l'appli
+ return noErr;
+}
+
+/***********************************************************************/
+pascal OSErr MyHandleQApp (const AppleEvent *theAppleEvent, AppleEvent *reply, UInt32 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 **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
Added: trunk/packages/seaview/branches/upstream/current/makefile
===================================================================
--- trunk/packages/seaview/branches/upstream/current/makefile (rev 0)
+++ trunk/packages/seaview/branches/upstream/current/makefile 2006-09-19 14:20:14 UTC (rev 111)
@@ -0,0 +1,16 @@
+FLTK = ../fltk-1.1.0
+
+OBJECTS = seaview.o use_mase_files.o regions.o load_seq.o align.o xfmatpt.o comlines.o chooser_plus.o resource.o nexus.o old_file_chooser.o
+
+CFLAGS = -c $(OPT) -I$(FLTK) $(DEBUG)
+
+CXX = CC
+
+seaview : $(OBJECTS)
+ $(CXX) $(DEBUG) -o $@ $(OBJECTS) -L$(FLTK)/lib -lfltk -lX11 -lm
+
+
+.SUFFIXES: .cxx .h .o
+
+.cxx.o :
+ $(CXX) $(CFLAGS) $<
Added: trunk/packages/seaview/branches/upstream/current/matpt.h
===================================================================
--- trunk/packages/seaview/branches/upstream/current/matpt.h (rev 0)
+++ trunk/packages/seaview/branches/upstream/current/matpt.h 2006-09-19 14:20:14 UTC (rev 111)
@@ -0,0 +1,41 @@
+#ifndef FD_matpt_h_
+#define FD_matpt_h_
+#include "seaview.h"
+
+typedef struct {
+ Fl_Window *form;
+ Fl_Widget *mat_panel, *ident_type_box, *win_size_type_box,
+ *compute_butt, *x_slider, *y_slider, *region_box,
+ *region_slider, *align_button, *choice_ref_seq,
+ *interrupt_butt;
+ int phys_width;
+ int view_x, view_y;
+ int view_size;
+ int longmax;
+ int seqlong1, seqlong2;
+ int maxseqlength;
+ char *seq1, *seq2;
+ char *seqname1, *seqname2;
+ char *plotname;
+ int margin;
+ int hitx, hity;
+ int region_size;
+ int fenetre, identites;
+ char regionboxtext[300];
+ char *title;
+ int totsegments;
+ int need_compute;
+ int modif_but_not_saved;
+ double factor, kx, ky;
+ int interrupted;
+ int rect_only;
+ gap_site *gap_sites;
+ int tot_gap_sites;
+ void *seaview_data;
+} FD_matpt;
+
+typedef struct {
+ int x, y, w, h;
+ } rectangle;
+
+#endif /* FD_matpt_h_ */
Added: trunk/packages/seaview/branches/upstream/current/nexus.cxx
===================================================================
--- trunk/packages/seaview/branches/upstream/current/nexus.cxx (rev 0)
+++ trunk/packages/seaview/branches/upstream/current/nexus.cxx 2006-09-19 14:20:14 UTC (rev 111)
@@ -0,0 +1,1310 @@
+#include "seaview.h"
+#include <ctype.h>
+#include <time.h>
+
+
+typedef struct _linked_strings {
+ void *data;
+ char *name;
+ struct _linked_strings *next;
+ } linked_strings;
+
+
+/* prototypes of local functions */
+int read_nexus_align(char *fname, char ***pseqs, char ***pseqnames,
+ char ***pcomments, char **pheader, char **err_message,
+ list_regions **charsets, int *pnum_species_sets,
+ int ***list_species_sets, char ***name_species_sets,
+ int *ptot_comment_lines, char ***comment_name, char ***comment_line,
+ int **comment_length);
+int read_nexus_file(FILE *in, char ***pseqs, int *nchars, int *protein,
+ char ***taxnames, char ***notes, char **header,
+ int *pnum_species_sets, int ***list_species_sets,
+ char ***name_species_sets,
+ list_regions **charsets,
+ int *tot_comment_lines, char ***comment_name, char ***comment_line);
+int save_nexus_file(const char *fname, int ntaxa, int protein,
+ char **seqs, char **taxnames, char **notes, char *header,
+ int num_species_sets, int **list_species_sets,
+ char **name_species_sets,
+ list_regions *charsets,
+ int tot_comment_lines, char **comment_name, char **comment_line,
+ region *region_used, int *sel_seqs, int tot_sel_seqs, int *eachlength);
+int nextbracket(FILE *in);
+char *next_token(FILE *in);
+FILE *is_nexus_file(char *nom);
+char *majuscules(char *p);
+char *next_block_name(FILE *in);
+int process_block_taxa(FILE *in, char ***taxnames);
+int is_block_end(char *p);
+void skip_block(FILE *in);
+void skip_command(FILE *in);
+int process_taxa_dim(FILE *in);
+int process_chars_dim(FILE *in, int *pntaxa);
+int process_chars_format(FILE *in, int *protein, int *interleave,
+ int *matchchar, int *missing);
+char **process_taxa_taxlabels(FILE *in, int ntax);
+char **process_block_characters(FILE *in, int *pntaxa, char ***taxnames,
+ int *nchars, int *protein);
+char **process_chars_m_interleave(FILE *in, int nsites, int gap, int ntaxa,
+ char **taxnames, int define_taxlabels, int matchchar, int missing,
+ int protein);
+char **process_chars_matrix(FILE *in, int nsites, int gap, int ntaxa,
+ char **taxnames, int define_taxlabels, int matchchar, int missing,
+ int protein);
+char **process_block_data(FILE *in, int *pntaxa, char ***ptaxnames, int
+ *nsites, int *protein);
+char **process_block_notes(FILE *in, int ntaxa, char **taxnames);
+int find_by_name_num(char *token, int nelt, char **elts);
+char *build_list(FILE *in, int nelt, char **elts);
+list_segments *build_list_pairs(FILE *in, int maxi);
+void process_notes_text(FILE *in, int ntaxa, char **taxnames, char **notes);
+char *process_sets_taxset(FILE *in, int ntaxa, char **taxnames, char
+ **setname);
+list_segments *process_sets_charset(FILE *in, char **setname, int max_chars);
+void process_block_sets(FILE *in, int ntaxa, char **taxnames, int nchars,
+ linked_strings **taxsets, list_regions **charsets);
+linked_strings *process_block_seaview(FILE *in, char **header);
+char *process_seaview_text(FILE *in, char **name);
+char **process_block_unaligned(FILE *in, int *ntaxa, char ***taxnames, int
+ *nchars, int *protein);
+int process_unal_dim(FILE *in);
+int process_unal_format(FILE *in);
+char **process_unal_matrix(FILE *in, int ntaxa, char **taxnames);
+char *out_with_apostrophe(char *p);
+int linked_to_series(linked_strings *linked, char ***names, char ***lines);
+void out_table_by_series(FILE *out, int *table, int dim);
+
+
+/* used functions */
+int output_next_res_from_region(char *seq, int lenseq,
+ list_segments **segment, int *current, FILE *out, int total,
+ int use_dots);
+
+
+
+int nextbracket(FILE *in)
+{
+int pos;
+pos = fgetc(in);
+while(pos != ']') {
+ if(pos == EOF) return EOF;
+ if(pos == '[') pos = nextbracket(in);
+ pos = fgetc(in);
+ }
+return pos;
+}
+
+
+#define PUNCTUATION "(){}/\\,;:=*\"+-<>"
+#define APOSTROPHE '\''
+
+char *next_token(FILE *in)
+{
+static char *big_token = NULL, *fin_token;
+int c, punct;
+char *p, *q;
+const int slice = 500;
+static int l_token;
+
+if(big_token == NULL) {
+ l_token = slice;
+ big_token = (char *)malloc(l_token);
+ if(big_token == NULL) return NULL;
+ fin_token = big_token + l_token;
+ }
+
+do {
+ c = fgetc(in);
+ if(c == '[' ) {
+ c = nextbracket(in);
+ c = fgetc(in);;
+ }
+ if(c == EOF) return NULL;
+ }
+while(isspace(c));
+if(strchr(PUNCTUATION, c) != NULL) {
+ big_token[0] = c; big_token[1] = 0;
+ return big_token;
+ }
+
+p = big_token;
+if(c == APOSTROPHE) {
+ while (1) {
+ c = fgetc(in);
+ if(c == EOF) break;
+ if(c == APOSTROPHE) {
+ punct = fgetc(in);
+ if(punct != APOSTROPHE) {
+ ungetc(punct, in);
+ break;
+ }
+ }
+ *p = c; p++;
+ if(p >= fin_token) {
+ l_token += slice;
+ q = (char *)realloc(big_token, l_token);
+ if(q == NULL) return NULL;
+ p = q + (p - big_token);
+ big_token = q;
+ fin_token = big_token + l_token;
+ }
+ }
+ *p = 0;
+ return big_token;
+ }
+do {
+ if(c == '[' ) {
+ c = nextbracket(in);
+ }
+ else {
+ *p = c; p++;
+ if(p >= fin_token) {
+ l_token += slice;
+ q = (char *)realloc(big_token, l_token);
+ if(q == NULL) return NULL;
+ p = q + (p - big_token);
+ big_token = q;
+ fin_token = big_token + l_token;
+ }
+ }
+ c = fgetc(in);
+ punct = FALSE;
+ if(c == EOF) break;
+ punct = (strchr(PUNCTUATION, c) != NULL);
+ }
+while( ! (isspace(c) || punct) );
+*p = 0;
+if(punct) ungetc(c, in);
+return big_token;
+}
+
+
+FILE *is_nexus_file(char *fname) /* return !0 iff seems a NEXUS file */
+{
+FILE *in;
+char *p;
+
+in = fopen(fname, "r");
+if(in == NULL) return NULL;
+p = majuscules(next_token(in));
+if(p == NULL || strcmp(p, "#NEXUS") != 0 ) { fclose(in); return NULL; }
+else return in;
+}
+
+
+char *next_block_name(FILE *in)
+{
+char *p;
+static char name[81];
+
+do {
+ p = majuscules(next_token(in));
+ if(p == NULL) return NULL;
+ }
+while(strcmp(p, "BEGIN") != 0);
+p = majuscules(next_token(in));
+if(p == NULL) return NULL;
+strcpy(name, p);
+next_token(in); /* skip the ; */
+return name;
+}
+
+
+int is_block_end(char *p)
+{
+majuscules(p);
+return p == NULL || strcmp(p, "END") == 0 || strcmp(p, "ENDBLOCK") == 0;
+}
+
+
+void skip_command(FILE *in)
+{
+char *p;
+
+do p = next_token(in);
+while(p != NULL && *p != ';');
+}
+
+
+void skip_block(FILE *in)
+{
+char *p;
+
+do p = next_token(in);
+while (!is_block_end(p));
+}
+
+
+int process_taxa_dim(FILE *in)
+{
+char *p;
+int ntax;
+
+p = majuscules(next_token(in));
+if(p == NULL) return 0;
+if(strcmp(p, "NTAX") == 0) {
+ next_token(in);
+ p = next_token(in);
+ if(p == NULL) return 0;
+ sscanf(p, "%d", &ntax);
+ }
+skip_command(in);
+return ntax;
+}
+
+
+int process_chars_dim(FILE *in, int *pntaxa)
+{
+char *p;
+int sites = 0;
+
+do {
+ p = majuscules(next_token(in));
+ if(p == NULL) break;
+ if(strcmp(p, "NCHAR") == 0) {
+ next_token(in); /* skip = */
+ p = next_token(in);
+ if(p == NULL) break;
+ sscanf(p, "%d", &sites);
+ }
+ else if(strcmp(p, "NEWTAXA") == 0) ;
+ else if(strcmp(p, "NTAX") == 0) {
+ next_token(in); /* skip = */
+ p = next_token(in);
+ if(p == NULL) break;
+ sscanf(p, "%d", pntaxa);
+ }
+ }
+while(*p != ';');
+return sites;
+}
+
+
+int process_chars_format(FILE *in, int *protein, int *interleave,
+ int *matchchar, int *missing)
+{
+char *p;
+int gap;
+*interleave = FALSE;
+
+do {
+ p = majuscules(next_token(in));
+ if(p == NULL) break;
+ if(strcmp(p, "DATATYPE") == 0) {
+ next_token(in); /* skip = */
+ p = majuscules(next_token(in));
+ if(p == NULL) break;
+ *protein = strcmp(p, "PROTEIN") == 0;
+ }
+ else if(strcmp(p, "GAP") == 0) {
+ next_token(in); /* skip = */
+ p = next_token(in);
+ if(p == NULL) break;
+ gap = *p;
+ }
+ else if(strcmp(p, "MATCHCHAR") == 0) {
+ next_token(in); /* skip = */
+ p = next_token(in);
+ if(p == NULL) break;
+ *matchchar = *p;
+ }
+ else if(strcmp(p, "MISSING") == 0) {
+ next_token(in); /* skip = */
+ p = next_token(in);
+ if(p == NULL) break;
+ *missing = *p;
+ }
+ else if(strcmp(p, "INTERLEAVE") == 0) {
+ *interleave = TRUE;
+ }
+ }
+while(*p != ';');
+return gap;
+}
+
+
+char **process_taxa_taxlabels(FILE *in, int ntax)
+{
+char *p, **names;
+int i;
+
+names = (char **)malloc(ntax * sizeof(char *));
+if(names == NULL) ntax = 0;
+for(i = 0; i < ntax; i++) names[i] = NULL;
+for(i = 0; i < ntax; i++) {
+ p = next_token(in);
+ if(p == NULL) break;
+ if(*p == ';') break;
+ names[i] = (char *)malloc(strlen(p)+1);
+ if(names[i] == NULL) break;
+ strcpy(names[i], p);
+ }
+if(p != NULL && *p != ';') skip_command(in);
+return names;
+}
+
+
+int process_block_taxa(FILE *in, char ***taxnames)
+{
+char *p;
+int ntax = 0;
+
+while(TRUE) {
+ p = next_token(in);
+ if(is_block_end(p)) break;
+ if(strcmp(p, "DIMENSIONS") == 0) ntax = process_taxa_dim(in);
+ else if(strcmp(p, "TAXLABELS") == 0)
+ *taxnames = process_taxa_taxlabels(in, ntax);
+ else skip_command(in);
+ }
+return ntax;
+}
+
+
+int find_by_name_num(char *token, int nelt, char **elts)
+{
+int num;
+
+for(num = 0; num < nelt; num++) {
+ if(strcmp(token, elts[num]) == 0) return num;
+ }
+if(num >= nelt) {num = -1; sscanf(token, "%d", &num); num--; }
+if(num < 0 || num >= nelt) num = -1;
+return num;
+}
+
+
+char *build_list(FILE *in, int nelt, char **elts)
+{
+char *p, *list;
+int num, previous = -1, need_range = FALSE, i;
+
+list = (char *)malloc(nelt + 1);
+if(list == NULL) { skip_command(in); return NULL; }
+memset(list, '0', nelt); list[nelt] = 0;
+while(TRUE) {
+ p = next_token(in);
+ if(p == NULL || *p == ';') break;
+ if(strcmp(p, "-") == 0) {
+ if(previous >= 0) need_range = TRUE;
+ continue;
+ }
+ if(strcmp(p, ".") == 0) num = nelt - 1;
+ else num = find_by_name_num(p, nelt, elts);
+ if(num == -1) continue;
+ list[num] = '1';
+ if(need_range) {
+ for(i = previous + 1; i < num; i++) list[i] = '1';
+ need_range = FALSE;
+ }
+ previous = num;
+ }
+return list;
+}
+
+
+list_segments *build_list_pairs(FILE *in, int maxi)
+{
+char *p;
+list_segments *list = NULL, *next, *elt;
+int num, previous = -1, need_range = FALSE;
+
+while(TRUE) {
+ p = next_token(in);
+ if(p == NULL || *p == ';') break;
+ if(strcmp(p, "-") == 0) {
+ if(previous >= 0) need_range = TRUE;
+ continue;
+ }
+ if(strcmp(p, ".") == 0) num = maxi;
+ else {num = -1; sscanf(p, "%d", &num); }
+ if(num == -1) { skip_command(in); return NULL; }
+ if(need_range) {
+ next->fin = num;
+ need_range = FALSE;
+ }
+ else {
+ elt = (list_segments *)malloc(sizeof(list_segments));
+ if(elt == NULL) { skip_command(in); return NULL; }
+ elt->debut = elt->fin = num;
+ elt->next = NULL;
+ if(list == NULL) list = elt;
+ else next->next = elt;
+ next = elt;
+ }
+ previous = num;
+ }
+return list;
+}
+
+
+char **process_chars_m_interleave(FILE *in, int nsites, int gap, int ntaxa,
+ char **taxnames, int define_taxlabels, int matchchar, int missing,
+ int protein)
+{
+int num, c, newtaxa = 0;
+char *p, **seq;
+
+seq = (char **)malloc(ntaxa * sizeof(char *));
+if(seq == NULL) { skip_command(in); return NULL;}
+for(num = 0; num < ntaxa; num++) seq[num] = NULL;
+while(TRUE) {
+ p = next_token(in);
+ if(p == NULL || *p == ';') break;
+ if(define_taxlabels) {
+ if(newtaxa >= ntaxa) {
+ num = find_by_name_num(p, ntaxa, taxnames);
+ }
+ else {
+ taxnames[newtaxa] = (char *)malloc(strlen(p) + 1);
+ if(taxnames[newtaxa] == NULL) num = -1;
+ else {
+ strcpy(taxnames[newtaxa], p);
+ num = newtaxa++;
+ }
+ }
+ }
+ else num = find_by_name_num(p, ntaxa, taxnames);
+ if(num == -1) { /* bad format */
+ skip_command(in); free(seq);
+ return NULL;
+ }
+ if(seq[num] == NULL) {
+ seq[num] = (char *)malloc(nsites + 1);
+ if(seq[num] == NULL) {
+ skip_command(in); free(seq); return NULL;
+ }
+ seq[num][0] = 0;
+ }
+ p = seq[num]; p += strlen(p);
+ while(TRUE) {
+ c = fgetc(in);
+ if(c == ';' || c == '\n' || c == '\r' || c == EOF) break;
+ if(isspace(c)) continue;
+ if(c == gap) c = '-';
+ if(p - seq[num] < nsites) *(p++) = c;
+ }
+ *p = 0;
+ }
+if(matchchar != 0) {
+ for(num = 1; num < ntaxa; num++) {
+ p = seq[num] - 1;
+ while(*(++p) != 0) if(*p == matchchar) *p = seq[0][p - seq[num]];
+ }
+ }
+if(missing != 0) {
+ char miss_char = (protein ? 'X' : 'N');
+ for(num = 0; num < ntaxa; num++) {
+ p = seq[num] - 1;
+ while(*(++p) != 0) if(*p == missing) *p = miss_char;
+ }
+ }
+return seq;
+}
+
+
+char **process_chars_matrix(FILE *in, int nsites, int gap, int ntaxa,
+ char **taxnames, int define_taxlabels, int matchchar, int missing,
+ int protein)
+{
+int num, c, newtaxa = 0;
+char *p, **seq;
+
+seq = (char **)malloc(ntaxa * sizeof(char *));
+if(seq == NULL) { skip_command(in); return NULL;}
+for(num = 0; num < ntaxa; num++) seq[num] = NULL;
+while(TRUE) {
+ p = next_token(in);
+ if(p == NULL || *p == ';') break;
+ if(define_taxlabels) {
+ if(newtaxa >= ntaxa) num = -1;
+ else {
+ taxnames[newtaxa] = (char *)malloc(strlen(p) + 1);
+ if(taxnames[newtaxa] == NULL) num = -1;
+ else {
+ strcpy(taxnames[newtaxa], p);
+ num = newtaxa++;
+ }
+ }
+ }
+ else num = find_by_name_num(p, ntaxa, taxnames);
+ if(num == -1) { /* bad format */
+ skip_command(in);
+ free(seq);
+ return NULL;
+ }
+ if(seq[num] != NULL) free(seq[num]);
+ seq[num] = (char *)malloc(nsites + 1);
+ if(seq[num] == NULL) { skip_command(in); free(seq); return NULL;}
+ p = seq[num];
+ do {
+ c = fgetc(in);
+ if(c == ';' || c == EOF) break;
+ if(c == '[') {
+ c = nextbracket(in);
+ if(c == EOF) break;
+ continue;
+ }
+ if(isspace(c)) continue;
+ if(c == gap) c = '-';
+ *(p++) = c;
+ }
+ while(p < seq[num] + nsites);
+ *p = 0;
+ if(c == ';' || c == EOF) break;
+ }
+for(num = 0; num < ntaxa; num++) {
+ if(seq[num] == NULL) {
+ seq[num] = (char *)malloc(1);
+ if(seq[num] == NULL) { free(seq); return NULL;}
+ seq[num][0] = 0;
+ }
+ }
+if(matchchar != 0) {
+ for(num = 1; num < ntaxa; num++) {
+ p = seq[num] - 1;
+ while(*(++p) != 0) if(*p == matchchar) *p = seq[0][p - seq[num]];
+ }
+ }
+if(missing != 0) {
+ char miss_char = (protein ? 'X' : 'N');
+ for(num = 0; num < ntaxa; num++) {
+ p = seq[num] - 1;
+ while(*(++p) != 0) if(*p == missing) *p = miss_char;
+ }
+ }
+return seq;
+}
+
+
+char **process_block_data(FILE *in, int *pntaxa, char ***ptaxnames,
+ int *nsites, int *protein)
+{
+char **seqs, **taxnames, *p;
+int gap, interleave = FALSE, matchchar = 0, missing = 0;
+
+seqs = NULL; *nsites = 0; taxnames = NULL; *pntaxa = 0;
+while(TRUE) {
+ p = next_token(in);
+ if(is_block_end(p)) break;
+ if(strcmp(p, "DIMENSIONS") == 0) {
+ *nsites = process_chars_dim(in, pntaxa);
+ if(*pntaxa > 0) taxnames =
+ (char **)malloc(*pntaxa * sizeof(char *));
+ if(*pntaxa > 0 && taxnames == NULL) {
+ *pntaxa = 0; seqs = NULL;
+ skip_block(in);
+ break;
+ }
+ }
+ else if(strcmp(p, "FORMAT") == 0)
+ gap = process_chars_format(in, protein, &interleave, &matchchar,
+ &missing);
+ else if(strcmp(p, "MATRIX") == 0) {
+ if(interleave)
+ seqs = process_chars_m_interleave(in, *nsites, gap,
+ *pntaxa, taxnames, TRUE, matchchar, missing, *protein);
+ else
+ seqs = process_chars_matrix(in, *nsites, gap,
+ *pntaxa, taxnames, TRUE, matchchar, missing, *protein);
+ }
+ else skip_command(in);
+ }
+*ptaxnames = taxnames;
+return seqs;
+}
+
+
+char **process_block_characters(FILE *in, int *pntaxa, char ***taxnames,
+int *nsites, int *protein)
+{
+char *p, **seqs;
+int interleave, gap, matchchar = 0, missing = 0;
+
+seqs = NULL; *nsites = 0;
+while(TRUE) {
+ p = next_token(in);
+ if(is_block_end(p)) break;
+ if(strcmp(p, "DIMENSIONS") == 0)
+ *nsites = process_chars_dim(in, pntaxa);
+ else if(strcmp(p, "FORMAT") == 0)
+ gap = process_chars_format(in, protein, &interleave, &matchchar,
+ &missing);
+ else if(strcmp(p, "TAXLABELS") == 0)
+ *taxnames = process_taxa_taxlabels(in, *pntaxa);
+ else if(strcmp(p, "MATRIX") == 0) {
+ if(interleave)
+ seqs = process_chars_m_interleave(in, *nsites, gap,
+ *pntaxa, *taxnames, FALSE, matchchar, missing, *protein);
+ else
+ seqs = process_chars_matrix(in, *nsites, gap,
+ *pntaxa, *taxnames, FALSE, matchchar, missing, *protein);
+ }
+ else skip_command(in);
+ }
+return seqs;
+}
+
+
+char **process_block_notes(FILE *in, int ntaxa, char **taxnames)
+{
+char *p, **notes;
+int num;
+
+/* notes[0 - ntaxa[ comments des seqs indiv */
+notes = (char **)malloc(ntaxa * sizeof(char *));
+if(notes == NULL) {skip_block(in); return NULL; }
+for(num = 0; num < ntaxa; num++) notes[num] = NULL;
+while(TRUE) {
+ p = next_token(in);
+ if(is_block_end(p)) break;
+ if(strcmp(p, "TEXT") == 0)
+ process_notes_text(in, ntaxa, taxnames, notes);
+ else skip_command(in);
+ }
+return notes;
+}
+
+
+char *process_sets_taxset(FILE *in, int ntaxa, char **taxnames, char **setname)
+{
+char *p, *set = NULL;
+
+p = next_token(in);
+if(p != NULL) *setname = (char *)malloc(strlen(p) + 1);
+if( p == NULL || *setname == NULL) { skip_command(in); return NULL; }
+strcpy(*setname, p);
+next_token(in); /* skip = */
+set = build_list(in, ntaxa, taxnames);
+return set;
+}
+
+
+list_segments *process_sets_charset(FILE *in, char **setname, int max_chars)
+{
+char *p;
+
+p = next_token(in);
+if(p != NULL) *setname = (char *)malloc(strlen(p) + 1);
+if( p == NULL || *setname == NULL) { skip_command(in); return NULL; }
+strcpy(*setname, p);
+next_token(in); /* skip = */
+return build_list_pairs(in, max_chars);
+}
+
+
+void process_block_sets(FILE *in, int ntaxa, char **taxnames, int max_chars,
+ linked_strings **taxsets, list_regions **charsets)
+{
+char *p, *set, *setname;
+list_segments *limits;
+linked_strings *chain_tax = *taxsets, *elt;
+list_regions *elt_reg, *chain_char = *charsets, *end_chain;
+region *maregion;
+
+end_chain = chain_char;
+if(end_chain != NULL) while(end_chain->next != NULL) end_chain =
+end_chain->next;
+while(TRUE) {
+ p = next_token(in);
+ if(is_block_end(p)) break;
+ if(strcmp(p, "TAXSET") == 0 && ( set = process_sets_taxset(in,
+ ntaxa, taxnames, &setname)) != NULL ) {
+ elt = (linked_strings *)malloc(sizeof(linked_strings));
+ if(elt != NULL) {
+ elt->data = (void *)set;
+ elt->name = setname;
+ elt->next = chain_tax;
+ chain_tax = elt;
+ }
+ }
+ else if(strcmp(p, "CHARSET") == 0 && (limits =
+ process_sets_charset(in, &setname, max_chars)) != NULL) {
+ maregion = (region *)malloc(sizeof(region));
+ elt_reg = (list_regions *)malloc(sizeof(list_regions));
+ if(maregion != NULL && elt_reg != NULL) {
+ maregion->list = limits;
+ maregion->name = setname;
+ elt_reg->element = maregion;
+ elt_reg->next = NULL;
+ if(end_chain != NULL) end_chain->next = elt_reg;
+ else chain_char = elt_reg;
+ end_chain = elt_reg;
+ }
+ }
+ else skip_command(in);
+ }
+*taxsets = chain_tax;
+*charsets = chain_char;
+return;
+}
+
+
+void process_notes_text(FILE *in, int ntaxa, char **taxnames, char **notes)
+{
+char *p, *q;
+int num, count;
+
+num = -1;
+do {
+ p = majuscules(next_token(in));
+ if(p == NULL) break;
+ if(strcmp(p, "TAXON") == 0) {
+ next_token(in); /* skip = */
+ p = next_token(in);
+ if(p == NULL) break;
+ num = find_by_name_num(p, ntaxa, taxnames);
+ if(num == -1) { skip_command(in); break; }
+ }
+ else if(strcmp(p, "TEXT") == 0) {
+ if(num == -1) { skip_command(in); break; }
+ next_token(in); /* skip = */
+ p = next_token(in);
+ if(p == NULL) break;
+ q = p; count = 0;
+ while( (q = strchr(q, '\n')) != NULL) { count++; q++; }
+ notes[num] = (char *)malloc(strlen(p) + 5 + count);
+ if(notes[num] != NULL) {
+ q = notes[num];
+ *q = ';'; q++;
+ while(*p != 0) {
+ *q = *p;
+ if(*p == '\n' && *(p+1) != 0) *(++q) = ';';
+ q++; p++;
+ }
+ *q = 0;
+ }
+ }
+ }
+while(*p != ';');
+}
+
+
+linked_strings *process_block_seaview(FILE *in, char **header)
+{
+char *p, *q, *name, *text;
+int count;
+
+linked_strings *chain = NULL, *elt;
+while(TRUE) {
+ p = next_token(in);
+ if(is_block_end(p)) break;
+ if(strcmp(p, "TEXT") == 0 ) {
+ text = process_seaview_text(in, &name);
+ if(text == NULL) continue;
+ if(name == NULL) {
+ /* text contains a header: add ;; at start of lines */
+ q = text; count = 0;
+ while( (q = strchr(q, '\n')) != NULL) { count++; q++; }
+ *header = (char *)malloc(strlen(text) + 5 + 2 * count);
+ if(*header != NULL) {
+ q = *header; p = text;
+ *q = ';'; q++; *q = ';'; q++;
+ while(*p != 0) {
+ *q = *p;
+ if(*p == '\n' && *(p+1) != 0) {
+ *(++q) = ';'; *(++q) = ';';
+ }
+ q++; p++;
+ }
+ *q = 0;
+ }
+ }
+ else { /* text contains a footer */
+ /* remove line breaks from footer */
+ p = text;
+ q = (char *)malloc(strlen(p) + 1);
+ elt = (linked_strings *)malloc(sizeof(linked_strings));
+ if(q != NULL && elt != NULL) {
+ elt->data = (void *)q;
+ do {
+ if(*p != '\n' && *p != '\r') *(q++)= *p;
+ }
+ while (*(p++) != 0);
+ elt->name = name;
+ elt->next = chain;
+ chain = elt;
+ }
+ }
+ free(text);
+ }
+ else skip_command(in);
+ }
+return chain;
+}
+
+
+char *process_seaview_text(FILE *in, char **name)
+{
+char *p, *text = NULL;
+
+*name = NULL;
+do {
+ p = majuscules(next_token(in));
+ if(p == NULL) break;
+ if(strcmp(p, "FOOTER") == 0) {
+ next_token(in); /* skip = */
+ p = next_token(in);
+ if(p == NULL) break;
+ *name = (char *)malloc(strlen(p) + 1);
+ if(*name == NULL) { skip_command(in); return NULL; }
+ strcpy(*name, p);
+ }
+ else if(strcmp(p, "HEADER") == 0) {
+ *name = NULL;
+ }
+ else if(strcmp(p, "TEXT") == 0) {
+ next_token(in); /* skip = */
+ p = next_token(in);
+ if(p == NULL) break;
+ text = (char *)malloc(strlen(p) + 1);
+ if(text != NULL) strcpy(text, p);
+ }
+ }
+while(*p != ';');
+return text;
+}
+
+
+char **process_block_unaligned(FILE *in, int *ntaxa, char ***taxnames, int
+*nsites, int *protein)
+{
+char *p, **seqs = NULL;
+int i, l, max_l;
+
+*protein = FALSE;
+while(TRUE) {
+ p = next_token(in);
+ if(is_block_end(p)) break;
+ if(strcmp(p, "DIMENSIONS") == 0) *ntaxa = process_unal_dim(in);
+ else if(strcmp(p, "FORMAT") == 0) *protein = process_unal_format(in);
+ else if(strcmp(p, "TAXLABELS") == 0)
+ *taxnames = process_taxa_taxlabels(in, *ntaxa);
+ else if(strcmp(p, "MATRIX") == 0) {
+ seqs = process_unal_matrix(in, *ntaxa, *taxnames);
+ }
+ else skip_command(in);
+ }
+l = max_l = 0;
+for(i = 0; seqs != NULL && i < *ntaxa; i++) {
+ if(seqs[i] != NULL) l = strlen(seqs[i]);
+ if(l > max_l) max_l = l;
+ }
+*nsites = max_l;
+return seqs;
+}
+
+
+int process_unal_dim(FILE *in)
+{
+char *p;
+int number = 0;
+
+p = majuscules(next_token(in));
+if(p == NULL || strcmp(p, "NEWTAXA") != 0) { skip_command(in); return 0; }
+p = majuscules(next_token(in));
+if(p == NULL || strcmp(p, "NTAX") != 0) { skip_command(in); return 0; }
+next_token(in); /* skip = */
+p = next_token(in);
+if(p != NULL) sscanf(p, "%d", &number);
+if(number <= 0) number = 0;
+if(p != NULL && *p != ';') skip_command(in);
+return number;
+}
+
+
+int process_unal_format(FILE *in)
+{
+char *p;
+int protein;
+
+p = majuscules(next_token(in));
+if(p == NULL || strcmp(p, "DATATYPE") != 0) { skip_command(in); return 0; }
+next_token(in); /* skip = */
+p = majuscules(next_token(in));
+if(p != NULL) protein = (strcmp(p, "PROTEIN") == 0);
+if(p != NULL && *p != ';') skip_command(in);
+return protein;
+}
+
+
+char **process_unal_matrix(FILE *in, int ntaxa, char **taxnames)
+{
+int num, c, lseq;
+char *p, **seq, *q;
+const int block = 5000;
+
+seq = (char **)malloc(ntaxa * sizeof(char *));
+if(seq == NULL) { skip_command(in); return NULL;}
+for(num = 0; num < ntaxa; num++) seq[num] = NULL;
+while(TRUE) {
+ p = next_token(in);
+ if(p == NULL) break;
+ num = find_by_name_num(p, ntaxa, taxnames);
+ if(num == -1) { /* bad format */
+ skip_command(in);
+ return seq;
+ }
+ lseq = 0;
+ p = seq[num];
+ while(TRUE) {
+ c = fgetc(in);
+ if(c == ';' || c == ',' || c == EOF) break;
+ if(isspace(c)) continue;
+ if(p >= seq[num] + lseq) {
+ lseq += block;
+ q = (char *)malloc(lseq + 1);
+ if(q == NULL) {
+ skip_command(in); free(seq); return NULL;
+ }
+ if(p > seq[num]) memcpy(q, seq[num], p - seq[num]);
+ p = q + (p - seq[num]);
+ if(seq[num] != NULL) free(seq[num]);
+ seq[num] = q;
+ }
+ *(p++) = c;
+ }
+ *p = 0;
+ if(c == ';' || c == EOF) break;
+ }
+return seq;
+}
+
+
+int read_nexus_align(char *fname, char ***pseqs, char ***pseqnames,
+ char ***pcomments, char **pheader, char **err_message,
+ list_regions **charsets, int *pnum_species_sets,
+ int ***list_species_sets, char ***name_species_sets,
+ int *ptot_comment_lines, char ***comment_name, char ***comment_line,
+ int **comment_length)
+{
+FILE *in;
+int lseqs, protein, i, tot;
+
+if( (in = is_nexus_file(fname) ) == NULL) {
+ *err_message = "not a NEXUS file";
+ return 0;
+ }
+tot = read_nexus_file(in, pseqs, &lseqs, &protein, pseqnames,
+ pcomments, pheader,
+ pnum_species_sets, list_species_sets, name_species_sets,
+ charsets, ptot_comment_lines, comment_name, comment_line);
+if(tot == 0) {
+ *err_message = "format error";
+ return 0;
+ }
+if(*ptot_comment_lines > 0) {
+ *comment_length = (int *)malloc(*ptot_comment_lines * sizeof(int));
+ if(*comment_length == NULL) *ptot_comment_lines = 0;
+ for(i = 0; i < *ptot_comment_lines; i++)
+ (*comment_length)[i] = strlen((*comment_line)[i]);
+ }
+return tot;
+}
+
+
+
+int read_nexus_file(FILE *in, char ***pseqs, int *nchars, int *protein,
+ char ***taxnames, char ***notes, char **header,
+ int *pnum_species_sets, int ***list_species_sets,
+ char ***name_species_sets,
+ list_regions **charsets,
+ int *tot_comment_lines, char ***comment_name, char ***comment_line)
+{
+char *p, **seqs = NULL;
+linked_strings *footers, *taxsets, *tmplist;
+int ntaxa, count, num;
+
+ntaxa = *nchars = *tot_comment_lines = *pnum_species_sets = 0;
+*protein = FALSE;
+*taxnames = *notes = NULL; *header = NULL;
+taxsets = footers = NULL;
+*charsets = NULL;
+*name_species_sets = NULL; *list_species_sets = NULL;
+while(TRUE) {
+ p = next_block_name(in);
+ if(p == NULL) break;
+ if(strcmp(p, "TAXA") == 0) ntaxa = process_block_taxa(in, taxnames);
+ else if(strcmp(p, "CHARACTERS") == 0)
+ seqs = process_block_characters(in, &ntaxa, taxnames,
+ nchars, protein);
+ else if(strcmp(p, "UNALIGNED") == 0)
+ seqs = process_block_unaligned(in,
+ &ntaxa, taxnames, nchars, protein);
+ else if(strcmp(p, "DATA") == 0) seqs = process_block_data(in, &ntaxa,
+ taxnames, nchars, protein);
+ else if(strcmp(p, "NOTES") == 0) *notes = process_block_notes(in,
+ ntaxa, *taxnames);
+ else if(strcmp(p, "SETS") == 0) process_block_sets(in, ntaxa,
+ *taxnames, *nchars, &taxsets, charsets);
+ else if(strcmp(p, "SEAVIEW") == 0)
+ footers = process_block_seaview(in, header);
+ else skip_block(in);
+ }
+fclose(in);
+if(seqs == NULL) {
+ *pseqs = NULL;
+ if(*taxnames != NULL)
+ for(num = 0; num < ntaxa; num++)
+ if((*taxnames)[num] != NULL) free((*taxnames)[num]);
+ return 0;
+ }
+if(footers != NULL)
+ *tot_comment_lines = linked_to_series(footers, comment_name,
+ comment_line);
+
+count = 0; tmplist = taxsets;
+while(tmplist != NULL) {
+ tmplist = tmplist->next; count++;
+ }
+if(count > 0) {
+ *name_species_sets = (char **)malloc(count * sizeof(char *));
+ if(*name_species_sets == NULL) count = 0;
+ *list_species_sets = (int **)malloc(count * sizeof(int *));
+ if(*list_species_sets == NULL) count = 0;
+ else {
+ for(num = 0; num < count; num++) {
+ (*list_species_sets)[num] =
+ (int *)calloc(ntaxa, sizeof(int));
+ if((*list_species_sets)[num] == NULL) count = 0;
+ }
+ }
+ if(count == 0) taxsets = NULL;
+ }
+*pnum_species_sets = count;
+while(taxsets != NULL) {
+ count--;
+ (*name_species_sets)[count] = taxsets->name;
+ p = (char *)taxsets->data - 1;
+ while( (p = strchr(p + 1, '1')) != NULL) {
+ num = p - (char *)taxsets->data;
+ (*list_species_sets)[count][num] = TRUE;
+ }
+ free(taxsets->data);
+ tmplist = taxsets;
+ taxsets = taxsets->next;
+ free(tmplist);
+ }
+*pseqs = seqs;
+return ntaxa;
+}
+
+
+int linked_to_series(linked_strings *linked, char ***names, char ***lines)
+{
+int i, count = 0;
+linked_strings *elt, *old;
+
+elt = linked;
+while(elt != NULL) { count++; elt = elt->next; }
+*names = (char **)malloc(count *sizeof(char *));
+*lines = (char **)malloc(count *sizeof(char *));
+if(*names == NULL || *lines == NULL) return 0;
+elt = linked; i = count;
+while(elt != NULL) {
+ i--;
+ (*names)[i] = elt->name;
+ (*lines)[i] = (char *)elt->data;
+ old = elt;
+ elt = elt->next;
+ free(old);
+ }
+return count;
+}
+
+
+char *out_with_apostrophe(char *p)
+{
+static char out[1000];
+char *q = out;
+
+if (p == NULL) return NULL;
+if(strchr(p, APOSTROPHE) == NULL) return p;
+while (TRUE) {
+ *(q++) = *p;
+ if(*p == 0) break;
+ if(*p == APOSTROPHE) *(q++) = APOSTROPHE;
+ p++;
+ }
+return out;
+}
+
+
+void out_table_by_series(FILE *out, int *table, int dim)
+{
+int num, pre = -1;
+
+for(num = 0; num < dim; num++) {
+ if(!table[num]) { pre = -1; continue; }
+ if(pre == - 1) {
+ fprintf(out, " %d", num + 1);
+ pre = num;
+ continue;
+ }
+ if(num < dim - 1 && table[num + 1]) continue;
+ fprintf(out, "-%d", num + 1);
+ pre = -1;
+ }
+}
+
+
+int save_nexus_file(const char *fname, int ntaxa, int protein,
+ char **seqs, char **taxnames, char **notes, char *header,
+ int num_species_sets, int **list_species_sets,
+ char **name_species_sets,
+ list_regions *charsets,
+ int tot_comment_lines, char **comment_name, char **comment_line,
+ region *region_used, int *sel_seqs, int tot_sel_seqs, int *eachlength)
+{
+FILE *out;
+int i, j, lmax, num, vtotseqs, current, ecrit;
+char *p, date_ligne[50];
+list_segments *psegment, all_sequence;
+region maregion;
+time_t heure;
+
+out = fopen(fname, "w");
+if(out == NULL) return TRUE;
+
+if(region_used == NULL) { /* on veut tout sauver */
+ tot_sel_seqs = 0;
+ all_sequence.debut = 1;
+ all_sequence.fin = eachlength[0];
+ for(i = 1; i < ntaxa; i++)
+ if( all_sequence.fin < eachlength[i] )
+ all_sequence.fin = eachlength[i];
+ all_sequence.next = NULL;
+ maregion.list = &all_sequence;
+ region_used = &maregion;
+ }
+/* calcul longueur des regions */
+lmax = 0;
+psegment = region_used->list;
+while(psegment != NULL) {
+ lmax += psegment->fin - psegment->debut + 1;
+ psegment = psegment->next;
+ }
+vtotseqs = 0;
+for(i=0; i < ntaxa; i++)
+ if(tot_sel_seqs == 0 || sel_seqs[i]) ++vtotseqs;
+
+
+time(&heure);
+strcpy(date_ligne, ctime(&heure));
+num = strlen(date_ligne) - 1; if(date_ligne[num] == '\n') date_ligne[num] = 0;
+fprintf(out,"#NEXUS\n[saved by seaview on %s]\n", date_ligne);
+fprintf(out, "BEGIN TAXA;\n DIMENSIONS NTAX=%d;\n TAXLABELS", vtotseqs);
+for(i = 0; i < ntaxa; i+=5) {
+ for(j = i; j < i + 5 && j < ntaxa; j++) {
+ if(tot_sel_seqs == 0 || sel_seqs[j]) fprintf(out, " '%s'",
+ out_with_apostrophe(taxnames[j]));
+ }
+ fputc('\n', out);
+ }
+fprintf(out, " ;\nEND;\nBEGIN CHARACTERS;\n DIMENSIONS NCHAR=%d;\n", lmax);
+fprintf(out, " FORMAT DATATYPE=%s\n GAP=-\n ;\nMATRIX\n",
+ (protein ? "PROTEIN" : "NUCLEOTIDE") );
+
+num = 0;
+for(i = 0; i < ntaxa; i++) {
+ if(tot_sel_seqs != 0 && ! sel_seqs[i]) continue;
+ fprintf(out, "[%d] '%s'\n", ++num, out_with_apostrophe(taxnames[i]));
+
+ current = 0; psegment = region_used->list;
+ all_sequence.fin = eachlength[i];
+ do {
+ ecrit = output_next_res_from_region(seqs[i], eachlength[i],
+ &psegment, ¤t, out, 60, FALSE);
+ if( ecrit > 0) putc('\n', out);
+ else if(ecrit == -1) break;
+ }
+ while(ecrit != 0);
+ if( (ecrit = lmax - eachlength[i]) > 0) {
+ for(j = 1; j <= ecrit; j++) {
+ putc('-', out); if(j % 60 == 0) putc('\n', out);
+ }
+ putc('\n', out);
+ }
+ if(ferror(out)) break;
+ }
+fprintf(out, ";\nEND;\n");
+
+if(notes != NULL) {
+ num = 0; current = 0;
+ for(i = 0; i < ntaxa; i++) {
+ if(tot_sel_seqs != 0 && ! sel_seqs[i]) continue;
+ ++num;
+ if(notes[i] == NULL || strcmp(notes[i], ";") == 0 ||
+ strcmp(notes[i], ";\n") == 0) continue;
+ if(current == 0) { fputs("BEGIN NOTES;\n", out); current++; }
+ fprintf(out, " TEXT TAXON=%d TEXT='", num);
+ p = notes[i] + 1;
+ while(*p != 0) {
+ fputc(*p, out);
+ if(*p == APOSTROPHE) fputc(APOSTROPHE, out);
+ if(*p == '\n' && *(p+1) != 0) p++;
+ p++;
+ }
+ fputs("';\n", out);
+ }
+ if(current != 0) fprintf(out, "END;\n");
+ }
+
+if(num_species_sets != 0 || charsets != NULL) {
+ fprintf(out, "BEGIN SETS;\n");
+ for(num = 0; num < num_species_sets; num++) {
+ fprintf(out, " TAXSET '%s' =",
+out_with_apostrophe(name_species_sets[num]));
+ out_table_by_series(out, list_species_sets[num], ntaxa);
+ fputs(";\n", out);
+ }
+ while(charsets != NULL) {
+ list_segments *pair;
+ fprintf(out, " CHARSET '%s' =",
+out_with_apostrophe(charsets->element->name));
+ pair = charsets->element->list;
+ while(pair != NULL) {
+ if(pair->debut != pair->fin)
+ fprintf(out, " %d-%d", pair->debut, pair->fin);
+ else fprintf(out, " %d", pair->debut);
+ pair = pair->next;
+ }
+ fputs(";\n", out);
+ charsets = charsets->next;
+ }
+ fprintf(out, "END;\n");
+ }
+
+if(header != NULL || tot_comment_lines != 0) {
+ fprintf(out, "BEGIN seaview;\n");
+ if(header != NULL) {
+ fputs(" TEXT HEADER TEXT='", out);
+ p = header + 2;
+ while(*p != 0) {
+ fputc(*p, out);
+ if(*p == APOSTROPHE) fputc(APOSTROPHE, out);
+ if(*p == '\n' && *(p+1) != 0) p += 2;
+ p++;
+ }
+ fputs("';\n", out);
+ }
+ for(i = 0; i < tot_comment_lines; i++) {
+ fprintf(out, " TEXT FOOTER='%s' TEXT='",
+ out_with_apostrophe(comment_name[i]));
+ p = comment_line[i];
+ j = 0;
+ while(*p != 0) {
+ fputc(*p, out); j++;
+ if(*p == APOSTROPHE) fputc(APOSTROPHE, out);
+ if(j >= 50) { fputc('\n', out); j = 0; }
+ p++;
+ }
+ fputs("';\n", out);
+ }
+ fprintf(out, "END;\n");
+ }
+
+fclose(out);
+return FALSE;
+}
Added: trunk/packages/seaview/branches/upstream/current/old_file_chooser.cxx
===================================================================
--- trunk/packages/seaview/branches/upstream/current/old_file_chooser.cxx (rev 0)
+++ trunk/packages/seaview/branches/upstream/current/old_file_chooser.cxx 2006-09-19 14:20:14 UTC (rev 111)
@@ -0,0 +1,738 @@
+//
+// "$Id: fl_file_chooser.cxx,v 1.10.2.7 2000/12/06 15:45:13 easysw Exp $"
+//
+// File chooser widget for the Fast Light Tool Kit (FLTK).
+//
+// Copyright 1998-2000 by Bill Spitzak and others.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Library General Public
+// License as published by the Free Software Foundation; either
+// version 2 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Library General Public License for more details.
+//
+// You should have received a copy of the GNU Library General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+// USA.
+//
+// Please report all bugs and problems to "fltk-bugs at fltk.org".
+//
+
+#include <config.h>
+
+#include <FL/Fl.H>
+#include <FL/Fl_Window.H>
+#include <FL/Fl_Box.H>
+#include <FL/Fl_Button.H>
+#include <FL/Fl_Return_Button.H>
+#include <FL/Fl_Browser_.H>
+#include <FL/Fl_Input.H>
+#include <FL/fl_draw.H>
+#include <FL/filename.H>
+
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <ctype.h>
+
+#ifdef __APPLE__
+#define fl_filename_isdir filename_isdir_mac
+extern "C" {
+ int filename_isdir_mac( const char *dirname );
+ void CtoP(const void *in, void *out);
+ void MG_FSSpecToPathname (FSSpec *myFSS, char *fname, int maxl);
+ }
+#endif
+
+static void default_callback(const char*) {}
+static void (*current_callback)(const char*) = default_callback;
+void fl_file_chooser_callback(void (*cb)(const char*)) {
+ current_callback = cb ? cb : default_callback;
+}
+
+
+// "File Chooser Browser" widget:
+class FCB : public Fl_Browser_ {
+ void* item_first() const ;
+ void* item_next(void*) const ;
+ void* item_prev(void*) const ;
+ int item_height(const dirent*, int) const ;
+ int item_height(void*) const ;
+ int item_width(const dirent*) const ;
+ int item_width(void*) const ;
+ int item_quick_height(void*) const ;
+ int incr_height() const ;
+ void item_draw(void*, int, int, int, int) const ;
+ int checkdir(const dirent*, char*) const ;
+ void draw();
+ void clear_prev();
+public:
+ char listed[FL_PATH_MAX];// current dir & starname
+ int dirend; // points after last / before starname
+ int nameend; // length to trailing '*' or '\0'
+ const char* pattern; // default pattern
+ dirent** list; // the file names
+ dirent** last; // pointer after end of list
+ const char* message; // message if no file names
+ char preved[FL_PATH_MAX];// directory listed in prev
+ dirent** prev; // cached list of another directory
+ dirent** prev_last; // end of that list
+ int prev_count;
+ FCB(int x, int y, int w, int h) : Fl_Browser_(x, y, w, h, 0) {
+ type(FL_HOLD_BROWSER);
+ listed[0] = 0;
+ dirend = nameend = 1;
+ pattern = 0;
+ list = prev = 0;
+ message = 0;
+ }
+ // ~FCB nyi
+ void clear();
+ void set(const char*);
+ int get(char*);
+};
+
+// "File Chooser Window" widget:
+class FCW : public Fl_Window {
+public:
+ int handle(int);
+ Fl_Input input;
+ Fl_Button* ok_button;
+ Fl_Button* cancel_button;
+ Fl_Button* normal_button;
+ Fl_Button* cwd_button; // + MG
+ FCB browser;
+ FCW();
+};
+
+#if defined(WIN32) || defined(__EMX__) && !defined(__CYGWIN__)
+// ':' needs very special handling!
+static inline int isdirsep(char c) {return c=='/' || c=='\\';}
+#elif defined(__APPLE__)
+#define isdirsep(c) ((c)=='/')
+#else
+#define isdirsep(c) ((c)=='/')
+#endif
+
+#if defined(__APPLE__)
+#define dirsep '/'
+#else
+#define dirsep '/'
+#endif
+
+
+/* Files are marked as being directories by replacing the trailing null
+ with a '/' if it is a directory, a '\001' if it is *not* a directory.
+ An item has height (and is thus selectable) if it is either a directory
+ or if it matches the pattern. Quick-height assummes all unknown files
+ are directories, and thus saves the time needed to do a stat().
+*/
+
+// return pointer to last character:
+static const char* end_of_name(const dirent* d) {
+#if HAVE_DIRENT_H || defined(__APPLE__) || defined(WIN32)
+ const char* e;
+ for (e = d->d_name; ;e++) switch (*e) {
+ case 0: case 1:
+#ifdef __APPLE__
+ case '/':
+#else
+ case '/':
+#endif
+ return e;
+ }
+#else
+ // warning: clobbers byte after end of name
+ return d->d_name + d->d_namelen;
+#endif
+}
+
+// return true if item is directory, when given pointer to last character:
+int FCB::checkdir(const dirent* d, char* e) const {
+ if (*e == 1) return 0;
+#ifdef __APPLE__
+ if (*e == '/') return 1;
+#else
+ if (*e == '/') return 1;
+#endif
+ char buf[FL_PATH_MAX];
+ memcpy(buf, listed, dirend);
+ memcpy(buf+dirend, d->d_name, e-d->d_name);
+ *(buf+dirend+(e-d->d_name)) = 0;
+ if (fl_filename_isdir(buf)) {
+ *e = '/';
+ return 1;
+ } else {
+ *e = 1; return 0;
+ }
+}
+
+void* FCB::item_first() const {return list;}
+
+void* FCB::item_next(void* p) const {
+ if ((dirent**)p+1 >= last) return 0;
+ return (dirent**)p+1;
+}
+
+void* FCB::item_prev(void* p) const {
+ if ((dirent**)p <= list) return 0;
+ return ((dirent**)p)-1;
+}
+
+#ifdef _MSC_VER
+#pragma optimize("a",off) // without this it does not change *e
+#endif
+static int ido_matching(const dirent* p, const char* e, const char* n) {
+ // replace / or 1 at end with 0 and do match, then put back. yukko
+ int save = *e; *(char*)e = 0;
+ int r = fl_filename_match(p->d_name, n);
+ *(char*)e = save;
+ return(r);
+}
+#ifdef _MSC_VER
+#pragma optimize("",on)
+#endif
+
+int FCB::incr_height() const {return textsize()+2;}
+
+int FCB::item_height(const dirent* p, int slow) const {
+ const char* e = end_of_name(p);
+ if (listed[dirend]) {
+// if (p->d_name[0]=='.' && listed[dirend]!='.') return 0;
+ if (isdirsep( listed[nameend-1] )) {
+ if (slow ? !checkdir(p, (char*)e) : *e==1) return 0;
+ ((char*)listed)[nameend-1] = 0;
+ int r = ido_matching(p, e, listed+dirend);
+ ((char*)listed)[nameend-1] = dirsep;
+ if (!r) return 0;
+ } else {
+ if (!ido_matching(p, e, listed+dirend)) return 0;
+ }
+ } else {
+ if (p->d_name[0]=='.') return 0;
+ if (pattern && (slow ? !checkdir(p, (char*)e) : *e==1) &&
+ !ido_matching(p, e, pattern)) return 0;
+ }
+ return textsize()+2;
+}
+
+int FCB::item_height(void* x) const {
+ return item_height(*(const dirent**)x, 1);
+}
+
+int FCB::item_quick_height(void* x) const {
+ return item_height(*(const dirent**)x, 0);
+}
+
+void FCB::item_draw(void* v, int x, int y, int, int h) const {
+ const dirent* p = *(const dirent**)v;
+ const char* e = end_of_name(p);
+ if (checkdir(p, (char*)e)) e++;
+ if (v == selection()) fl_color(fl_contrast(textcolor(), selection_color()));
+ else fl_color(textcolor());
+ fl_font(textfont(), textsize());
+ fl_draw(p->d_name, e-p->d_name, x+4, y+h-3);
+}
+
+int FCB::item_width(const dirent* p) const {
+ const char* e = end_of_name(p); if (isdirsep( *e) ) e++;
+ fl_font(textfont(), textsize());
+ return (int)fl_width(p->d_name, e-p->d_name)+4;
+}
+
+int FCB::item_width(void* x) const {
+ return item_width(*(const dirent**)x);
+}
+
+// "get" the current value by copying the name of the selected file
+// or if none are selected, by copying as many common letters as
+// possible of the matched file list:
+int FCB::get(char* buf) {
+ dirent** q = (dirent**)selection(); // the file to copy from
+ int n = 0; // number of letters
+ if (q) { // a file is selected
+ const char* e = end_of_name(*q);
+ n = e - (*q)->d_name;
+ if (isdirsep(*e)) n++;
+ } else { // do filename completion
+ for (q = list; q < last && !item_height(*q, 0); q++);
+ if (q < last) {
+ const char* e = end_of_name(*q);
+ n = e - (*q)->d_name;
+ if (isdirsep(*e)) n++;
+ for (dirent** r = q+1; n && r < last; r++) {
+ if (!item_height(*r, 0)) continue;
+ int i;
+#if defined(_WIN32) || defined(WIN32) || defined(__APPLE__)
+ for (i=0; i<n && tolower((*q)->d_name[i])==tolower((*r)->d_name[i]); i++) {}
+#else
+ for (i=0; i<n && (*q)->d_name[i]==(*r)->d_name[i]; i++) {}
+#endif
+ n = i;
+ }
+ }
+ }
+ if (n) {
+ memcpy(buf, listed, dirend);
+ memcpy(buf+dirend, (*q)->d_name, n);
+ buf[dirend+n]=0;
+ }
+ return n;
+}
+
+// "set" the current value by changing the directory being listed and
+// changing the highlighted item, if possible:
+void FCB::set(const char* buf) {
+
+ int bufdirend;
+ int ispattern = 0;
+ const char* c = buf;
+ for (bufdirend=0; *c;) switch(*c++) {
+ case '?': case '[': case '*': case '{': ispattern = 1; goto BREAK;
+#if defined(WIN32) || defined(__EMX__) && !defined(__CYGWIN__)
+ case '\\':
+#endif
+ case '/': bufdirend=c-buf; break;
+ }
+#if defined(WIN32) || defined(__EMX__) && !defined(__CYGWIN__)
+ if ((!bufdirend) && isalpha(buf[0]) && (buf[1]==':')) bufdirend = 2;
+#endif
+ BREAK:
+ int bufend = strlen(buf);
+ if (bufend<=bufdirend) ispattern = 1;
+
+ // if directory is different, change list to xxx/ :
+ if (bufdirend != dirend || strncmp(buf, listed, bufdirend)) {
+ if (prev &&
+ preved[bufdirend]==0 && !strncmp(buf, preved, bufdirend)) {
+ strcpy(preved, listed); preved[dirend] = 0;
+ dirent** t;
+ t = prev; prev = list; list = t;
+ t = prev_last; prev_last = last; last = t;
+ strcpy(listed, buf);
+ dirend = nameend = bufdirend;
+ message = 0;
+ } else {
+ if (list) {
+ clear_prev();
+ strcpy(preved, listed); preved[dirend]=0;
+ prev = list;
+ prev_last = last;
+ }
+ list = last = 0;
+ message = "reading..."; redraw(); Fl::flush(); redraw();
+ strcpy(listed, buf);
+ dirend = nameend = bufdirend;
+ listed[dirend] = listed[dirend+1] = 0;
+ int n = fl_filename_list( dirend ? listed : "." , &list, NULL);
+ if (n < 0) {
+#ifndef __APPLE__
+ if (errno==ENOENT)
+ message = "No such directory";
+ else
+#endif
+ message = strerror(errno);
+ n = 0; list = 0;
+ } else message = 0;
+ last = list+n;
+ }
+ if (list && last <= list+2) message = "Empty directory";
+ new_list();
+ }
+
+ dirent** q = 0; // will point to future selection
+ int any = 0; // true if any names shown
+
+ // do we match one item in the previous list?
+ if (!ispattern && bufend >= nameend) {
+ for (q = list; ; q++) {
+ if (q >= last) {q = 0; break;}
+ if (item_height(*q, 0)==0) continue;
+ any = 1;
+ const char* a = (*q)->d_name;
+ const char* b = buf+bufdirend;
+#if ( defined(WIN32) && !defined(__CYGWIN__) ) || defined ( __APPLE__ )
+ while (*b && tolower(*a)==tolower(*b)) {a++; b++;}
+#else
+ while (*b && *a==*b) {a++; b++;}
+#endif
+ if (!*b && (*a==0 || /* *a=='/' ||*/ *a==1)) break;
+ }
+ }
+
+ // no, change the list pattern to the new text + a star:
+ if (!q) {
+ strcpy(listed+dirend, buf+bufdirend);
+ nameend = bufend;
+ if (!ispattern) {listed[nameend]='*'; listed[nameend+1]=0;}
+ any = 0;
+ // search again for an exact match:
+ for (q = list; ; q++) {
+ if (q >= last) {q = 0; break;}
+ if (item_height(*q, 0)==0) continue;
+ any = 1;
+ const char* a = (*q)->d_name;
+ const char* b = buf+bufdirend;
+#if ( defined(WIN32) && !defined(__CYGWIN__) ) || defined ( __APPLE__ )
+ while (*b && tolower(*a)==tolower(*b)) {a++; b++;}
+#else
+ while (*b && *a==*b) {a++; b++;}
+#endif
+ if (!*b && (*a==0 || /* *a=='/' ||*/ *a==1)) break;
+ }
+ new_list();
+ }
+
+ if (any) message = 0;
+ else if (!message) message = "No matching files";
+ select_only(q);
+ if (q) current_callback(buf);
+}
+
+void FCB::draw() {
+ if (!message) {
+ Fl_Browser_::draw();
+ if (full_height() > 0) return;
+ message = "No matching files";
+ }
+ Fl_Boxtype b = box(); if (!b) b = FL_DOWN_BOX;
+ draw_box(b,color());
+ fl_color(FL_INACTIVE_COLOR);
+ fl_font(textfont(), textsize());
+ fl_draw(message, x()+7, y()+3, w(), h()-3, FL_ALIGN_TOP_LEFT);
+ // insure scrollbars are redrawn if error message goes away:
+ scrollbar.redraw();
+ hscrollbar.redraw();
+}
+
+void FCB::clear_prev() {
+ if (prev) {
+ for (dirent**p=prev_last-1; p>=prev; p--) free((void*)*p);
+ free((void*)prev);
+ prev = prev_last = 0;
+ }
+}
+
+void FCB::clear() {
+ if (list) {
+ for (dirent**p=last-1; p>=list; p--) free((void*)*p);
+ free((void*)list);
+ list = last = 0;
+ }
+ clear_prev();
+ listed[0] = 0; dirend = 1;
+}
+
+////////////////////////////////////////////////////////////////
+
+static void fcb_cb(Fl_Widget*, void* v) {
+ FCW* w = (FCW*)v;
+ char buf[FL_PATH_MAX];
+ if (w->browser.get(buf)) {
+ w->input.value(buf);
+ w->input.position(10000);
+// w->input.position(10000, w->browser.dirend);
+ if (Fl::event_button()==1) {
+ if (Fl::event_clicks()) w->ok_button->do_callback();
+ else w->browser.set(buf);
+ } else {
+ current_callback(buf);
+ }
+ }
+}
+
+static void tab_cb(Fl_Widget*, void* v) {
+ FCW* w = (FCW*)v;
+ char buf[FL_PATH_MAX];
+ if (w->browser.get(buf)) {
+ w->input.value(buf);
+ w->input.position(10000);
+ w->browser.set(buf);
+ }
+}
+
+
+static void input_cb(Fl_Widget*, void* v) {
+ FCW* w = (FCW*)v;
+ const char* buf = w->input.value();
+ char localbuf[FL_PATH_MAX];
+ if (buf[0] && isdirsep(buf[w->input.size()-1])
+ && fl_filename_expand(localbuf, buf)) {
+ buf = localbuf;
+ w->input.value(localbuf);
+ w->input.position(10000);
+ }
+ w->browser.set(buf);
+}
+
+static void up_cb(Fl_Widget*, void* v) { // the .. button
+ FCW* w = (FCW*)v;
+ char* p;
+ const char* newname;
+ char buf[FL_PATH_MAX];
+ p = w->browser.listed+w->browser.dirend-1; // point right before last '/'
+ if (p < w->browser.listed)
+ newname = "../"; // go up from current directory
+ else {
+ for (; p>w->browser.listed; p--) if (isdirsep(*(p-1))) break;
+ if (isdirsep(*p) || *p=='.' &&
+ (isdirsep(p[1]) || p[1]=='.' && isdirsep(p[2]))) {
+ p = w->browser.listed+w->browser.dirend;
+ memcpy(buf, w->browser.listed, p-w->browser.listed);
+ strcpy(buf+(p-w->browser.listed), "../");
+ } else {
+ memcpy(buf, w->browser.listed, p-w->browser.listed);
+ buf[p-w->browser.listed] = 0;
+ }
+ newname = buf;
+ }
+ w->input.value(newname);
+ w->input.position(10000);
+ w->browser.set(newname);
+}
+
+static void dir_cb(Fl_Widget* obj, void* v) { // directory buttons
+ FCW* w = (FCW*)v;
+ const char* p = obj->label(); if (*p=='&') p++;
+ char buf[FL_PATH_MAX];
+ char* q; for (q=buf; *p && *p!=' '; *q++ = *p++); *q = 0;
+ fl_filename_expand(buf, buf);
+ w->input.value(buf);
+ w->input.position(10000);
+ w->browser.set(buf);
+}
+
+static void working_cb(Fl_Widget*, void* v) { // directory buttons
+ FCW*w = (FCW*)v;
+ char buf[FL_PATH_MAX];
+ fl_filename_absolute(buf, 100, "");
+ w->input.value(buf);
+ w->input.position(10000);
+ w->browser.set(buf);
+}
+
+static void files_cb(Fl_Widget* obj, void* v) { // file pattern buttons
+ FCW* w = (FCW*)v;
+ char buf[FL_PATH_MAX];
+ strcpy(buf, w->input.value());
+ char* q = buf+w->browser.dirend;
+ if (obj != w->normal_button) { // tack on first word of label
+ const char* p = obj->label(); if (*p=='&') p++;
+ for (; *p && *p!=' '; *q++ = *p++);
+ }
+ *q = 0;
+ w->input.value(buf);
+ w->input.position(10000, w->browser.dirend);
+ w->browser.set(buf);
+}
+
+/*----------------------- The Main Routine ----------------------*/
+#define HEIGHT_BOX (4*WIDTH_SPC+HEIGHT_BUT+HEIGHT_INPUT+HEIGHT_BROWSER)
+#define HEIGHT_BUT 23
+#define HEIGHT_INPUT 23
+#define HEIGHT_BROWSER (9*HEIGHT_BUT+2) // must be > buttons*HEIGHT_BUT
+#define WIDTH_BOX (3*WIDTH_SPC+WIDTH_BUT+WIDTH_BROWSER)
+#define WIDTH_BROWSER 350
+#define WIDTH_BUT 125
+#define WIDTH_OK 60
+#define WIDTH_SPC 5
+
+int FCW::handle(int event) {
+ if (Fl_Window::handle(event)) return 1;
+ if (event==FL_KEYBOARD && Fl::event_key()==FL_Tab) {
+ tab_cb(this, this);
+ return 1;
+ }
+ return 0;
+}
+
+// set this to make extra directory-jumping button:
+const char* fl_file_chooser_button;
+extern const char* fl_ok;
+extern const char* fl_cancel;
+
+FCW::FCW() : Fl_Window(WIDTH_BOX, HEIGHT_BOX),
+ input(WIDTH_SPC, HEIGHT_BOX-HEIGHT_BUT-2*WIDTH_SPC-HEIGHT_INPUT,
+ WIDTH_BOX-2*WIDTH_SPC, HEIGHT_INPUT, 0),
+ browser(2*WIDTH_SPC+WIDTH_BUT, WIDTH_SPC,
+ WIDTH_BROWSER, HEIGHT_BROWSER)
+{
+ int but_y = WIDTH_SPC;
+ input.callback(input_cb, this);
+ input.when(FL_WHEN_CHANGED);
+ // add(browser);
+ browser.callback(fcb_cb, this);
+
+ begin();
+ Fl_Widget* obj;
+ obj = ok_button = new Fl_Return_Button(
+ WIDTH_BOX-2*(WIDTH_SPC+WIDTH_OK), HEIGHT_BOX-WIDTH_SPC-HEIGHT_BUT,
+ WIDTH_OK, HEIGHT_BUT, fl_ok);
+ obj = cancel_button = new Fl_Button(
+ WIDTH_BOX-WIDTH_SPC-WIDTH_OK, HEIGHT_BOX-WIDTH_SPC-HEIGHT_BUT,
+ WIDTH_OK, HEIGHT_BUT, fl_cancel);
+ cancel_button->shortcut("^[");
+
+ obj=new Fl_Button(WIDTH_SPC,but_y,WIDTH_BUT,HEIGHT_BUT, "&Up one directory");
+ obj->callback(up_cb, this);
+ but_y += HEIGHT_BUT;
+#ifndef __APPLE__
+ obj = new Fl_Button(WIDTH_SPC, but_y, WIDTH_BUT, HEIGHT_BUT, "&~/ Home");
+ obj->callback(dir_cb, this);
+ but_y += HEIGHT_BUT;
+#endif
+ obj = new Fl_Button(WIDTH_SPC, but_y, WIDTH_BUT, HEIGHT_BUT, "&/ Root");
+ obj->callback(dir_cb, this);
+ but_y += HEIGHT_BUT;
+
+ cwd_button = new Fl_Button(WIDTH_SPC, but_y, WIDTH_BUT, HEIGHT_BUT, "&Current dir");
+ cwd_button->callback(working_cb, this);
+ but_y += HEIGHT_BUT;
+
+ if (fl_file_chooser_button) {
+ obj=new Fl_Button(WIDTH_SPC,but_y,WIDTH_BUT,HEIGHT_BUT,fl_file_chooser_button);
+ obj->callback(dir_cb, this);
+ but_y += HEIGHT_BUT;
+ }
+
+ normal_button = new Fl_Button(WIDTH_SPC, but_y, WIDTH_BUT, HEIGHT_BUT, "");
+ normal_button->callback(files_cb, this);
+ but_y += HEIGHT_BUT;
+
+ obj = new Fl_Button(WIDTH_SPC,but_y, WIDTH_BUT, HEIGHT_BUT, "* &All files");
+ obj->callback(files_cb, this);
+ but_y += HEIGHT_BUT;
+#ifndef __APPLE__
+ obj = new Fl_Button(WIDTH_SPC,but_y,WIDTH_BUT,HEIGHT_BUT, ". &Hidden files");
+ obj->callback(files_cb, this);
+ but_y += HEIGHT_BUT;
+#endif
+
+ obj = new Fl_Button(WIDTH_SPC,but_y,WIDTH_BUT,HEIGHT_BUT, "*/ &Directories");
+ obj->callback(files_cb, this);
+ but_y += HEIGHT_BUT;
+
+ resizable(new Fl_Box(browser.x(), but_y,
+ ok_button->x()-browser.x(),
+ browser.y()+browser.h()-but_y));
+ // add(input); // put last for better draw() speed
+ end();
+ set_modal();
+}
+
+
+#ifdef __APPLE__
+
+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)
+{
+ static char pathname[FL_PATH_MAX];
+ if( MG_GetInputFName(pathname, FL_PATH_MAX, (char *)message) ) return pathname;
+ else return NULL;
+}
+
+#else
+
+char* fl_file_chooser(const char* message, const char* pat, const char* fname)
+{
+ static FCW* f; if (!f) f = new FCW();
+ f->ok_button->label(fl_ok);
+ f->cancel_button->label(fl_cancel);
+
+ if (pat && !*pat) pat = 0;
+ if (fname && *fname) {
+ f->input.value(fname);
+ } else if (f->browser.pattern != pat && (!pat || !f->browser.pattern ||
+ strcmp(pat,f->browser.pattern))) {
+ // if pattern is different, remove name but leave old directory:
+ const char* p = f->input.value();
+ const char* q = fl_filename_name(p);
+ f->input.value(p, q-p);
+ }
+ f->browser.pattern = pat;
+ f->normal_button->label(pat ? pat : "visible files");
+ f->browser.set(f->input.value());
+ f->input.position(10000, f->browser.dirend);
+
+ f->label(message);
+ f->hotspot(f);
+ f->show();
+ int ok = 0;
+ for (;;) {
+ Fl::wait();
+ Fl_Widget* o = Fl::readqueue();
+ if (o == f->ok_button) {ok = 1; break;}
+ else if (o == f->cancel_button || o == f) break;
+ }
+ f->hide();
+ f->browser.clear();
+
+ if (!ok) return 0;
+ const char* r = f->input.value();
+ const char* p;
+ for (p=r+f->browser.dirend; *p; p++)
+ if (*p=='*' || *p=='?' || *p=='[' || *p=='{') return 0;
+ static char final[FL_PATH_MAX];
+ strcpy(final, r);
+ return final;
+}
+
+
+#endif
+//
+// End of "$Id: fl_file_chooser.cxx,v 1.10.2.7 2000/12/06 15:45:13 easysw Exp $".
+//
Added: trunk/packages/seaview/branches/upstream/current/protein.mase
===================================================================
--- trunk/packages/seaview/branches/upstream/current/protein.mase (rev 0)
+++ trunk/packages/seaview/branches/upstream/current/protein.mase 2006-09-19 14:20:14 UTC (rev 111)
@@ -0,0 +1,2483 @@
+;; saved by seaview on Wed Sep 25 16:02:40 2002
+;; saved by seaview on Mon Feb 4 17:37:12 2002
+;; saved by seaview on Mon Nov 19 17:33:17 2001
+;; saved by seaview on Tue Jul 3 19:19:18 2001
+;; saved by seaview on Tue Jul 3 19:18:16 2001
+;; saved by seaview on Tue Jul 3 19:13:44 2001
+;; saved by seaview on Tue Jul 3 19:06:14 2001
+;; saved by seaview on Fri Nov 24 13:23:50 2000
+;; saved by seaview on Fri Nov 24 13:23:22 2000
+;; saved by seaview on Wed Oct 25 11:32:09 2000
+;; saved by seaview on Wed May 17 17:11:58 2000
+;; saved by seaview on Tue Oct 15 14:32:47 1996
+;; saved by seaview on Tue Oct 15 14:32:24 1996
+;; saved by seaview on Mon Oct 14 15:44:10 1996
+;; saved by seaview on Mon Oct 14 11:45:27 1996
+;; saved by seaview on Mon Oct 14 11:16:43 1996
+;; saved by seaview on Mon Oct 14 10:44:48 1996
+;; saved by seaview on Mon Oct 14 10:35:42 1996
+;; saved by seaview on Fri Sep 27 10:47:32 1996
+;;Mase format
+;;# of segments=1 all seqs
+;; 52,653
+;;# of segments=1 to-BiP
+;; 52,719
+;;# of segments=1 encephalitoz
+;; 220,442
+;;|Comments
+;;----aA&@#i--------------------------------------------------
+;;------------------------------------------------------------
+;;------------------------------------------------------------
+;;------------------------------------------------------------
+;;------------------------------------------------------------
+;;------------------------------------------------------------
+;;------------------------------------------------------------
+;;------------------------------------------------------------
+;;------------------------------------------------------------
+;;------------------------------------------------------------
+;;------------------------------------------------------------
+;;------------------------------------------------------------
+;;------------------------------------------------------------
+;;------------------------------------------------------------
+;;-
+;;||
+;;@ of species = 79 to-BiP
+;; 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
+;; 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
+;; 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45,
+;; 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60,
+;; 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 74, 75, 76,
+;; 77, 78, 79, 81
+;;@ of species = 72 true-hsp70
+;; 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
+;; 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
+;; 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45,
+;; 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60,
+;; 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72
+;;@ of species = 70 strict-true-hsp70
+;; 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
+;; 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 28, 29, 30, 31,
+;; 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
+;; 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61,
+;; 62, 63, 64, 65, 66, 67, 69, 70, 71, 72
+;XLHSP70.PE1 648 residues Frame 0 Code 0
+;DEFINITION Xenopus gene for hsp 70 heat shock protein.
+;ACCESSION X01102 M11915
+; CDS 488..2431
+; /codon_start=1
+; /product="hsp 70 protein"
+; /db_xref="PID:g64796"
+; /db_xref="SWISS-PROT:P02827"
+Xenopus
+------------MATKGVAVGIDLGTTYSCVGVFQHGKVEIIANDQGNRTTPSYVAFT-D
+-TERLIGDAAKNQVAMNPQNTVFDAKRLIGRKFNDPVVQCDLKHWPFQVVSDE-GKPKVK
+VEYK-----GEEKSFFPEEISSMVLTKMKETA-EAYLG--HPVTNAVITVPAYFNDSQRQ
+ATKDAGVLAGLNILRIINEPTAAAIAYGLDKGA----RGEQNVLIFDLGGGTFDVSILTI
+DDG--IFEVKATAGDTHLGGEDFDNRMVNHFVEEFKRKHK------------KDIGQNKR
+ALRRLRTACDRAKRTLSS-SSQASIEIDSLFEGIDFY----TAITRARFEELCSDLFRGT
+LEPVEKALRDA-------KLDKSQIHEIVLVGGSTRIPKVQKL-LQDFFNGRELNKSINP
+DEAV-AYGAAVQAAILMGDKSE----N-VQDLLLLDVAPLSLGLETAGGVMTVLIKRNTT
+IPTKQTQSF-TTYSDNQPGVLIQVFEGER-AMTKDNNLLGK----FELSGIPPAPRG-VP
+QIEVTFDIDANGIL-NVSAVEKS-SGKQNKITITNDKGRLSKE-DIEKMVQEAEKYKADD
+DAQRERVDAKNALESYAFNL--KSMVEDE-NVKGKISDEDKRTISEKCTQVISWLENNQ-
+LAEKEEYAFQQKDLEKVCQPIITKLYQGGVPGGVPGGMPGSSCGAQARQGGNSGPTIEEV
+D-----------------------------------------------------------
+-------------------------------------------------------
+;HSP70B.PE1 644 residues Frame 0 Code 0
+;DEFINITION Human heat-shock protein HSP70B' gene.
+;ACCESSION X51757
+; CDS 251..2182
+; /note="heat-shock protein HSP70B' (AA 1-643)"
+; /codon_start=1
+; /db_xref="PID:g35222"
+; /db_xref="SWISS-PROT:P17066"
+Homo-B'
+-----------mqaprelavgidlgttyscvgvfqqgrveilandqgnrttpsyvaft-D
+-TERLVGDAAKSQAALNPHNTVFDAKRLIGRKFADTTVQSDMKHWPFRVVSEG-GKPKVP
+VSYR-----GEDKTFYPEEISSMVLSKMKETA-EAYLG--QPVKHAVITVPAYFNDSQRQ
+ATKDAGAIAGLNVLRIINEPTAAAIAYGLDRRG----AGERNVLIFDLGGGTFDVSVLSI
+DAG--VFEVKATAGDTHLGGEDFDNRLVNHFMEEFRRKHG------------KDLSGNKR
+ALGRLRTACERAKRTLSS-STQATLEIDSLFEGVDFY----TSITRARFEELCSDLFRST
+LEPVEKALRDA-------KLDKAQIHDVVLVGGSTRIPKVQKL-LQDFFNGKELNKSINP
+DEAV-AYGAAVQAAVLMGDKCE----K-VQDLLLLDVAPLSLGLETAGGVMTTLIQRNAT
+IPTKQTQTF-TTYSDNQPGVFIQVYEGER-AMTKDNNLLGR----FELSGIPPAPRG-VP
+QIEVTFDIDANGIL-SVTATDRS-TGKANKITITNDKGRLSKE-EVERMVHEAEQYKAED
+EAQRDRVAAKNSLEAHVFHV--KGSLQEE-SLRDKIPEEDRRKMQDKCREVLAWLEHNQ-
+LAEKEEYEHQKRELEQICRPIFSRLYGGPGVPGGSSCGTQARQGDPSTGPIIEEVD----
+------------------------------------------------------------
+-------------------------------------------------------
+;HUMHSP70D.HSPA1L 641 residues Frame 0 Code 0
+;DEFINITION Human heat shock protein (hsp 70) gene, complete cds.
+;ACCESSION M11717 M15432
+; CDS 489..2411
+; /gene="HSPA1L"
+; /note="70 kDa"
+; /codon_start=1
+; /db_xref="GDB:G00-120-058"
+; /product="heat shock protein"
+; /db_xref="PID:g386785"
+Homo-1L
+-------------MAKAAAVGIDLGTTYSCVGVFQHGKVEIIANDQGNRTTPSYVAFT-D
+-TERLIGDAAKNQVALNPQNTVFDAKRLIGRKFGDPVVQSDMKHWPFQVINDG-DKPKVQ
+VSYK-----GETKAFYPEEISSMVLTKMKEIA-EAYLG--YPVTNAVITVPAYFNDSQRQ
+ATKDAGVIAGLNVLRIINEPTAAAIAYGLDRTG----KGERNVLIFDLGGGTFDVSILTI
+DDG--IFEVKATAGDTHLGGEDFDNRLVNHFVEEFKRKHK------------KDISQNKR
+AVRRLRTACERAKRTLSS-STQASLEIDSLFEGIDFY----TSITRARFEELCSDLFRST
+LEPVEKALRDA-------KLDKAQIHDLVLVGGSTRIPKVQKL-LQDFFNGRDLNKSINP
+DEAV-GYGAAVQAAILMGDKSE----N-VQDLLLLDVAPLSLGLETAGGVMTALIKRNST
+IPTKQTQIF-TTYSDNQPGVLIQVYEGER-AMTKDNNLLGR----FELSGIPPAP-G-VP
+QIEVTFDIDANGIL-NVTATDKS-TGKANKITITNDKGRLSKE-EIERMVQEAEKYKAED
+EVQRERVSAKNALESYAFNM--KSAVEDE-GLKGKISEADKKKVLDKCQEVISWLDANT-
+LAEKDEFEHKRKELEQVCNPIISGLYQGAGGPGPGGFGAQGPKGGSGSGPTIEEVD----
+------------------------------------------------------------
+-------------------------------------------------------
+;HUMMHHSP.HSP70-1 642 residues Frame 0 Code 0
+;DEFINITION Human MHC class III HSP70-1 gene (HLA), complete cds.
+;ACCESSION M59828 M34267
+; CDS 490..2415
+; /gene="HSP70-1"
+; /codon_start=1
+; /product="heat shock-induced protein"
+; /db_xref="PID:g188488"
+Homo-1
+-------------MAKAAAIGIDLGTTYSCVGVFQHGKVEIIANDQGNRTTPSYVAFT-D
+-TERLIGDAAKNQVALNPQNTVFDAKRLIGRKFGDPVVQSDMKHWPFQVINDG-DKPKVQ
+VSYK-----GETKAFYPEEISSMVLTKMKEIA-EAYLG--YPVTNAVITVPAYFNDSQRQ
+ATKDAGVIAGLNVLRIINEPTAAAIAYGLDRTG----KGERNVLIFDLGGGTFDVSILTI
+DDG--IFEVKATAGDTHLGGEDFDNRLVNHFVEEFKRKHK------------KDISQNKR
+AVRRLRTACERAKRTLSS-STQASLEIDSLFEGIDFY----TSITRARFEELCSDLFRST
+LEPVEKALRDA-------KLDKAQIHDLVLVGGSTRIPKVQKL-LQDFFNGRDLNKSINP
+DEAV-AYGAAVQAAILMGDKSE----N-VQDLLLLDVAPLSLGLETAGGVMTALIKRNST
+IPTKQTQIF-TTYSDNQPGVLIQVYEGER-AMTKDNNLLGR----FELSGIPPAPRG-VP
+QIEVTFDIDANGIL-NVTATDKS-TGKANKITITNDKGRLSKE-EIERMVQEAEKYKAED
+EVQRERVSAKNALESYAFNM--KSAVEDE-GLKGKISEADKKKVLDKCQEVISWLDANT-
+LAEKDEFEHKRKELEQVCNPIISGLYQGAGGPGPGGFGAQGPKGGSGSGPTIEEVD----
+------------------------------------------------------------
+-------------------------------------------------------
+;HUMMHHSP2.PE1 642 residues Frame 0 Code 0
+;DEFINITION Human MHC class III HSP70-2 gene (HLA), complete cds.
+;ACCESSION M59830 M34269
+; CDS 486..2411
+; /gene="HSP70-2"
+; /codon_start=1
+; /product="heat shock-induced protein"
+; /db_xref="PID:g188490"
+Homo-2
+-------------MAKAAAIGIDLGTTYSCVGVFQHGKVEIIANDQGNRTTPSYVAFT-D
+-TERLIGDAAKNQVALNPQNTVFDAKRLIGRKFGDPVVQSDMKHWPFQVINDG-DKPKVQ
+VSYK-----GETKAFYPEEISSMVLTKMKEIA-EAYLG--YPVTNAVITVPAYFNDSQRQ
+ATKDAGVIAGLNVLRIINEPTAAAIAYGLDRTG----KGERNVLIFDLGGGTFDVSILTI
+DDG--IFEVKATAGDTHLGGEDFDNRLVNHFVEEFKRKHK------------KDISQNKR
+AVRRLRTACERAKRTLSS-STQASLEIDSLFEGIDFY----TSITRARFEELCSDLFRST
+LEPVEKALRDA-------KLDKAQIHDLVLVGGSTRIPKVQKL-LQDFFNGRDLNKSINP
+DEAV-AYGAAVQAAILMGDKSE----N-VQDLLLLDVAPLSLGLETAGGVMTALIKRNST
+IPTKQTQIF-TTYSDNQPGVLIQVYEGER-AMTKDNNLLGR----FELSGIPPAPRG-VP
+QIEVTFDIDANGIL-NVTATDKS-TGKANKITITNDKGRLSKE-EIERMVQEAEKYKAED
+EVQRERVSAKNALESYAFNM--KSAVEDE-GLKGKISEADKKKVLDKCQEVISWLDANT-
+LAEKDEFEHKRKELEQVCNPIISGLYQGAGGPGPGGFGAQGPKGGSGSGPTIEEVD----
+------------------------------------------------------------
+-------------------------------------------------------
+;HUMMHHSPHO.PE1 642 residues Frame 0 Code 0
+;DEFINITION Human MHC class III HSP70-HOM gene (HLA), complete cds.
+;ACCESSION M59829 M34268
+; CDS 960..2885
+; /gene="HSP70-HOM"
+; /codon_start=1
+; /product="heat shock-induced protein"
+; /db_xref="PID:g188492"
+Homo-HOM
+-----------MATAKGIAIGIDLGTTYSCVGVFQHGKVEIIANDQGNRTTPSYVAFT-D
+-TERLIGDAAKNQVAMNPQNTVFDAKRLIGRKFNDPVVQADMKLWPFQVINEG-GKPKVL
+VSYK-----GENKAFYPEEISSMVLTKLKETA-EAFLG--HPVTNAVITVPAYFNDSQRQ
+ATKDAGVIAGLNVLRIINEPTAAAIAYGLDKGG----QGERHVLIFDLGGGTFDVSILTI
+DDG--IFEVKATAGDTHLGGEDFDNRLVSHFVEEFKRKHK------------KDISQNKR
+AVRRLRTACERAKRTLSS-STQANLEIDSLYEGIDFY----TSITRARFEELCADLFRGT
+LEPVEKALRDA-------KMDKAKIHDIVLVGGSTRIPKVQRL-LQDYFNGRDLNKSINP
+DEAV-AYGAAVQAAILMGDKSE----K-VQDLLLLDVAPLSLGLETVGGVMTALIKRNST
+IPPKQTQIF-TTYSDNQPGVLIQVYEGER-AMTKDNNLLGR----FDLTGIPPAPRG-VP
+QIEVTFDIDANGIL-NVTATDKS-TGKVNKITITNDKGRLSKE-EIERMVLDAEKYKAED
+EVQREKIAAKNALESYAFNM--KSVVSDE-GLKGKISESDKNKILDKCNELLSWLEVNQ-
+LAEKDEFDHKRKELEQMCNPIITKLYQGGCTGPACGTGYVPGRPATGPTIEEVD------
+------------------------------------------------------------
+-------------------------------------------------------
+;MUSHP7A2.HSP70A1 642 residues Frame 0 Code 0
+;DEFINITION Mouse heat shock inducible (hsp70A1) gene, complete cds.
+;ACCESSION M76613
+; CDS 1040..2965
+; /gene="hsp70A1"
+; /note="putative"
+; /citation=[2]
+; /codon_start=1
+; /function="heat shock induced protein"
+; /product="hsp70A1"
+; /db_xref="PID:g193983"
+Mus-A1
+-------------MAKNTAIGIDLGTTYSCVGVFQHGKVEIIANDQGNRTTPSYVAFT-D
+-TERLIGDAAKNQVALNPQNTVFDAKRLIGRKFGDAVVQSDMKHWPFQVVNDG-DKPKVQ
+VNYK-----GESRSFFPEEISSMVLTKMKEIA-EAYLG--HPVTNAVITVPAYFNDSQRQ
+ATKDAGVIAGLNVLRIINEPTAAAIAYGLDRTG----KGERNVLIFDLGGGTFDVSILTI
+DDG--IFEVKATAGDTHLGGEDFDNRLVSHFVEEFKRKHK------------KDISQNKR
+AVRRLRTACERAKRTLSS-STQASLEIDSLFEGIDFY----TSITRARFEELCSDLFRGT
+LEPVEKALRDA-------KMDKAQIHDLVLVGGSTAIPKVQKL-LQDFFNGRDLNKSINP
+DEAV-AYGAAVQAAILMGDKSE----N-VQDLLLLDVAPLSLGLETAGGVMTALIKRNST
+IPTKQTQTF-TTYSDNQPGVLIQVYEGER-AMTRDNNLLGR----FELSGIPPAPRG-VP
+QIEVTFDIDANGIL-NVTATDKS-TGKANKITITNDKGRLSKE-EIERMVQEAERYKAED
+EVQRDRVAAKNALESYAFNM--KSAVEDE-GLKGKLSEADKKKVLDKCQEVISWLDSNT-
+LADKEEFVHKREELERVCSPIISGLYQGAGAPGAGGFGAQAPKGASGSGPTIEEVD----
+------------------------------------------------------------
+-------------------------------------------------------
+;CAHSP70.PE1 639 residues Frame 0 Code 0
+;DEFINITION C.aethiops mRNA for heat shock protein 70.
+;ACCESSION X70684
+; CDS 181..2097
+; /codon_start=1
+; /product="heat shock protein 70"
+; /db_xref="PID:g22782"
+Cercopithecus
+-------------MAKAAAIGIDLGTTYSCVGVFQHGKVEIIANDQGNRTTPSYVAFT-D
+-TERLIGDAAKNQVALNPQNTVFDAKRLIGRKFGDPVVQSDMKHWPFQVINDG-DKPKVQ
+VSYK-----GETKAFYPEEISSMVLTKMKEIA-EADLG--YPVTNAVITVPAYFNDSQRQ
+ATKDAGVIAGLNVLRIINEPTR-TIAYALDRTG----KGERNVLIFDLGGGTFDVSILTI
+DDG--IFEVKATAGDTTWV-EDFDNRLVNHFVEEFKRKHK------------KDISQNKR
+AVRRLRTACERAKRTLSS-STQASLEIDSLFEGIDFY----TSITRARFEELCSDLFRST
+LEPVEKALRDA-------KLDKAQIHDLVLVGGSTRIPKVQKL-LQDFFNGRDLNKSINP
+DEAV-AYGAAVQAAILMGDKSE----N-VQDLLLLDVAPLSLGLETPGGVMTALIKRNST
+IPTKQTQIF-TTYSDNQPGVLIQVYEGER-AMTKDNNLLGR----FELSGIPPAP-G-VP
+QIEVTFEIDANGIL-NVTATDKS-TGKANKITITNDKGRLSKE-EIERMVQEAEKYKAED
+EVQRERVSAKNALESYALNM--KSAVEDE-GLKGKISEADKKKVLDKCQEVISWLDANT-
+LAEKDEFEHKRKELEQVCNPIISGLYQGGGGPGPGGFGAQGPKGGSGSGPTIEEVD----
+------------------------------------------------------------
+-------------------------------------------------------
+;MUSHSC70T.HSC70T 642 residues Frame 0 Code 0
+;DEFINITION Mouse heat shock protein 70 (Hsc70t) gene, complete cds.
+;ACCESSION L27086
+; CDS 1..1926
+; /gene="Hsc70t"
+; /codon_start=1
+; /product="heat shock protein 70"
+; /db_xref="PID:g457300"
+Mus-t
+-----------MAANKGMAIGIDLGTTYSCVGVFQHGKVEIIANDQGNRTTPSYVAFT-D
+-TERLIGDAAKNQVAMNPQNTVFDAKRLIGRKFNDPVVQSDMKLWPFQVINEA-GKPKVM
+VSYK-----GEKKAFYPEEISSMVLTKMKETA-EAFLG--HNVTNAVITVPAYFNDSQRQ
+ATKDAGVIAGLNVLRIINEPTAAAIAYGLDKGS----HGERHVLIFDLGGGTFDVSILTI
+DDG--IFEVKATAGDTHLGGEDFDNRLVSHFVEEFKRKHK------------KDISQNKR
+AVRRLRTACERAKRTLSS-STQANLEIDSLYEGIDFY----TSITRARFEELCADLFRGT
+LEPVEKSLRDA-------KMDKAKIHDIVLVGGSTRIPKVQKL-LQDYFNGRDLNKSINP
+DEAV-AYGAAVQAAILMGDKSE----K-VQDLLLLDVAPLSLGLETAGGVMTVLIKRNST
+IPTKQTQIF-TTYSDNQPGVLIQVYEGER-AMTRDNNLLGR----FDLTGIPPAPRG-VP
+QIEVTFDIDANGIL-NVTAMDKS-TGKANKITITNDKGRLSKE-EIERMVQEAERYKAED
+EGQREKIAAKNALESYAFNM--KSAVGDE-GLKDKISESDKKKILDKCNEVLSWLEANQ-
+LAEKDEFDHKRKELENMCNPIITKLYQSGCTGPTCTPGYTPGRAATGPTIEEVD------
+------------------------------------------------------------
+-------------------------------------------------------
+;MUSHSP7A2.PE1 643 residues Frame 0 Code 0
+;DEFINITION Mouse heat shock protein 70.1 (hsp70.1) gene, complete cds.
+;ACCESSION M35021
+; CDS 806..2734
+; /note="hsp70.1"
+; /codon_start=1
+; /db_xref="PID:g387211"
+Mus-1
+-------------MAKNTAIGIDLGTTYSCVGVFQHGKVEIIANDQGNRTTPSYVAFT-D
+-TERLIGDAAKNQVALNPQNTVFDAKRLIGRKFGDAVVQSDMKHWPFQVVNDG-DKPKVQ
+VNYK-----GESRSFFPEEISSMVLTKMKEIA-EAYLG--HPVTNAVITVPAYFNDSQRQ
+ATKDAGVIAGLNVLRIINEPTAAAIAYGLDRTG----KGERNVLIFDLGGGTFDVSILTI
+DDG--IFEVKATAGDTHLGGEDFDNRLVSHFVEEFKRKHK------------KDISQNKR
+AVRRLRTACERAKRTLSS-STQASLEIDSLFEGIDFY----TSITRARFEELCSDLFRGT
+LEPVEKALRDA-------KMDKAQIHDLVLVGGSTRIPKVQKL-LQDFFNGRDLNKSINP
+DEAV-AYGAAVQAAILMGDKSE----N-VQDLLLLDVAPLSLGLETAGGVMTALIKRNST
+IPTKQTQTF-TTYSDNQPGVLIQVYEGER-AMTRDNNLLGR----FELSGIPPAPRG-VP
+QIEVTFDIDANGIL-NVTATDKS-TGKANKITITNDKGRLSKE-EIERMVQEAERYKAED
+EVQRDRVAAKNALESYAFNM--KSAVEDE-GLKGKLSEADKKKVLDKCQEVISWLDSNT-
+LADKEEFVHKREELERVCSPIISGLYQGAGAPGAGGFGAQAPPKGASGSGPTIEEVD---
+------------------------------------------------------------
+-------------------------------------------------------
+;MUSHSPCA.PE1 647 residues Frame 0 Code 0
+;DEFINITION Mouse heat shock protein 70 cognate mRNA, complete cds.
+;ACCESSION M19141
+; CDS 66..2006
+; /note="heat shock protein 70 cognate"
+; /codon_start=1
+; /db_xref="PID:g309319"
+Mus-mRNA
+-------------MSKGPAVGIDLGTTYSCVGVFQHGKVEIIANDQGNRTTPSYVAFT-D
+-TERLIGDAAKNQVAMNPTNTVFDAKRLIGRRFDDAVVQSDMKHWPFMVVNDA-GRPKVQ
+VEYK-----GETKSFYPEEVSSMVLTKMKEIA-EAYLG--KTVTNAVVTVPAYFNDSQRQ
+ATKDAGTIAGLNVLRIINEPTAAAIAYGLDKKV----GAERNVLIFDLGGGTFDVSILTI
+EDG--IFEVKSTAGDTHLGGEDFDNRMVNHFIAEFKRKHK------------KDISENKR
+AVRRLRTACERAKRTLSS-STQASIEIDSLYEGIDFY----TSITRARFEELNADLFRGT
+LDPVEKALRDA-------KLDKSQIHDIVLVGGSTRIPKIQKL-LQDFFNGKELNKSINP
+DEAV-AYGAAVQAAILSGDKSE----N-VQDLLLLDVTPLSLGIETAGGVMTVLIKRNTT
+IPTKQTQTL-TTYSDNQPGVLIQVYEGER-AMTKDNNLLGK----FELTGIPPAPRG-VP
+QIEVTFDIDANGIL-NVSAVDKS-TGKENKITITNDKGRLSKE-DIERMVQEAEKYKAED
+EKQRDKVSSKNSLESYAFNM--KATVEDE-KLQGKINDEDKQKILDKCNEIISWLDKNQ-
+TAEKEEFEHQQKELEKVCNPIITKLYQSAGGMPGGMPGGFPGGGAPPSGGASSGPTIEEV
+D-----------------------------------------------------------
+-------------------------------------------------------
+;RNHSP70.HSP70.1 642 residues Frame 0 Code 0
+;DEFINITION R.norvegicus hsp70 gene for heat shock protein 70.
+;ACCESSION X74271
+; CDS 2146..4071
+; /gene="hsp70.1"
+; /citation=[1]
+; /codon_start=1
+; /product="heat shock protein 70"
+; /db_xref="PID:g396270"
+Rattus.1
+-------------MAKKTAIGIDLGTTYSCVGVFQHGKVEIIANDQGNRTTPSYVAFT-D
+-TERLIGDAAKNQVALNPQNTVFDANGLIGRKFGDPVVQSDMKHWPFQVVNDG-DKPKVQ
+VNYK-----GENRSFYPEEISSMVLTKMKEIA-EAYLG--HPVTNAVITVPAYFNDSQRQ
+ATKDAGVIAGLNVLRIINEPTAAAIAYGLDRTG----KGERNVLIFDLGGGTFDVSILTI
+DDG--IFEVKATAGDTHLGGEDFDNRLVSHFVEEFKRKHK------------KDISQNKR
+AVRRLRTACERAKRTLSS-STQASLEIDSLFEGIDFY----TSITRARFEELCSDLFRGT
+LEPVEKALRDA-------KLDKAQIHDLVLVGGSTRIPKVQKL-LQDFFNGRDLNKSINP
+DEAV-AYGAAVQAAILMGDKSE----N-VQDLLLLDVAPLSLGLETAGAVMTALIKRNST
+IPTKQTQTF-TTYSDNQPGVLIQVYEGER-AMTRDNNLLGR----FELSGIPPAPRG-VP
+QIEVTFDIDANGIL-NVTATDKS-TGKANKITITNDKGRLSKE-EIERMVQEAERYKAED
+EVQRERVAAKNALESYAFNM--KSAVEDE-GLKGKISEADKKKVLDKCQEVISWLDSNT-
+LAEKEEFVHKREELERVCNPIISGLYQGAGAPGAGGFGAQAPKGGSGSGPTIEEVD----
+------------------------------------------------------------
+-------------------------------------------------------
+;RNHSC73.PE1 647 residues Frame 0 Code 0
+;DEFINITION Rat gene for hsc73 , the major hsp70-like protein.
+;ACCESSION Y00054
+; CDS join(1039..1243,1507..1712,1829..1981,2062..2617,
+; 2831..3033,3249..3447,3533..3765,4022..4207)
+; /codon_start=1
+; /product="hsc73"
+; /db_xref="PID:g56379"
+; /db_xref="SWISS-PROT:P08109"
+Rattus-hsc73
+-------------MSKGPAVGIDLGTTYSCVGVFQHGKVEIIANDQGNRTTPSYVAFT-D
+-TERLIGDAAKNQVAMNPTNTVFDAKRLIGRRFDDAVVQSDMKHWPFMVVNDA-GRPKVQ
+VEYK-----GETKSFYPEEVSSMVLTKMKEIA-EAYLG--KTVTNAVVTVPAYFNDSQRQ
+ATKDAGTIAGLNVLRIINEPTAAAIAYGLDKKV----GAERNVLIFDLGGGTFDVSILTI
+EDG--IFEVKSTAGDTHLGGEDFDNRMVNHFIAEFKRKHK------------KDISENKR
+AVRRLRTACERAKRTLSS-STQASIEIDSLYEGIDFY----TSITRARFEELNADLFRGT
+LDPVEKALRDA-------KLDKSQIHDIVLVGGSTRIPKIQKL-LQDFFNGKELNKSINP
+DEAV-AYGAAVQAAILSGDKSE----N-VQDLLLLDVTPLSLGIETAGGVMTVLIKRNTT
+IPTKQTQTF-TTYSDNQPGVLIQVYEGER-AMTKDNNLLGK----FELTGIPPAPRG-VP
+QIEVTFDIDANGIL-NVSAVDKS-TGKENKITITNDKGRLSKE-DIERMVQEAEKYKAED
+EKQRDKVSSKNSLESYAFNM--KATVEDE-KLQGKINDEDKQKILDKCNEIISWLDKNQ-
+TAEKEEFEHQQKELEKVCNPIITKLYQSAGGMPGGMPGGFPGGGAPPSGGASSGPTIEEV
+D-----------------------------------------------------------
+-------------------------------------------------------
+;RNHSP701.HSP70-1 642 residues Frame 0 Code 0
+;DEFINITION R.norvegicus Hsp70-1 gene.
+;ACCESSION X77207
+; CDS 126..2051
+; /gene="Hsp70-1"
+; /codon_start=1
+; /product="heat shock protein 70"
+; /db_xref="PID:g450930"
+; /db_xref="SWISS-PROT:Q07439"
+Rattus-1
+-------------MAKKTAIGIDLGTTYSCVGVFQHGKVEIIANDQGNRTTPSYVAFT-D
+-TERLIGDAAKNQVALNPQNTVFDAKRLIGRKFGDPVVQSDMKHWPFQVVNDG-DKPKVQ
+VNYK-----GENRSFYPEEISSMVLTKMKEIA-EAYLG--HPVTNAVITVPAYFNDSQRQ
+ATKDAGVIAGLNVLRIINEPTAAAIAYGLDRTG----KGERNVLIFDLGGGTFDVSILTI
+DDG--IFEVKATAGDTHLGGEDFDNRLVSHFVEEFKRKHK------------KDISQNKR
+AVRRLRTACERAKRTLSS-STQASLEIDSLFEGIDFY----TSITRARFEELCSDLFRGT
+LEPVEKALRDA-------KLDKAQIHDLVLVGGSTRIPKVQKL-LQDFFNGRDLNKSINP
+DEAV-AYGAAVQAAILMGDKSE----N-VQDLLLLDVAPLSLGLETAGGVMTALIKRNST
+IPTKQTQTF-TTYSDNQPGVLIQVYEGER-AMTRDNNLLGR----FELSGIPPAPRG-VP
+QIEVTFDIDANGIL-NVTATDKS-TGKANKITITNDKGRLSKE-EIERMVQEAERYKAED
+EVQRERVAAKNALESYAFNM--KSAVEDE-GLKGKISEADKKKVLDKCQEVISWLDSNT-
+LAEKEEFVHKREELERVCNPIISGLYQGAGAPGAGGFGAQAPKGGSGSGPTIEEVD----
+------------------------------------------------------------
+-------------------------------------------------------
+;RNHSP703.HSP70-3 642 residues Frame 0 Code 0
+;DEFINITION R.norvegicus Hsp70-3 gene.
+;ACCESSION X77209
+; CDS 272..2197
+; /gene="Hsp70-3"
+; /codon_start=1
+; /product="heat shock protein 70"
+; /db_xref="PID:g450934"
+Rattus-3
+-----------MAANKGMAIGIDLGTTYSCVGVFQHGKVEIIANDQGNRTTPSYVAFT-D
+-TERLIGDAAKNQVAMNPQNTVFDAKRLIGRKFNDPVVQSDMKLWPFQVINEA-GKPKVL
+VSYK-----GEKKAFYPEEISSMVLTKMKETA-EAFLG--HSVTNAVITVPAYFNDSQRQ
+ATKDAGVIAGLNVLRIINEPTAAAIAYGLDKGS----HGERHVLIFDLGGGTFDVSILTI
+DDG--IFEVKATAGDTHLGGEDFDNRLVSHFVEEFKRKHK------------KDISQNKR
+AVRRLATACERAKRTLSS-STQANLEIDSLYEGIDFY----TSITRARFEELCADLFRGT
+LEPVEKSLRDA-------KMDKAKIHDIVLVGGSTRIPKVQKL-LQDYFNGRDLNKSINP
+DEAV-AYGAAVQAAILMGDKSE----K-VQDLLLLDVAPLSLGLETAGGVMTVLIKRNST
+IPTKQTQIF-TTYSDNQPGVLIQVYEGER-AMTRDNNLLGR----FDLTGIPPAPRG-VP
+QIEVTFDIDANGIL-NVTAMDKS-TGKANKITITNDKGRLSKE-EIERMVQEAERYKAED
+EGQREKIAAKNALESYAFNM--KSAVGDE-GLKDKISESDKKKILDKCSEVLSWLEANQ-
+LAEKEEFDHKRKELENMCNPIITKLYQSGCTGPTCAPGYTPGRARTGPTIEEVD------
+------------------------------------------------------------
+-------------------------------------------------------
+;RATHSP70A.HSP70 642 residues Frame 0 Code 0
+;DEFINITION Rattus norvegicus heat shock protein 70 (HSP70) mRNA, complete cds.
+;ACCESSION L16764
+; CDS 178..2103
+; /gene="HSP70"
+; /codon_start=1
+; /product="heat shock protein 70"
+; /db_xref="PID:g294568"
+Rattus-mRNA
+-------------MAKKTAIGIDLGTTYSCVGVFQHGKVEIIANDQGNRTTPSYVAFT-D
+-TERLIGDAAKNQVALNPQNTVFDAKRLIGRKFGDPVVQSDMKHWPFQVVNDG-DKPKVQ
+VNYK-----GENRSFYPEEISSMVLTKMKEIA-EAYLG--HPVTNAVITVPAYFNDSQRQ
+ATKDAGVIAGLNVLRIINEPTAAAIAYGLDRTG----KGERNVLIFDLGGGTFDVSILTI
+DDG--IFEVKATAGDTDLGGEDFDNRLVSHFVEEFKRKHK------------KDISQNKR
+AVRRLRTACERAKRTLSS-STQASLEIDSLFEGIDFY----TSITRARFEELCSDLFRGT
+LEPVEKALRDA-------KLDKAQIHDLVLVGGSTRIPKVQKL-LQDFFNGRDLNKSINP
+DEAV-AYGAAVQAAILMGDKSE----N-VQDLLLLDVAPLSLGLETAGGVMTALIKRNST
+IPTKQTQTF-TTYSDNQPGVLIQVYEGER-AMTRDNNLLGR----FELSGIPPAPRG-VP
+QIEVTFDIDANGIL-NVTATDKS-TGKANKITITNDKGRLSKE-EIERMVQEAERYKAED
+EVQRERVAAKNALESYAFNM--KSAVEDE-GLKGKISEADKKKVLDKCQEVISWLDSNT-
+LAEKEEFVHKREELERVCNPIISGLYQGAGAPGAGGFGAQAPKGGSGSGPTIEEVD----
+------------------------------------------------------------
+-------------------------------------------------------
+;RNHS70P.HSP-70 642 residues Frame 0 Code 0
+;DEFINITION R.norvegicus (Wistar) hsp70 gene for heat shock protein 70.
+;ACCESSION X75357
+; CDS 502..2427
+; /gene="hsp 70"
+; /codon_start=1
+; /product="heat shock protein 70"
+; /db_xref="PID:g407164"
+rattus
+-------------MAKKTAIGIDLGTTYSCVGVFQHGKVEIIANDQGNRTTPSYVAFT-D
+-TERLIGDAAKNQVALNPQNTVFDANGLIGRKFGDPVVQSDMKHWPFQVVNDG-DKPKVQ
+VNYK-----GKNRSFYPEEISSMVLTKMKEIA-EAYLG--HPVTNAVITVPAYFNDSQRQ
+ATKDAGVIAGLNVLRIINEPTAAAIAYGLDRTG----KGERNVLIFDLGGGRFDVSILTI
+DDG--IFEVKATAGDTHLGGEDFDNRLVSHFVEEFKRKHK------------KDISQNKR
+AVRPLADGVERAKRTLSS-STQASLEIDSLFEGIDFY----TSITRARFEELCSDLFRGT
+LEPVEKALRDA-------KLDKAQIHDLVLVGGSTRIPKVQKL-LQDFFNGRDLNKSINP
+DEAV-AYGAAVQAAILMGDKSE----N-VQDLLLLDVAPLSLGLETAGGVMTALIKRNST
+IPTKQTQTF-TTYSDNQPGVLIQVYEGER-AMTRDNNLLGR----FELSGIPPAPRG-VP
+QIEVTFDIDANGIL-NVTATDKS-TGKANKITITNDKGRLSKE-EIERMVQEAERYKAED
+EVQRERVAAKNALESYAFNM--KSAVEDE-GLKGKISEADKKKVLDKCQEVISWLDSNT-
+LAEKEEFVHKREELERVCNPIISGLYQGAGAPGAGGFGAQAPKGGSGSGPTIEEVD----
+------------------------------------------------------------
+-------------------------------------------------------
+;SSHSP70.HSP70 644 residues Frame 0 Code 0
+;DEFINITION S.scrofa mRNA for heat shock protein 70.
+;ACCESSION X68213
+; CDS 106..2037
+; /gene="Hsp70"
+; /codon_start=1
+; /product="heat shock protein 70"
+; /db_xref="PID:g1978"
+; /db_xref="SWISS-PROT:Q04967"
+Sus
+-----------MSAAREVAIGIDLGTTYSCVGVFQHGRVEILANDQGNRTTPSYVAFT-D
+-TERLVGDAAKSQAALNPQNTVFDAKRLIGRKFADPTVQSDLKHWPFQVVSEG-GKPKVR
+VSYR-----GEDKAFYPEEISSMVLSKMKETA-EAYLG--QPVRHAVITVPAYFNDSQRQ
+ATKDAGAIAGLNVLRIINEPTAAAIAYGLDRRG----AGERNVLIFDLGGGTFDVSVLTI
+DAG--VFEVKATAGDTHLGGEDFDNRLVNHFMEEFRRKHR------------KDLSRNKR
+ALRRLRTACERAKRTLSS-STQATLEIDSLFEGVDFY----TSITRARFEELCSDLFRST
+LEPVEKALRDA-------KLDKAQIHDIVLVGGSTRIPKIQKL-LQDFFNGRELNKSINP
+DEAV-AYGAAVQAAVLMGDKCE----K-VQDLLLLDVAPLSLGLETAGGVMTTLIQRNAT
+IPTKQTQTF-TTYSDNQPGVLIQVYEGER-AMTRDNNLLGR----FELSGIPPAPRG-VP
+QIEVTFDIDANGIL-SVTATDRS-TGRANKITITNDKGRLSKE-EVERMVREADEYKVED
+EAQRDRVAAKNSLEAYVFHV--KGSLHEE-SLRDKIPEEDRCKVQDKCQEVLTWLEHNQ-
+LAEKEEYEHQKRELEQICRPIFSRLYGAPGIPGGSSCGAQARQGAPSTGPVIEEVD----
+------------------------------------------------------------
+-------------------------------------------------------
+;BOVHSPIII.PE1 632 residues Frame 0 Code 0
+;DEFINITION Bos taurus 70 kDa heat shock protein-3 (HSP70-3) gene, complete
+; cds.
+;ACCESSION L10428
+; CDS 492..2387
+; /standard_name="HSP70-3"
+; /note="putative"
+; /citation=[1]
+; /codon_start=1
+; /product="70 kDa heat shock protein"
+; /db_xref="PID:g163161"
+Bos
+------------MSARGPAIGIDLGTTYSCVGVFQHGKVEIIANDQGNRTTPSYVAFT-D
+-TERLIGTAAKNQVAMNPTNTIFDAKRLIGRKFEDATVQSDMKHWPFRVVSEG-GKPKVQ
+VEYK-----GEIKTFFPEEISSMVLTKMKEIA-EAYLG--GKVQSAVITVPAYFNDSQRQ
+ATKDAGTITGLNVLRIINEPTAAAIAYGLDKKGC--AGGEKNVLIFDLGGGTFDVSILTI
+EDG--IFEVKSTAGDTHLGGEDFDNRMVSHWAEEFKRKHK------------KDI-----
+APARLRTACERAKRTLSS-STQASIEIDSLYEGVDFY----TSITRARFEELNADLFRVP
+LEPVEKALRDA-------KLDKGQIQEIVLVGGSTRIPKIQKL-LQDFFNGKELNKSINP
+DEAV-AYGAAVQAAILIGDKSE----N-VQDLLLLDVTPLSLGIETAGGVMTPLIKRNTT
+IPTKQTQTF-TTYSDNQSSVLVQVYEGER-AMTKDNNLLGK----FDLTGIPPAPRG-VP
+QIEVTFDIDANGIL-NVTAADKS-TGKENKITITNDKGCLSKD-DIDRMVQEAERYKSED
+EANRDRVAAKNAVESYTYNI--KQTVEDE-KLRGKISDQDKNKILDKCQEVINWLDRNQ-
+MAEKDEYEHKQKELERVCNPIISKLYQGGPGGGGGSGASGGPTIEEVD------------
+------------------------------------------------------------
+-------------------------------------------------------
+;BTU02892.HSP70-2 642 residues Frame 0 Code 0
+;DEFINITION Bos taurus Angus 70 kda heat shock protein-2 (HSP70-2) gene,
+; complete cds.
+;ACCESSION U02892
+; CDS 427..2352
+; /gene="HSP70-2"
+; /codon_start=1
+; /product="70 kda heat shock protein-2"
+; /db_xref="PID:g414975"
+Bos-2
+-------------MAKNTAIGIDLGTTYSCVGVFQHGKVEIIANDQGNRTTPSYVAFT-D
+-TERLIGDAAKNQVALNPQNTVFDAKRLIGRKFGDPVVQSDMKHWPFRVINDG-DKPKVQ
+VSYK-----GETKAFYPEEISSMVLTKMKEIA-EAYLG--HPVTNAVITVPAYFNDSQRQ
+ATKDAGVIAGLNVLRIINEPTAAAIAYGLDRTG----KGERNVLIFDLGGGTFDVSILTI
+DDG--IFEVKATAGDTHLGGEDFDNRLVNHFVEEFKRKHK------------KDISQNKR
+AVRRLRTACERAKRTLSS-STQASLEIDSLFEGIDFY----TSITRARFEELCSDLFRST
+LEPVEKALRDA-------KLDKAQIHDLVLVGGSTRIPKVQKL-LQDFFNGRDLNKSINP
+DEAV-AYGAAVQAAILMGDKSE----N-VQDLLLLDVAPLSLGLETAGGVMTALIKRNST
+IPTKQTQIF-TTYSDNQPGVLIQVYEGER-AMTRDNNLLGR----FELSGIPPAPRG-VP
+QIEVTFDIDANGIL-NVTATDKS-TGKANKITITNDKGRLSKE-EIERMVQEAEKYKAED
+EVQRERVSAKNALESYAFNM--KSAVEDE-GLKGKISEADKKKVLDKCQEVISWLDANT-
+LAEKDEFEHKRKELEQVCNPIISRLYQGAGGPGAGGFGAQGPKGGSGSGPTIEEVD----
+------------------------------------------------------------
+-------------------------------------------------------
+;BTU09861.HSP70 642 residues Frame 0 Code 0
+;DEFINITION Bos taurus 70 kDA heat-shock protein (hsp70) mRNA, complete cds.
+;ACCESSION U09861
+; CDS 157..2082
+; /gene="hsp70"
+; /note="inducible Hsp70"
+; /codon_start=1
+; /product="70 kDa heat-shock protein"
+; /db_xref="PID:g497938"
+Bos-mRNA
+-------------MAKNMAIGIDLGTTYSCVGVFQHGKVEIIANDQGNRTTPSYVAFT-D
+-TERLIGDAAKNQVALNPQNTVFDAKRLIGRKFGDPVVQSDMKEWPFRVINDG-DKPKVQ
+VSYK-----GETKAFYPEEISSMVLTKMKEIA-EAYLG--HPVTNAVITVPAYFNDSQRQ
+ATKDAGVIAGLNVLRIINEPTAAAIAYGLDRTG----KGERNVLIFDLGGGTFDVSILTI
+DDG--IFEVKATAGDTHLGGEDFDNRLVNHFVEEFKRKHK------------KDISQNKR
+AVRRLRTACERAKRTLSS-STQASLEIDSLFEGIDFY----TSITRARFEELCSDLFRST
+LEPVEKALRDA-------KLDKAQIHDLVLVGGSTRIPKVQKL-LQDFFNGRDLNKSINP
+DEAV-AYGAAVQAAILMGDKSE----N-VQDLLLLDVAPLSLGLETAGGVMTALIKRNST
+IPTKQTQIF-TTYSDNQPGVLIQVYEGER-AMTRDNNLLGR----FELSGIPPAPRG-VP
+QIEVTFDIDANGIL-NVTATDKS-TGKANKITITNDKGRLSKE-EIERMVQEAEKYKAED
+EVQRERVSAKNALESYAFNM--KSAVEDE-GLKGKISEADKKKVLDKCQEVISWLDANT-
+LAEKDEFEHKRKELEQVCNPIISRLYQGAGGPGAGGFGAQGPKGGSGSGPTIEEVD----
+------------------------------------------------------------
+-------------------------------------------------------
+;PWHSP70MR.HSP70 646 residues Frame 0 Code 0
+;DEFINITION Pleurodeles waltl mRNA for HSP70.
+;ACCESSION X71951
+; CDS 86..2023
+; /gene="hsp70"
+; /codon_start=1
+; /product="heat shock protein HSP70"
+; /db_xref="PID:g431201"
+Pleurodeles
+-----------MSAPKGVAFGIDLGTTYSCVGVFQHGKVEIIANNQGNRTTPSYVAFT-D
+-TERLIGAPAKNQVSLNPQNTVFDAKRLIGRKFNDTVVQADMKHWPFKVVS-DEWKPKVQ
+VEYK-----GDNKTFFPDEVSSMVLIKMKEIA-EAYLG--HLVSNAVITVPSYLTASQRQ
+ATKDAGVLAGLNVLSIVNEPTAAAIAYDLDKAG----RGELNVLIFDLGGGTFDVSILTI
+DDG--IFEVKATAGDTHLGGEDFDNRMVNHFHEPFKRKHK------------KDITKNKR
+AVRRLRTACERAKRTLSS-STQASIEIDSLFEGIDFY----TSITRARFEELCADLFRGP
+LEPVEKALRDA-------KLDKAQIHEIVLVGGSTRIPKIQKL-LQDFFNGRELNKSINP
+DEAV-AYGAAVQAAILMGDKSEN-----LQDLLLLDVAPLSLGLETAGGVMTVLIKRNST
+IPTKQTQIF-TTYSDNQPGVLIQVYEGER-AMTKDNSLLGK----FELSGIPPAPRG-VP
+QIEVTFDIDANGIL-NVSAVDKS-SGKQNKITITNDKGRLSKE-EIERMVQEAERYKADD
+EAQREKVSAKNTLESIAFNM--KSTVEGD-NLKDKISEDDRKKIVDKCNQTISWMENNQ-
+MAEKEEYEHQQKELEKVCNSIITKLYQGG--------------MPGGMPSGSSG------
+---------A---QARQG--------SSSTGPTIEEVD----------------------
+-------------------------------------------------------
+;OTU35064.HSP70 645 residues Frame 0 Code 0
+;DEFINITION Oncorhynchus tschawytscha heat shock protein 70 (HSP70) mRNA,
+; complete cds.
+;ACCESSION U35064
+; CDS 46..1980
+; /gene="HSP70"
+; /codon_start=1
+; /product="heat shock protein 70"
+; /db_xref="PID:g1006833"
+Oncorhynchus
+-----------MSSAKGPSIGIDLGTTYSCVGVFQHGKVEIIANDQGNRTTPSYVAFT-D
+-TERLIGDAAKNQVAMNPNNTVFDAKRLIGRKFNDQVVQADMKHWPFKVVSDG-GKPKVQ
+VDYK-----GENKSFNPEEISSMVLVKMREIA-EAYLG--QKVSNAVITVPAYFNDSQRQ
+ATKDAGVIAGLNVLRIINEPTAAAIAYGMDKGM----SRERNVLIFDLGGGTFDVSILTI
+EDG--IFEVKATAGDTHLGGEDFDNRLVSHFVEEFKRKHK------------KDISQNKR
+ALRRLRTACERAKRTLSS-SSQASIEIDSLFEGIDFY----TSITRARFEEMCSDLFRGT
+LEPVEKALRDA-------KMDKAQIHDVVLVGGSTRIPKVQKL-LQDFFNGRELNKSINP
+DEAV-AYGAAIQAAILSGDKSE----N-VQDLLLLDVAPLSLGIETAGGVMTALIKRNTT
+IPSKQTQTF-TTYSDNQPGVMIQVYEGER-AMTKDNNLLGK----FELSGIPPAPRG-VP
+QIEVTFDIDANGIL-NVSAVDKS-TGKENKITITNDKGRLSKE-DIERMVQDADKYKAED
+DAQREKIAAKNSLESYAFNM--KSSVEDD-NMKGKISQEDKKKVVDRCDQTISWLENNQ-
+LGDKEEYEHQLKELEKVCQPIITKLYQQGGMPTGCCGDQARTSSGDSSQGPTIEEID---
+------------------------------------------------------------
+-------------------------------------------------------
+;IPU22460.PE1 650 residues Frame 0 Code 0
+;DEFINITION Ictalurus punctatus heat shock protein 70 (CF Hsp70) mRNA, complete
+; cds.
+;ACCESSION U22460
+; CDS 36..1985
+; /gene="CF Hsp70"
+; /codon_start=1
+; /product="heat shock protein 70"
+; /db_xref="PID:g761725"
+Ictalurus
+-------------MSKGPAVGIDLGTTYSCVGVFQHGKVEIIANDQGNRTTPSYVAFT-D
+-SERLIGDAAKNQVAMNPTNTIFDAKRLIGRRFEDSVVQADMKHWPFKVISDG-GRPRLE
+VEYK-----GEAKNFYPEEISSMVLVKMKEIA-EAYLG--KSINNAVITVPAYFNDSQRQ
+RTKDAGTISGLNVLRIINEPTAAAIAYGLDKKV----GSERNVLIFDLGGGTFDVSILTI
+EDG--IFDLKSTAGDTHLGGEDFDNRMVNHFIAEFKRKHK------------KDISDNKR
+AVRRLATACERAKRTLSS-STQASIEIDSLYEGVDFY----TSITRARFEELNADLFRGT
+LDPVEKALRDA-------KMDKAQVHDIVLVGGSTRIPKMEKL-LQDFFNGKELNKSINP
+DEAV-AYGAAVQAESSLGDKSE----N-VQDLVLLDVTPLSLGIETAGGVMTVLIKRNTT
+IPTKQTQTF-TTYSDNQPGVLIQVYEGER-AMTKDNNLLGK----FELTGIPPAPRG-VP
+QIEVTFDIDANGIM-NVSAVDKS-TGKENKITITNDKGRLSKE-DIERMVQEAEKYKAED
+DVQRDKVSAKNGLESYAFNM--KSTVEDE-KLKGKISDEDKHKILDKCNEVISWLDKNQ-
+TAEKDEYEHQQKDLEKVCNPIITKLYQSDGGMPGGMPDGMPGGFQELGAAPGGGSSGPTI
+EEVD--------------------------------------------------------
+-------------------------------------------------------
+;BSU51901.HPS70.1 630 residues Frame 0 Code 0
+;DEFINITION Botryllus schlosseri heat shock protein 70 (HSP70.1) gene, complete
+; cds.
+;ACCESSION U51901
+; CDS 1507..3396
+; /gene="HPS70.1"
+; /note="heat-inducible"
+; /codon_start=1
+; /product="heat shock protein 70"
+; /db_xref="PID:g1518938"
+Botryllus.1
+----------------MPAIGIDLGTTYSCVGVYQHGKVEIIANDQGNRTTPSYVAFT-D
+-TERLIGDAAKNQVAMNPTNTVFDAKRLIGRKFNDSTVQSDKKHWSFNVIADG-DKPKIE
+VEFK-----GEKKRFFAEEISSMVLTKMKETA-EAYLG--QGVTDAVITVPAYFNDSQRQ
+ATKDAAVIAGLNVLRIINEPTAAAIAYGLDKKT-----SERNILIFDLGGGTFDVSVLTI
+DSG--IFEVKATRGDTHLGGEDFDNRMVNHFVQEFRRKYK------------KDLTVNKR
+AVRRLRTACDRAKRTLPS-SPQARIEIDSLFEGIDFY----SSITRARFEELCSDLFRQT
+LDPVEQGLRDS-------KLDKGKIDEIVLVGGSTRIPKIQKL-LRDFFNGKDLNKLLNP
+DEAV-AYGAAVQAAILSGDQSE----Q-VKDVLLLDVAPLSLGIETAGGVMTTLIKRGTT
+IPAKQSQVF-TTYSDNQPAVXIQVYEGER-ALTKDNNLLGK----FDLTGLPPAPRG-VP
+QIEVAFNVDQNGIM-NVSASDKS-SGKSQNITISNDKGRLSKD-EIERMVQEASKYKEAD
+DRERERIQAKNSLESYIFNVI-KASVEDD-KVGGKLSAEDKKTILDKCSESLSWLDNNH-
+TAENEEYEYQQKELENVPTTILPKLHQGHSADPNGSNATGPTVEEVD-------------
+------------------------------------------------------------
+-------------------------------------------------------
+;BSU51902.HSP70.2 629 residues Frame 0 Code 0
+;DEFINITION Botryllus schlosseri heat shock protein 70 (HSP70.2) gene, complete
+; cds.
+;ACCESSION U51902
+; CDS 1353..3239
+; /gene="HSP70.2"
+; /note="heat-inducible hsp70 gene"
+; /codon_start=1
+; /product="heat shock protein 70"
+; /db_xref="PID:g1518940"
+Botryllus.2
+----------------MPAIGIDLGTTYSCVGVYQHGKVEIIANDQGNRTTPSYVAFT-D
+-TERLIGDAAKNQVAMNPTNTVFDAKRLIGRKFNDSTVKSDKKHWSFNVIADG-DKPKIE
+VEFK-----GEKKRFFPEEISSMLLTKMKETA-EAYLG--QGVTDAVISVPAYFNDSQRQ
+ATKDAAVIAGLNVLRIINEPTAAAIAYGLDKKT-----SERNILIFDLGGGTFDVSVLTI
+DSG--IFEVKATRGDTHLGGEDFDNRMVNHFVQEFKRKYK------------KDLTVNKR
+SLRRLRTACERAKRTLSS-STQASIEIDSLFEGIDFY----SSITRARFEELCSDLFRQT
+LDPVEQALRDS-------KLDKGKIDEIVLVGGSTRIPKIQKL-LRDFFNGKDLNKSINP
+DEAV-AYGAAVQAAILSGDQSE----Q-VKDVLLLDVAPLSLGIETAGGVMTTLIKRGTT
+IPAKQSQVF-TTYSDNQPAVTIQVYEGER-ALTKDNNLLGK----FDLTGLPPAPRG-VP
+QIEVAFNVDQNGIM-NVSASDKS-TGKSQNITITNDKGRLSKD-EIERMVQEAEKYKEAD
+DRERERIQAKNSLESYIFNV--KASVEDD-KVSGKLSAQDKQTILDKCNESLSWLDNNH-
+TAEKDEYEYQQKELENVTSPILTKLHQGQSADSNGGNATRPTVEEVD-------------
+------------------------------------------------------------
+-------------------------------------------------------
+;PLHSP70A.PE1 640 residues Frame 0 Code 0
+;DEFINITION P.lividus hsp70-IV gene for heat shock protein 70 kDa.
+;ACCESSION X61379 S50315
+; CDS join(790..971,2490..4227)
+; /gene="hsp70-IV"
+; /standard_name="heat shock protein 70 kDa"
+; /codon_start=1
+; /product="heat shock protein protein"
+; /db_xref="PID:g312917"
+; /db_xref="SWISS-PROT:Q06248"
+Paracentrotus
+-------------MESGPAIGIDLGTTYSCVGVFQNGKVEIIANDQGNRTTPSYVAFT-D
+-SERLIGDAAKNQVAMNPTNTIFDAKRLIGRRFNDSSIQADMKHWPFRVINKD-GKPMLQ
+AEYM-----GETKTLSPEEVSSMVLTKMKETA-EAYLG--KKVTSAVITVPAYFNDAQRQ
+ATKDAGVIAGINVLRIINEPTRAALAYGLDKKL----TGEKHVLIFDLGGGTFDVSLLAI
+DDG--VFEVLTTAGDTHLGGEDFDNRLVNHTSLEFKRKYK------------KDMRTNPR
+AIRRLRTAAERAKRTLSS-SAQANIEVDSLFEGIDFY----TSISRARFEDLCSDLFRKC
+LEPVERAILDA-------KIDKKKIDTVVLVGGSTRIPKIQKL-LQEFLNGKELNKSINP
+DEAV-AYGAAVQAAILSGDKSD----E-IKDVLLVDVAPLSLGIETAGGVMSKIIERNTR
+VPTKASQTF-TTYSDNQPGVSIQVFEGER-AMTKDNNRLGQ----FELSGIPPAPRG-RP
+KIEVSFDIDANGIM-HVTAKDES-SGRSNKITITNDSDRLSKD-DIDRMINDAERFKAED
+DAQRERINAKNQLEGYAFNL--KSAVDDA-AAQSKLSPGDKETVTKAVNDVLQWLDSNS-
+LADKEEFTYKLEELQKTCSPIMAKMHAGTGGPRGGGPQGFPSGGAGGPTVEEVD------
+------------------------------------------------------------
+-------------------------------------------------------
+;EGU26448.HSP70 666 residues Frame 0 Code 0
+;DEFINITION Echinococcus granulosus heat shock 70 kDa protein mRNA, complete
+; cds.
+;ACCESSION U26448
+; CDS 1..1998
+; /gene="hsp70"
+; /codon_start=1
+; /product="heat shock 70 kDa protein"
+; /db_xref="PID:g1305453"
+Echinococcus
+------------MMSKGPAVGIDLGTTFSCVGVFQHGKVEIIANDQGNRTTPSYVAFT-D
+-TERLIGDAAKNQVAMNPTNTVFDAKRLIGRRFDDRAVQDDIKHWAFKVINAG-GKPKIE
+VEYR-----GETKCFSAEEISSMVLLKMKETA-EAYLG--KKVSDTVISVPAYFNDSQRQ
+ATKDAGTISGLNVLRIINEPTAAAIAYGLDKKV----ERERNVLIFDLGGGTFDVSILSI
+EDG--IFEVKSTAGDTHLGGEDFDSRLVNHFVEEFKRKHKG-----------KDLTTNKR
+AVRRLRTACERAKRTLSS-SAQANIEIDSLLEGIDFY----TSITRARFEELCSDLFRST
+LDPVEKALRDA-------KLDKGAVHEIVLVGGSTRIPKVQKL-LQDFFNGRELNKSINP
+DEAV-AYGAAVQAAILTGDKSE----A-VQDLLLLDVAPLSLGLETAGGVMTALIKRNTT
+IPTKQTQTF-TTYSDNQPGVLIQVYEGER-AMKRDNNLLGK----FELSGIPPGPRG-VP
+QIEVTFDIDANGIL-NVSAVDKS-TGKQNKITITRDKGRLSKE-EIERMVNDAEKFKQED
+EKQRDRVAAKNGLESYAFSM--KSTVEDE-KVKEKIGESDRRRIMEKCEETVKWLDGNQ-
+QAEKEEYEHRQKELESVCNPIIAKMYQEAGGVGGIPGGIPGGGMPGGTPGGGIPAGMAGG
+MSGDPSSGGRGPTIEEVD------------------------------------------
+-------------------------------------------------------
+;BRPHSPAA.HSP70 645 residues Frame 0 Code 0
+;DEFINITION B.malayi heat shock protein 70 (hsp70) gene, complete cds.
+;ACCESSION M68933
+; CDS join(1161..1256,1649..1754,1908..2269,2348..2470,
+; 2586..2737,2841..3099,3226..3447,3616..3963,4039..4225,
+; 4341..4420)
+; /gene="hsp70"
+; /codon_start=1
+; /db_xref="PID:g156070"
+Brugia
+--------------MSKNAIGIDLGTTYSCVGVFMHGKVEIIANDQGNRTTPSYVAFT-D
+-TERLIGDAAKNQVAMNPHNTVFDANRLIGRKFDDGSVQSDMKHWPFKVVNAGGGKPKVQ
+VEYK-----GETKTFTPEEISSMVLVKMKETA-EAFLG--HAVKDAVITVPAYFNDSQRQ
+ATKDSGAIAGLNVLRIINEPTAAAIAYGLDKKG----HGERNVLIFDLGGGTFDVSILTI
+EDG--IFEVKSTAGDTHLG-EDFDNRMVNHFVAEFKRNDK------------KDLASNPR
+ALRRLRTACERAKRTLSS-SSQASIEIDSLFEGIDFY----TNITRARFEELCADLFRST
+MDPVEKALRDA-------KMDKAQVHDIVLVGGSTRIPKVQKL-LSDFFSGKELNKSINP
+DEAV-AYGAAVQAAILSGDKSE----A-VQDLLLLDVAPLSLGIETAGGVMTALIKRNTT
+IPTKTSETF-TTYSDNQPGVLIQVYEGER-ALTKDNNLLGK----FELSGIPPAPRG-VP
+QIEVTFDIDANGIL-NVSAQDKS-TGKQNKITITNDKGRLSKD-EIERMVQEAEKYKADD
+EAQKDRIAAKNALESYAFNM--KQTIEDE-KLKDKISEEDKKKIQEKCDETVRWLDGNQ-
+TAEKDEFEHRQKELESVCNPIITKLYQSAGGMPGGMPGGMPGGAPGAGSTGGGPTIEEVD
+------------------------------------------------------------
+-------------------------------------------------------
+;MSQHSP70A.HSP70 641 residues Frame 0 Code 0
+;DEFINITION Anopheles albimanus heat shock protein 70 (hsp70) gene (clone
+; p70a), complete cds.
+;ACCESSION M96662
+; CDS complement(146..2068)
+; /gene="hsp70"
+; /codon_start=1
+; /product="heat shock protein 70, hsp70A2"
+; /db_xref="PID:g159589"
+Anopheles-1
+---------------MPSAIGIDLGTTYSCVGVFQHGKVEIIANDQGNRTTPSYVAFS-D
+-TERLIGDAAKNQVAMNPTNTVFDAKRLIGRKFDDPKIQADMKHWPFTVVNDC-GKPKIR
+VEFK-----GERKTFAPEEISSMVLTKMKETA-EAYLG--QSVKNAVITVPAYFNDSQRQ
+ATKDAGAIAGLNVMRIINEPTAAALAYGLDKNL----KGERNVLIFDLGGGTFDVSILTI
+DEGS-LFEVRATAGDTHLGGEDFDNRMVAHFVEEFKRKFK------------KDLSKNAR
+ALRRLRTACERAKRTLSS-STEATIEIDALMDGIDYY----TKISRARFEELCSDLFRST
+LQPVEKALSDA-------KMDKSSIHDIVLVGGSTRIPKVQSL-LQNFFAGKSLNLSINP
+DEAV-AYGAAVQAAILSGDKDD----K-IQDVLLVDVAPLSLGIETAGGVMTKLIERNSR
+IPCKQTKIF-STYADNQPGVSIQVFEGER-AMTKDNNLLGQ----FDLSGIPPAPRG-VP
+QIEVTFDLDANGIL-NVAAKDKS-SGKEKNITIKNDKGRLSQA-DIDRMVSEAEKYREED
+EKQREAIAARNQLEAYCFNL--KQSLDGE--GSSKLSEADRRTVQDRCDETLRWIDGNT-
+MAEKEEYEHQMQELSRVCSPIMTKLHQQAAGGPQPTSCGQQAGGFGGRTGPTVEEVD---
+------------------------------------------------------------
+-------------------------------------------------------
+;MSQHSP70B.PE2 641 residues Frame 0 Code 0
+;DEFINITION Anopheles albimanus heat shock protein 70 (hsp70) gene (clone
+; p70b), complete cds.
+;ACCESSION M96661
+; CDS 2706..4628
+; /gene="hsp70"
+; /note="single base deletion between nucleotides 3418 and
+; 3419 predicts premature termination in this clone.
+; Insertion of 'N' restores reading frame and is silent"
+; /codon_start=1
+; /product="heat shock protein 70, hsp70A2"
+; /db_xref="PID:g159593"
+Anopheles-b
+---------------MPSAIGIDLGTTYSCVGVFQHGKVEIIANDQGNRTTPSYVAFS-D
+-TERLIGDAAKNQVAMNPTNTVFDAKRLIGRKFDDPKIQADMKHWPFTVVNDG-GKPKIR
+VEFK-----GERKTFAPEEISSMVLTKMKETA-EAYLG--QSVKNAVITVPAYFNDSQRQ
+ATKDAGAIAGLNVMRIINEPTAAALAYGLDKNL----KGERNVLIFDLGGGTFDVSILTI
+DEGS-LFEVRSTAGDTHLGGEDFDNRMVXHFVEEFKRKHK------------KDLSKNAR
+ALRRLRTACERAKRTLSS-STEATIEIDALMDGIDYY----TKISRARFEELCSDLFRST
+LQPVEKALSDA-------KMDKSSIHDIVLVGGSTRIPKVQSL-LQNFFAGKSLNLSINP
+DEAV-AYGAAVQAAILSGDKDD----K-IQDVLLVDVAPLSLGIETAGGVMTKLIERNSR
+IPCKQTQIF-STYADNQPGVSIQVFEGER-AMTKDNNLLGQ----FDLSGIPPAPRG-VP
+QIEVTFDLDANGIL-NVAAKEKS-TGKEKNITIKNDKGRLSQA-DIDRMVSEAEKFREED
+EKQRERISARNQLEAYCFNL--KQSLDGE--GASKLSDADRKTVQDRCEETLRWIDGNT-
+MADKEEFEHKMQELTKACSPIMTKLHQQAAGGPSPSSCAQQAGGFGGRTGPTVEEVD---
+------------------------------------------------------------
+-------------------------------------------------------
+;DROHSC1A.HSC70-1 642 residues Frame 0 Code 0
+;DEFINITION Drosophila melanogaster heat shock protein cognate 70 (Hsc1) mRNA,
+; complete cds.
+;ACCESSION L01501
+; CDS 257..2182
+; /gene="Hsc70-1"
+; /note="Description: Heat shock protein cognate 1"
+; /codon_start=1
+; /product="heat shock protein cognate 70"
+; /db_xref="PID:g157656"
+Droso-mela-1
+-------------MPKLPAVGIDLGTTYSCVGVFQHGKVEIIANDQGNRTTPSYVAFT-E
+-SERLIGDAAKNQVAMNPNNTIFDAKRLIGRRFDDATVQSDMKHWPFEVFAEN-GKPRIR
+VEYK-----GERKSFYPEEVSSMVLTKMRETA-EAYLG--GTVTDAVVTVPAYFNDSQRQ
+ATKDAGAIAGLNVLRIINEPTAAAIAYGLDKQG----TSERNVLIFDLGGGTFDVSVLTI
+EDG--IFEVKATAGDTHLGGEDFDNRLVNHFVQEFQRKHK------------KDLGQNKR
+ALRRLRTACERAKRTLSS-STQASIEIDSLFEGVDFY----TSVTRARFEELNGDLFRGT
+MEPVAKALRDA-------KMDKGQIHDIVLVGGSTRIPKVQRL-LQDFFNGKELNKSINP
+DEAV-AYGAAVQAAILHGDKSE----A-VQDLLLLDVTPLSLGIETAGGVMTTLIKRNTT
+IPTKQTQIF-TTYADNQPGVLIQVFEGER-AMTRDNNSLGK----FELSAIPPAPRG-VP
+QVEVTFDIDANGIL-NVTALEKS-TGKENRITITNDKGRLSKE-DIERMVNDAEAYRQAD
+EQQRDRINAKNQLESYCFQL--RSTLDDE-HLSSRFSPADRETIQQRSSETIAWLDANQ-
+LAERQEFEHKQQELERICSPIITRLYQGAGMAPPPTAGGSNPGATGGSGPTIEEVD----
+------------------------------------------------------------
+-------------------------------------------------------
+;DROHSC4A 652 residues Frame 0 Code 0
+;DEFINITION Drosophila melanogaster heat shock protein cognate 70 (Hsc4) gene,
+; complete cds.
+;ACCESSION L01500
+Droso-mela-4
+-------------MSKAPAVGIDLGTTYSCVGVFQHGKVEIIANDQGNRTTPSYVAFT-D
+-TERLIGDAAKNQVAMNPTQTIFDAKRLIGRKFDDAAVQSDMKHWPFEVVSAD-GKPKIE
+VTYK-----DEKKTFFPEEISSMVLTKMKETA-EAYLG--KTVTNAVITVPAYFNDSQRQ
+ATKDAGTIAGLNVLRIINEPTAAAIAYGLDKKA----VGERNVLIFDLGGGTFDVSILSI
+DDG--IFEVKSTAGDTHLGGEDFDNRLVTHFVQEFKRKHK------------KDLTTNKR
+ALRRLRTACERAKRTLSS-STQASIEIDSLFEGTDFY----TSITRARFEELNADLFRST
+MDPVEKALRDA-------KLDKSVIHDIVLVGGSTRIPKVQRL-LQDLFNGKELNKSINP
+DEAV-AYGAAVQAAILHGDKSQ----E-VQDLLLLDVTPLSLGIETAGGVMSVLIKRNTT
+IPTKQTQTF-TTYSDNQPGVLIQVYEGER-AMTKDNNLLGK----FELSGIPPAPRG-VP
+QIEVTFDIDANGIL-NVTALERS-TNKENKITITNDKGRLSKE-DIERMVNEAEKYRNED
+EKQKETIAAKNGLESYCFNM--KATLDED-NLKTKISDSDRTTILDKCNETIKWLDANQ-
+LADKEEYEHRQKELEGVCNPIITKLYQGAGFPPGGMPGGPGGMPGAAGAAGAAGAGGAGP
+TIEEVD------------------------------------------------------
+-------------------------------------------------------
+;DROHSP7A2.HSP70A 644 residues Frame 0 Code 0
+;DEFINITION D.melanogaster heat shock protein 70 genes, locus 87A7, seg. 2.
+; (partial proximal gene, spacer region and complete distal gene).
+;ACCESSION J01103
+; CDS 1997..3928
+; /gene="Hsp70Ab"
+; /note="Description: Heat-shock-protein-70Ab; heat shock
+; protein 70 (87A7 distal gene)"
+; /codon_start=1
+; /db_xref="FlyBase:FBgn0013276"
+; /db_xref="PID:g157713"
+Droso-mela-Ab
+----------------MPAIGIDLGTTYSCVGVYQHGKVEIIANDQGNRTTPSYVAFT-D
+-SERLIGEPAKNQVAMNPRNTVFDAKRLIGRKYDDPKIAEDMKHWPFKVVSDG-GKPKIG
+VEYK-----GESKRFAPEEISSMVLTKMKETAAEAYLG--ESITDAVITVPAYFNDSQRQ
+ATKDAGHIAGLNVLRIINEPTAAALAYGLDKNL----KGERNVLIFDLGGGTFDVSILTI
+DEGS-LFEVRSTAGDTHLGGEDFDNRLVTHLADEFKRKYK------------KDLRSNPR
+ALRRLRTAAERAKRTLSS-STEATIEIDALFEGQDFY----TKVSRARFEELCADLFRNT
+LQPVEKALNDA-------KMDKGQIHDIVLVGGSTRIPKVQSL-LQDFFHGKNLNLSINP
+DEAV-AYGAAVQAAILSGDQSG----K-IQDVLLVDVAPLSLGIETAGGVMTKLIERNCR
+IPCKQTKTF-STYADNQPGVSIQVYEGER-AMTKDNNALGT----FDLSGIPPAPRG-VP
+QIEVTFDLDANGIL-NVSAKEMS-TGKAKNITIKNDKGRLSQA-EIDRMVNEAEKYADED
+EKRRQRVTSRNALESHVLNV--KQAVEQA--PAGKLDEADKNSDLDKCNDTIRWLDSNT-
+TAEKEEFDHKLEELTRHCSPIMTKMHQQGAGAGAGGPGANCGQQAGGFGGYSGRTVEEVD
+------------------------------------------------------------
+-------------------------------------------------------
+;DROHSP7D1.HSP70B 642 residues Frame 0 Code 0
+;DEFINITION D.melanogaster heat shock locus 87C1: distal hsp70 genes.
+;ACCESSION J01104 J01105
+; CDS 1755..3680
+; /gene="Hsp70Bb"
+; /note="Description: Heat-shock-protein-70Bb; hsp70 distal
+; 1 protein"
+; /codon_start=1
+; /db_xref="FlyBase:FBgn0013278"
+; /db_xref="PID:g157723"
+Droso-mela-Bb
+----------------MPAIGIDLGTTYSCVGVYQHGKVEINAYDQGNRTTPSYVAFT-D
+-SERLNGEPAKNQVAMNPRNTVFDAKRLIGRKYDDPKIAEDMKHWPFKVVSDG-GKPKIG
+VEYK-----GESKRFAPEEISSMVLTKMKETA-EAYLG--ESITDAVITVPAYFNDSQRQ
+ATKDAGHIAGLNVLRIINEPTAAALAYGLDKNL----KGERNVLIFDLGGGTFDVSILTI
+DEGS-LFEVRSTAGDTHLGGEDFDNRLVTHLAEEFKRKYK------------KDLRSNPR
+ALRRLRTAAERAKRTLSS-STEATIEIDALFEGQDFY----TKVSRARFEELCANLFRNT
+LQPVEKALNDA-------KMDKGQIHDIVLVGGSTRIPKVQSL-LQEFFHGKNLNLSINP
+DEAV-AYGAAVQAAILSGDQSG----K-IQDVLLVDVAPLSLGIETAGGVMTKLIERNCR
+IPCKQTKTF-STYSDNQPGVSIQVYEGER-AMTKDNNALGT----FDLSGIPPAPRG-VP
+QIEVTFDLDANGIL-NVSAKEMS-TGKAKNITIKNDKGRLSQA-EIDRMVNEAEKYADED
+EKHRQRITSRNALESYVFNV--KQSVEQA--PAGKLDEADKNSVLDKCNETIRWLDSNT-
+TAEKEEFDHKMEELTRHCSPIMTKMHQQGAGAAGGPGANCGQQAGGFGGYSGPTVEEVD-
+------------------------------------------------------------
+-------------------------------------------------------
+;DAHSOP70.HSP70 644 residues Frame 0 Code 0
+;DEFINITION D.auraria mRNA for hsp70.
+;ACCESSION X78403
+; CDS 207..2138
+; /gene="hsp70"
+; /codon_start=1
+; /product="heat shock protein hsp70"
+; /db_xref="PID:e109454"
+; /db_xref="PID:g1165012"
+Drosophila-au
+----------------MPAIGIDLGTTYSCVGVYQHGKVEIIANDQGNRTTPSYVAFT-D
+-SERLIGDPAKNQVAMNPRNTVFDAKRLIGRKYDDPKIAEDMKHWPFKVVSDG-GKPKIG
+VEFK-----GEAKRFAPEEISSMVLVKMRETA-EAYLG--ETVTDAVITVPAYFNDSQRQ
+ATKDAGRIAGLNVLRIINEPTAAALAYGLDKNL----QGERNVLIFDLGGGTFDVSILTI
+DEGS-LFEVRATAGDTHLGGEDFDNRLVTHLADEFKRKFR------------KDLRSNPR
+ALRRLRTAAERAKRTLSS-STEATIEIDALFEGHDFY----TKVSRARFEELCADLFRNT
+LQPVEKALTDA-------KMDKGQIHDIVLVGGSTRIPKVEAL-LQEYFHGKSLNLSINP
+DEAV-AYGAAVQAAILSGDQTG----K-IQDVLLVDVAPLSLGIETAGRVMTKLIERNCR
+IPCKQTKTF-STYSDNQPGVSIQVYEGER-AMTKDNNALGT----FDLSGIPPAPRG-VP
+QIEVTFDMDANGIL-NVSAKEMS-TGKAKNITIKNDKGRLSQA-EIDRMVNEAEKYADED
+EKHRQRIASRNALESYVFNV--KQAVEQA--GAGKLDEADKNSVLEKCNETISWLDSNT-
+TAEKEEFDHRLEELTRHCSPIMTKMHQQGAGAQAGGGPGANCGQQAGGFGGYSGPTVEEV
+D-----------------------------------------------------------
+-------------------------------------------------------
+;HYDHSP701B.PE1 655 residues Frame 0 Code 0
+;DEFINITION Hydra magnipapillata heat shock protein 70.1 (hsp70.1) gene,
+; partial cds.
+;ACCESSION M84019
+; CDS join(458..662,768..841,996..2681)
+; /gene="hsp70.1"
+; /codon_start=1
+; /product="heat shock protein 70.1"
+; /db_xref="PID:g159268"
+Hydra
+-------------MSKAPAIGIDLGTTYSCVGVFQHGKVEIIANEQGNRTTPSYVAFT-D
+-TERLIGDAAKNQVAMNPSNTVFDAKRLIGRKFNDPSVTSDRKHWPFNVIDDG-SRPKIQ
+VEFK-----GETKSFYPEEISSMVLLKMEEIA-DAYLG--KKVTDVVITVPAYFNDSQRQ
+ATKDAGVIAGLNVLRIINEPTAAAIAYGLDKKV----GTEKNVLIFDLGGGTFDVSILAI
+EDG--IFEIKSTAGDTHLGGEDFDNRLVNHFVDEFKRKHK------------KDISSNKR
+ALRRLRTACERAKRTLSA-STQASVEIDSLFDGIDFY----TSITRARFEELCIDLFRGT
+LGPVADAIRGAGKNSSGQNFSKSDIHEVVLVGGSTRIPKVQSL-LQEFFNGKELNKSINP
+DEAV-AYGAAVQAAILAGDKHE----A-VQDLLLLDVAPLSLGIETAGGVFTPLIKRNTT
+VPTKYSQVF-TTYSDNQPGVLIQVFEGER-SMTAHNNLLGK----FELSGIPLAPRG-VP
+QIEVTFDVDANGIL-NVSALDKS-TGKENKITITNDKGRLSKE-DIERMVQEAEKYKADD
+ELQRDKVQAKNSLESYCYNM--KQTVEDE-KVKGKISEEDKKTIIKKCNETVEWVDKNQ-
+TAEKDQYEHKQKELEKVCNPIITKLYQAGGGMPGGMPGGMPGGMPGSGSKASSGGPTIEE
+VD----------------------------------------------------------
+-------------------------------------------------------
+;GCHSP70.HSP70 664 residues Frame 0 Code 0
+;DEFINITION G.cydonium mRNA for heat shock protein 70.
+;ACCESSION X94985
+; CDS 19..2010
+; /gene="hsp70"
+; /codon_start=1
+; /product="heat shock protein 70"
+; /db_xref="PID:e218571"
+; /db_xref="PID:g1469234"
+Geodia
+------------MAKKAPAVGIDLGTTYSCVGVFQHGKVEIIANDQGNRTTPSYVAFT-D
+-SERLIGDAAKNQVAMNPTNTVFDAKRFIGRRSNDPVVSSDKKHWSFEVIDEA-GRPRVR
+VEYK-----GEKKSFFAEEISSMVLTKMKETA-EAYLG--KTITDAVVTVPAYFNDSQRQ
+ATKDAGIISGLNILRIINEPTAAAIAYGLDKKHD---SSEQNILIFDLGGGTFDVSILTI
+EEG--IFEVKSTAGDTHLGGEDFDNRMVNHFISEFKRKFK------------KDMSGNKR
+AVRRLRTACERAKRTLSS-ITEASIEIDSLFEGIDYY----TKITRARFEELCGDLFRGT
+LEPVEKALRDS-------KFDKGQIHEIVLVGGSTRIPRIQKL-LQDFFNGKTLNKSINP
+DEAV-AYGAAIQADILTGDTSE----E-VQDLLLLDVTPLSLGIETAGGVMTALIKRNST
+IPKKETETF-TTYSDNQPGVLIQVYEGER-AMTKDNNLLGK----FELTGIPPAPRE-VP
+QIQVTFDIDRNGIL-NVSAADKS-TGKENKITITNDKGRLSAE-EIDRMVREAEQYKAAD
+DAQRERVSAKNQLESYAFQM--KSTFEED-KVKEKVPEEDREKVISKCKEVIDWLDKNQ-
+SAEKEEFEHQQKELEGICTPIVTKLYQAGGAPGGGMPGGMPGGMPGGMPGGFPGGAGPTS
+GGSTGGGSGPTIEEVD--------------------------------------------
+-------------------------------------------------------
+;YSCHSPSSA4.SSA4 643 residues Frame 0 Code 0
+;DEFINITION Yeast (S.cerevisiae) 70 kDa heat shock protein (SSA4) gene,
+; complete cds.
+;ACCESSION J05637
+; CDS 1284..3212
+; /gene="SSA4"
+; /codon_start=1
+; /product="70 kDa heat shock protein"
+; /db_xref="PID:g171728"
+Saccharo-SSA4
+---------------MSKAVGIDLGTTYSCVAHFANDRVEIIANDQGNRTTPSYVAFT-D
+-TERLIGDAAKNQAAMNPHNTVFDAKRLIGRKFDDPEVTNDAKHYPFKVIDKG-GKPVVQ
+VEYK-----GETKTFTPEEISSMILTKMKETA-ENFLG--TEVKDAVVTVPAYFNDSQRQ
+ATKDAGTIAGLNVLRIINEPTAAAIAYGLDKKS----QKEHNVLIFDLGGGTFDVSLLSI
+DEG--VFEVKATAGDTHLGGEDFDSRLVNFLAEEFKRKNK------------KDLTTNQR
+SLRRLRTAAERAKRTLSS-SAQTSIEIDSLFEGIDFY----TSITRARFEELCADLFRST
+LEPVEKVLADS-------KLDKSQIDEIVLVGGSTRIPKVQKL-VSDFFNGKEPNRSINP
+DEAV-AYGAAVQAAILTGDQSS----T-TQDLLLLDVAPLSLGIETAGGIMTKLIPRNST
+IPTKKSEVF-STYADNQPGVLIQVFEGER-TRTKDNNLLGK----FELSGIPPAPRG-VP
+QIEVTFDIDANGIL-NVSAVEKG-TGKSNKITITNDKGRLSKE-DIDKMVAEAEKFKAED
+EQEAQRVQAKNQLESYAFTL--KNSVSEN-NFKEKVGEEDARKLEAAAQDAINWLDASQ-
+AASTEEYKERQKELEGVANPIMSKFYGAAGGAPGAGPVPGAGAGPTGAPDNGPTVEEVD-
+------------------------------------------------------------
+-------------------------------------------------------
+;YSCSSA3B.SSA3 650 residues Frame 0 Code 0
+;DEFINITION S.cerevisiae heat shock protein 70 (SSA3) gene (clone pSSA3H),
+; complete cds.
+;ACCESSION M97225
+; CDS 1..1950
+; /gene="SSA3"
+; /codon_start=1
+; /db_xref="SGD:L0002071"
+; /product="heat shock protein 70, hsp70A2"
+; /db_xref="PID:g172718"
+Saccharo-SSA3
+---------------MSRAVGIDLGTTYSCVAHFSNDRVEIIANDQGNRTTPSYVAFT-D
+-TERLIGDAAKNQAAINPHNTVFDAKRLIGRKFDDPEVTTDAKHFPFKVISRD-GKPVVQ
+VEYK-----GETKTFTPEEISSMVLSKMKETA-ENYLG--TTVNDAVVTVPAYFNDSQRQ
+ATKDAGTIAGMNVLRIINEPTAAAIAYGLDKKG----RAEHNVLIFDLGGGTFDVSLLSI
+DEG--VFEVKATAGDTHLGGEDFDNRLVNHLATEFKRKTK------------KDISNNQR
+SLRRLRTAAERAKRALSS-SSQTSIEIDSLFEGMDFY----TSLTRARFEELCADLFRST
+LEPVEKVLKDS-------KLDKSQIDEIVLVGGSTRIPKIQKL-VSDFFNGKEPNRSINP
+DEAV-AYGAAVQAAILTGDQST----K-TQDLLLLDVAPLSLGIETAGGIMTKLIPRNST
+IPTKKSETF-STYADNQPGVLIQVFEGER-TRTKDNNLLGK----FELSGIPPAPRG-VP
+QIDVTFDIDANGIL-NVSALEKG-TGKSNKITITNDKGRLSKD-DIDRMVSEAEKYRADD
+EREAERVQAKNQLESYAFTL--KNTINEA-SFKEKVGEDDAKRLETASQETIDWLDASQ-
+AASTDEYKDRQKELEGIANPIMTKFYGAGAGAGPGAGESGGFPGSMPNSGATGGGEDTGP
+TVEEVD------------------------------------------------------
+-------------------------------------------------------
+;CAHSP70G.CAHSP70 657 residues Frame 0 Code 0
+;DEFINITION C.albicans (ATCC 20955) cahsp70 mRNA for heat shock protein 70.
+;ACCESSION Z30210
+; CDS 105..2075
+; /gene="cahsp70"
+; /codon_start=1
+; /transl_table=12
+; /product="heat shock protein 70"
+; /db_xref="PID:g607055"
+; /db_xref="SWISS-PROT:P41797"
+Candida
+---------------MSKAVGIDLGTTYSCVAHFANDRVEIIANDQGNRTTPSFVAFT-D
+-TERLIGDAAKNQAAMNPANTVFDAKRLIGRKFDDPEVINDAKHFPFKVIDKA-GKPVIQ
+VEYK-----GETKTFSPEEISSMVLTKMKEIA-EGYLG--STVKDAVVTVPAYFNDSQRQ
+ATKDAGTIAGLNVLRIINEPTAAAIAYGLDKKG---SRGEHNVLIFDLGGGTFDVSLLAI
+DEG--IFEVKATAGDTHLGGEDFDNRLVNFFIQEFKRKNK------------KDISTNQR
+ALRRLRTACERAKRTLSS-SAQTSIEIDSLYEGIDFY----TSITRARFEELCADLFRST
+LDPVGKVLADA-------KIDKSQVEEIVLVGGSTRIPKIQKL-VSDFFNGKELNKSINP
+DEAV-AYGAAVQAAILTGDTSS----K-TQDILLLDVAPLSLGIETAGGIMTKLIPRNST
+IPTKKSETF-STYADNQPGVLIQVFEGER-AKTKDNNLLGK----FELSGIPPAPRG-VP
+QIEVTFDIDANGIL-NVSALEKG-TGKTQKITITNDKGRLSKE-EIDKMVSEAEKFKEED
+EKEAARVQAKNQLESYAYSL--KNTINDG-EMKDKIGADDKEKLTKAIDETISWLDASQ-
+AASTEEYEDKRKELESVANPIISGAYGAAGGAPGGAGGFPGAGGFPGGAPGAGGPGGATG
+GESSGPTVEEVD------------------------------------------------
+-------------------------------------------------------
+;PAU49932.HSA2 644 residues Frame 0 Code 0
+;DEFINITION Pichia angusta heat shock protein 70 homolog (HSA2) gene, complete
+; cds.
+;ACCESSION U49932
+; CDS 296..2227
+; /gene="HSA2"
+; /note="similar to S. cerevisae SSA2, SwissProt Accession
+; Number P10592"
+; /codon_start=1
+; /product="heat shock protein 70 homolog"
+; /db_xref="PID:g1256759"
+Pichia
+---------------MSKAVGIDGGTTYSCVAHFANDRVEIIANDQGNRTTPSFVAFT-D
+-TERLSGDAAKNQAAMNPANTVFDAKRLIGRKFDDPEVQGDIKHFPFKVVDKS-GKPQIQ
+VEFK-----GETKVFTPEEISSMVLTKMKETA-ESFLG--TTVKDAVITVPAYFNDSQRQ
+ATKDAGLIAGLNVMRIINEPTAAAIAYGLDKKS----QGEQNVLIFDLGGGTFDVSLLSI
+EDG--IFEVKATAGDTHLGGEDFDNRLVNHFINEFKRKNK------------KDICGNQR
+ALRRLRTACERAKTTLSS-SAQTSLEIDSLYEGIDFY----TSITRARFEELCQDLFRST
+LDPVEKVLKDA-------KLDKSQVNEIVLVGGSTRIPKVQKL-VSDFFNGKEPNKSINP
+DEAV-AYGAAVQAAILTGDTSS----K-TQDLLLLDVAPLSLGIETAGGVMTKLIPRNTT
+IPTKKSEIF-STYSDNQPGVLIQVYEGER-ARTKDNNLLGK----FELSGIPPAPRG-VP
+QIEVTFDIDANGIL-NVSAVEKG-TGKSEKITITNDKGRLSQE-EIERMVSEAEKYKEED
+EKEAKRIAAKNGLESYAYSL--KQTTSEK-QFEEKVEASKREAFTKACDDTIAWLDENQ-
+TATAEEYDDKRKELEQAGNEVLKDLYAEGGVPGGAPGGFPGAGGAPSTEETQGPTVEEVD
+------------------------------------------------------------
+-------------------------------------------------------
+;HPHSA1SP.HSA1 646 residues Frame 0 Code 0
+;DEFINITION H.polymorpha (Wildtype) HSA1 gene for heat-shock protein.
+;ACCESSION Z29379
+; CDS 253..2190
+; /gene="HSA1"
+; /standard_name="hsp70"
+; /function="heat resistance"
+; /codon_start=1
+; /label=hsp1
+; /product="heat-shock protein"
+; /db_xref="PID:g443915"
+Pichia-poly
+---------------MSKAVGIDLGTTYSCVAHFVNDRVEIIANDQGNRTTPSFVAFT-D
+-TERLIGDAAKNQAAMNPANTVFDAKRLIGRKFDDPEVQNDIKHFPFKVVE-KGGKPHIQ
+VEFK-----GETKVFTPEEISSMVLTKMKETA-ESYMG--GKVTDAVITVPAYFNDSQRQ
+ATKDAGLIAGLNVLRIINEPTAAAIAYGLDKKEQ--GKGEQNILIFDLGGGTFDVSLLSI
+DEG--IFEVKATAGDTHLGGEDFDNRLVNHFANEFKRKYK------------KDLTTNQR
+ALRRLRTACERAKRTLSS-SAQTSVEIDSLYEGIDFY----TSITRARFEELCQDLFRST
+LDPVEKVMRDG-------KLDKSQVAEIVLVGGSTRIPKIQKL-VSDFFNGKEPNKSINP
+DEAV-AYGAAVQAAILTGDTSS----K-TQDLLLLDVAPLSLGIETAGGVMTKLIPRNTT
+IPTKKSEIF-STYSDNQPGVLIQVYEGER-AKTKDNNLLGK----FELSGIPPAPRG-VP
+QIEVTFDIDANGIL-NVSAVEKG-TGKSQKITITNDKGRLSKE-EIDRMVAEAEKYKEED
+EKEAARIAAKNGLESYAYSL--KQTASEK-QFEEKVDASKRESLNKAIEETISWLDNNQ-
+SATTDEYEDKRKELEGIANDALKDLYAAGGVPGGAAPGGFPGAGGAAPGADQGPSVEEVD
+------------------------------------------------------------
+-------------------------------------------------------
+;NCU10443.HSP70 647 residues Frame 0 Code 0
+;DEFINITION Neurospora crassa major stress-inducible 70 kDa heat shock protein
+; (hsp70) gene, complete cds.
+;ACCESSION U10443
+; CDS join(2310..2378,2445..3114,3217..3534,3610..3632,
+; 3734..4594)
+; /gene="hsp70"
+; /codon_start=1
+; /product="70 kDa heat shock protein"
+; /db_xref="PID:g607818"
+Neurospora
+---------------MAPAVGIDLGTTYSCVGVFREDRCEIIANDQGNRTTPSFVAFT-D
+-TERLVGDAAKNQVAMNPANTVFDAKRLIGRKFSDPEVQADMKHFPFKVID-RGGKPVIQ
+VEFK-----GETKVFTPEEISAMILQKMKETA-EAYLG--GTVNNAVVTVPAYFNDSQRQ
+ATKDAGLIAGLNVLRIINEPTAAAIAYGLDKKVE--G--ERNVLIFDLGGGTFDVSLLTI
+EEG--IFEVKSTAGDTHLGGEDFDNRLVNHFVQEFKRKDK------------KDLSTNAR
+ALRRLRTACERAKRTLSS-SAQTSIEIDSLFEGIDFY----TSITRARFEELCQDLFRST
+LQPVDRVLTDA-------KIDKSQVHEIVLVGGSTRIPRIQKL-ISDYFDGKEPNKRINP
+DEAV-AYGAAVQAAILSGDTSS----KSTSEILLLDVAPLSLGIETAGGMMTKLIPRNTT
+IPTKKSEVF-STFSDNQPGVLIQVYEGER-QRTKDNNLLGK----FELTGIPPAPRG-VP
+QIEVTFDVDANGIM-NVSALEKG-TGKTNQITITNDKGRLSKE-EIERMLAEAEKFKEED
+EAEAKRVAAKNGLESYAYSL--RNTLSDS-KVDEKLDAADKEKLKSEIDKIVAWLDENQ-
+QATREEYEERQKELEAIANPIMMKFYGAGG-------------APGGMPGAAPG------
+----------GFPGGAPGS-------NDNEGPTVEEVD----------------------
+-------------------------------------------------------
+;SPAC13G7.PE2 645 residues Frame 0 Code 0
+;DEFINITION S.pombe chromosome I cosmid c13G7.
+;ACCESSION Z69729
+; CDS complement(1675..3609)
+; /gene="SPAC13G7.02c"
+; /note="SPAC13G7.02c, heat shock protein HSP70 family, len:
+; 644, similar to eg SW:HS71_YEAST P10591, SSA1, (80.3%
+; identity in 644 aa overlap), contains PS00297 Heat shock
+; hsp70 proteins family signature 1, PS00329 Heat shock
+; hsp70 proteins familysignature 2, PS01036 Heat shock hsp70
+; proteins family signature 3"
+; /codon_start=1
+; /product="unknown"
+; /db_xref="PID:e223693"
+; /db_xref="PID:g1204169"
+Schizosacc
+---------------MSKSIGIDLGTTYSCVGHFSNNRVEIIANDQGNRTTPSYVAFT-D
+-TERLIGDAAKNQVAMNPHNTIFDAKRLIGRRFNDPEVQSDMKHWPFKVIE-KDGKPLIQ
+VEFK-----GETKTFTPEEISSMVLLKMRESA-EAFLG--GKVTDAVVTVPAYFNDSQRQ
+ATKDAGLIAGLNVLRIINEPTAAAIAYGLDRSNQ--H--ETNVLIFDLGGGTFDVSLLTI
+EEG--IFEVKATAGDTHLGGEDFDSRLVNHFAQEFKRKNK------------KDITGNAR
+AVRRLRTACERAKRTLSS-SAQASIEIDSLYEGIDFY----TSITRARFEELCADLFRNT
+MEPVEKVLRDS-------KIDKSSVNEIVLVGGSTRIPRIQKL-VSDFFNGKEPCKSINP
+DEAV-AYGAAVQAAILVGDTSE----K-TQDLLLLDVAPLSLGIETAGGVMTPLIKRNTT
+IPTKKSEVF-STYADNQPGVLIQVFEGER-ARTKDCNLLGK----FELSGIPPAPRG-VP
+QIEVTFDVDANGIL-NVSALEKG-TGKTQKITITNDKGRLSKE-EIDRMVSEAEKYKAED
+EAETSRIQAKNHLESYAYSL--RNSLDDP-NLKDKVDASDKEAIDKAVKETIEWLDHNT-
+TAAKDEYEDKQKELEGVANPIMAKIYQAGGAPGGAPGGMPGGAPGGAPGGADNGPEVEEV
+D-----------------------------------------------------------
+-------------------------------------------------------
+;CHHSP70.HSP70 644 residues Frame 0 Code 0
+;DEFINITION C.herbarum mRNA for heat shock protein 70.
+;ACCESSION X81860
+; CDS 49..1980
+; /gene="hsp70"
+; /codon_start=1
+; /product="heat shock protein 70"
+; /db_xref="PID:g551228"
+; /db_xref="SWISS-PROT:P40918"
+Cladosporium
+---------------MAPAIGIDLGTTYSCVGIYRDDRIEIIANDQGNRTTPSFVAFT-D
+-TERLIGDSAKNQVAINPHNTVFDAKRLIGRKFQDAEVQADMKHFPFKVIE-KAGKPVTQ
+VEFK-----GETKDFTPEEISSMILTKMRETA-ESYLG--GTVNNAVITVPAYFNDSQRQ
+ATKDAGLIAGLNVLRIINEPTAAAIAYGLDKKQE--G--EKNVLIFDLGGGTFDVSFLTI
+EEG--IFEVKSTAGDTHLGGEDFDNRLVNHFSNEFKRKHK------------KDLSDNAR
+ALRRLRTACERAKRTLSS-SAQTSIEIDSLFEGIDFF----TSNTRARFEEVGQDLFRGN
+MEPGERTLRDD-------KIDKSSVHEIVLGGGSTRIPKVQKL-VSDFFNGKEPCKSINP
+DEAV-AYGAAVQAAILSGDTSS----KSTKEILLLDVAPLSLGIETAGGVMTALIKRNTT
+IPTKKSETF-STFSDNQPGVLIQVFEGER-ARTKDINLMGK----FELSGIRPAPRG-VP
+QIEVTFDLDANGIM-NVSALEKG-TGKTNKIVITNDKGRLSKE-EIERMLADAEKYKEED
+EAEAGRIQAKNGLESYAYSL--KNTVSDP-KVEEKLSAEDKETLTGAIDKTVAWIDENQ-
+TATKEEYEAEQKQLESVANPVMMKIYGAEGGAPGGMPGQGAGAPPPGAGDDGPTVEEVD-
+------------------------------------------------------------
+-------------------------------------------------------
+;BSIAHSP70X.HSP70 650 residues Frame 0 Code 0
+;DEFINITION Blastocladiella emersonii heat shock protein (hsp70) gene, complete
+; cds.
+;ACCESSION L22497
+; CDS join(775..811,977..2889)
+; /gene="hsp70"
+; /codon_start=1
+; /product="heat shock protein"
+; /db_xref="PID:g773670"
+Blastocladiella
+----------MTTKLDSPAVGIDLGTTYSCVGVWQNDRVEIIANDQGNRTTPSYVGFT-D
+-SERLIGDAAKNQVAMNPHNTVFDAKRLIGRRFDDDVVQADMKHWSFTVVN-KNSKPLFQ
+VEFK-----GETKTFTPEEFSSMILTKMKETA-EAYLG--TKVNHAVVTVPAYFNDSQRQ
+ATKDAGAIAGLNVLRIINEPTAAAIAYGLDKKAE--AG-EKNVLIFDLGGGTFDVSLLTI
+EDG--IFEVKATAGDTHLGAEDFDNRLVNHFVQEFKRKHK------------KDLSGKAR
+P-RRLRTACERAKRTLSS-SAQTSIEIDSLFEGIDFY----TSITRARFEELCADLFRST
+LDPVEKVLRDA-------KMAKNEVHEIVLVGGSTRIPRIQKL-VSDFFNGKEPNKSINP
+DEAV-AYGAAVQAAILAGDQSE----K-VQDLLLLDVAPLSLGIETAGGVMTPLIKRNTT
+IPAKKSETF-STYADNQPGVLIQVYEGER-ARTKDNNLLGK----FELTGIPPAPPR-VP
+QIEVSFDVGADGIL-NVSAVDKS-TNRSNKITITNDKGRLSKE-EIERMVAEAEKYKKED
+EEAASRIQAKNGLESYAYNL--RNTLNDD-KVAGKMDAADKETLNKAIDETISWLDGNQ-
+EGAKDEYEHKQKELEGVANPIMTKLYSAAGGAPGGMPGGFDPSGAPPPAADTTGPTIEEV
+D-----------------------------------------------------------
+-------------------------------------------------------
+;PHHSP70G.HSP70 652 residues Frame 0 Code 0
+;DEFINITION Petunia hsp70 gene.
+;ACCESSION X06932
+; CDS join(240..453,1076..2817)
+; /codon_start=1
+; /product="heat shock protein 70"
+; /db_xref="PID:g20557"
+; /db_xref="SWISS-PROT:P09189"
+Petunia
+----------MAGKGEGPAIGIDLGTTYSCVGVWQHDRVEIIANDQGNRTTPSYVGFT-D
+-TERLIGDAAKNQVAMNPINTVFDAKRLIGRRFSDPSVQSDIKLWPFKVIPGPGDKPMIV
+VTYK-----GEEKQFAAEEISSMVLTKMKEIA-EAYLG--TTIKNAVVTVPAYFNDSQRQ
+ATKDAGVIAGLNVMRIINEPTAAAIAYGLDKKAS--SAGEKNVLIFDLGGGTFDVSLLTI
+EEG--IFEVKATAGDTHLGGEDFDNRMVNHFVQEFKRKNK------------KDISGNPR
+ALRRLRTACERAKRTLSS-TAQTTIEIDSLYEGIDFY----STITRARFEELNMDLFRKC
+MEPVEKCLRDA-------KMDKSSVHDVVLVGGSTRIPKVQQL-LQDFFNGKELCKSINP
+DEAV-AYGAAVQAAILSGEGNE----K-VQDLLLLDVTPLSLGLETAGGGMTVLIPRNTT
+IPTKKEQVF-STYSDNQPGVLIQVYEGER-ARTKDNNLLGK----FELSGIPPAPRG-VP
+QITVCFDIDANGIL-NVSAEDKT-TGQKNKITITNDKGRLSKE-EIERMVQEAEKYKSED
+EELKKKVEAKNALENYAYNM--RNTIKDD-KINSQLSAADKKRIEDAIDEAIKWLDNNQ-
+LAEADEFEDKMKELESICNPIIAKMYQGGAGGATMDEDGPSVGGSAGSQTGAGPKIEEVD
+------------------------------------------------------------
+-------------------------------------------------------
+;ATHSC70.HSC70 652 residues Frame 0 Code 0
+;DEFINITION A.thaliana hsc70 mRNA for heat shock cognate protein.
+;ACCESSION X74604
+; CDS 75..2030
+; /gene="hsc70"
+; /codon_start=1
+; /product="heat shock protein 70 cognate"
+; /db_xref="PID:g397482"
+; /db_xref="SWISS-PROT:P22953"
+Arabidopsis
+----------MSGKGEGPAIGIDLGTTYSCVGVWQHDRVEIIANDQGNRTTPSYVAFT-D
+-SERLIGDAAKNQVAMNPVNTVFDAKRLIGRRFSDSSVQSDMKLWPFKIQAGPADKPMIY
+VEYK-----GEEKEFAAEEISSMVLIKMREIA-EAYLG--VTIKNAVVTVPAYFNDSQRQ
+ATKDAGVIAGLNVMRIINEPTAAAIAYGLDKKAT--TVGEKNVLIFDLGGGTFDVSLLTI
+EEG--IFEVKATAGDTHLGGEDFDNRMVNHFVQEFKRKSK------------KDITGNPR
+ALRRLRTSCERAKRTLSS-TAQTTIEIDSLYEGIDFY----STITRARFEELNMDLFRKC
+MEPVEKCLRDA-------KMDKSTVHDVVLVGGSTRIPKVQQL-LQDFFNGKELCKSINP
+DEAV-AYGAAVQGAILSGEGNE----K-VQDLLLLDVTPLSLGLETAGGVMTTLIPRNTT
+IPTKKEQVF-STYSDNQPGVLIQVYEGER-ARTKDNNLLGK----FELSGIPPAPRG-VP
+QITVCFDIDANGIL-NVSAEDKT-TGQKNKITITNDKGRLSKD-EIEKMVQEAEKYKSED
+EEHKKKVEAKNALENYAYNM--RNTIQDE-KIGEKLPAADKKKIEDSIEQAIQWLEGNQ-
+LAEADEFEDKMKELESICNPIIAKMYQGAGGEAGGPGASGMDDDAPPASGGAGPKIEEVD
+------------------------------------------------------------
+-------------------------------------------------------
+;GMHSP70.HSP70 646 residues Frame 0 Code 0
+;DEFINITION Glycine max hsp 70 gene.
+;ACCESSION X62799
+; CDS 771..2708
+; /gene="hsp70"
+; /codon_start=1
+; /product="Heat Shock 70kD protein"
+; /db_xref="PID:g18663"
+; /db_xref="SWISS-PROT:P26413"
+Glycine
+-----------MATKEGKAIGIDLGTTYSCVGVWQNDRVEIIPNDQGNRTTPSYVAFT-D
+-TERLIGDAAKNQVAMNPQNTVFDAKRLIGRRFSDSSVQNDMKLWPFKVGGSPCDKPMIV
+VNYK-----GEEKKFSAEEISSMVLVKMREVA-EAFLG--HAVKNAVVTVPAYFNDSQRQ
+ATKDAGAISGLNVLRIINEPTAAAIAYGLDKKAS--RKGEQNVLIFDLGGGTFDVSILTI
+EEG--IFEVKATAGDTHLGGEDFDNRMVNHFVSEFKRKNK------------KDISGNAR
+ALRRLRTACERAKRTLSS-TAQTTIEIDSLYEGIDFY----ATITRARFEEMNMDLFRKC
+MEPVEKCLRDA-------KIDKSQVHEVVLVGGSTRIPKVHQL-LQDFFNGKELCKSINP
+DEAV-AYGAAVQAAILSGQGDE----K-VQDLLLLDVTPLSLGLETAGGVMTVLIPRNTT
+IPTKKEQIF-STYSDNQPGVLIQVFEGER-ARTKDNNLLGK----FELTGIPPAPRG-VP
+QVNVCFDIDANGIL-NVSAEDKT-AGVKNKITITNDKGRLSKE-EIEKMVKDAERYKAED
+EEVKKKVEAKNSLENYAYNM--RNTIKDE-KIGGKLSPDEKQKIEKAVEDAIQWLEGNQ-
+MAEVDEFEDKQKELEGICNPIIAKMYQGAAGPGGDVPMGADMPAAGAGPKIEEVD-----
+------------------------------------------------------------
+-------------------------------------------------------
+;DCHSP70.HSP70 656 residues Frame 0 Code 0
+;DEFINITION Carrot hsp70 gene for heat shock protein 70.
+;ACCESSION X60088
+; CDS 284..2251
+; /evidence=experimental
+; /gene="hsp70"
+; /note="predicted M.W.=71.98kDa"
+; /codon_start=1
+; /product="heat shock protein 70"
+; /db_xref="PID:g18357"
+; /db_xref="SWISS-PROT:P26791"
+Daucus
+-----------MASKGGKAIGIDLGTTYSCVGVWQNDRVEIIANDQGNRTTPSYFAFT-D
+-TSRLIGD-AKNQVAMNPSNTVFDAKRLIGRRFNHPSVQSDMKLWPLQVIPGPGEKPMIV
+VNYK-----GESKQFAAEEISSMVLIKMLEIA-EAFLG--HSVNDAVVTVPAYFNDSQRQ
+ATKDTGVIAGLNVMRIINEPNCAQIAYGLDKKSS--NPPEQNVLIFDLGGGTFDVSLLTI
+EEG--IYEVKAPKSDTHLGGEDFDNRLVNRFVTEFLTNNK------------KDIRWECE
+ALRRLRTACERAKRTLSSSTAQTTIEIDSLYEGVDFY----TTITRARFEELNMDLFKKC
+MDPVEKCLRDS-------KIDKAQVHEVVLVGGSTRIPKVQQL-LQDFFNGKELCKSINP
+DEAV-AYGAAVQAAILSGEGNE----R-SD-LLLLDVTPLSLGLETAGGVMTVLIPRNTT
+IPTKKEQIF-STYSDNQPGVLIQVYEGER-ARTRDNKLLGKLLGKFELTGIPPAPRG-VP
+QINVVFDIDANGIL-NVFAEDKT-AGVKNKITITNDNGRLSKD-EIEKLVKEAEKYKAED
+EEVKKKVEAKNALENYAYNM--RNTIKDD-KIPGKLDAGDKEKIETAVNEAIEWLEKNQ-
+LAEVDELEDKLKELEGLCNPIIARLYQGRGDVPIGGPGDMPGGGYGGSRGSSGAGPKIEE
+VD----------------------------------------------------------
+-------------------------------------------------------
+;LEHSC170.HSC70 651 residues Frame 0 Code 0
+;DEFINITION Lycopersicon esculentum hsc-1 mRNA for heat shock protein 70 kD.
+;ACCESSION X54029
+; CDS 38..1990
+; /gene="hsc70"
+; /codon_start=1
+; /product="heat shock protein cognate 70"
+; /db_xref="PID:g19256"
+; /db_xref="SWISS-PROT:P24629"
+Lycopersicon-1
+----------MAGKGEGPAIGIDLGTTYSCVGVWQHDRVEIIANDQGNRTTPSYVGFT-D
+-TERLIGDAAKNQVALNPINTVFDAKRLIGRRFSDASVQEDMKLWPFKVIPGPGDKPMIV
+VTYK-----GEEKEFAAEEISSMVLTKMKEIA-EAFLG--STVKNAVVTVPAYFNDSQRQ
+ATKDAGVISGLNVMRIINEPTAAAIAYGLDKKAT--SAGEKNVLIFDLGGGTFDVSLLTI
+EEG--IFEVKATAGDTHLGGEDFDNRMVNHFVHEFKRKHK------------KDITGNPR
+ALRRLRTACERAKRTLSS-TAQTTIEIDSLYEGVDFY----STITRARFEELNMDLFRKC
+MEPVEKCLRDA-------KMDKSTVHDVVLVGGSTRIPKVQQVAMTNFFNGKELCKSINP
+DEAV-AYGAAVQAAILSGEGNE----K-VQDLLLLDVTPLSLGLETAGGVMTVLIPRNTT
+IPTKKEQVF-STYSDNQPGVLIQVFEGERRARTRDNNLLGK----FELSVIPPAPRV-VP
+QITVCFDIDANGIL-NVSAEDKT-TGQKNKITITNDKGRLSKE-EIEKMVQEAEKYKAED
+EELKKKVEAKNSLENYAYNM--RNTVKDE-KIGSKLSSDDKKKIEDAVDQAISWLESNQ-
+LAEVDEFEDKMKELEGICNPIIAKMYQGAGGDAGVPMDDDAPPSGGSSAGPKIEEVD---
+------------------------------------------------------------
+-------------------------------------------------------
+;LEHSC270.HSC70 645 residues Frame 0 Code 0
+;DEFINITION Lycopersicon esculentum hsc-2 mRNA for heat shock protein cognate
+; 70.
+;ACCESSION X54030
+; CDS 73..2007
+; /gene="hsc70"
+; /codon_start=1
+; /product="heat shock protein cognate 70"
+; /db_xref="PID:g19258"
+; /db_xref="SWISS-PROT:P27322"
+Lycopersicon-2
+----------MAGKGEGPAIGIDLGTTYSCVGVWQHDRVEIIANDQGNRTTPSYVGFT-D
+-SERLIGDAAKNQVAMNPINTVFDAKRLIGRRFSDASVQSDMKLWPFKVIPGPGDKPMIV
+VNYK-----GEEKQFSAEEISSMVLIKMKEIA-EAFLG--TTVKNAVVTVPAYSNDSQRQ
+ATKDAGVISGLNVMRIINEPTAAAIAYGLDKKAT--SVGEKNVLIFDLGGGTFDVSLLTI
+EEG--IFEVKATAGDTHLGGEDFDNRMVNHFVQEFKRKNK------------KDITGNPR
+ALRRLRTACERAKRTLSS-TAQTTIEIDSLYEGIDFY----STITRARFEELNMDLFRKC
+MEPVEKCLRDA-------KMDKSTVHDVVLVGGSTRIPKVQQL-LQDFFNGKELCKSINP
+DEAV-AYGAAVQAAILSGEGNE----K-VQDLLLLDVTPLSLGLETAGGVMTVLIPRNTT
+IPTKKEQVF-STYSDNQPGVLIQVYEGER-TRTRDNNLLGK----FELSGIPPAPRG-VP
+QITVCFDIDANGTL-NVSAEDKT-TGQKNKITITNDKGRLSKE-EIEKMVQEAEKYKSED
+EEHKKKVEAKNALENYAYNM--RNTIKDE-KIASKLSADDRTKIEDAIEQAIQWLDGNQ-
+LAEAEEFEDKMKELESLCNPIIAKMYQGAGGDMDDEGPAPSGGGAGPKIEEVD-------
+------------------------------------------------------------
+-------------------------------------------------------
+;LILLIM18.LIM18 650 residues Frame 0 Code 0
+;DEFINITION Lily mRNA for HSP70, complete cds.
+;ACCESSION D21824
+; CDS 9..1958
+; /gene="LIM18"
+; /codon_start=1
+; /product="HSP70"
+; /db_xref="PID:g431144"
+Lilium
+----------MAGKDEVPAIGIDLGTTYSCVGVWQHDRVEIIANDQGNRTTPSYVAFT-D
+-TERLIGDAAKNQVAMNPTNTVFDAKRLIGRHFSDPSVQADMKLWPFKVISGTRDKPMIV
+VQYK-----GEEKQFAVEEVSSMVLVKMREIA-VAYLG--RSINNAVVTVPAYFNDSQRQ
+ATKDAGAIAGLNVLRIINEPTAAAIAYGLDKKAT--SPSEKNVLIFDLGGGTFDVSLLTI
+EEG--IFEVKATAGDTHLGGEDFDNRMVNHFAQEFKRKHK------------KDISGNPR
+ALRRLRTACERAKRTLSS-TAQTTIEIDSLCDGIDFY----STITRARFEELNIDLFRKC
+MDPVEKCLTDA-------KMDKSSVHDVVLVGGSTRIPKVQQL-LQDFFNGKELCKSINP
+DEAV-AYGAAVQAAILSGERNE----K-VQDLLLLDVTPLSLGLETAGGVMTILIPRNTT
+IPTKKEQVF-STYTDNQSGVLIQVYEGER-TRSKDNNLLGK----FELLGISPAARG-VP
+QITVTFDIDANGIL-NVSAEDKT-TRQKNKITITNDKGRLSKE-EIEKMVKEAERYKSED
+EKHKKQVAAKNALETYIYNM--RNAVNDE-RITSKLPAEVKKKIDDAMEGAIQWLEANQ-
+LAEVDEFDDKRRELEGICKPVIEKLCQGIGVIADRMGMNEDGTASRTGGAGPKIEEVD--
+------------------------------------------------------------
+-------------------------------------------------------
+;CREHSP70A.HSP70 650 residues Frame 0 Code 0
+;DEFINITION C.veinhardtii 70kDa heat shock protein (hsp70) gene, complete cds.
+;ACCESSION M76725
+; CDS join(849..898,969..1095,1171..1309,1383..1543,1748..1848,
+; 2194..3263,3498..3799)
+; /gene="hsp70"
+; /codon_start=1
+; /product="70 kDa heat shock protein"
+; /db_xref="PID:g167421"
+Chlamydomonas
+------------MGKEAPAIGIDLGTTYSCVGLWQNDRVEIIANDQGNRTTPSYVAFT-D
+-TERLIGDAAKNQVAMNPRHTVFDAKRLIGRKFSDPIVQSDIKLWPSQV-APAHDVPEIV
+VSYR-----TEEKVFKAEEISSMVLIKMKETA-QASLGADREVKKAVVTVPAYFNDSQRQ
+ATKDAGMIAGLEVLRIINEPTAAAISYGLDKKDS--GLGERNVLIFDLGGGTFDVSLLTI
+EEG--IFEVKATAGDTHLGGEDFDERLVNHFANEFQRKYK------------KDLKTSPR
+ALRRLRTACERAKRTLSS-AAQTTIELDSLFEGVDFA----TSITRARFEELCMDLFRKC
+MDPVEKCLHDA-------KMDKMTVHDVVLVGGSTRIPKVQQL-LQDFFNGKELNKSINP
+DEAV-AYGAAVQAAILTGEGGE----K-VQDLLLLDVTPLSLGLETAGGVMTVLIPRNTT
+IPTKKEQVF-STYSDNQPGVLIQVYEGER-ARTKDNNLLGK----FELTGIPPAPRG-VP
+QINVIFDIDANGIL-NVSAEDKT-TGNKNKITITNDKGRLSKD-EIERMVQEAEKYKADD
+EQLK-KVEAKNSLENYAYNM--RNTIRED-KVASQLSASDKESMEKALTAAMDWLEANQ-
+MAEVEEFEHHLKELEGLCNPIITRLYQGGAGAGGMPGGGAGAGAAPSGGSGAGPKIEEVD
+------------------------------------------------------------
+-------------------------------------------------------
+;AKU02504.PE1 653 residues Frame 0 Code 0
+;DEFINITION Achlya klebsiana heat shock protein 70 gene, complete cds.
+;ACCESSION U02504
+; CDS 1684..3642
+; /codon_start=1
+; /product="heat shock protein 70"
+; /db_xref="PID:g407302"
+Achlya
+-----------MSGVQGASVGIDLGTTYSCVGVWQNDRVEIIANDQGNRTTPSYVAFT-D
+-SERLIGDAAKNQVAMNPANTVFDAKRLIGRKFNDPATQADIKHWPFKVTPGAGDKPQIT
+VEFK-----GETKTFQPEEISSMVLIKMKEVA-EAFIG--TAVNNAVITVPAYFNDSQRQ
+ATKDAGAIAGLNVLRIINEPTRAAIAYGLDKKG-----GERNVLIFDLGGGTFDVSLLTI
+EEG--IFEVKATAGDTHLGGEDFDNRLVDHFTAEFKRKHR------------KDMTQNQR
+ALRRLRTACERAKRTLSS-SAQAYIEIDSLFDGIDFN----STITRARFEDMCGDYFRKT
+MEPVEKVLRDS-------KLSKSQVHEVVLVGGSTRIPKVQQL-LSDFFNGKEPCKSINP
+DEAV-AFGATVQAAILSGNDSSE---K-LQDLLLLDVTPLSLGLETAGGVMTTLIQRNTT
+VPTKKSQTF-STYADNQPGVLIQVFEGER-SMTRDNNLLGK----FSLDGIPPMPRG-VP
+QIDVTFDIDANGIL-NVSAVEKS-TGKENKITITNDKGRLTKD-DIERMVQEAEKYKSED
+EANNVRIEAKNGLENYAYNL--RNTLNDE-KLQGKIDESDKKVIDDKVTDIINWLDHNQ-
+SAEKEEFEAKQKELEGIANPIMQKMYAAAGGAPGGMPGGMPDMGGAGAPPPASHAQGPKI
+EEVD--------------------------------------------------------
+-------------------------------------------------------
+;BRMHSP70.PE1 677 residues Frame 0 Code 0
+;DEFINITION B.lactucae heat shock protein 70 (hsp70) gene, complete cds.
+;ACCESSION M27825
+; CDS 591..2621
+; /note="heat shock protein 70"
+; /codon_start=1
+; /db_xref="PID:g167184"
+Bremia
+----------MAQSVSGYSVGIDLGTTYSCVGVWQNDRVEIIANDQGNRTTPSYVAFT-D
+-TERLIGDAAKNQVAMNAHNTVFDAKPLIGRKFSDPIVQADIKHWPFKLTSG-WRQAQIV
+VQFK-----GESKTFQPEEISSMVLIKMREVA-EAFIG--KEVKNAVITVPAYFNDSQRQ
+ATKDAGAIAGLNVLRIINEPTAAAIAYGLDKKG-----GERNVLIFDLGGGTFDVSLLSI
+EEG--IFEVKSTARDTHLGGEDFDNRLVDHFTQEFKRKHR------------KDITENQR
+ALRRLRTACERAKRTLSS-SAQAYIEIDSLFDGIDFN----STITRARFEDMCGDYFRKT
+MEPVAPVLRDA-------KLSKSQVHEVVLVGGSTRIPKVQQL-LSDFFNGKEPNKSINP
+DEPV-AYGATVQAAILSGNDSSQ---K-LQDLLLLDVTPLSLGLETAGGVMTTLIARNTT
+VPTKKSQTF-STYADNQPGVLIQLFEGER-SMTRDNNLLGK----FNLDGIPPMPRG-VP
+QIDVTFDIDANGIF-NVSAVEKS-TGKENKITITNDRVVCRRH-DIDRMVSEAEKYKSED
+EANKIRIEAKNGLENYSYNL--RNTLNDE-KLKDQIPEDDKKAIEDKVTETINWLDANQ-
+SAEKEEYEGKQKELEGIANPILQKMYAAAGAAGGMPGGMPGMPGGMPGMPGGMPGMPGGM
+PGGMPGGMPGGWPPCWSSDQGPKIEEVD--------------------------------
+-------------------------------------------------------
+;DDHSC70.PE1 641 residues Frame 0 Code 0
+;DEFINITION D.discoideum (AX3) mRNA for heat shock cognate protein (hsc70).
+;ACCESSION X75263
+; CDS 56..1978
+; /codon_start=1
+; /product="heat shock protein (hsc70)"
+; /db_xref="PID:g433875"
+; /db_xref="SWISS-PROT:P36415"
+Dictyostelium
+----------------MSSIGIDLGTTYSCVGVWQNDRVEIIANDQGNRTTPSYVAFT-D
+-TERLIGDAAKNQVAMNPTNTVFDAKRLIGRKFSDKEVQSDMKHWPFKVIPKDGDKPHIQ
+VEFK-----GETKVFSPEEISSMVLLKMKETA-EAYLG--KTINNAVITVPAYFNDSQRQ
+ATKDAGTISKLNVQRIINEPTAAAIRYGLEKKG----SGEKNILIFDLGGGTFDVSLLTI
+EDG--VFEVKATAGDTHLGGEDFDNRLVSHFVDEFKRKHK------------KDIMGNQR
+AVRRLRTACERAKRTLSS-SAQASIEIDSLFEGIDFY----TSITRARFEELCADLFRGC
+LDPVEKVLKDS-------KLDKKSIHEIVLVGGSTRIPKVQQL-LQEFFNGKELNKSINP
+DEAV-AYGAAVQAAILSNEGGAK-----VADLLLLDVAPLSMGLETAGGVMTTLIPRNTT
+IPCKKTQTF-STYSDNQPGVLIQVYEGER-AMTKDNNLLGK----FELSGIPPAPRG-VP
+QVEVTFDVDANGIL-NVSAEDKS-TGNKQKITITNDKGRLSKE-EIEKMVADAEKFKQQD
+EQQKDRVESKNKLENYAFTV--KNSIKDE-KVAAKISDSDKSTIESETESVLKWLESNQ-
+TAEKDEYEDKMKALEAVVNPIMSKLYQEGGMP-----------QGGGMPGGMSN------
+---------D-SPKSSNN------------K--VDELD----------------------
+-------------------------------------------------------
+;ENHHSP70A.HSP70 657 residues Frame 0 Code 0
+;DEFINITION Entamoeba heat shock protein (Hsp70) mRNA, complete cds.
+;ACCESSION M84652
+; CDS 10..1980
+; /gene="Hsp70"
+; /codon_start=1
+; /product="heat shock protein 70, hsp70A2"
+; /db_xref="PID:g158956"
+Entamoeba
+-----------MSKYTGPAVGIDLGTTYSCVGIWQNDRVEIIANDQGNRTTPSYVAFT-D
+-TERLIGDAAKNQIAMNVKNTVFDAKRLIGRRFSDPAIQNDMKHWSFKVIDDGHDKPLIE
+VEYK-----GEVKKFTPEEISSMVLTKMKETA-ESFVG--KEVKNAVITCPAYFNDSQRQ
+ATKDAGTIAGMNVMRIINEPTAAAIAYGLDKKS----DREKNVLIFDLGGGTFDVSLLAI
+DDG--VFEVKASNGDTHLGGEDFDNRLVNHFIAEFKRKYK------------KDISGNAR
+AVRRLRTACERAKRTLSS-AATANIEVDQLFDGIDFY----TSITRARFEELNIDLFKST
+IGPVERVLQDA-------KLDKGSIDDVVLIGGSTRIPKVVQL-LQDFFNGKEPNKSINP
+DEAV-AYGAAVQAAILTGTGGKA-----TEDVLLLDVAPLTLGIETAGGVMTALIPRNST
+IPAKKSQVF-STYADNQPGVLIQVFEGEA-SMTNHCNLLGK----FELTGIPPAPRG-VP
+QIEVTFDIDANGIL-NVSAEDKT-TGKKNKITITNDKGRLSKE-QIDKMVAEAEKFKAED
+DKMKQRVEAKNKLENFCYSV--KNTLS-E-QFADKIAAEDKTTIENIVKETLDWIDNNQ-
+NASTEEYDNKMKEVEGKVQPIFTKLYQQAG-------------AAGGMPGGMPN------
+---------G-FPGAGAAPQGNAQPKSSGKGPTIEEVD----------------------
+-------------------------------------------------------
+;ONU37280.PE1 652 residues Frame 0 Code 6
+;DEFINITION Oxytricha nova Hsp70 gene, complete cds.
+;ACCESSION U37280
+; CDS 431..2386
+; /note="heat-shock protein 70"
+; /codon_start=1
+; /transl_table=6
+; /product="Hsp70"
+; /db_xref="PID:g1051276"
+;Genetic code used: UAR=Q
+Oxytricha
+--------------MSGPAIGIDLGTTYSCVGVWLNDKVEIIPNDQGNNTTPSYVAFT-E
+-EERLIGDAAKNQVARNPKNTVFDAKRLIGRKFSDKQIQEDMKHWPFKVEQGPGDKPIII
+VEYK-----GENKKFQPEEISSMVLVKMKEIA-EAYLS--KTVKNAVITVPAYFNDSQRQ
+ATKDAGTISGLNVLRIINEPTAAAIAYGLDKKS----SQEKNVLIFDLGGGTFDVSLLTI
+EEG--IFEVKATNGHTHLGGEDFDNRLVDYCVAEFKKKTG------------INIDGNAR
+ALRRLRTQCEKAKRILSA-AHQAPIECETLAEGEDFN----TQISRAKFEELCMDLFRKC
+MPPVENVLKDA-------SLAKGQIHEVVLVGGSTRIPKVQQM-LSDFFNGKTLNRSINP
+DEAV-AYGAAVQAAILTGEGDSN-----VKDLLLLDVAPLSLGIETAGGVMTILIGRNTT
+IPTKKSQIF-TTYADNQPGVLIQVFEGER-SMTKDNHLLGK----FNLEGIPPAPRG-VP
+QIEVTFDIDANGIL-NVSAVDKG-TGKINKITITNDKGRLSKE-EIEKMVNDAEKFKGED
+EKMKKRIEAKNSFENYCFQM--KNTLNDE-KLKEKFTEDDKKVIEDASKEGLQWLEGNP-
+MAEPEEIEAKQKEVEAKYNPIMMRVYQAAGG------------MPGGMPGGMPG------
+---------G-MPGGFPGGAGGAAP---GGG-DVNDLD----------------------
+-------------------------------------------------------
+;TPU40190.HSP-70 648 residues Frame 0 Code 0
+;DEFINITION Theileria parva 70 kDa heat shock protein (hsp 70) mRNA, complete
+; cds.
+;ACCESSION U40190
+; CDS 194..2137
+; /gene="hsp 70"
+; /note="stress protein; chaperon"
+; /codon_start=1
+; /product="70 kDa heat shock protein"
+; /db_xref="PID:g1100900"
+Theileria
+-------------MT-GPAIGIDLGTTYSCVAVYKDNNVEIIPNDQGNRTTPSYVAFT-D
+-TERLIGDAAKNQEARNPENTIFDAKRLIGRKFDDRTVQEDMKHWPFKVTNGPNGKPNIE
+VTFQ-----GEKKTFHAEEISSMVLTKMKEIA-EAFLG--KSVKDVVITVPAYFNDSQRQ
+ATKDAGTIAGLNVMRIINEPTAAAIAYGLDKKG----GGEKNVLIFDLGGGTFDVSILTI
+EDG--IFEVKATAGDTHLGGEDFDNLLVEHCVRDFMRLNNG-----------KNISSNKR
+ALRRLRTHCERAKRVLSS-STQATIELDSLYEGIDYN----TTISRARFEELCNEKFRST
+LVPVEKALESS-------GLDKRSIHEVVLVGGSTRIPKIQTL-IKNFFNGKEPCRSINP
+DEAV-AYGAAVQAAILSGNQSEK-----IQELLLLDVAPLSLGLETAGGVMTVLIKRNTT
+IPTKKNQIF-TTNEDRQEGVLIQVFKGER-AMTKDNNLLGK----FHLTGIAPAPRG-VP
+QIEVTFDIDANGIL-NVTAMDKS-TGKSEHVTITNDKGRLSQE-EIDRMVEEAEKYKEED
+EKRRKCVESKHKLENYCYSM--KNTLSED-QVKQKLGADEVDNALNTITEALKWVETNQ-
+LAEHDEFEDKLKHVEGVCNPLVTKLYQSGGAPGA------GPDMGAGFPGGAPPP-----
+--------------------------SSSSGPTVEEVD----------------------
+-------------------------------------------------------
+;ACU46464.PE1 706 residues Frame 0 Code 0
+;DEFINITION Ajellomyces capsulatus heat shock protein 70 gene, complete cds.
+;ACCESSION U46464
+; CDS join(470..485,570..1300,1464..2515,2625..2943)
+; /codon_start=1
+; /product="heat shock protein 70"
+; /db_xref="PID:g1230567"
+Ajellomyces
+---------------MAPAVGIDLGTTYSCVGIFRDDRIEIIANDQGNRTTPSFVAFT-D
+-TERLIGDAAKNQVAMNPANTVFDAKRLIGRKFADPEVQADMKHFPFKITDKGGKP-VIQ
+VEFK-----GETKEFTPEEISSMVLTKMRETA-EAYLG--GTVNNAVVTVPAYFNDSQRQ
+ATKDAGLIAGLNVLRIINEPTAAAIAYGLDKKA----DGERNVLIFDLGGGTFDVSLLTI
+EEG--IFEVKSTAGDTHLGGEDFDNRLVNHFVSEFKRKFKK-----------ISPAERAR
+ALRRSPTACERAKRTLSS-AAQTSIEIDSLYEGIDFY----TSITRARFEELCQDLFRST
+MEPVERVLRDA-------KIDKSSVHEIVLVGGSTRIPRIQKL-VSDFFNGKEPNKSINP
+DEAV-AYGAAVQAAILSGDTSSK---S-TNEILLLDVAPLSLGIETAGGVMTPLIKRNTT
+IPTKKSETF-STFSDNQPGVLIQVFEGER-ARTKDNNLLGK----FELTGI-PRARG-VP
+QIEVTFDVDANGIM-NVSALEKG-TRKTNKIVITNDKGRLSKE-EIERMLAEAEKYKAED
+EAEASRIRPKNGLESYAYSL--RNSLRHS-KVDEKLEAGDKEKLKSEIDKTVQWLDENQ-
+TATKEEYESQQKELEAVANPIMMKFYAGGEGAPGGFPGAGGPGGFPGGPGAGHASGGGDD
+GPTVEEVDLKFPMLPLPWQLSVRKMHRPFFLFLLFLIFLIFLILFLFYFFLPVRFNESCF
+S------------------------------------------------------
+;CPU11761.HSP70 675 residues Frame 0 Code 0
+;DEFINITION Cryptosporidium parvum KSU-1 heat shock 70 kDa protein (hsp70)
+; gene, complete cds.
+;ACCESSION U11761
+; CDS 1272..3296
+; /gene="hsp70"
+; /note="cytoplasmic protein; aa 620-663 are 11 perfect
+; repeats of GGMP; aa 11-18 and 202-209 are conserved in all
+; eukaryotic 70kDa heat shock proteins; C-terminal aa
+; 671-674 are specific to eukaryotic, cytoplasmic 70 kDa
+; heat shock proteins"
+; /codon_start=1
+; /function="molecular chaperone protein, ATP binding
+; protein"
+; /product="heat shock 70 kDa protein"
+; /db_xref="PID:g607864"
+Cryptosporidium
+-----------MTSSEGPAIGIDLGTTYSCVGVWRNDTVDIVPNDQGNRTTPSYVAFT-E
+-TERLIGDAAKNQVARNPENTVFDAKRLIGRKFDDQAVQSDMTHWPFKVVRGPKDKPIIS
+VNYL-----GEKKEFHAEEISAMALQKMKEIS-EAYLG--RQIKNAVVTVPAYFNDSQRQ
+ATKDAGAIAGLNVMRIINEPTAAAIAYGLDKKG----TGERNVLTFDLGGGTFDVSLLTI
+EDG--IFEVKATAGDTHLGGEDFDNRLVEFCVQDFKRKNRG-----------MDLTSNAR
+ALRRLRTQCERAKRTLSS-STQATIELDSLYEGIDYS----VAISRARFEELCADYFRAT
+LAPVEKVLKDA-------GMDKRSVHDVVLVGGSTRIPKVQAL-IQEFFNGKEPCKAINP
+DEAV-AYGAAVQAAILNGEQSSA-----VQDLLLLDVAPLSLGLETAGGVMTKLIERNTT
+IPAKKTQVF-TTYADNQSGVLIQVYEGER-AMTKDNHLLGK----FHLDGIPPAPRG-VP
+QIEVTFDIDANGIL-NVSAVDKS-TGKSSKITITNDKGRLSKVSDIERMVNDAEKYKGED
+EQNRLKIEAKNSLENYLYNM--RNTIQEP-KVKEKLSQSEIDEAEKKIKDALDWLEHNQ-
+TAEKDEFEHQQKEIETHMNPLMMKIYSAEGGMPGGMPGGMPGGMPGGMPGGMPGGMPGGM
+PGGMPGGMPGGMPGSNGPTVEEVD------------------------------------
+-------------------------------------------------------
+;PFAHSP70B.HSP70 687 residues Frame 0 Code 0
+;DEFINITION Plasmodium cynomolgi heat shock protein 70 (hsp70) gene, complete
+; cds.
+;ACCESSION M90978
+; CDS 570..2630
+; /gene="hsp70"
+; /codon_start=1
+; /product="heat shock protein 70, hsp70A2"
+; /db_xref="PID:g160350"
+Plasmod-cyno
+--MASGKASKPNLPESNIAIGIDLGTTYSCVGVWRNENVDIIANDQGNRTTPSYVAFT-D
+-TERLIGDAAKNQVARNPENTVFDAKRLIGRKFTESSVQSDMKHWPFTVKSGVDEKPMIE
+VSYQ-----GEKKLFHPEEISSMVLQKMKENA-EAFLG--KSIKNAVITVPAYFNDSQRQ
+ATKDAGTIAGLNVMRIINEPTAAAIAYGLHKKG----KGEKNILIFDLGGGTFDVSLLTI
+EDG--IFEVKATAGDTHLGGEDFDNRLVNFCVEDFKRKNRG-----------KDLSKNSR
+ALRRLRTQCERAKRTLSS-STQATIEIDSLFEGIDYS----VTVSRARFEELCIDYFRDT
+LIPVEKVLKDA-------MMDKKSVHEVVLVGGSTRIPKIQTL-IKEFFNGKEACRSINP
+DEAV-AYGAAVQAAILSGDQSNA-----VQDLLLLDVCSLSLGLETAGGVMTKLIERNTT
+IPAKKSQIF-TTYADNQPGVLIQVYEGER-ALTKDNNLLGK----FHLDGIPPAPRK-VP
+QIEVTFDIDANGIL-NVTAVEKS-TGKQNHITITNDKGRLSPE-EIDRMVNDAEKYKAED
+EENKKRIEARNSLENYCYGV--KSSLEDQ-KIKEKLQPSEIETCMKSITTILEWLEKNQ-
+LASKEEYESKQKEAESVCAPIMSKIYQDVGGAAGGMPGGMPGGMPGGMPGGMPGGGM---
+------PGGMNFPGGMPGGGMPGGA-PAGSGPTVEEVD----------------------
+-------------------------------------------------------
+;PFAHSP70H.HSP70 682 residues Frame 0 Code 0
+;DEFINITION Plasmodium falciparum heat shock protein (HSP70) homologue mRNA,
+; complete cds.
+;ACCESSION M19753
+; CDS 23..2068
+; /gene="HSP70"
+; /note="homologue"
+; /codon_start=1
+; /product="heat shock protein 70"
+; /db_xref="PID:g309690"
+Plasmod-falci
+--MASAKGSKPNLPESNIAIGIDLGTTYSCVGVWRNENVDIIANDQGNRTTPSYVAFT-D
+-TERLIGDAAKNQVARNPENTVFDAKRLIGRKFTESSVQSDMKHWPFTVKSGVDEKPMIE
+VTYQ-----GEKKLFHPEEISSMVLQKMKENA-EAFLG--KSIKNAVITVPAYFNDSQRQ
+ATKDAGTIAGLNVMRIINEPTAAAIAYGLHKKG----KGEKNILIFDLGGGTFDVSLLTI
+EDG--IFEVKATAGDTHLGGEDFDNRLVNFCVEDFKRKNRG-----------KDLSKNSR
+ALRRLRTQCERAKRTLSS-STQATIEIDSLFEGIDYS----VTVSRARFEELCIDYFRDT
+LIPVEKVLKDA-------MMDKKSVHEVVLVGGSTRIPKIQTL-IKEFFNGKEACRSINP
+DEAV-AYGAAVQAAILSGDQSNA-----VQDLLLLDVCSLSLGLETAGGVMTKLIERNTT
+IPAKKSQIF-TTYADNQPGVLIQVYEGER-ALTKDNNLLGK----FHLDGIPPAPRK-VP
+QIEVTFDIDANGIL-NVTAVEKS-TGKQNHITITNDKGRLSQD-EIDRMVNDAEKYKAED
+EENRKRIEARNSLENYCYGV--KSSLEDQ-KIKEKLQPAEIETCMKTITTILEWLEKNQ-
+LAGKDEYEAKQKEAESVCAPIMSKIYQDAAGAAGGMPGGMPGGMPGGMPSGMPG------
+--------GMNFPGGMPGAGMPGNA-PAGSGPTVEEVD----------------------
+-------------------------------------------------------
+;SCMHSP70X.HSP70 638 residues Frame 0 Code 0
+;DEFINITION Schistosoma mansoni heat shock protein 70 (HSP70) gene, complete
+; cds.
+;ACCESSION L02415
+; CDS 533..2446
+; /gene="HSP70"
+; /codon_start=1
+; /product="heat shock protein 70"
+; /db_xref="PID:g552242"
+Schistosoma
+-------------MP-N-AIGIDLGTTYSCVGVFQHGKVEIIANDQGNRTTPSYVAFT-D
+-SERLIGDGAKNQVAMNPTNTVFDAKRLIGRRFDDPSVQSDMKHWPFEVTQ-VGGKLKIC
+VEYK-----GEKKMFSAEEISSMVLTKMKEVA-ESYLG--RTVSDAVITVPAYFNDSQRQ
+ATKDAGAIAGLNVLRIINEPTAAAIAYGLDKKV----GGERNVLIFDLGGGTFDVSILTI
+EDG--IFEVKSTAGDTHLGGEDFDNRMVDHFVKEFQKKYN------------KDIRSNKR
+ALRRLRTACERAKRTLSS-SAQTNLEIDSLCDGTDFY----TVITRARFEELNADLFRGT
+LDPVEKALRDA-------KMDKSQIHDIVLVGGSTRIPKVQKL-LQDFFNGKELNKSINP
+DEAV-AYGAAVQAAILSGEKCEA-----VQDLLLLDVAPLSLGLETAGGVMTALIKRNTT
+IPTKQTQTF-TTYSDNQPGVLIQVFEGER-ALTKDNNLLGK----FELSGIPPAPRG-TP
+QIEVTFDIDANGIL-NVSAVDKG-TGKQNKITITNDKGRLSKE-EIERMVADADKYKAED
+EKQRDRVSAKNSLESYVYTM--KQQVEG--ELKEKIPESDRQVIISKCEDTISWLDVHQ-
+SAEKHEYESKREELEKVCAPIITKVYQA-----------------GGMPGGMHE------
+---------A---SGAGG--------GSGKGPTIEEVD----------------------
+-------------------------------------------------------
+;LEIHSP70C.HSP70 653 residues Frame 0 Code 0
+;DEFINITION Leishmania amazonensis heat shock protein 70 (hsp70) mRNA, complete
+; cds.
+;ACCESSION L14604
+; CDS 152..2110
+; /standard_name="hsp70"
+; /codon_start=1
+; /product="heat shock protein 70"
+; /db_xref="PID:g293057"
+Leishma-ama
+-------------MTFDGAIGIDLGTTYSCVGVWQNDRVEIIANDQGNRTTPSYVAFT-D
+-SERLIGDAAKNQVAMNPHNTVFDAKRLIGRKFNDLVVQSDMKHWPFKVTTKGDDKPVIS
+VQYR-----GEEKTFTPEKISSMVLLKMKETA-EAYLG--KQVKKAVVTVPAYFNDSQRQ
+ATKDAGTISGLEVLRIINEPTAAAIAYGLDKGD---DGKERNVLIFDLGGGTFDVTLLTI
+DGG--IFEVKATNGDTHLGGEDFDNRLVTFFTEEFKRKNKG-----------KNLASSHR
+SLRRLRTACERAKRTLSS-ATQATIEIDALFDNVDFQ----ATINRARFEELCGDLFRST
+IQPVERVLQDA-------KMDKRSVHDVVLVGGSTRIPKVQSL-VSDFFGGKELNKSINP
+DEAV-AYGAAVQAFILTGGKSKQ-----TEGLLLLDVTPLTLGIETAGGVMTALIKRNTT
+IPTKKSQIF-STYADNQPGVHIQVFEGER-AMTKDCHLLGT----FDLSGIPPAPRG-VP
+QIEVTFDLDANGIL-NVSAEEKG-TGKRNQITITNDKGRLSKD-EIERMVNDAMKYEADD
+KAQADRVEAKNGLENYAYSM--KNTLGDS-NVSGKLDDTDKSTLNKEIEAALEWLSSNQ-
+EATKEEYEHKQKELENVCNPIMTKMYQSMGGGA--------GGMAG-MPDMSSMSG----
+-------------ARPAG--------GASSGPKVEEVD----------------------
+-------------------------------------------------------
+;LMHSP704G 632 residues Frame 0 Code 0
+;DEFINITION L.major hsp70.4 gene for heat shock protein 70-related protein.
+;ACCESSION X69825
+Leishma-maj-4
+-------------MSSTNAIAIDLGTTYSCVGVFKNEQVDIIANDQGNRTTPSYVAFT-E
+-TERLNRRCAKNQVAMNPSNTVFDAKRMIGRKFDDPDLQSDMKHWPFKVIVKDG-KPVIS
+VEYQ-----NQTKTFFPEEISATVLQKMKETA-EAYLG--TTVKDAVITVPAYFNDSQRQ
+ATKDAGSIAGLNVLRIINEPTAAAIAYGMDRKG---DKGEKNVLIFDLGGGTFDVTLLTI
+ESG--VFEVKATAGDTHLGGEDFDNRLVDYSPLSSRCAAA------------RTAVATPA
+PRAGLRTACERVKRTLSS-STTANIEIDALYEGNDFF----SKITRARFEEMCRDQFEKC
+LEPVKKVLADA-------DMKPQDVDDVVLVGGSTRIPKIQQI-VSQFFGGKELNRSINP
+DEAV-AYGAAVQAHILAGGHSSK-----TDGLLLLDVTPLSLGVETSGGVMSVLIPRNST
+MPVQKTQTY-SNNADNQRNVVIKVYEGER-PLVSQCQCLGT----FTLTDIPPMPRG-KA
+RINVTFDVNTDGIL-IVSAVEES-GGRKEAITIQNDTGRLSKE-QIESMVREAEKFAEED
+RMNSERVEARNTLENYTFSM--RATLDDP-DVQNGITQGDRQQIQDAVNAASSWLEKNR-
+EATKEEYMEQTKLIEGIAHRFCRSSTKACHG------GPTKRWAEGRCPLR---------
+------------------------------------------------------------
+-------------------------------------------------------
+;LDHSP70.PE1 654 residues Frame 0 Code 0
+;DEFINITION Leishmania hsp70 gene for heat shock protein 70.
+;ACCESSION X52314
+; CDS 165..2126
+; /note="heat shock protein (AA 1 - 653)"
+; /codon_start=1
+; /db_xref="PID:g9496"
+; /db_xref="SWISS-PROT:P17804"
+Leishmania-dono
+-------------MTFDGAIGIDLGTTYSCVGVWQNERVDIIANDQGNRTTPSYVAFT-D
+-SERLIGDAAKNQVAMNPHNTVFDAKRLIGRKFNDSVVQSDMKHWPFKVTTKGDDKPMIA
+VQYR-----GEEKTFTPEEISSMVLLKMKETA-EAYLG--KQVKKAVVTVPAYFNDSQRQ
+ATKDAGTIAGLEVLRIINEPTR-AIAYGLDKGD---DGKERNVLIFDLGGGTFDVSLLTI
+DGG--IFEVKATNGDTHLGGEDFDNRLVTFFTEEFKRKNKG-----------KNLASSHR
+ALRGLRTACERAKRTLSS-ATQATIEIDALFENVDFQ----ATITRARFEELCGDLFRST
+IQPVERVLQDA-------KMDKRSVHDVVLVGGSTRIPKVQSL-VSDFFGGKELNKSINP
+DEAV-AYGAAVQAFILTGGKSKQ-----TEGLLLLDVTPLTLGIETAGGVMTALIKRNTT
+IPTKKSQIF-STYADNQPGVHIQVFEGER-AMTKDCHLLGT----FDLSGIPPAPRG-VP
+QIEVTFDLDANGIL-NVSAEEKG-TGKRNQITITNDKGRLSKD-EIERMVNDAMKYEADD
+RAQRDRVEAKNGLENYAYSM--KNTLGDS-NVSGKLDDSDKATLNKEIDVTLEWLSSNQ-
+EATKEEYEHKQKELESVCNPIMTKMYQSMGGAG--------GGMPGGMPDMSGMSGG---
+----AGPAG-----------------GASSGPKVEEVD----------------------
+-------------------------------------------------------
+;TCHSP70.PE1 681 residues Frame 0 Code 0
+;DEFINITION Trypanosoma cruzi hsp70 gene.
+;ACCESSION X07083 X13690
+; CDS 302..2344
+; /note="hsp70 protein"
+; /codon_start=1
+; /db_xref="PID:g10622"
+; /db_xref="SWISS-PROT:P05456"
+Trypanosoma
+-------------MTYEGAIGIDLGTTYSCVGVWQNERVEIIANDQGNRTTPSYVAFT-D
+-SERLIGDAAKNQVAMNPRNTVFDAKRLIGRKFSDPVVQSDMKHWPFKVITKGDDKPVIQ
+VQFR-----GETKTFNPEEVSSMVLSKMKEIA-ESYLG--KQVKKAVVTVPAYFNDSQRQ
+ATKDAGTIAGLEVLRIINEPTAAAIAYGLDKVE---DGKERNVLIFDLGGGTFDVTLLTI
+DGG--IFEVKATNGDTHLGGEDFDNRLVAHFTDEFKRKNKG-----------KDLSTNLR
+ALRRLRTACERAKRTLSS-AAQATIEIDALFDNVDFQ----ATITRARFEELCGELFRGT
+LQPVERVLQDA-------KMDKRAVHDVVLVGGSTRIPKVMQL-VSDFFRGKELKKSIQP
+DEAV-AYGAAVQAFILTGGKSKQ-----TEGLLLLDVTPLTLGIETAGGVMTSLIKRNTT
+IPTKKSQIF-STYADNQPGVHIQVFEGER-AMTKDCHLLGT----FELSGIPPPPRG-VP
+QIEVTFDLDANGIL-NVSAEEKG-TGKRNQIVLTNDKGRLSRA-EIERMVREAAKYEAED
+KDQVRQIDAKNGLENYAFSM--KNAVNDP-NVAGKIEEADKKTITSAVEEALEWLNNNQ-
+EASKEEYEHRQKELENLCTPIMTNMYQGMAGAGM------PGGMPGGMPGGMPGGMPGGM
+PGGMPGGMPGGMPGGMPGGMPGGANPSSSSGPEVEEVD----------------------
+-------------------------------------------------------
+;TCHSPR70.HSP70 679 residues Frame 0 Code 0
+;DEFINITION T.cruzi mRNA for HSP70.
+;ACCESSION X67716
+; CDS 76..2112
+; /gene="Hsp70"
+; /codon_start=1
+; /product="Heat shock protein 70"
+; /db_xref="PID:g10626"
+Trypano-mRNA
+-------------MTYEGAIGIDLGTTYSCVGVWQNERVEIIANDQGNRTTPSYVAFT-D
+-TERLIGDAAKNQVAMNPTNSPFDAKRLIGRKFSDPVVQSDMKHWPFKVITKGDDKPVIQ
+VQFR-----GETKTFNPEEVSSMVLSKMKEIA-ESYLG--KQVKKAVVTVPAYFNDSQRQ
+ATKDAGTIAGMEVLRIINEPTRAAIAYGLDKVE---DGKERNVLIFDLGGGTFDVTLLTI
+DGG--IFEVKATNGDTHLGGEDFDNRLVSHFTDEFKRKNKG-----------KDLTTSQR
+ALRRLRTACERAKRTLSS-AAQATIEIDALFDNVDFQ----ATITRARFEELCGDLFRGT
+LQPVERVLQDA-------KMDKRAVHDVVLVGGSTRIPKVMQL-VSDFFGGKELNKSINP
+DEAV-AYGAAVQAFILTGGKSKQ-----TEGLLLLDVTPLTLGIETAGGVMTSLIKRNTT
+IPTKKSQIF-STYADNQPGVHIQVFEGER-AMTKDCHLLGT----FDLSGIPPAPRG-VP
+QIEVTFDLDANGIL-NVSAEEKG-TGKRNQIVITNDKGRLSKA-DIERMVSEAAKYESQD
+KEQRERIDAKNGLENYAFSM--KNTVNEP-NVAGKIEEADKNTITSAVEEALQWLNNNQ-
+EASKEEYEHRQKELENLCTPIMTKMYQGMGAG---------GGMPGGMPGGMPGGMP---
+----GGANP-----------------SSSSGPKVEEVERGRIPEDVLMAASARERITRWF
+SPL----------------------------------------------------
+;GLU04874.PE1 665 residues Frame 0 Code 0
+;DEFINITION Giardia lamblia Portland 1 cytoplasmic 70 kDa heat shock protein
+; gene, complete cds.
+;ACCESSION U04874
+; CDS 168..2162
+; /note="molecular chaperone protein; ATP binding protein;
+; shares homology with heat shock protein HSP70, Swiss-Prot
+; Accession Number P11142"
+; /codon_start=1
+; /function="translocation of proteins across intracellular
+; membranes"
+; /product="cytoplasmic 70 kDa heat shock protein"
+; /db_xref="PID:g468014"
+Giardia-c
+-------------MATAPAVGIDLGTTYSCVGVYQNEKVEIIANEQGAYTTPSYVAFT-D
+-ADGLIGDSAKNQCALNPENTIFDAKRLIGRRFNDPEVQADLKHFRSRSSCGPTRTPQIQ
+VVYK-----GETKTFTPEEISSMVLTKMKDIA-SDYLG--NKVTEAIVTVPAYFSDAHGK
+ATQNAGTIAGLNVLRIINEPTAAAIAYGLDKST---SKKERNILIFDLGGGTFDVSLLTV
+DPSSGVFEVKATAGDTHLGGEDFDSRVVNYFIAEFKKKH-G-----------KDISGSNR
+AMRRLRTACEEAKRTLSS-SQQASIEIESLFEGIDFF----TNITRAKFEDLCIDLFRKC
+LDPVDRVLRDS-------KLGKNDVHDIVLVGGSTRIPKVQQM-LRDFFSGRELSKNVNP
+DEAV-AYGASVQAALLSSYKDQAGSGA-INDILLLDVTPLSLGIETSGTNMTTLIPRNTT
+VPVSRKETF-TTYADNQTTVTIRIFEGER-PLTKDNNLLGT----FDLGGIPPAPRG-TP
+KIEVTYDVSADGVL-TVTAKDLGGTGNSKQLSINQNANRLSQE-EIDRMVKDAERFAKED
+EKIREGQKARNELESLVFSV--KSTLGEG-KVQISDDDKKK--IETAVNECATWLENNK-
+VGDKEQFEAKKKELEAIVHPVMAAGMGAAGMPPGGFPGGMPPGGFPGGFPGGMPGGAAPG
+GAPAGPSVDDLD------------------------------------------------
+-------------------------------------------------------
+;EMHSP70.HSP70 522 residues Frame 0 Code 0
+;DEFINITION E.maxima hsp70 gene for heat-shock protein.
+;ACCESSION Z46964
+; CDS <3..1568
+; /gene="hsp70"
+; /citation=[1]
+; /codon_start=1
+; /product="heat-shock protein"
+; /db_xref="PID:g603812"
+Eimeria-maxima
+------------------------------------------------------------
+------------------------------------------------------------
+----------------------------------QFIG--KEIKEAVITVPAYFNDSQRQ
+ATKDAGTIAGLNVLRIINEPTAAAIAYGLDKKG----QGEMNVLIFDMGGGTFDVSLLTI
+EDG--IFEVKATAGDTHLGGEDFDNRLVDFCIQDFKRKNRS-----------KDPSNNSR
+ALRRLRTQCERAKRTLSS-STQATIEIDSLYEGIDYS----VSLSRARFEELCMDYFRNS
+LIPVEKVLKDS-------NIDKRSVHEVVLVGGSTRIPKIQQL-IQEFFNGKEPCRSINP
+DEAV-AYGAAVQAAILKGVNSTQ-----VQDLLLLDVAPLSLGLETAGGVMTKLIERNTT
+IPTKKSQIF-TTYADNQPGVLIQVYEGER-AMTKDNNLLGK----FHLDGIPPAPRG-VP
+QIEVTFDIDANGIM-NVTATEKN-TGKSNQITITNDKGRLSQG-EIDRMVAEAEKYKAED
+EANKQRIEAKNNLENYCYSM--RSTLDEE-KVKDKISKEDKDTAAAAIQKTLDWLDKNQ-
+LAEKEEYESKLKEIEGVCTPIVTKMYQAAA--------GAAGGMPGAAAGMPGGMPDMS-
+----------------------GAAAAPGAGPTVEEVD----------------------
+-------------------------------------------------------
+;SCSSB1G.PE1 614 residues Frame 0 Code 0
+;DEFINITION Yeast SSB1 heat shock cognate gene.
+;ACCESSION X13713
+; CDS 210..2051
+; /note="heat shock protein 70 cognate (AA 1-613)"
+; /codon_start=1
+; /db_xref="PID:g4548"
+; /db_xref="SWISS-PROT:P11484"
+Saccharo-SSB1
+----------MAEGVFQGAIGIDLGTTYSCVATYESS-VEIIANEQGNRVTPSFVAFT-P
+-EERLIGDAAKNQAALNPRNTVFDAKRLIGRRFDDESVQKDMKTWPFKVIDVD-GNPVIE
+VQYL-----EETKTFSPQEISAMVLTKMKEIA-EAKIG--KKVEKAVITVPAYFNDAQRQ
+ATKDAGAISGLNVLRIINEPTAAAIAYGLGAGK---SEKERHVLIFDLGGGTFDVSLLHI
+AGG--VYTVKSTSGNTHLGGQDFDTNLLEHFKAEFKKKTG------------LDISDDAR
+ALRRLRTAAERAKRTLSS-VTQTTVEVDSLFDGEDFE----SSLTRARFEDLNAALFKST
+LEPVEQVLKDA-------KISKSQIDEVVLVGGSTRIPKVQKL-LSDFFDGKQLEKSINP
+DEAV-AYGAAVQGAILTGQSTSD---E-TKDLLLLDVAPLSLGVGMQGDMFGIVVPRNTT
+VPTIKRRTF-TTCADNQTTVQFPVYQGER-VNCKENTLLGE----FDLKNIPMMPAG-EP
+VLEAIFEVDANGIL-KVTAVEKS-TGKSSNITISNAVGRLSSE-EIEKMVNQAEEFKAAD
+EAFAKKHEARQRLESYVASI--EQTVTDPVLSSKLKRGSKSKIEAALSDALAALQIEDPS
+ADELRKAEVGLKRVVTKAMSSR--------------------------------------
+------------------------------------------------------------
+-------------------------------------------------------
+;CELHSP3.PE1 662 residues Frame 0 Code 0
+;DEFINITION C. elegans BiP (hsp3) gene, complete cds.
+;ACCESSION M26604
+; CDS join(442..628,675..1148,1387..2132,2237..2815)
+; /note="BiP, heat shock protein 3"
+; /codon_start=1
+; /db_xref="PID:g156346"
+Caenorhabditis-BiP
+IYCKEEEKTEKKETKYETIIGIDLGTTYSCVGVYKNGRVEIIANDQGNRITPSYVAFSGD
+QGDRLIGDAAKNQLTINPENTIFDAKRLIGRDYNDKTVQADIKHWPFKVIDKS-NKPSVE
+VKVG-----SDNKQFTPEEVSAMVLVKMKEIA-ESYLG--KEVKNAVVTVPAYFNDAQRQ
+ATKDAGTIAGLNVVRIINEPTAAAIAYGLDKKD-----GERNILVFDLGGGTFDVSMLTI
+DNG--VFEVLATNGDTHLGGEDFDQRVMEYFIKLYKKKSG------------KDLRKDKR
+AVQKLRREVEKAKRALST-QHQTKVEIESLFDGEDFS----ETLTRAKFEELNMDLFRAT
+LKPVQKVLEDS-------DLKKDDVHEIVLVGGSTRIPKVQQL-IKEFFNGKEPSRGINP
+DEAV-AYGAAVQGGVISGEED-------TGEIVLLDVNPLTMGIETVGGVMTKLIGRNTV
+IPTKKSQVF-STAADNQPTVTIQVFEGER-PMTKDNHQLGK----FDLTGLPPAPRG-VP
+QIEVTFEIDVNGIL-HVTAEDKG-TGNKNKITITNDQNRLSPE-DIEAMINDAEKFAEDD
+KKVKDKAEARNELESYAYNL--KNQIEDKEKLGGKLDEDDKKTIEEAVEEAISWLGSNA-
+EASAEELKEQKKDLESKVQPIVSKLYKDAGAGERRPQKRDLDDKDEL-------------
+------------------------------------------------------------
+-------------------------------------------------------
+;ACBIP.PE1 668 residues Frame 0 Code 0
+;DEFINITION A.californica mRNA for BiP/GRP78 homologue.
+;ACCESSION Z15041
+; CDS 132..2135
+; /codon_start=1
+; /product="BiP/GRP78"
+; /db_xref="PID:g5570"
+Aplysia-BiP
+ADGDEEDEGDKKKSEVGTVIGIDLGTTYSCVGVFKNGRVDIIANDQGNRITPSYVAFTAD
+-GERLIGDAAKNQLTSNPENTIFDVKRLIGRTFDDKSVQHDIKFYPFKVTNAN-NKPHIQ
+AATG-----EGDRSFAPEEISAMVLSKMRDIA-EEYLG--KKITNAVVTVPAYFNDAQRQ
+ATKDAGTIAGLNVMRIINEPTAAAIAYGLDKK-----EGEKNILVFDLGGGTFDVSLLTI
+DNG--VFEVVSTNGDTHLGGEDFDQRVMEHFIKLYKKKKG------------KDIRKDNR
+AVQKLRREVEKAKRALSS-AHQVRLEIESFFDGEDFS----ESLTRAKFEELNMDLFRST
+MKPVKQVLEDA-------DLKTDDIDEIVLVGGSTRIPKVQQL-VKEYFNGKEPSRGINP
+DEAV-AYGAAVQAGVLSGEED-------TGDLVLLDVNPLTMGIETVGGVMTKLIPRNTV
+IPTKKSQIF-STAADNQPTVTIQVYEGER-SMTKDNHLLGK----FDLTGIPPAPRG-VP
+QIEVTFEIDVNGIL-KVTAEDKG-TGSKNQIVIQNDQNRLSPE-DIERMINDAEKYADED
+KKVKEKVDAKNELESYAYSL--KNQIGDKEKLGAKLSDEDKEKITEAVDEAIKWLESNA-
+EAESEAFNEKKTELEGIVQPIMTKLYEQSGGAPPPSGEEESEEAEKDEL-----------
+------------------------------------------------------------
+-------------------------------------------------------
+;SPBIP.BIP 664 residues Frame 0 Code 0
+;DEFINITION S.pombe bip gene.
+;ACCESSION X64416 S94662
+; CDS 441..2432
+; /gene="bip"
+; /codon_start=1
+; /product="BiP"
+; /db_xref="PID:g4917"
+; /db_xref="SWISS-PROT:P36604"
+Schizosacc-bip
+LPMAFASGDDNSTESYGTVIGIDLGTTYSCVAVMKNGRVEIIANDQGNRITPSYVAFT-E
+-DERLVGEAAKNQAPSNPENTIFDIKRLIGRKFDEKTMAKDIKSFPFHIVNDK-NRPLVE
+VNVG-----GKKKKFTPEEISAMILSKMKQTA-EAYLG--KPVTHSVVTVPAYFNDAQRQ
+ATKDAGTIAGLNVIRIVNEPTAAAIAYGLDKT-----DTEKHIVVYDLGGGTFDVSLLSI
+DNG--VFEVLATSGDTHLGGEDFDNRVINYLARTYNRKNN------------VDVTKDLK
+AMGKLKREVEKANGTLSS-QKSVRIEIESFFNGQDFS----ETLSRAKFEEIKHGSLQED
+FEPVEQVLKDS-------NLKKSEIDDIVLVGGSTRIPKVQEL-LESFF-GKKASKGINP
+DEAV-AYGAAVQAGVLSGEEG-------SDNIVLLDVIPLTLGIETTGGVMTKLIGRNTP
+IPTRKSQIF-STAVDNQNTVLIQVYEGER-TLTKDNNLLGK----FDLRGIPPAPRG-VP
+QIEVTFEVDANGVL-TVSAVDKSGKGKPEKLVIKNDKGRLSEE-DIERMVKEAEEFAEED
+KILKERIEARNTLENYAYSL--KGQFDDDEQLGGKVDPEDKQAVLDAVEDVAEWLEIHGE
+DASKEEFEDQRQKLDAVVHPITQKLYSEGAGDADEEDDDYFDDEADEL------------
+------------------------------------------------------------
+-------------------------------------------------------
+;
+;GLU04875.BIP 663 residues Frame 0 Code 0
+;DEFINITION Giardia lamblia Portland 1 immunoglobulin heavy chain binding
+; protein (Bip), glucose-related protein (GRP78) gene, complete cds.
+;ACCESSION U04875
+; CDS 514..2502
+; /gene="Bip"
+; /note="endoplasmic reticulum resident; ATP binding
+; protein; protein also called glucose-related protein; gene
+; also called GRP78; molecular chaperone protein; belongs to
+; heat shock family of proteins; shares homology with HSP70,
+; Swiss-Prot Accession Number P11142, Bip/GRP78, Swiss-Prot
+; Accession Number P22010, and Kar2p, Swiss-Prot Accession
+; Number P16474"
+; /codon_start=1
+; /function="translocation of proteins across intracellular
+; membranes"
+; /product="immunoglobulin heavy chain binding protein"
+; /db_xref="PID:g468016"
+Giardia-BIP
+----MLALVFAALALAETIIGIDLGTTYSCVAVSRAGQVEIIPNELGARVTPSYVAFTAD
+-GERLVGDAAKNYAPISPENTIFDVKRLIGRKFDDPEVQKDMKLLPYKVINKD-GRPFVQ
+LSGTNLPKELQNKIMSPEEISAMVLTKMKTIA-EDYLG--EKITKAVVTVPAYFSDSQRS
+ATKDAGRIAGLDVVRIINEPTSSSIAYGLDKKTQETSGKAKNILVFDCGGGTHDVSILSV
+DSG--VFEVLATAGNTHLGGEDFDRRLLDHFIAIFKKKNNIDLSITNTGDKAKDMAV-KK
+AISRLRREIEAGKRQLST-ASSVQIVVDSLIDGIDFS----ELVTRAKFEELNIDLFKKS
+IKPVEQVLRDA-------KLKTTDIDEVVLVGGSTRIPKIRQL-LQDYFNGKALNKDINA
+DEAV-AWGAAVQASILSGAK--------DHDVLLIDVTPLTLGIETQGGIMTPLIERNSY
+IPVKKSKIF-STVQDQQTMVKIQVYEGER-SMVKDNNLLGN----FDLNDIPPAPRG-TP
+QIEVTFEIDSNGIL-TVSAVEKS-SGKEESITIKNDRGRLSED-EINRLVKEAEEFAEED
+KINRERAEARNAFEMIVSITTTQTTADKEGNIVDKISSDDLEKVKEAVKEAQDWLRDNT-
+DASKEEIEEEKSKFEKVVQPILGENFGRSASAGSSGPEYDYAEKDEL-------------
+------------------------------------------------------------
+-------------------------------------------------------
+;SPIHSC70A.HSC70 669 residues Frame 0 Code 0
+;DEFINITION Spinacia oleracea ER-lumenal protein (HSC70) mRNA, complete cds.
+;ACCESSION L23551
+; CDS 75..2081
+; /gene="HSC70"
+; /standard_name="BiP, GRP-78, HSP70"
+; /codon_start=1
+; /function="molecular chaperone"
+; /product="ER-lumenal protein"
+; /db_xref="PID:g388065"
+Spinacia-BiP
+GSLFAFVSAKDEAPKLGTVIGIDLGTTYSCVGVYKDGKVEIIANDQGNRITPSWVAFT-N
+-DERLIGEAAKNQAAANPERTIFDVKRLIGRKFEDKEVQKDMKLVPYKIVNRD-GKPYIQ
+VKVQE----GETKVFSPEEISAMILTKMKETA-ETFLG--KKIKDAVVTVPAYFNDAQRQ
+ATKDAGVIAGLNVARIINEPTAAAIAYGLDKR-----GGEKNILVFDLGGGTFDVSVLTI
+DNG--VFEVLATNGDTHLGGEDFDQRLMEYFIKLIKKKHT------------KDISKDNR
+ALGKLRRECERAKRALSS-QHQVRVEIESLFDGVDFS----EPLTRARFEELNNDLFRKT
+MGPVKKAMDDA-------GLEKNQIDEIVLVGGSTRIPKVQQL-LKEFFNGKEPSKGVNP
+DEAV-AFGAAVQGSILSGEGGE----E-TKEILLLDVAPLTLGIETVGGVMTKLIPRNTV
+IPTKKSQVF-TTYQDQQTTVTIQVFEGER-SLTKDCRLLGK----FDLTGIAPAPRG-TP
+QIEVTFEVDANGIL-NVKAEDKA-SGKSEKITITNDKGRLSQE-EIERMVREAEEFAEED
+KKVKEKIDARNSLETYIYNM--KNQISDADKLADKLESDEKEKIEGAVKEALEWLDDNQ-
+SAEKEDYDEKLKEVEAVCNPIITAVYQRSGGPSGESGADSEDSEEGHDEL----------
+------------------------------------------------------------
+-------------------------------------------------------
+;BLYHSPHAA.HSP70 609 residues Frame 0 Code 0
+;DEFINITION Hordeum vulgare HSP70 mRNA, complete cds.
+;ACCESSION L32165
+; CDS 94..1920
+; /standard_name="HSP70"
+; /note="Heat-shock protein HSP70; The predicted amino acid
+; sequence is highly homologous (more than 80% identity) to
+; other plant heat-shock proteins (HSP70s) in the database;
+; however the C terminus is quite unique.; putative"
+; /codon_start=1
+; /function="Molecular chaperone"
+; /product="HSP70"
+; /db_xref="PID:g476003"
+Hordeum
+GSLFALCAAKEEAKKLGTVIGIDLGTTYSCVGVYKNGHVEIIANDQGNRITPSWVGFT-D
+-GERLIGEAAKNQAAVNPERTVFDVKRLIGRKFEDKEVQRDMRLVPYKIVNKE-GKPYIQ
+VKIKD----GETKVFSPEEVSAMILGKMKETA-EAYLG--KKINDAVVTVPAYFNDAQRQ
+ATKDAGVIAGLNVARIINEPTAAAIAYGLDKR-----GGEKNILVFDLGGGTFDVSILTI
+DNG--VFEVLATNGDTHLGGEDFDHRIMDYFIKLIKKKHG------------KDISKDNR
+ALGKLRREAERAKRALSN-QHQVRVEIESLFDGTDFS----EPLTRARFEELNNDLFRKT
+MGPVKKAMDDA-------GLEKTQIHEIVLVGGSTRIPKVQQL-LRDYFDGKEPNKGVNP
+DEAV-AFGAAVQGSILSGEGGD----E-TKDILLLDVAPLTLGIETVGGVMTKLIPRNTV
+IPTKKSQVF-TTYQDQQTTVSIQVFEGER-SMTKDCRLLGK----FDLSGIPAAPRG-TP
+QIEVTFEVDANGIL-NVKAEDKG-TGKSEKITITNEKGRLSQE-EIDRMVKEAEEFAEED
+KKVKERIDARNQLETYVYNM--KNTVGDK-DKLADKLESEEKEKMEGSWPNNN-------
+------------------------------------------------------------
+------------------------------------------------------------
+-------------------------------------------------------
+;TOMBIPGRBC.PE1 667 residues Frame 0 Code 0
+;DEFINITION Tomato BiP (binding protein)/grp78 (glucose-regulated protein, 78
+; kD) (BiP/grp78) mRNA, complete cds.
+;ACCESSION L08830
+; CDS 120..2120
+; /gene="BiP/grp78"
+; /note="an endoplasmic reticulum residing heat shock
+; protein 70 family member; precursor peptide"
+; /codon_start=1
+; /function="molecular chaperon (precursor)"
+; /product="glucose-regulated protein 78"
+; /db_xref="PID:g170384"
+Lycopersicon-BiP
+GCLSALSNAKEEATKLGTVIGIDLGTTYSCVGVYKNGHVEIIANDQGNRITPSWVAFT-D
+-NERLIGEAAKNLAAVNPERTIFDVKRLIGRKFEDKEVQRDMKLVPYKIVSKD-GKPYIQ
+VKIKD----GEVKVFSPEEISAMILTKMKETA-EAFLG--KTIKDAVVTVPAYFNDAQRQ
+ATKDAGVIAGLNVARIINEPTAAAIAYGLDKK-----GGEKNILVFDLGGGTFDVSILTI
+DNG--VFEVLATNGDTHLGGEDFDQRIMEYFIKLIKKKHG------------KDISKDNR
+ALGKLRREAERAKRSLSS-QHQVRVEIESLFDGTDFS----EPLTRARFEELNNDLFRKT
+MGPVKKAMDDA-------GLQKNQIDEIVLVGGSTRIPKVQQL-LKDYFDGKEPSKGVNP
+DEAV-AYGAAVQGGILSGEGGD----E-TKDILLLDVAPLTLGIETVGGVMTKFIPRNTV
+IPTKKSQVF-TTYQDQQTTVSIQVFEGER-SLTKDCRNLGK----FDLTGIPPAPRG-TP
+QIEVTFEVDANGIL-NVKAEDKG-TGKAEKITITNDKGRLSQE-EIERMVREAEEFAEED
+KKVKEKIDARNALETYVYNM--KNQINDKDKLADKLESDEKEKIETATKEALEWLDDNQ-
+SAEKEDYDEKLKEVEAVCNPIITAVYQRSGGAPGGGASEEEDDSHDEL------------
+------------------------------------------------------------
+-------------------------------------------------------
+;OSCHLPLXX.DNAK 615 residues Frame 0 Code 0
+;DEFINITION O.sinensis chloroplast DNA, complete genome.
+;ACCESSION Z67753
+; CDS 30213..32057
+; /gene="dnaK"
+; /codon_start=1
+; /product="Hsp70-type chaperone"
+; /db_xref="PID:e211836"
+; /db_xref="PID:g1185167"
+Odontella-CP
+---------------MGKVVGIDLGTTNSVVAAIEGGQPSVIVNAEGLRTTPSIVAYT-K
+KQELLVGQIAKRQAVINPENTFFSVKRFIGSK-ELE-ISADSKKLPYKVVKDQNGNIKIN
+CS-------SLNKEFSPEEISAQVLRKLINDA-TSYLG--QDVTQAVITVPAYFNDSQRQ
+ATMDAGKIAGVEVLRIINEPTAASLAYGLDKK------QNETILVFDLGGGTFDVSILEV
+GDG--IFEVLATAGDTNLGGDDFDKVLVRWLVKEFEDQEG------------IDLTQDIQ
+ALQRLTEAAEKAKMELST-VEKTTIHLPFITADKTGPKHIEKELTRKTFETLCQELIERC
+QIPVEKALTDA-------RLEKSDINEVVLVGGSTRIPAIQNL-VESLT-NKKPNQSVNP
+DEVV-AIGAAIQAGILAGE---------IKDVLLLDVTPLSLGVETLGGVMTKIIARNTT
+IPVKKSEMF-STAVENQTNVEIHVLQGER-ELVAGNKSLGN----FRLDGIPAAERG-VP
+QIEVTFDINVDGLL-SVKAKELE-TGIEQSVTIQ-GASNLDES-EVSDMLAEAEKYAALN
+KEKRQNIDLKNQAETLCFEA--EKELDLFKTSIPEEKQQNVQK---LIENIRQDTQTD--
+--NFESLKLLVEELKMAMKDMVEAKPF----VDQTDTDPMSNLNDL--------------
+------------------------------------------------------------
+-------------------------------------------------------
+;PPU38804.DNAK 621 residues Frame 0 Code 0
+;DEFINITION Porphyra purpurea chloroplast genome, complete sequence.
+;ACCESSION U38804
+; CDS 106219..108081
+; /gene="dnaK"
+; /codon_start=1
+; /product="Hsp70-type chaperone"
+; /db_xref="PID:g1276781"
+Porphyra-CP
+---------------MGKVVGIDLGTTNSVIAVMEGGKPTVIPNAEGFRTTASVVAYT-K
+SGDKLVGQIAR-QAVINPENTFYSVKRFIGRK-QNE-ISQEIRQTSYNVK-TSGSSIKIE
+CP-------ALNKDFAPEEISAQVLRKLVEDA-STYLG--ETVTQAVITVPAYFNDSQRQ
+ATKDAGKIAGLDVLRIINEPTAASLSYGLDKQ------NNETILVFDLGGGTFDVSILEV
+GDG--VFEVLSTSGDTHLGGDDFDQQIVEWLIKDFKQSEG------------IDLGKDRQ
+ALQRLTEASEKAKIELSN-LTQTEINLPFITATQDGPKHLEKTVTRAKFEELCSRLIDKC
+SIPVNNALKDA-------KLEASSIDEVVLVGGSTRIPAIQQM-VKRLI-GKDPNQSVNP
+DEVV-AIGAAVQAGVLAGE---------VKDILLLDVTPLSLGVETLGGVMTKIIPRNTT
+IPTKKSEVF-STAVDNQPNVEIQVLQGER-ELTKDNKSLGT----FRLDGIMPAPRG-VP
+QIEVTFDIDANGIL-SVKAKEKA-TGKEQSITIS-GASTLPKD-DVERMVKEAEENFDVD
+QKRRKNIDIRNQAESLCYQS--EKQVKEFEDKIDEELKNRITN---LISELRSNLEKE--
+--ELDSIEANSEKLQNALMEIGKNATS-----AEKDTQNASNDDTVIDTDFSEAK-----
+------------------------------------------------------------
+-------------------------------------------------------
+;PSTASP70.HSP70 630 residues Frame 0 Code 0
+;DEFINITION P.lutherii hsp70 gene for 70 kd heat shock protein.
+;ACCESSION X59555
+; CDS 181..2070
+; /gene="hsp70"
+; /codon_start=1
+; /product="heat shock protein 70"
+; /db_xref="PID:g20905"
+; /db_xref="SWISS-PROT:P30722"
+Pavlova-CP
+---------------MAKVVGIDLGTTNSVVAVMEGGKPTVITNSEGGTTTPSVVAYA-K
+NGDLLVGQIAKRQAVINSENTFYSVKRFIGRP-SKE-VSDELRQTPYKIE-DSEGKIRLK
+CP-------NLNKNFAAEEISAQVLRKLVNDA-NKYLG--EKVEKAVITVPAYFNDSQRQ
+ATKDAGKIAGLEVLRIINEPTAASLAYGLDKK------DNETILVFDLGGGTFDVSILEV
+GDG--VFEVLSTSGDTRLGGDDFDEKIVKWLLNEFEKEEK------------FSLKGDSQ
+ALQRLTEAAEKAKIELSS-LSQTEINLPFITANENGAKHIEKTLTGEKFESLCSDLFDRC
+RIPVENALKDA-------KLKPNQIDEVVLVGGSTRIPAVKKL-VKDIL-GKEPNETVNP
+DEVV-AIGAAIQAGVLSGE---------VKDILLLDVTPLSLGVETLGGVTTKIIPRNTT
+VPTKKSEIF-STAVDNQPNVEIHVLQGER-EFARDNKSLGT----FRLDGILPAPRG-IP
+QIEVTFDIDANGIL-SVTAQDKG-TSKQQSITIS-GASTLPKE-EVEKMVKEAEQNAAAD
+KEKGENIRVKNEADLYCYQA--EKQISELPEALVNENQSLIKESKETVEMLKENIKKE--
+--DYDKIKENLKKLQEKLMEIGQKAYAKKEPLKDEDSNKAGSQDDFIDADFTESK-----
+------------------------------------------------------------
+-------------------------------------------------------
+;CRYCPHCFC.CTP70 628 residues Frame 0 Code 0
+;DEFINITION Cryptomonas phi heat shock 70 protein (ctp70) histone-like protein
+; (hcfc) and acyl carrier protein (acpC) genes, complete cds.
+;ACCESSION M76547
+; CDS 199..2082
+; /gene="ctp70"
+; /codon_start=1
+; /product="heat shock protein"
+; /db_xref="PID:g455155"
+Cryptomonas-CP
+---------------MGKVVGIDLGTTNSVVAVMEGGKPAVIQNAEGFRTTPSVVAYT-K
+TGDRLVGQIAKRQAVINPDNTFYSVKRFIGRR-SEE-VSEELKQVSYIVKTDSNGNIKLD
+CP-------SLKKEFASEEISAEVLRKLVDDA-SKYLG--ESVKQAVITVPAYFNDSQRQ
+ATKDAGRIAGLEVLRIINEPTAASLAYGLDKK------NNETILVFDLGGGTFDVSVLEV
+GDG--VFEVLSTSGDTHLGGDDFDDKIVQWLLKEFETEHS------------INLKSDRQ
+ALQRLTEASEKAKIELSN-LSQTEINLPFLTATETGPKHLERSITRAKFEELCSDLINRV
+KIPVENALKDA-------KLDSSKIDEVVLVGGSTRIPAIQEL-VKRIL-NKTPNQTVNP
+DEVV-AIGAAVQAGVLAGE---------VKDILLLDVTPLSLGVETLGGVTTRIIPRNTT
+IPTKKSEVF-STAVDNQPNVEIHVLQGER-EFAKDNKSLGT----FRLDGILPAPRG-VP
+QIEVTFDIDANGIL-SVTAKDKG-TGKEQSITIT-GASTLPSD-EVERMVNEAQNSAKED
+KEKRDKIDLKNQSDSLCYQS--EKQLKEL-EGKIDDTNKNKISSMI-----SELRNAIN-
+NENYDEMRDLNSKLQTALMDLGKSVYEKTSKEQTSTSSPTNSNDSVIDADFSETK-----
+------------------------------------------------------------
+-------------------------------------------------------
+;CSHSP70.HSP70 708 residues Frame 0 Code 0
+;DEFINITION C.sativus mRNA for heat shock protein 70 (hsp70).
+;ACCESSION X73961
+; CDS 101..2224
+; /gene="hsp70"
+; /codon_start=1
+; /product="heat shock protein 70"
+; /db_xref="PID:e81202"
+; /db_xref="PID:g1143427"
+Cucumis
+NTSRRNSSVRPLRIVNEKVVGIDLGTTNSAVAAMEGGKPTIVTNAEGQRTTPSVVAYT-K
+NGDRLVGQIAKRQAVVNPENTFFSVKRFIGRK-MSE-VDEESKQVSYRVERDENGNVKLE
+CP-------AIGKQFAAEEISAQVLRKLVDDA-SKFLN--DKVTKAVVTVPAYFNDSQRT
+ATKDAGRIAGLEVLRIINEPTAASLAYGFEKK------SNETILVFDLGGGTFDVSVLEV
+GDG--VFEVLSTSGDTHLGGDDFDKRIVDWLAANFKRDEG------------IDLLKDKQ
+ALQRLTETAEKAKMELSS-LTQANISLPFITATADGPKHIETTITRAKFEELCSDLLDRL
+KTPVENSLRDA-------KLSFKDIDEVILVGGSTRIPAVQEL-VKKMT-GKEPNVTVNP
+DEVV-ALGAAVQAGVLAGD---------VSDIVLLDVSPLSLGLETLGGVMTKIIPRNTT
+LPTSKSEVF-STAADGQTSVEINVLQGER-EFVRDNKSLGS----FRLDGIPPAPRG-VP
+QIEVKFDIDANGIL-SVTAIDKG-SGKKQDITIT-GASTLPSD-EVERMVSEADKFAKED
+KEKRDAIDTKNQADSVVYQT--EKQLKEL-GDKVPGPVKEKVESKL-----GELKEAIS-
+GGSTEAIKEAMAALNQEVMQLGQSLYNQPGAGAAPGPGASSESGPSESTGKGPEGDVIDA
+DFSDSK------------------------------------------------------
+-------------------------------------------------------
+;PSST70.PSST70 707 residues Frame 0 Code 0
+;DEFINITION P.sativum Psst70 gene for heat-shock protein.
+;ACCESSION X69213
+; CDS join(775..1326,1456..1708,1790..1869,1979..2121,
+; 2228..2326,2459..2648,2831..3229,3331..3735)
+; /gene="Psst70"
+; /codon_start=1
+; /product="Psst70 (stress 70 protein)"
+; /db_xref="PID:g871515"
+; /db_xref="SWISS-PROT:Q02028"
+Pisum
+LSSKTFKKGFTLRVVSEKVVGIDLGTTNSAVAAMEGGKPTIITNAEGQRTTPSVVAYT-K
+NGDRLVGQIAKRQAVVNPENTFFSVKRFIGRK-MSE-VDEESKQVSYRVIRDDNGNVKLD
+CP-------AIGKSFAAEEISAQVLRKLVDDA-SKFLN--DKVTKAVVTVPAYFNDSQRT
+ATKDAGRIAGLEVLRIINEPTAASLAYGFERK------NNETILVFDLGGGTFDVSVLEV
+GDG--VFEVLSTSGDTHLGGDDFDKRVVDWLAGDFKRDEG------------IDLLKDKQ
+ALQRLTETAEKAKMELSS-LSQTNISLPFITATADGPKHIETTLTRAKFEELCSDLLDRL
+RTPVENSLRDA-------KLSIKDIDEVILVGGSTRIPAVQEL-VKKLI-GKDPNVTVNP
+DEVV-ALGAAVQAGVLAGD---------VSDIVLLDVSPLSLGLETLGGVMTKIIPRNTT
+LPTSKSEVF-STAADGQTSVEINVLQGER-EFVRDNKSLGS----FRLDGIPPAPRG-VP
+QIEVKFDIDANGIL-SVAAIDKG-TGKKQDITIT-GASTLPGD-EVERMVSEAERFSKED
+KEKREAIDTKNQADSVVYQT--EKQLKEL-GEKVPAPVKEKVEAKL-----GELKEAIT-
+GGSTQTIKDALAALNQEVMQLGQSLYNQPGAAGQAGPTPPGSESGPSESSGKEGPEGDVI
+DADFTDSK----------------------------------------------------
+-------------------------------------------------------
+;CRHSP70B.HSP70B 680 residues Frame 0 Code 0
+;DEFINITION C.reinhardtii hsp70b gene.
+;ACCESSION X96502
+; CDS join(1222..1347,1442..1588,1988..2101,2423..2551,
+; 2892..3254,3478..4638)
+; /gene="hsp70b"
+; /codon_start=1
+; /product="heat shock protein 70B"
+; /db_xref="PID:e228634"
+; /db_xref="PID:g1225970"
+Chlamydomonas-B
+GRAGVSRRALAVSVRAEKVVGIDLGTTNSAVAAMEGGKPTIITNAEGGRTTPSVVAFT-K
+TGDRLVGQIAKRQAVVNPENTFFSVKRFIGRR-MSE-VGSESTQVPYRVI-EDGGNVKIK
+CP-------NAGKDFAPEEISAQVLRKLTEDA-AKFLN--DKVEKAVITVPAYFNDSQRQ
+ATKDAGKIAGLEVLRIINEPTAASLAYGFDKK------ANETILVFDLGGGTFDVSVLEV
+GDG--VFEVLSTSGDTHLGGDDFDKRIVDFLADDFKKSEG------------IDLRKDRQ
+ALQRLTEAAEKAKIELSG-MAQTSINLPFITATADGPKHIDTQLTRAKFEEMCNDLLERC
+KVPVQQALRDA-------KLSISDIQEVILVGGSTRIPAVQEI-VRKLSGGKDPNVTVNP
+DEVV-ALGAAVQAGVLAGE---------VSDIVLLDVTPLSLGLETLGGVMTKLIPRNTT
+LPTSKSEVF-STAADGQTSVEINVLQGER-EFARDNKSLGT----FRLDGIPPAPRG-VP
+QIEVKFDIDANGIL-SVTATDKG-TSKKQDIRIT-GASTLDKG-DVERMVKEAEKFAGED
+KKRRESVETKNQAETMVYQT--EKQLKEF-EGKVPADIKAKVEAKL-----GELKAALP-
+ADDAEATKAAMNALQQEVMAMGQAMYSQAGAAPGGAPGAEPGAGAGAGGAPGGKKDDDVI
+DAEFTDKK----------------------------------------------------
+-------------------------------------------------------
+;ETHSP70.HSP70 678 residues Frame 0 Code 0
+;DEFINITION E.tenella hsp70 gene encoding organellar heat shock protein.
+;ACCESSION Z46965
+; CDS 80..2113
+; /standard_name="hsp70"
+; /note="Isolated by screening with antibodies raised to
+; rhoptry organelles. Resembles hsp70 molecules from
+; mitochondria and chloroplasts and is a putative organellar
+; hsp70."
+; /codon_start=1
+; /product="organellar heat shock protein"
+; /db_xref="PID:g603814"
+Eimeria-tenella
+GTLSSLAGRRGFSGVRGDVVGIDLGTTNSCVAVMEGSQPKVLENSEGMRTTPSVVAFT-K
+DGQRLVGVVAKRQAITNPENTFFSTKRLIGRSFDEEAIAKERKILPYKVIRADNGDAWVE
+GW---------GKKYSPSQIGAFVLMKMKETA-ESYLG--RDVNQAVITVPAYFNDSQRQ
+ATKDAGKIAGLDVLRIINEPTAAALAYGMEKE------DGRTIAVYDLGGGTFDVSILEI
+LGG--VFEVKATNGNTSLGGEDFDQKVLQFLVNEFKKKEG------------IDLSKDRL
+ALQRLREAAETAKIELSS-KLSTEINLPFITADQSGPKHLQVSLSRAHLEELVGALLQQS
+IEPCEKCIRDA-------GVQKADLSDVILVGGMTRMPKVAEV-VKNIF-HKEPSKGVNP
+DEAV-AAGAAIQAGVLKGE---------IKDLLLLDVCPLSLGIETLGGVFTRLINRNTT
+IPTKKSQIF-STAADNQTQVGIKVYQGER-EMASANKLLGQ----FDLVGIPPAPRG-VP
+QIEVTFDVDANGIM-NISAVDKS-TAKRQQITIQ-SSGGLSEA-QIKQMVEDAERFKDED
+QRQKDLVAAKNEAETLVYSV--EKQISDLKDKISAEDKTDLESRIQELRSALVEGELE--
+TIRSRVKALQELSWKVSQQAYSQSNNTSADGDSSSTSSGDSSSKP---------------
+------------------------------------------------------------
+-------------------------------------------------------
+;LMHSPL701 635 residues Frame 0 Code 0
+;DEFINITION L.major hsp70.1 gene for heat-shock protein 70-related protein.
+;ACCESSION X64137
+Leishma-1
+AASAACLARHESQKVQGDVIGVDLGTTYSCVATMDGDKARVLENSEGFRTTPSVVAFK-G
+-SEKLVGLAAKRQAITNPQSTFYAVKRLIGRRFEDEHIQKDIKNVPYKIVRAGNGDAWVQ
+DG--------NGKQYSPSQIGAFVLEKMKETA-ENFLG--HKVSNAVVTCPAYFNDAQRQ
+ATKDAGTIAGLNVIRVVNEPTAAALAYGMDKT------KDSLIAVYDLGGGTFDISVLEI
+AGG--VFEVKATNGDTHLGGEDFDLALSDYILEEFRKTSG------------IDLSKERM
+ALQRVREAAEKAKCELSS-AMETEVNLPFITANADGAQHIQMRISRSKFEGITQRLIERS
+IAPCKQCMKDA-------GVELKEINDVVLVGGMTRI-RSGGG-GEEVL-PEGPVRGVNP
+DEAV-ALGAATLGGVLRGK---------ASDLILVDVTPLSLGTSVVGDVFVPIIPKNTT
+IPCMRSHIF-TTVDDGQTAIKFKVFIPPA-PRGVPQVEVT-----FDIDANQGEREI-AS
+ENQIRGEFDLSGGICHVTAKDKA-TGKTQNITIT-ANGGLSKE-QIEQMIRDSEQHAEAD
+RVKRELVEVRNNAETQLTTA--ERQLGEWKYVSDAEKENVKTLV-AELRKAMENPNVAKD
+DLAAATDKLQKAVMECGRTEYQQAAAANSGQC----------------------------
+------------------------------------------------------------
+-------------------------------------------------------
+;TRBMTP70.MTP70 657 residues Frame 0 Code 0
+;DEFINITION Trypanosoma cruzi mitochondrial HSP70 (MTP70) gene, complete CDS.
+;ACCESSION M73627
+; CDS 504..2474
+; /gene="MTP70"
+; /codon_start=1
+; /product="mitochondrial HSP70"
+; /db_xref="PID:g162158"
+Trypanosoma-mt
+SLAAASLARWQSSKVTGDVIGIDLGTTYSCVAVMEGDKPRVLENTEGFRATPSVVAFK-G
+Q-EKLVGLAAKRQAVTNPQSTFFAVKRLIGRRFEDSNIQHDIKNVPYKIGRSSNGDAWVQ
+DA--------NGKQYSPSQVGAFVLEKMKETA-ENFLG--RKVSNAVVTCPAYFNGPQRQ
+ATKDAGTIAGLNVIRVVNGPTAAALAYGLDKT------KDSMIAVYDLGGGTFDISVLEI
+AGG--VFEVKATNGDTHLGGEDFDLCLSDYILTEFKKSTG------------IDLSNERM
+ALQRIREAAEKAKCELST-TMETEVNLPFITANQDGAQHVQMTVSRSKFESLAEKLVQRS
+LGPCKQCIKDA-------AVDLKEISEVVLVGGMTRMPKVIEA-VKQFF-GRDPFRGVNP
+DEAV-ALGGATLGGVLRRD---------VKGLVLLDVTPLSLGVETLGGVFTRMIPKNTT
+IPTKKSQTFFSTAAFNQTQVGIKVFQGER-EMAADNQMMGQ----FDLVGIPPAPRG-VP
+QIEVTFDIEPNGIC-HVTAKDKA-TGKTQNITIT-ASGGLSKE-QIERMIRDSESHAESD
+RLKRELVEVRNNAETQANTA--ERQLTEWKYVSDAEKENVRTLL-RACRKSMENPNVTKD
+ELSAATDKLQKAVMECGRTEYQQAAAGNSSSSSGNTDSSQGEQQQQGDQQKQ--------
+------------------------------------------------------------
+-------------------------------------------------------
+;
+;YSCSSC1A.SSC1 655 residues Frame 0 Code 0
+;DEFINITION Saccharomyces cerevisiae nuclear-encoded mitochondrial heat shock
+; protein (Ssc1) gene, complete cds.
+;ACCESSION M27229
+; CDS 361..2325
+; /gene="Ssc1"
+; /codon_start=1
+; /product="heat shock protein"
+; /db_xref="PID:g717089"
+Yeast-mt
+SSSFRIATRLQSTKVQGSVIGIDLGTTNSAVAIMEGKVPKIIENAEGSRTTPSVVAFT-K
+EGERLVGIPAKRQAVVNPENTLFATKRLIGRRFEDAEVQRDIKQVPYKIVKHSNGDAWVE
+AR---------GQTYSPAQIGGFVLNKMKETA-EAYLG--KPVKNAVVTVPAYFNDSQRQ
+ATKDAGQIVGLNVLRVVNEPTAAALAYGLEKS------DSKVVAVFDLGGGTFDISILDI
+DNG--VFEVKSTNGDTHLGGEDFDIYLLREIVSRFKTETG------------IDLENDRM
+AIQRIREAAEKAKIELSS-TVSTEINLPFITADASGPKHINMKFSRAQFETLTAPLVKRT
+VDPVKKALKDA-------GLSTSDISEVLLVGGMSRMPKVVET-VKSLF-GKDPSKAVNP
+DEAV-AIGAAVQGAVLSGE---------VTDVLLLDVTPLSLGIETLGGVFTRLIPRNTT
+IPTKKSQIF-STAAAGQTSVEIRVFQGER-ELVRDNKLIGN----FTLAGIPPAPKG-VP
+QIEVTFDIDADGII-NVSARDKA-TNKDSSITVA-GSSGLSEN-EIEQMVNDAEKFKSQD
+EARKQAIETANKADQLANDT--ENSLKEFEGKVDKAEAQKVRDQITSLKELVARVQGGEE
+-VNAEELKTKTEELQTSSMKLFEQLYKNDSNNNNNNNGNNAESGETKQ------------
+------------------------------------------------------------
+-------------------------------------------------------
+;YSPHSP70.HSP70 642 residues Frame 0 Code 0
+;DEFINITION S.pombe mitochondrial heat shock protein (HSP70) mRNA, complete
+; cds.
+;ACCESSION M60208 M32806
+; CDS 251..2176
+; /gene="HSP70"
+; /codon_start=1
+; /product="mitochondrial heat shock protein"
+; /db_xref="PID:g173408"
+Schizosacc-mt
+MTARWNSNASGNEKVKGPVIGIDLGTTTSCLAIMEGQTPKVIANAEGTRTTPSVVAFT-K
+DGERLVGVSAKRQAVINPENTFFATKRLIGRRFKEPEVQRDIKEVPYKIVEHSNGDAWLE
+AR---------GKTYSPSQIGGFILSKMRETA-STYLG--KDVKNAVVTVPAYFNDSQRQ
+ATKAAGAIAGLNVLRVVNEPTAAALAYGLDKK------NDAIVAVFDLGGGTFDISILEL
+NNG--VFEVRSTNGDTHLGGEDFDVALVRHIVETFKKNEG------------LDLSKDRL
+AVQRIREAAEKAKCELSS-LSKTDISLPFITADATGPKHINMEISRAQFEKLVDPLVRRT
+IDPCKRALKDA-------NLQTSEINEVILVGGMTRMPRVVET-VKSIF-KREPAKSVNP
+DEAV-AIGAAIQGGVLSGH---------VKDLVLLDVTPLSLGIETLGGVFTRLINRNTT
+IPTRKSQVF-STAADGQTAVEIRVFQGER-ELVRDNKLIGN----FQLTGIAPAPKG-QP
+QIEVSFDVDADGII-NVSARDKA-TNKDSSITVA-GSSGLTDS-EIEAMVADAEKYRASD
+MARKEAIENGNRAESVCTDI--ESNLDIHKDKLDQQAVEDLRSKITDLRETVAKVNAGDE
+GITSEDMKKKIDEIQQLSLKVFESVYKNQ-NQGNESSGDNSAPEG--DKK----------
+------------------------------------------------------------
+-------------------------------------------------------
+;DROHSC5A.HSC70-5 688 residues Frame 0 Code 0
+;DEFINITION Drosophila melanogaster heat shock protein cognate 71 (Hsc5) mRNA,
+; complete cds.
+;ACCESSION L01502
+; CDS 245..2308
+; /gene="Hsc70-5"
+; /note="Description: Heat shock protein cognate 5"
+; /codon_start=1
+; /product="heat shock protein cognate 71"
+; /db_xref="PID:g157667"
+Drosophila-Hsc70-5
+SNGISSQLRYKSGEVKGAVIGIDLGTTNSCLAVMEGKQAKVIENAEGARTTPSHVAFT-K
+DGERLVGMPAKRQAVTNSANTFYATKRLIGRRFDDPEVKKDITNLSYKVVKASNGDAWVS
+ST--------DGKVYSPSQIGAFILMKMKETA-EAYLN--TPVKNAVVTVPAYFNDSQRQ
+ATKDAGQIAGLNVLRVINEPTAAALAYGMDKT------EDKIIAVYDLGGGTFDISILEI
+QKG--VFEVKSTNGDTLLGGEDFDNHIVNFLVVEFKKDSG------------IDIRKDNI
+AMQRLKEAAEKAKCELSS-SQQTDINLPYLTMDAAGPQHMNLKLTRSKLESLVGDLIKRT
+IQPCQKALSDA-------EVSKSEIGEVLLVGGMTRMPKVQST-VQELF-GRQPSRSVNP
+DEAV-AVGAAVQGGVLAGD---------VTDVLLLDVTPLSLGIETLGGVFTRLISRNTT
+IPTKKSQVF-STASDGQTQVEIKVHQGER-EMANDNKLLGS----FTLVGIPPAPRG-VP
+QIEVVFDIDANGIV-HVSAKDKG-TGKEQQIVIQ-SSGGLSKD-EIENMIKKAEEYATAD
+KQKRELIEIVNQGESIVHDT--ETKMEEFKSQLPAEECEKLKKEIADLRTLLANKET---
+-ADLEEVRKATSSLQQSSLKLFELAYKKMSAERETNAGAGSSDSSSSSDTSASQEGREEL
+N-----------------------------------------------------------
+-------------------------------------------------------
+;S75280.PE1 680 residues Frame 0 Code 0
+;DEFINITION pre-mtHSP70=70 kda heat shock protein precursor [rats, hepatoma
+; cells H4, mRNA Partial, 2090 nt].
+;ACCESSION S75280
+; CDS 51..2090
+; /note="70 kda heat shock protein precursor; Method:
+; conceptual translation with partial peptide sequencing.
+; This sequence comes from Fig. 2. "
+; /codon_start=1
+; /product="pre-mtHSP70"
+; /db_xref="PID:g896232"
+Rattus-mt
+VFRFVSRRDYASEAIKGAVVGIDLGTTNSCVAVMEGKQAKVLENSEGARTTPSVVAFT-P
+DGERLVGMPAKRQAVTNPNNTFYATKRLIGRRYDDPEVQKDTKNVPFKIVRASNGDAWVE
+AH---------GKLYSPSQIGAFVLMKMKETA-ENYLG--HTAKNAVITVPAYFNDSQRQ
+ATKDAGQISGLNVLRVINEPTAAALAYGLDKS------EDKVIAVYDLGGGTFDISILEI
+QKG--VFEVKSTNGDTFLGGEDFDQALLRHIVKEFKRETG------------VDLTKDNM
+ALQRVREAAEKAKCELSS-SVQTDINLPYLTMDASGPKHLNMKLTRAQFEGIVTDLIKRT
+IAPCQKAMQDR-------EVSKSDIGEVILVGGMTRMPKVQQT-VQDLF-GRAPSKAVNP
+DEAV-AIGAAIQGGVLAGD---------VTDVLLLDVTPLSLGIETLGGVFTKLINRNTT
+IPTKKSQVF-STAADGQTQVEIKVCQGER-EMAGDNKLLGQ----FTLIGIPPAPRG-VP
+QIEVTFDIDANGIV-HVSAKDKG-TGREQQIVIQ-SSGGLSKD-DIENMVKNAEKYAEED
+RRKKERVEAVNMAEGIVHDT--ETKMEEFKDQLPADECNKLKEEISKMRELLARKDS--E
+--TGENIRQAASSLQQASLKLFEMAYKKM-ASEREGSGSSSTGEQKEDQKEEKQ------
+------------------------------------------------------------
+-------------------------------------------------------
+;PSPHSP1.PHSP1 676 residues Frame 0 Code 0
+;DEFINITION P.sativum PHSP1 mRNA for HSP70.
+;ACCESSION X54739
+; CDS 27..2054
+; /gene="PHSP1"
+; /codon_start=1
+; /product="HSP70"
+; /db_xref="PID:g20835"
+; /db_xref="SWISS-PROT:P37900"
+Pisum-mt
+HKLASLTRPFSSRPAGNDVIGIDLGTTNSCVSVMEGKNPKVIENSEGARTTPSVVAFN-Q
+KSELLVGTPAKRQAVTNPTNTLFGTKRLIGRRFDDAQTQKEMKMVPYKIVRAPNGDAWVE
+AN---------GQQYSPSQIGAFVLTKIKETA-EAYLG--KTISKAVVTVPAYFNDAQRQ
+ATKDAGRIAGLDVQRIINEPTAAALSYGMNNK-------EGLIAVFDLGGGTFDVSILEI
+SNG--VFEVKATNGDTFLGGEDFDNALLDFLVSEFKRTES------------IDLAKDKL
+ALQRLREAAEKAKIELSS-TSQTEINLPFISADASGAKHLNITLTRSKFEALVNNLIERT
+KAPCKSCLKDA-------NISIKDVDEVLLVGGMTRVPKVQQV-VSEIF-GKSPSKGVNP
+DEAV-AMGAALQGGILRGD---------VKELLLLDVTPLSLGIETLGGIFTRLISRNTT
+IPTKKSQVF-STAADNQTQVGIKVLQGER-EMAADNKSLGE----FDLVGIPPAPRG-LP
+QIEVTFDIDANGIV-TVSAKDKS-TGKEQQITIR-SSGGLSDD-EIDKMVKEAELHAQRD
+QERKALIDIRNSADTSIYSI--EKSLAEYREKIPAEVAKEIEDAVSDLRTAMAGENA---
+----DDIKAKLDAANKAVSKIGQHMSGG--SSGGPSEGG-SQGGEQAPEAEYEEVKK---
+------------------------------------------------------------
+-------------------------------------------------------
+;S59747.PE1 683 residues Frame 0 Code 0
+;DEFINITION HSP68=68 kda heat-stress DnaK homolog [Solanum tuberosum=potatoes,
+; mRNA, 2418 nt].
+;ACCESSION S59747
+; CDS 99..2147
+; /note="mismatch(525[T->I]); 68 kda heat-stress DnaK
+; homolog; This sequence comes from Fig. 5. Author-given
+; protein sequence is in conflict with the conceptual
+; translation. "
+; /codon_start=1
+; /product="HSP68"
+; /db_xref="PID:g300264"
+Solanum-mt
+AKWAGLARPFSSKPAGNEIIGIDLGTTNSCVAVMEGKNPKVIENSEGARTTPSVVAFN-Q
+KGELLVGTPAKRQAVTNPTNTLSGTKRLIGRRFDDPQTQKEMKMVPYKIVRGSNGDAWVE
+AN---------GQQYSPTQIGAFILTKMKETA-EAYLG--KSINKAVITVPAYFNDAQRQ
+AIKDAGAIAGLDVQRIINEPTAAALSYGMNSK-------EGLVAVFDLGGGTFDVSILEI
+SNG--VFEVKATNGDTFLGGEDFDNALLEFLVSEFKRTEG------------IDLSKDKL
+ALQRLREAAEKAKIELSS-TSQTDINLPFITADASGAKHLNITLTRSKFETLVNHLIERT
+RNPCKNCLKDA-------GVSLKDVDEVLLVGGMTRVPKVQEI-VSEIF-GKSPSKGVNP
+DEAV-AMGAALQGGILRGD---------VKELLLLDVTPLARGIETLGGIFTRLINRNTT
+IPTKKSQVF-STAADNQTQVGIKVLQGER-EMASDNKLLGE----FDLVGIPPAPKGYCP
+QIEVIFDIDANGMV-TVSAKDKA-TSKEQQITIR-SSGGLSED-EIDKMVREAEMHAQRI
+KNARHLLISGIVQSTTIYSI--EKSLSEYKEKVPKEVVTEIETAISDLRAAMGTENI---
+----DDIKAKLDAANKAVSKIGEHMAGG--SSGGASGGGGAQGGDQPPEAEYEEVKK---
+------------------------------------------------------------
+-------------------------------------------------------
+;TVU70308.PE1 610 residues Frame 0 Code 0
+;DEFINITION Trichomonas vaginalis mitochondrial-type HSP70 mRNA, complete cds.
+;ACCESSION U70308
+; CDS 10..1839
+; /function="molecular chaperone"
+; /codon_start=1
+; /product="mitochondrial-type HSP70"
+; /db_xref="PID:g1597734"
+Trichomonas-mt
+---------------MTPIIGIDLGTTNSCVSVVEGGTPKVIQNAEGVRTTPSIVAFT-N
+TGERLVGEQAKRQAITNSKSTFFATKRLIGCSFDDEMTKKCREMVPYQIVKAKSGDAWVK
+DE--------KGNEYSPSQIGAFVLMKMKETA-EAYLG--TSVKDAVITVPAYFNDSQRQ
+ATKDAGKIAGLNVMRTLNEPTAAALAYGTERK------QGQTVAVFDLGGGTFDFSILEI
+SKD-GVFEVKATNGDTFLGGEDFDAALMKYVIQDFQAKNQ------------IDLAKDPL
+ALQRIREAVEKAKCELSS-MMTTEINLPYITVTGAGPKHLQMPITRATFEKITQHLIART
+INPCKNCLKDA-------GLTPQQINEVILVGGMTRMPKVIDS-VKEFF-GKDPFRGVNP
+DEVV-AIGASIQGSVMRGD---------HKDIVLLDVTPLSLGIETMGGVFSRLIPRNTV
+VPTKKSQEF-TTAADGQTHVNIRVFQGER-DLVEGNKLLGE----FTLVGIPPAPRG-VP
+KIEVTFDIDANSIV-HVSAKDKQ-TNKEQQMTIQ-QHGGLSQD-EIAKMIQDAEKHAAED
+KKKREILEKKYAMKQYINEI--EKTISENEKKLPADLLKRIRDSVKDLKDAIAGNDE---
+----KKIEEKYDALKAASMEIYNAISDNNTNKNKK-------------------------
+------------------------------------------------------------
+-------------------------------------------------------
+;
+D_Trichomonas-mt
+---------------MTPIIGIDLGTTNSCVSVVEGGTPKVIQNAEGVRTTPSIVAFT-N
+TGERLVGEQAKRQAITNSKSTFFATKRLIGCSFDDEMTKKCREMVPYQIVKAKSGDAWVK
+DE--------KGNEYSPSQIGAFVLMKMKETA-EAYLG--TSVKDAVITVPAYFNDSQRQ
+ATKDAGKIAGLNVMRTLNEPTAAALAYGTERK------QGQTVAVFDLGGGTFDFSILEI
+SKD-GVFEVKATNGDTFLGGEDFDAALMKYVIQDFQAKNQ------------IDLAKDPL
+ALQRIREAVEKAKCELSS-MMTTEINLPYITVTGAGPKHLQMPITRATFEKITQHLIART
+INPCKNCLKDA-------GLTPQQINEVILVGGMTRMPKVIDS-VKEFF-GKDPFRGVNP
+DEVV-AIGASIQGSVMRGD---------HKDIVLLDVTPLSLGIETMGGVFSRLIPRNTV
+VPTKKSQEF-TTAADGQTHVNIRVFQGER-DLVEGNKLLGE----FTLVGIPPAPRG-VP
+KIEVTFDIDANSIV-HVSAKDKQ-TNKEQQMTIQ-QHGGLSQD-EIAKMIQDAEKHAAED
+KKKREILEKKYAMKQYINEI--EKTISENEKKLPADLLKRIRDSVKDLKDAIAGNDE---
+----KKIEEKYDALKAASMEIYNAISDNNTNKNKK-------------------------
+------------------------------------------------------------
+-------------------------------------------------------
+;
+D_D_Trichomonas-mt
+---------------MTPIIGIDLGTTNSCVSVVEGGTPKVIQNAEGVRTTPSIVAFT-N
+TGERLVGEQAKRQAITNSKSTFFATKRLIGCSFDDEMTKKCREMVPYQIVKAKSGDAWVK
+DE--------KGNEYSPSQIGAFVLMKMKETA-EAYLG--TSVKDAVITVPAYFNDSQRQ
+ATKDAGKIAGLNVMRTLNEPTAAALAYGTERK------QGQTVAVFDLGGGTFDFSILEI
+SKD-GVFEVKATNGDTFLGGEDFDAALMKYVIQDFQAKNQ------------IDLAKDPL
+ALQRIREAVEKAKCELSS-MMTTEINLPYITVTGAGPKHLQMPITRATFEKITQHLIART
+INPCKNCLKDA-------GLTPQQINEVILVGGMTRMPKVIDS-VKEFF-GKDPFRGVNP
+DEVV-AIGASIQGSVMRGD---------HKDIVLLDVTPLSLGIETMGGVFSRLIPRNTV
+VPTKKSQEF-TTAADGQTHVNIRVFQGER-DLVEGNKLLGE----FTLVGIPPAPRG-VP
+KIEVTFDIDANSIV-HVSAKDKQ-TNKEQQMTIQ-QHGGLSQD-EIAKMIQDAEKHAAED
+KKKREILEKKYAMKQYINEI--EKTISENEKKLPADLLKRIRDSVKDLKDAIAGNDE---
+----KKIEEKYDALKAASMEIYNAISDNNTNKNKK-------------------------
+------------------------------------------------------------
+-------------------------------------------------------
+;
+D_D_D_Trichomonas-mt
+---------------MTPIIGIDLGTTNSCVSVVEGGTPKVIQNAEGVRTTPSIVAFT-N
+TGERLVGEQAKRQAITNSKSTFFATKRLIGCSFDDEMTKKCREMVPYQIVKAKSGDAWVK
+DE--------KGNEYSPSQIGAFVLMKMKETA-EAYLG--TSVKDAVITVPAYFNDSQRQ
+ATKDAGKIAGLNVMRTLNEPTAAALAYGTERK------QGQTVAVFDLGGGTFDFSILEI
+SKD-GVFEVKATNGDTFLGGEDFDAALMKYVIQDFQAKNQ------------IDLAKDPL
+ALQRIREAVEKAKCELSS-MMTTEINLPYITVTGAGPKHLQMPITRATFEKITQHLIART
+INPCKNCLKDA-------GLTPQQINEVILVGGMTRMPKVIDS-VKEFF-GKDPFRGVNP
+DEVV-AIGASIQGSVMRGD---------HKDIVLLDVTPLSLGIETMGGVFSRLIPRNTV
+VPTKKSQEF-TTAADGQTHVNIRVFQGER-DLVEGNKLLGE----FTLVGIPPAPRG-VP
+KIEVTFDIDANSIV-HVSAKDKQ-TNKEQQMTIQ-QHGGLSQD-EIAKMIQDAEKHAAED
+KKKREILEKKYAMKQYINEI--EKTISENEKKLPADLLKRIRDSVKDLKDAIAGNDE---
+----KKIEEKYDALKAASMEIYNAISDNNTNKNKK-------------------------
+------------------------------------------------------------
+-------------------------------------------------------
Added: trunk/packages/seaview/branches/upstream/current/regions.cxx
===================================================================
--- trunk/packages/seaview/branches/upstream/current/regions.cxx (rev 0)
+++ trunk/packages/seaview/branches/upstream/current/regions.cxx 2006-09-19 14:20:14 UTC (rev 111)
@@ -0,0 +1,1043 @@
+#include "seaview.h"
+
+
+/* prototypes of included functions */
+region *duplicate_region(region *source, const char *name);
+void free_region(region *reg);
+region *copy_region(region *from, region *to);
+int create_empty_region(SEA_VIEW *view, const char *name);
+void save_active_region(SEA_VIEW *view, int ask_confirm);
+void hide_region_line(SEA_VIEW *view);
+int rename_current_region(SEA_VIEW *view, const char *name);
+void delete_region(SEA_VIEW *view, int rang);
+void activate_region_line(SEA_VIEW *view, int rang);
+void ajout_segment(region *maregion, int debut, int fin);
+int suppr_segment(region *maregion, int site, char *line);
+list_segments *get_segment(region *maregion, int site);
+void draw_region_line(Fl_Widget *ob, SEA_VIEW *view);
+void regions_menu_callback(Fl_Widget *ob, void *extra);
+int begin_change_segment(SEA_VIEW *view, int new_site);
+int continue_change_segment(SEA_VIEW *view, int new_site);
+void end_change_segment(SEA_VIEW *view);
+int extend_segment_at_left(SEA_VIEW *view, int new_site);
+static void delete_in_region_line(SEA_VIEW *view, int numsite, int total);
+void delete_region_part(SEA_VIEW *view, int numsite, int total);
+static void insert_in_active_region(SEA_VIEW *view, int numsite, int total);
+void insert_region_part(SEA_VIEW *view, int numsite, int total);
+list_regions *parse_regions_from_header(char *header);
+void draw_region_background(SEA_VIEW *view, int f_seq0, int l_seq0);
+char *create_species_set(SEA_VIEW *view, char *set_name);
+void species_menu_callback(Fl_Widget *ob, void *extra);
+void get_menu_taille_valeur(Fl_Widget *menu, int *taille, int *valeur);
+void init_menu_taille_valeur(Fl_Widget *menu, int taille, int valeur,
+ int offset);
+void update_menu_taille_valeur(Fl_Widget *menu, int taille, int valeur,
+ int offset);
+int parse_species_sets_from_header(char *header, int **list_species_sets,
+ char **name_species_sets, int totseqs);
+
+
+extern void adjust_menu_edit_modes(SEA_VIEW *view);
+int compute_size_params(SEA_VIEW *view, int force_recompute);
+
+
+region *duplicate_region(region *source, const char *name)
+{
+region *destin;
+list_segments *pseg, *dest_seg, *prev;
+
+destin = (region *)calloc(1, sizeof(region));
+if(destin == NULL) return NULL;
+if(name != NULL) {
+ size_t l;
+ l = strlen(name);
+ destin->name = (char *)calloc(l+1, 1);
+ if(destin->name == NULL) return NULL;
+ memcpy(destin->name, name, l+1);
+ }
+if(source == NULL) return destin;
+pseg = source->list;
+if(pseg == NULL) return destin;
+destin->list = (list_segments *)calloc(1, sizeof(list_segments));
+if(destin->list == NULL) return NULL;
+*(destin->list) = *pseg;
+destin->list->next = NULL;
+pseg = pseg->next;
+prev = destin->list;
+while(pseg != NULL) {
+ dest_seg = (list_segments *)calloc(1, sizeof(list_segments));
+ if(dest_seg == NULL) return NULL;
+ *dest_seg = *pseg;
+ dest_seg->next = NULL;
+ prev->next = dest_seg;
+ prev = dest_seg;
+ pseg = pseg->next;
+ }
+return destin;
+}
+
+
+void free_region(region *reg)
+{
+list_segments *pseg, *suiv;
+if(reg == NULL) return;
+pseg = reg->list;
+while(pseg != NULL) {
+ suiv = pseg->next;
+ free(pseg);
+ pseg = suiv;
+ }
+if(reg->name != NULL) free(reg->name);
+free(reg);
+}
+
+
+region *copy_region(region *from, region *to)
+{
+region *retval;
+char *name;
+name = to->name;
+to->name = NULL;
+free_region(to);
+retval = duplicate_region(from, NULL);
+if(retval == NULL) out_of_memory();
+retval->name = name;
+return retval;
+}
+
+
+int create_empty_region(SEA_VIEW *view, const char *name)
+{
+list_regions *old, *new_list;
+region *maregion;
+/* le nom existe-t-il deja? */
+old = view->regions;
+while(old != NULL) {
+ if(strcmp(name, old->element->name) == 0) return FALSE;
+ old = old->next;
+ }
+maregion = (region *)calloc(1,sizeof(region));
+if(maregion == NULL) out_of_memory();
+maregion->name=(char *)malloc(strlen(name)+1);
+if(maregion->name == NULL) out_of_memory();
+strcpy(maregion->name,name);
+new_list = (list_regions *)calloc(1, sizeof(list_regions));
+if(new_list == NULL) out_of_memory();
+new_list->element = maregion;
+/* placer nouvelle region en fin de liste des regions connues */
+if(view->regions == NULL)
+ view->regions = new_list;
+else {
+ old = view->regions;
+ while(old->next != NULL) old = old->next;
+ old->next = new_list;
+ }
+view->active_region = duplicate_region(maregion, name);
+if(view->active_region == NULL) return TRUE; /*mess no mem serait mieux */
+Fl_Menu_Item *items = (Fl_Menu_Item *) ((Fl_Menu_ *)view->menu_file)->menu();
+items[SAVE_REGIONS].activate();
+view->region_length = view->seq_length;
+memset(view->region_line, '-', view->region_length);
+view->region_line[view->region_length] = 0;
+compute_size_params(view, TRUE);
+return TRUE;
+}
+
+
+int rename_current_region(SEA_VIEW *view, const char *name)
+{
+list_regions *old, *new_list;
+region *maregion;
+size_t l;
+char *p;
+
+/* le nom existe-t-il deja? */
+old = view->regions;
+while(old != NULL) {
+ if(strcmp(name, old->element->name) == 0) return FALSE;
+ old = old->next;
+ }
+l = strlen(name);
+p = (char *)calloc(l+1, 1);
+if(p == NULL) return TRUE; /*mess no mem serait mieux */;
+memcpy(p, name, l+1);
+free(view->active_region->name);
+view->active_region->name = p;
+maregion = duplicate_region(view->active_region, name);
+if(maregion == NULL) return TRUE; /*mess no mem serait mieux */
+new_list = (list_regions *)calloc(1, sizeof(list_regions));
+if(new_list == NULL) out_of_memory();
+new_list->element = maregion;
+/* placer nouvelle region en fin de liste des regions connues */
+if(view->regions == NULL)
+ view->regions = new_list;
+else {
+ old = view->regions;
+ while(old->next != NULL) old = old->next;
+ old->next = new_list;
+ }
+Fl_Menu_Item *items = (Fl_Menu_Item *) ((Fl_Menu_ *)view->menu_file)->menu();
+items[SAVE_REGIONS].activate();
+return TRUE;
+}
+
+
+void save_active_region(SEA_VIEW *view, int ask_confirm)
+{ /* save changes in current region */
+list_regions *list;
+list_segments *act_seg, *mem_seg;
+int tmp, taille;
+
+if(view->menu_regions == NULL) return;
+get_menu_taille_valeur(view->menu_regions, &taille, &tmp);
+if(tmp == 0) return;
+list = view->regions;
+if(tmp > 1) while( --tmp) list= list->next;
+/* compare active and region in list */
+act_seg = list->element->list;
+mem_seg = view->active_region->list;
+while ( (act_seg != NULL && mem_seg != NULL) ||
+ (act_seg == NULL && mem_seg == NULL) ) {
+ if( act_seg == NULL && mem_seg == NULL )
+ return;
+ if(act_seg->debut != mem_seg->debut || act_seg->fin != mem_seg->fin)
+ break;
+ act_seg = act_seg->next;
+ mem_seg = mem_seg->next;
+ }
+if(ask_confirm) {
+ char question[200];
+ sprintf(question,
+ "Do you want to save changes\nin current sites selection?\n%s",
+ list->element->name);
+ tmp = fl_ask(question);
+ }
+else tmp = TRUE;
+if(tmp) list->element = copy_region(view->active_region, list->element);
+}
+
+
+void hide_region_line(SEA_VIEW *view)
+{
+free_region(view->active_region);
+view->active_region = NULL;
+Fl_Menu_Item *items = (Fl_Menu_Item *) ((Fl_Menu_ *)view->menu_file)->menu();
+items[SAVE_REGIONS].deactivate();
+compute_size_params(view, TRUE);
+}
+
+
+void delete_region(SEA_VIEW *view, int rang)
+{
+list_regions *list, *previous;
+region *maregion;
+list_segments *segment, *next;
+
+list = view->regions;
+if(rang == 1)
+ view->regions = list->next;
+else {
+ while( --rang) {
+ previous = list;
+ list= list->next;
+ }
+ previous->next = list->next;
+ }
+maregion = list->element;
+segment = maregion->list;
+while(segment != NULL) {
+ next = segment->next;
+ free(segment);
+ segment = next;
+ }
+free(maregion->name);
+free(maregion);
+free(list);
+hide_region_line(view);
+}
+
+
+void activate_region_line(SEA_VIEW *view, int rang)
+{
+list_regions *list;
+list_segments *segment;
+list = view->regions;
+while ( --rang )
+ list = list->next;
+if(view->active_region == NULL) {
+ Fl_Menu_Item *items =
+ (Fl_Menu_Item *) ((Fl_Menu_ *)view->menu_file)->menu();
+ items[SAVE_REGIONS].activate();
+ }
+view->active_region = duplicate_region(list->element, list->element->name);
+view->region_length = view->seq_length;
+memset(view->region_line, '-', view->region_length);
+view->region_line[view->region_length] = 0;
+segment = view->active_region->list;
+while(segment != NULL) {
+ memset(view->region_line + segment->debut - 1, 'X',
+ segment->fin - segment->debut + 1);
+ segment = segment->next;
+ }
+}
+
+
+void ajout_segment(region *maregion, int debut, int fin)
+/* toutes inferferences entre nouveau segment et anciens sont acceptees
+*/
+{
+list_segments *psegment, *next, *prev;
+prev = NULL; psegment = maregion->list;
+while(psegment != NULL) { /* recherche premier segment apres le nouveau */
+ if(debut <= psegment->fin + 1) break;
+ prev = psegment;
+ psegment = psegment->next;
+ }
+if(psegment == NULL || fin < psegment->debut - 1) { /* nouveau sans interference*/
+ next = (list_segments *)calloc(1, sizeof(list_segments));
+ if(next == NULL) out_of_memory();
+ next->debut = debut; next->fin = fin; next->next = psegment;
+ if(prev != NULL) prev->next = next;
+ else maregion->list = next;
+ return;
+ }
+/* nouveau segment interfere avec un(des) autre(s) */
+psegment->debut = FL_min(debut, psegment->debut);
+psegment->fin = FL_max(fin, psegment->fin);
+while(psegment->next != NULL && psegment->fin >= psegment->next->debut - 1) {
+ psegment->fin = FL_max(psegment->fin, psegment->next->fin);
+ next = psegment->next->next;
+ free(psegment->next);
+ psegment->next = next;
+ }
+return;
+}
+
+
+int suppr_segment(region *maregion, int site, char *line)
+/* suppression du segment entier exact contenant le site site
+et la ligne-regions ligne est mise a jour avec des - (sauf si line==NULL)
+valeur rendue TRUE si pas de segment supprime, FALSE si ok.
+*/
+{
+list_segments *psegment, *prev, *next;
+int debut, fin;
+
+psegment = maregion->list; prev = NULL;
+while(psegment != NULL && psegment->fin < site) {
+ prev = psegment;
+ psegment = psegment->next;
+ }
+if(psegment == NULL || psegment->debut > site) return TRUE;
+next = psegment->next; debut = psegment->debut; fin = psegment->fin;
+free(psegment);
+if(prev != NULL) prev->next = next;
+else maregion->list = next;
+if(line != NULL) memset(line+debut-1, '-', fin-debut+1);
+return FALSE;
+}
+
+
+list_segments *get_segment(region *maregion, int site)
+/* rend le segment contenant site ou NULL si site n'est pas dans un segment */
+{
+list_segments *psegment;
+psegment = maregion->list;
+while(psegment != NULL && psegment->fin < site) {
+ psegment = psegment->next;
+ }
+if(psegment == NULL || psegment->debut > site) return NULL;
+return psegment;
+}
+
+
+void draw_region_line(Fl_Widget *ob, SEA_VIEW *view)
+{
+int offset, x, y, l_line;
+
+x = view->x_seq;
+y = view->y_seq + FL_min(view->tot_lines, view->tot_seqs) * view->line_height;
+fl_font(ob->labelfont(),ob->labelsize());
+/* clear the background of the region line */
+fl_color(ob->color());
+fl_rectf(x - view->char_width, y - view->line_height + fl_descent(),
+ (view->tot_sites + 2) * view->char_width, view->line_height);
+/* write region line */
+offset= view->first_site - 1;
+l_line = ( offset + view->tot_sites < view->region_length ?
+view->tot_sites : view->region_length - offset);
+if(l_line <= 0) return;
+fl_color(view->region_color);
+fl_draw(view->region_line + offset, l_line, x, y);
+}
+
+
+void regions_menu_callback(Fl_Widget *ob, void *extra)
+{
+SEA_VIEW *view;
+const char *reg_name;
+int taille, valeur, reponse = ((Fl_Menu_ *)ob)->value() + 1;
+Fl_Menu_Item *items = (Fl_Menu_Item *) ((Fl_Menu_ *)ob)->menu();
+
+if(reponse <= 0 ) return;
+view = (SEA_VIEW *) ((user_data_plus *)extra)->p;
+get_menu_taille_valeur(ob, &taille, &valeur);
+if(reponse == 1) { /* create new region */
+ reg_name = fl_input("New region name?", "all seqs");
+ if(reg_name == NULL) return;
+ if( !create_empty_region(view, reg_name) ) {
+ fl_alert("This name is already used: %s",reg_name);
+ return;
+ }
+ view->DNA_obj->redraw();
+ items[0].deactivate();
+ items[1].activate();
+ items[2].activate();
+ items[3].activate();
+ items[4].activate();
+ ((Fl_Menu_ *)ob)->add(reg_name, 0, NULL, NULL, FL_MENU_RADIO);
+ taille++;
+ update_menu_taille_valeur(ob, taille, taille, 5);
+ }
+else if(reponse == 2) { /* save changes in current region */
+ save_active_region(view, FALSE);
+ }
+else if(reponse == 3) { /* rename current region */
+ reg_name = fl_input("New region name?", "all seqs");
+ if(reg_name == NULL) return;
+ if( !rename_current_region(view, reg_name) ) {
+ fl_alert("This name is already used: %s",reg_name);
+ return;
+ }
+ view->DNA_obj->redraw();
+ ((Fl_Menu_ *)ob)->add(reg_name, 0, NULL, NULL, FL_MENU_RADIO);
+ taille++;
+ update_menu_taille_valeur(ob, taille, taille, 5);
+ }
+else if(reponse == 4) { /* hide current region */
+ hide_region_line(view);
+ view->DNA_obj->redraw();
+ items[0].activate();
+ items[1].deactivate();
+ items[2].deactivate();
+ items[3].deactivate();
+ items[4].deactivate();
+ update_menu_taille_valeur(ob, taille, 0, 5);
+ }
+else if(reponse == 5) { /* delete current region */
+ list_regions *list;
+ char question[200];
+ int tmp;
+ tmp = valeur;
+ list = view->regions;
+ if(tmp > 1) while( --tmp) list= list->next;
+ sprintf(question, "Confirm deletion of region:\n%s",
+ list->element->name);
+ if( fl_ask(question) ) {
+ delete_region(view, valeur);
+ view->DNA_obj->redraw();
+ items[0].activate();
+ items[1].deactivate();
+ items[2].deactivate();
+ items[3].deactivate();
+ items[4].deactivate();
+ ((Fl_Menu_ *)ob)->remove(valeur + 5 - 1);
+ init_menu_taille_valeur(ob, taille - 1, 0, 5);
+ }
+ }
+else { /* choix d'une region courante */
+ valeur = reponse - 5;
+ activate_region_line(view, valeur);
+ compute_size_params(view, TRUE);
+ view->DNA_obj->redraw();
+ update_menu_taille_valeur(ob, taille, valeur, 5);
+ items[0].deactivate();
+ items[1].activate();
+ items[2].activate();
+ items[3].activate();
+ items[4].activate();
+ }
+}
+
+
+static int new_debut, new_fin, prev_site;
+static list_segments *modified_segment;
+
+int begin_change_segment(SEA_VIEW *view, int new_site)
+/*
+returns TRUE si click sur extremite d'un segment ou entre 2 segments, FALSE sinon et enleve le site clique de la region
+*/
+{
+int tmp;
+modified_segment = get_segment(view->active_region, new_site);
+if ( modified_segment != NULL && new_site != modified_segment->debut &&
+ new_site != modified_segment->fin) {
+ /* enlever un site au milieu d'un segment */
+ tmp = modified_segment->fin;
+ modified_segment->fin = new_site - 1;
+ ajout_segment(view->active_region, new_site+1, tmp);
+ view->region_line[new_site - 1] ='-';
+ return FALSE;
+ }
+if(modified_segment != NULL) {
+ new_debut = modified_segment->debut;
+ new_fin = modified_segment->fin;
+ }
+else {
+ new_debut = new_fin = new_site;
+ view->region_line[new_site - 1] ='X';
+ }
+prev_site = new_site;
+return TRUE;
+}
+
+int continue_change_segment(SEA_VIEW *view, int new_site)
+{
+int min;
+char *pos, new_char;
+list_segments *current_segment;
+
+if(new_site == prev_site) return FALSE;
+current_segment = get_segment(view->active_region, new_site);
+if( current_segment != NULL && current_segment != modified_segment)return FALSE;
+pos = view->region_line + new_site - 1;
+if( *pos == '-' ) new_char = 'X';
+else new_char = '-';
+min = FL_min(prev_site, new_site);
+memset( view->region_line + min - 1, new_char, abs(prev_site - new_site) + 1 );
+view->region_line[new_site - 1] = 'X';
+if(new_char == 'X') {
+ new_debut = FL_min(new_debut, new_site);
+ new_fin = FL_max(new_fin, new_site);
+ }
+else {
+ if(new_site > prev_site)
+ new_debut = new_site;
+ else
+ new_fin = new_site;
+ }
+prev_site = new_site;
+return TRUE;
+}
+
+
+void end_change_segment(SEA_VIEW *view)
+{
+if(modified_segment == NULL ) /* nouveau segment */
+ ajout_segment(view->active_region, new_debut, new_fin);
+else {
+ if (new_fin > modified_segment->fin)
+ /* segment rallonge par sa fin */
+ ajout_segment(view->active_region, modified_segment->debut,
+ new_fin);
+ else if( new_fin < modified_segment->fin )
+ /*segment raccourci par sa fin */
+ modified_segment->fin = new_fin;
+ if (new_debut < modified_segment->debut)
+ /* segment rallonge par son debut */
+ ajout_segment(view->active_region, new_debut,
+ modified_segment->fin);
+ else if( new_debut > modified_segment->debut )
+ /* segment raccourci par son debut */
+ modified_segment->debut = new_debut;
+ }
+}
+
+
+int extend_segment_at_left(SEA_VIEW *view, int new_site)
+{
+list_segments *segment;
+
+segment = view->active_region->list;
+if(segment == NULL || segment->debut > new_site) return TRUE;
+if(get_segment(view->active_region, new_site) != NULL) return TRUE;
+while(segment->next != NULL) {
+ if(segment->next->debut > new_site) break;
+ segment = segment->next;
+ }
+memset(view->region_line + segment->fin, 'X', new_site - segment->fin);
+ajout_segment(view->active_region, segment->fin, new_site);
+return FALSE;
+}
+
+
+static void delete_in_region_line(SEA_VIEW *view, int numsite, int total)
+/* delete total sites in pos numsite of view->region_line */
+{
+char *site;
+int l;
+l = view->region_length;
+site = view->region_line + numsite - 1;
+memmove(site - total, site, l - numsite + 2);
+view->region_length -= total;
+}
+
+
+void delete_region_part(SEA_VIEW *view, int numsite, int total)
+{
+int debut, fin;
+list_segments *segment, *previous;
+list_regions *next_region;
+list_regions active;
+
+if(total >= numsite) total = numsite - 1;
+if(total == 0) return;
+if(view->active_region != NULL) delete_in_region_line(view, numsite, total);
+/* pour toutes les regions en commencant par active_region */
+if(view->active_region != NULL) {
+ active.element = view->active_region;
+ active.next = view->regions;
+ next_region = &active;
+ }
+else
+ next_region = view->regions;
+while(next_region != NULL) {
+ segment = next_region->element->list;
+ while(segment != NULL) {
+ debut = segment->debut; fin = segment->fin;
+ if(debut >= numsite) debut -= total;
+ else if(debut >= numsite - total) debut = numsite - total;
+ if(fin >= numsite - total) {
+ fin -= total;
+ if(fin < debut) {
+ debut = segment->debut;
+ segment = segment->next;
+ suppr_segment(next_region->element, debut,
+ NULL);
+ }
+ else {
+ segment->debut = debut;
+ segment->fin = fin;
+ segment = segment->next;
+ }
+ }
+ else
+ segment = segment->next;
+ }
+/* il peut etre necessaire de fusionner 2 segments consecutifs */
+ segment = next_region->element->list;
+ previous = NULL;
+ while(segment != NULL) {
+ if(previous != NULL && segment->debut == previous->fin + 1) {
+ fin = segment->fin;
+ suppr_segment(next_region->element, segment->debut,
+ NULL);
+ ajout_segment(next_region->element, previous->debut,
+ fin);
+ segment = previous;
+ }
+ previous = segment;
+ segment = segment->next;
+ }
+ next_region = next_region->next;
+ }
+}
+
+
+static void insert_in_active_region(SEA_VIEW *view, int numsite, int total)
+/*
+insert total sites in pos numsite of view->region_line and of ->active_region
+*/
+{
+char *site, new_char;
+list_segments *segment;
+
+site = view->region_line + numsite - 1;
+memmove(site + total, site, view->region_length - numsite + 2);
+view->region_length += total;
+segment = view->active_region->list;
+new_char = '-';
+while(segment != NULL) {
+ if(segment->debut <= numsite && segment->fin >= numsite) {
+ new_char = 'X';
+ }
+ if(segment->debut > numsite) segment->debut += total;
+ if(segment->fin >= numsite) segment->fin += total;
+ segment = segment->next;
+ }
+memset(site, new_char, total);
+}
+
+
+void insert_region_part(SEA_VIEW *view, int numsite, int total)
+/* insert total sites in pos numsite of all known regions */
+{
+list_segments *segment;
+list_regions *next_region;
+
+if(total + view->region_length > view->max_seq_length)
+ total = view->max_seq_length - view->region_length;
+if(total == 0) return;
+if(view->active_region != NULL) insert_in_active_region(view, numsite, total);
+next_region = view->regions;
+while(next_region != NULL) {
+ segment = next_region->element->list;
+ while(segment != NULL) {
+ if(segment->debut > numsite) segment->debut += total;
+ if(segment->fin >= numsite) segment->fin += total;
+ segment = segment->next;
+ }
+ next_region = next_region->next;
+ }
+}
+
+
+list_regions *parse_regions_from_header(char *header)
+/* parse the region information from header lines
+and remove it from them
+*/
+{
+char *p, reg_name[200], aux[200], separ[5], *i, *j, *new_header,
+ *fin_new_header, *old_header;
+int nreg, tot_reg, l, *endpoints, l_header;
+region *maregion;
+list_segments *segment;
+list_regions *rlist, *deb_rlist = NULL, *cur_list;
+if(header == NULL) return NULL;
+old_header = header;
+l_header=strlen(header);
+if( (new_header = (char *)malloc(l_header+1)) == NULL) out_of_memory();
+fin_new_header = new_header;
+*new_header = 0;
+while (*header!= 0) {
+ if(strncmp(header,";;#",3) == 0) {
+ p=strchr(header,'=') + 1;
+ while(*p == ' ') p++;
+ sscanf(p,"%d",&tot_reg);
+ endpoints = (int *)malloc(2*tot_reg*sizeof(int));
+ if(endpoints==NULL) out_of_memory();
+ while(*p != ' ' && *p != '\n') p++;
+ while(*p == ' ') p++;
+ if( *p == '\n') { /* no region name in file */
+ strcpy(reg_name, "regions");
+ header = p;
+ }
+ else {
+ header = strchr(p,'\n');
+ memcpy(reg_name, p, header - p);
+ l = header - p;
+ reg_name[l] = 0;
+ while(reg_name[--l]==' ') reg_name[l] = 0;
+ }
+ header++;
+ nreg=0;
+ while(nreg <= 2*tot_reg-1) {
+ j = (char *)memccpy(aux, header, '\n', sizeof(aux));
+ if(j == NULL) goto next_line;
+ *(j - 1) = 0;
+ strcpy(separ,";, "); j=aux;
+ while( (i=strtok(j,separ)) != NULL) {
+ sscanf(i,"%d",&l);
+ if( nreg > 0 &&
+ l <= *(endpoints+nreg-1) - nreg%2 ) {
+ fprintf(stderr,
+ "Region endpoints are not in increasing order: %d\n",l);
+ goto next_line;
+ }
+ *(endpoints + nreg++) = l;
+ j = NULL;
+ }
+ header = strchr(header,'\n') + 1;
+ }
+ maregion = (region *)calloc(1,sizeof(region));
+ if(maregion == NULL) out_of_memory();
+ l=strlen(reg_name);
+ maregion->name = (char *)malloc(l+1);
+ if(maregion->name == NULL) out_of_memory();
+ strcpy(maregion->name, reg_name);
+ for(nreg = 2*tot_reg -1; nreg >= 0; nreg -= 2) {
+ segment = (list_segments *)
+ malloc(sizeof(list_segments));
+ if(segment == NULL) out_of_memory();
+ segment->fin = endpoints[nreg];
+ segment->debut = endpoints[nreg - 1];
+ segment->next = maregion->list;
+ maregion->list = segment;
+ }
+ free(endpoints);
+ rlist = (list_regions *)malloc(sizeof(list_regions));
+ if(rlist == NULL) out_of_memory();
+ rlist->element = maregion;
+ rlist->next = NULL;
+ if(deb_rlist == NULL)
+ deb_rlist = rlist;
+ else {
+ cur_list = deb_rlist;
+ while(cur_list->next != NULL)
+ cur_list = cur_list->next;
+ cur_list->next = rlist;
+ }
+ continue;
+ }
+ else {
+ j=(char *)memccpy(fin_new_header, header, '\n', l_header);
+ fin_new_header += (j - fin_new_header);
+ }
+next_line:
+ header = strchr(header,'\n') + 1;
+ }
+*fin_new_header = 0;
+strcpy(old_header, new_header);
+free(new_header);
+return deb_rlist;
+}
+
+
+void draw_region_background(SEA_VIEW *view, int f_seq0, int l_seq0)
+{
+list_segments *segment;
+int nb_sites, debut, der_site, h, x, y, w, seqnum, y0;
+Fl_Widget *ob = view->DNA_obj;
+
+if(view->active_region == NULL || view->numb_gc == 1) return;
+segment = view->active_region->list;
+if(segment == NULL) return;
+der_site = view->first_site + view->tot_sites - 1;
+if(view->mod_seq == 0) { /* toutes les seqs */
+ h = FL_min(view->tot_lines, view->tot_seqs - view->first_seq + 1) *
+ view->line_height;
+ y0 = view->y_seq - view->line_height + fl_descent();
+ f_seq0 = l_seq0 = 0;
+ }
+else if(view->mod_seq == -1) { /* les seqs selectionnees seulement */
+ h = view->line_height;
+ y0 = view->y_seq - view->line_height + fl_descent() +
+ (f_seq0 + 1 - view->first_seq) * view->line_height;
+ }
+else { /* la seq mod_seq seulement */
+ h = view->line_height;
+ y0 = view->y_seq - view->line_height + fl_descent() +
+ (view->mod_seq - view->first_seq) * view->line_height;
+ f_seq0 = l_seq0 = 0;
+ }
+fl_color(ob->selection_color());
+do {
+ if(segment->debut > der_site) break;
+ if(segment->fin < view->first_site) continue;
+ debut = FL_max(segment->debut, view->first_site);
+ nb_sites = FL_min(segment->fin, der_site) - debut + 1;
+ x = view->x_seq + (debut - view->first_site) * view->char_width;
+ y = y0;
+ w = nb_sites * view->char_width;
+ for(seqnum = f_seq0; seqnum <= l_seq0; seqnum++) {
+ if(view->mod_seq != -1 || view->sel_seqs[seqnum])
+ fl_rectf( x, y, w, h);
+ y += view->line_height;
+ }
+ }
+while( (segment = segment->next) != NULL );
+}
+
+
+char *create_species_set(SEA_VIEW *view, char *set_name)
+{
+int newnumb, i;
+if(view->numb_species_sets >= MAX_SPECIES_SETS)
+ return "Cannot create more sets";
+/* le nom existe-t-il deja? */
+for(i=0; i< view->numb_species_sets; i++) {
+ if(strcmp(set_name, view->name_species_sets[i]) == 0)
+ return "Name already used";
+ }
+newnumb = view->numb_species_sets + 1;
+view->list_species_sets[newnumb-1] = (int *)calloc(view->tot_seqs, sizeof(int));
+if(view->list_species_sets[newnumb-1] == NULL)
+ return "Not enough memory";
+view->name_species_sets[newnumb-1] =
+ (char *)calloc(strlen(set_name)+1, sizeof(char));
+if(view->name_species_sets[newnumb-1] == NULL)
+ return "Not enough memory";
+memcpy(view->list_species_sets[newnumb-1], view->sel_seqs,
+ view->tot_seqs * sizeof(int) );
+strcpy(view->name_species_sets[newnumb-1], set_name);
+view->numb_species_sets = newnumb;
+return NULL;
+}
+
+
+void species_menu_callback(Fl_Widget *ob, void *extra)
+{
+SEA_VIEW *view;
+char *set_name, *message;
+int i, rang, numset, taille, reponse = ((Fl_Menu_ *)ob)->value() + 1;
+
+if(reponse <= 0 ) return;
+view = (SEA_VIEW *) ((user_data_plus *)extra)->p;
+get_menu_taille_valeur(ob, &taille, &rang);
+if(reponse == 1) { /* create new set of species */
+ if(view->tot_sel_seqs == 0) return;
+ set_name = (char *)fl_input("New species set name?", "good seqs");
+ if(set_name == NULL) return;
+ if( (message = create_species_set(view, set_name) ) != NULL ) {
+ fl_alert("%s\n%s", message, set_name);
+ return;
+ }
+ ((Fl_Menu_ *)ob)->add(set_name, 0, NULL, NULL, FL_MENU_RADIO);
+ taille++;
+ update_menu_taille_valeur(ob, taille, taille, 2);
+ Fl_Menu_Item *items = (Fl_Menu_Item *) ((Fl_Menu_ *)ob)->menu();
+ items[0].deactivate();
+ items[1].activate();
+ }
+else if( reponse == 2) { /* effacer un set */
+ Fl_Menu_Item *items = (Fl_Menu_Item *) ((Fl_Menu_ *)ob)->menu();
+ items[1].deactivate();
+ if(rang == 0) return; /* par securite */
+ numset = rang - 1;
+ ((Fl_Menu_ *)view->menu_species)->remove(numset + 3 - 1);
+ init_menu_taille_valeur(view->menu_species, taille - 1, 0, 2);
+ free(view->list_species_sets[numset]);
+ free(view->name_species_sets[numset]);
+ memcpy(view->list_species_sets + numset,
+ view->list_species_sets + numset + 1,
+ (view->numb_species_sets - numset - 1)*sizeof(int *) );
+ memcpy(view->name_species_sets + numset,
+ view->name_species_sets + numset + 1,
+ (view->numb_species_sets - numset - 1)*sizeof(char *) );
+ (view->numb_species_sets)--;
+ view->tot_sel_seqs = 0;
+ memset(view->sel_seqs, 0, view->tot_seqs * sizeof(int));
+ view->DNA_obj->redraw();
+ }
+else { /* choix d'un set courant */
+ int minvis, maxvis, visible = FALSE, premier = 0;
+ rang = reponse - 2;
+ memcpy(view->sel_seqs, view->list_species_sets[rang-1],
+ view->tot_seqs * sizeof(int) );
+ view->tot_sel_seqs = 0;
+ minvis = view->first_seq; maxvis = minvis + view->tot_lines - 1;
+ for(i=0; i< view->tot_seqs; i++)
+ if(view->sel_seqs[i]) {
+ ++(view->tot_sel_seqs);
+ if(!visible) visible = (i+1 >= minvis && i+1 <= maxvis);
+ if(premier == 0) premier = i + 1;
+ }
+ if(premier != 0 && !visible ) {
+ int maxi;
+ maxi = (int)((Fl_Slider *)view->vertsli)->maximum();
+ if(premier > maxi) premier = maxi;
+ view->first_seq = premier;
+ ((Fl_Slider *)view->vertsli)->value(premier);
+ }
+ view->DNA_obj->redraw();
+ update_menu_taille_valeur(ob, taille, rang, 2);
+ Fl_Menu_Item *items = (Fl_Menu_Item *) ((Fl_Menu_ *)ob)->menu();
+ items[1].activate();
+ adjust_menu_edit_modes(view);
+ }
+}
+
+
+void get_menu_taille_valeur(Fl_Widget *menu, int *taille, int *valeur)
+{
+user_data_plus *extra = (user_data_plus *)menu->user_data();
+int u_ldata = extra->value;
+*taille = u_ldata / 100;
+*valeur = u_ldata % 100;
+}
+
+
+void init_menu_taille_valeur(Fl_Widget *obj, int taille, int valeur,
+ int offset)
+{
+int i;
+Fl_Menu_ *menu = (Fl_Menu_ *)obj;
+
+for(i = 1; i <= taille; i++) menu->mode(offset + i - 1, FL_MENU_RADIO);
+if(valeur != 0) menu->mode(offset + valeur - 1, FL_MENU_RADIO | FL_MENU_VALUE);
+int u_ldata = 100 * taille + valeur;
+user_data_plus *extra = (user_data_plus *)menu->user_data();
+extra->value = u_ldata;
+}
+
+
+void update_menu_taille_valeur(Fl_Widget *obj, int taille, int valeur,
+ int offset)
+{
+int old_taille, old_valeur;
+Fl_Menu_ *menu = (Fl_Menu_ *)obj;
+
+get_menu_taille_valeur(menu, &old_taille, &old_valeur);
+if(valeur != old_valeur) {
+ if(old_valeur != 0)
+ menu->mode(offset + old_valeur - 1, FL_MENU_RADIO);
+ if(valeur != 0)
+ menu->mode(offset + valeur - 1, FL_MENU_RADIO | FL_MENU_VALUE);
+ }
+int u_ldata = 100 * taille + valeur;
+user_data_plus *extra = (user_data_plus *)menu->user_data();
+extra->value = u_ldata;
+}
+
+
+int parse_species_sets_from_header(char *header, int **list_species_sets,
+ char **name_species_sets, int totseqs)
+/* parse the species sets information from header lines
+and remove it from them
+*/
+{
+char *p, set_name[200], aux[200], separ[5], *i, *j, *new_header,
+ *fin_new_header, *old_header;
+int numset, tot_spec, l, l_header, num;
+if(header == NULL) return 0;
+old_header = header;
+l_header=strlen(header);
+if( (new_header = (char *)malloc(l_header+1)) == NULL) out_of_memory();
+fin_new_header = new_header;
+*new_header = 0;
+numset = -1;
+while (*header!= 0) {
+ if(strncmp(header,";;@",3) == 0) {
+ numset++;
+ p=strchr(header,'=') + 1;
+ while(*p == ' ') p++;
+ sscanf(p,"%d",&tot_spec);
+ list_species_sets[numset] = (int *)calloc(totseqs, sizeof(int));
+ if(list_species_sets[numset]==NULL) out_of_memory();
+ while(*p != ' ' && *p != '\n') p++;
+ while(*p == ' ') p++;
+ if( *p == '\n') { /* no set name in file */
+ strcpy(set_name, "species set");
+ header = p;
+ }
+ else {
+ header = strchr(p,'\n');
+ memcpy(set_name, p, header - p);
+ l = header - p;
+ set_name[l] = 0;
+ while(set_name[--l]==' ') set_name[l] = 0;
+ }
+ l = (int) strlen(set_name);
+ name_species_sets[numset] = (char *)malloc(l+1);
+ if(name_species_sets[numset] == NULL) out_of_memory();
+ memcpy(name_species_sets[numset], set_name, l+1);
+ header++;
+ num = 0;
+ while(num < tot_spec) {
+ j = (char *)memccpy(aux, header, '\n', sizeof(aux));
+ if(j == NULL) goto next_line;
+ *(j - 1) = 0;
+ strcpy(separ,";, "); j=aux;
+ while( (i=strtok(j,separ)) != NULL) {
+ sscanf(i,"%d",&l);
+ if( l>= 1 && l <= totseqs)
+ list_species_sets[numset][l-1] = 1;
+ num++;
+ j = NULL;
+ }
+ header = strchr(header,'\n') + 1;
+ }
+ continue;
+ }
+ else {
+ j=(char *)memccpy(fin_new_header, header, '\n', l_header);
+ fin_new_header += (j - fin_new_header);
+ }
+next_line:
+ header = strchr(header,'\n') + 1;
+ }
+*fin_new_header = 0;
+strcpy(old_header, new_header);
+free(new_header);
+return numset + 1;
+}
Added: trunk/packages/seaview/branches/upstream/current/resource.cxx
===================================================================
--- trunk/packages/seaview/branches/upstream/current/resource.cxx (rev 0)
+++ trunk/packages/seaview/branches/upstream/current/resource.cxx 2006-09-19 14:20:14 UTC (rev 111)
@@ -0,0 +1,193 @@
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+// included functions
+void decodecolorname(char *colname, int *r, int *g, int *b);
+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);
+
+
+#if defined(__APPLE__)
+
+char *load1res(char *resname)
+{
+ char **h, *p, pname[256];
+ int l;
+
+ strcpy(pname + 1, resname);
+ pname[0] = strlen(resname);
+ 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;
+}
+
+void decodecolorname(char *colname, int *r, int *g, int *b)
+{
+;
+}
+
+
+#elif defined(WIN32)
+
+#include <fcntl.h>
+
+void decodecolorname(char *colname, int *r, int *g, int *b)
+{
+;
+}
+
+extern "C" {
+char *get_prog_dir(void);
+}
+
+/* !!! en debut de programme, l'utilisation de stdio fait planter le progr !!! */
+void *load_resources(char *progname)
+{
+char fname[200];
+char *buf;
+int in, total;
+strcpy(fname, get_prog_dir());
+strcat(fname, "seaview.ini");
+in = open(fname, O_RDONLY);
+if(in == -1) return NULL;
+total = lseek(in, 0, SEEK_END);
+buf = (char *)malloc(total + 1);
+if(buf != NULL) {
+ lseek(in, 0, SEEK_SET);
+ read(in, buf, total);
+ buf[total] = 0;
+ }
+close(in);
+return (void *)buf;
+}
+
+char *get_res_value(char *name, char *def_value, void *v_db)
+{
+char *p, *q, *db = (char *)v_db;
+static char value[200];
+int l;
+if(db == NULL) return def_value;
+p = db; l = strlen(name);
+while(strncmp(p, name, l) != 0 || (*(p + l) != '=' && *(p + l) != ' ') ) {
+ p = strchr(p, '\n');
+ if(p == NULL) return def_value;
+ p++;
+ }
+p += l;
+while( *p == ' ' || *p == '=' ) p++;
+q = strchr(p, '\n');
+if(q == NULL) q = p + strlen(p);
+memcpy(value, p, q - p); value[q - p] = 0; if(value[q - p - 1] == '\r') value[q - p - 1] = 0;
+return value;
+}
+
+#else
+
+#include <X11/Xlib.h>
+#include <X11/Xresource.h>
+#include <FL/x.H>
+#include <ctype.h>
+
+void decodecolorname(char *colname, int *r, int *g, int *b)
+/* decodes color name and returns rgb in [0,255] */
+{
+int status;
+XColor exact, couleur;
+status = XLookupColor(fl_display, fl_colormap, colname, &exact, &couleur);
+if(status == 0) return;
+*r = couleur.red >> 8;
+*g = couleur.green >> 8;
+*b = couleur.blue >> 8;
+}
+
+
+void *load_resources(char *progname)
+{
+XrmDatabase db = NULL;
+char *rm, fname[100], Pname[50];
+strcpy(Pname, progname); Pname[0] = toupper(Pname[0]);
+fl_open_display();
+XrmInitialize();
+strcpy(fname, "/usr/lib/X11/app-defaults/");
+strcat(fname, Pname);
+XrmCombineFileDatabase(fname, &db, 1);
+rm = getenv("XAPPLRESDIR");
+if(rm != NULL) {
+ strcpy(fname, rm);
+ strcat(fname, "/");
+ strcat(fname, Pname);
+ XrmCombineFileDatabase(fname, &db, 1);
+ }
+// ajouter resources de xrdb
+rm = XResourceManagerString(fl_display);
+if(rm != NULL) XrmMergeDatabases(XrmGetStringDatabase(rm), &db);
+rm = XScreenResourceString(ScreenOfDisplay(fl_display, fl_screen));
+if(rm != NULL) {
+ XrmMergeDatabases(XrmGetStringDatabase(rm), &db);
+ XFree(rm);
+ }
+return (void *)db;
+}
+
+
+char *get_res_value(char *name, char *def_value, void *v_db)
+{
+static char full_name[100] = "Seaview.";
+static const int pre_len = (int)strlen(full_name);
+XrmDatabase db = (XrmDatabase)v_db;
+char *res_type;
+XrmValue valeur;
+strcpy(full_name + pre_len, name);
+int status = XrmGetResource(db, full_name, NULL, &res_type, &valeur);
+return (status ? valeur.addr : def_value);
+}
+
+#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');
+}
+
Added: trunk/packages/seaview/branches/upstream/current/seaview.cxx
===================================================================
--- trunk/packages/seaview/branches/upstream/current/seaview.cxx (rev 0)
+++ trunk/packages/seaview/branches/upstream/current/seaview.cxx 2006-09-19 14:20:14 UTC (rev 111)
@@ -0,0 +1,4218 @@
+#include "seaview.h"
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <ctype.h>
+#include "FL/Fl_Double_Window.H"
+#include "FL/Fl_Pack.H"
+
+
+/* allongement maximal prevu pour les seqs suite a edition */
+#define MAX_SEQ_ALLONG 5000
+#define MINI_MAX_LENGTH 10000 /* pour depart avec fichier vide */
+
+/*
+Purpose
+resource argument type default exemple
+
+Default file format for saving operations
+save -save {mase, phylip, mase phylip
+ clustal, msf, fasta, nexus}
+
+Control of printout options
+printoutblock N/A integer 10 3
+printoutcpl N/A integer 80 90
+ [this is the paper width, not the # of residues desired on each line]
+printoutlpp N/A integer 66 90
+Name of help file
+helpfile N/A string "seaview.help"
+
+Standard coloring of protein sequences (<= 10 colors + white for gaps)
+(colors are red, green, yellow, blue, cyan, magenta, salmon, purple, aquamarine,
+and dark-gray)
+stdcolorgroups N/A string EDQNHRKBZ,ILMV,APSGT,FY,WC
+ BZDE,ACWY,FGHIK,LMNPQRSTV
+Alternate coloring of protein sequences
+altcolorgroups N/A string \0 AC,DEFGHIK,LMNPQRS,WY,TV
+
+Faster but less smooth writing
+fast -fast no-value False
+
+Residues colored on background
+inverted -inverted no-value False
+
+N/A filename
+*/
+
+Fl_Group *create_dna_scroller(SEA_VIEW *view, int x, int y, int w, int h,
+ int dbl_buff);
+SEA_VIEW *create_the_form(int double_buffer, int inverted,
+ known_format default_format, int numb_dnacolors,
+ int *dnacolors,
+ int numb_stdprotcolors, int *stdprotcolors,
+ int numb_altprotcolors, int *altprotcolors,
+ color_choice curr_color_choice, char *progname, char *movekeys,
+ char *win_size, int allow_lower, char *help_file);
+int prep_custom_colors(int *colors, char *customcolors,
+ int max_colors);
+color_choice prep_aa_color_code(char *list_std, char *list_alt,
+ int maxprotcolors, int *numb_stdprotcolors, int *numb_altprotcolors);
+void deplacer_grp_seqs(SEA_VIEW *view, int target);
+void del_gap_only_sites(SEA_VIEW *view);
+void reference_toggle(SEA_VIEW *view, int on);
+void handle_mouse(SEA_VIEW *view, int mx, int my,
+ int *p_selecting_seqs, int *p_sel_seq_move, int *p_modifying_segment);
+void handle_keyboard(SEA_VIEW *view, unsigned int key, int istext);
+void handle_push(SEA_VIEW *view, int mx, int my, int key,
+ int *p_modifying_segment, int *p_selecting_seqs, int *p_sel_seq_move);
+int delete_gaps_before(SEA_VIEW *view, int numseq, int numsite, int total);
+void set_save_format(SEA_VIEW *view, int val);
+void use_initial_file(SEA_VIEW *view, char *masename);
+
+/* external functions */
+void draw_comment_lines(Fl_Widget *ob, SEA_VIEW *view);
+void get_menu_taille_valeur(Fl_Widget *menu, int *taille, int *valeur);
+void init_menu_taille_valeur(Fl_Widget *menu, int taille, int valeur,
+ int offset);
+void update_menu_taille_valeur(Fl_Widget *menu, int taille, int valeur,
+ int offset);
+char* fl_file_chooser_plus(const char* message, const char* pat,
+ const char* fname, int use_only_button);
+char* fl_file_chooser_save_as(const char* message, const char* pat,
+ const char* fname, void *view);
+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);
+void decodecolorname(char *colname, int *r, int *g, int *b);
+void minuscules(char *);
+known_format what_format(const char *filename);
+#ifdef __APPLE__
+extern "C" {
+ void MGinit_apple_events(SEA_VIEW *view);
+ void add_apropos(char *progname);
+ }
+#endif
+
+/* variables globales */
+/* pour controle parametres option printout */
+int printout_block;
+int printout_cpl;
+int printout_lpp;
+int printout_vary = FALSE;
+char *f_format_names[] = {"Mase", "Phylip", "Clustal", "MSF", "Fasta", "NEXUS"};
+int nbr_formats = sizeof(f_format_names)/sizeof(char *);
+int emul_3_buttons;
+
+
+#ifdef WIN32
+#define LINE_HEIGHT_FACTOR 0.85
+#else
+#define LINE_HEIGHT_FACTOR 1.
+#endif
+
+
+int main(int argc, char *argv[])
+{
+char *masename, *progname;
+known_format defaultformat;
+static int dnacolors[] =
+ { FL_WHITE, FL_RED, FL_GREEN, FL_YELLOW, FL_BLUE };
+int numb_dnacolors = sizeof(dnacolors) / sizeof(int);
+static int protcolors[] =
+ { FL_WHITE, FL_RED, FL_GREEN, FL_YELLOW, FL_BLUE, FL_CYAN,
+ FL_MAGENTA, 9/*salmon*/, 13/*purple*/, 14/*aquamarine*/, 8/*darkgray*/};
+int max_protcolors = sizeof(protcolors) / sizeof(int);
+static char def_stdcolorgroups[] = "EDQNHRKBZ,ILMV,APSGT,FY,WC";
+int numb_stdprotcolors, numb_altprotcolors, i;
+color_choice curr_color_choice;
+
+static int quick_and_dirty, inverted, allow_lower;
+static char stdcolorgroups[50], altcolorgroups[50];
+static char customdnacolors[200];
+static char customprotcolors[300];
+char **possible_formats;
+int def_format = 0;
+static char save_format[10];
+static char movekeys[5], win_size[12];
+static char *help_file;
+void *resources;
+
+progname = (char *)"seaview";
+resources = load_resources(progname);
+
+possible_formats = (char **)malloc(nbr_formats * sizeof(char *));
+for(i= 0; i < nbr_formats; i++) {
+ possible_formats[i] = (char *)malloc( strlen(f_format_names[i]) + 1 );
+ strcpy(possible_formats[i], f_format_names[i]);
+ minuscules(possible_formats[i]);
+ }
+
+/* access to resources */
+quick_and_dirty = bool_res_value("fast", 0, resources);
+inverted = bool_res_value("inverted", 0, resources);
+strcpy(save_format, get_res_value("save", possible_formats[def_format], resources) );
+strcpy(stdcolorgroups,
+ get_res_value("stdcolorgroups", def_stdcolorgroups, resources) );
+strcpy(altcolorgroups, get_res_value("altcolorgroups", "", resources) );
+printout_block = int_res_value("printoutblock", 10, resources);
+printout_cpl = int_res_value("printoutcpl", 80, resources);
+printout_lpp = int_res_value("printoutlpp", 66, resources);
+allow_lower = bool_res_value("lowercase", 0, resources);
+help_file = get_res_value("helpfile",
+#ifdef WIN32
+ "seaview.hlp",
+#elif defined(__APPLE__)
+ NULL,
+#else
+ "seaview.help",
+#endif
+ resources );
+strcpy(customdnacolors, get_res_value("dnacolors", "", resources) );
+strcpy(customprotcolors, get_res_value("protcolors", "", resources) );
+strcpy(movekeys, get_res_value("movekeys", "][><", resources) );
+strcpy(win_size, get_res_value("window",
+#if defined(WIN32) || defined(__APPLE__)
+ "700x500",
+#else
+ "1000x700",
+#endif
+ resources) );
+#if defined(WIN32) || defined(__APPLE__)
+ emul_3_buttons = TRUE;
+#else
+ emul_3_buttons = bool_res_value("emulate_3_b", FALSE, resources);
+#endif
+
+/* process custom color settings */
+prep_custom_colors(dnacolors, customdnacolors, numb_dnacolors);
+max_protcolors = prep_custom_colors(protcolors, customprotcolors,
+ max_protcolors);
+/* process resource-read stdcolorgroups and altcolorgroups */
+curr_color_choice = prep_aa_color_code(stdcolorgroups, altcolorgroups,
+ max_protcolors, &numb_stdprotcolors, &numb_altprotcolors);
+
+/* argument processing */
+masename = NULL;
+i = 1;
+while(i < argc) {
+ if(argv[i][0] != '-') masename = argv[i];
+ if(strcmp(argv[i], "-fast") == 0) quick_and_dirty = TRUE;
+ if(strcmp(argv[i], "-inverted") == 0) inverted = TRUE;
+ if(strcmp(argv[i], "-save") == 0)
+ if(++i < argc) strcpy(save_format, argv[i]);
+ i++;
+ }
+for( i=0; i < nbr_formats; i++)
+ if(strcmp(save_format, possible_formats[i]) == 0) break;
+if( i >= nbr_formats )
+ defaultformat = (known_format)MASE_FORMAT;
+else
+ defaultformat = (known_format)i;
+
+fl_message_font(FL_HELVETICA_BOLD, FL_NORMAL_SIZE );
+
+SEA_VIEW *view = create_the_form(!quick_and_dirty, inverted,
+ defaultformat, numb_dnacolors, dnacolors,
+ numb_stdprotcolors, protcolors,
+ numb_altprotcolors, protcolors, curr_color_choice,
+ progname, movekeys, win_size, allow_lower, help_file);
+#ifdef __APPLE__
+MGinit_apple_events(view);
+add_apropos(progname);
+#else
+if(masename != NULL) use_initial_file(view, masename);
+#endif
+view->dnawin->show();
+fl_reset_cursor(view->dnawin);
+// Fl::run(); ici bug ou focus est perdu des que autre fenetre utilisee
+while( Fl::wait() ) { // reparation du bug
+ if(Fl::focus() == NULL) {
+ view->DNA_obj->take_focus();
+ }
+ }
+return 0;
+}
+
+
+void use_initial_file(SEA_VIEW *view, char *masename)
+{
+known_format defaultformat;
+
+defaultformat = what_format(masename);
+if(defaultformat >= 0) {
+ set_save_format(view, defaultformat);
+ load_alignment_file(view, masename, NULL, NULL, defaultformat);
+ }
+else
+ fl_alert("File %s\nis not of a format readable by seaview", masename);
+}
+
+
+#ifdef _AIX
+/* sur IBM RISC __filbuf est en fait _filbuf utilise a l'interieur de xforms */
+int __filbuf(FILE *fich)
+{
+return _filbuf(fich);
+}
+#endif
+
+
+class DNA_obj : public Fl_Widget {
+ FL_EXPORT void draw(void);
+ FL_EXPORT int handle(int);
+public:
+ FL_EXPORT DNA_obj(int x,int y,int w,int h, void *view) :
+ Fl_Widget(x,y,w,h,NULL) {
+ this->user_data(view);
+ }
+};
+
+
+char *majuscules(char *p)
+{
+char *q = p;
+if(p == NULL) return NULL;
+while(*q != 0) { *q = toupper(*q); q++; }
+return p;
+}
+
+
+void out_of_memory(void)
+{
+fl_alert("Error: Not enough memory!");
+exit(1);
+}
+
+
+void minuscules(char *p)
+{
+if(p == NULL) return;
+while(*p) {
+ *p = tolower(*p);
+ p++;
+ }
+return;
+}
+
+
+char *extract_filename(char *fname)
+{
+static char *p, *q;
+q = (char *)fname;
+if(q == NULL) return "";
+do {
+#ifdef __VMS
+ p = strchr(q,']');
+ if(p == NULL) p = strchr(q,':');
+#elif defined(WIN32)
+ p = strchr(q,'\\');
+#elif defined(__APPLE__)
+ p = strchr(q,':');
+#else
+ p = strchr(q,'/');
+#endif
+ if(p != NULL) q = p+1;
+ }
+while (p != NULL);
+return q;
+}
+
+
+void allonge_seqs(char **seq, int totseqs, int maxlen, int *eachlength,
+ int tot_comment_lines, char **comment_line)
+{
+int num, l;
+char *newseq;
+
+for(num = 0; num < totseqs; num++) {
+ l = eachlength[num];
+ newseq = (char *)malloc(maxlen+1);
+ if(newseq==NULL) out_of_memory();
+ memcpy(newseq,seq[num],l+1);
+ free(seq[num]);
+ seq[num] = newseq;
+ }
+for(num = 0; num < tot_comment_lines; num++) {
+ l = strlen(comment_line[num]);
+ newseq = (char *)malloc(maxlen+1);
+ if(newseq == NULL) out_of_memory();
+ memcpy(newseq, comment_line[num], l+1);
+ free(comment_line[num]);
+ comment_line[num] = newseq;
+ }
+}
+
+
+/* memoire pour contenir coloriage standard */
+static int color_for_aa_gaps;
+static char std_aminoacids[30];
+static int std_aa_color[30];
+/* memoire pour contenir coloriage alternatif */
+static char alt_aminoacids[30] = "";
+static int alt_aa_color[30];
+/* pointeurs vers coloriage courant */
+static char *current_aminoacids;
+static int *current_aa_color;
+
+
+int decode_color_scheme(char *list, char *aminoacids, int *aa_color,
+ int maxprotcolors)
+{
+int nbr_colors = 1, current = 0, i;
+char *p;
+aminoacids[0] = 0;
+p=strtok(list,",");
+while( p!= NULL && nbr_colors < maxprotcolors) {
+ strcat(aminoacids,p);
+ for(i=0; i < (int) strlen(p); i++)
+ aa_color[current++] = nbr_colors;
+ nbr_colors++;
+ p=strtok(NULL,",");
+ }
+return nbr_colors;
+}
+
+
+int prep_custom_colors(int *colors, char *customcolors,
+ int max_colors)
+{
+char *nom;
+int rank = 0, r, g, b;
+Fl_Color col;
+
+if(*customcolors == 0) return max_colors;
+nom = strtok(customcolors, ",");
+while(nom != NULL && rank < max_colors - 1) {
+ r = g = b = -1;
+ sscanf(nom, "%d%d%d", &r, &g, &b);
+ if( r<0 || g<0 || b<0 ) decodecolorname(nom, &r, &g, &b);
+ if( r>=0 && g>=0 && b>=0 )
+ col = fl_color_cube(r*FL_NUM_RED/256, g*FL_NUM_GREEN/256,
+ b*FL_NUM_BLUE/256);
+ else col = FL_BLACK;
+ colors[++rank] = (int)col;
+ nom = strtok(NULL, ",");
+ }
+return rank + 1;
+}
+
+
+color_choice prep_aa_color_code(char *list_std, char *list_alt,
+ int maxprotcolors, int *numb_stdprotcolors, int *numb_altprotcolors)
+{
+/* couleur pour gaps = 1ere couleur connue (comptee a partir de 0) */
+color_for_aa_gaps = 0;
+current_aminoacids = std_aminoacids;
+current_aa_color = std_aa_color;
+/* decodage du coloriage standard des proteines */
+*numb_stdprotcolors =
+ decode_color_scheme(list_std, std_aminoacids, std_aa_color,
+ maxprotcolors);
+if(*list_alt == 0) return NO_ALT_COLORS;
+/* decodage du coloriage alternatif des proteines */
+*numb_altprotcolors =
+ decode_color_scheme(list_alt, alt_aminoacids, alt_aa_color,
+ maxprotcolors);
+return USING_STANDARD_COLORS;
+}
+
+
+void set_aa_color_mode(color_choice choice)
+{
+if(choice == USING_ALT_COLORS) {
+ current_aminoacids = alt_aminoacids;
+ current_aa_color = alt_aa_color;
+ }
+else {
+ current_aminoacids = std_aminoacids;
+ current_aa_color = std_aa_color;
+ }
+}
+
+
+int get_color_for_aa( int key )
+/* returns the color # used to display character key in protein */
+{
+char *pos;
+pos = strchr(current_aminoacids, toupper(key) );
+return ( pos == NULL ?
+ color_for_aa_gaps : current_aa_color[pos - current_aminoacids] );
+}
+
+
+int get_color_for_base( int key )
+/* returns the color # used to display character key in DNA */
+{
+static char bases[]="ACGTU";
+static int base_color[] = {1,2,3,4,4};
+char *pos;
+pos=strchr(bases, toupper(key) );
+return ( pos == NULL ? 0 : base_color[pos - bases] );
+}
+
+
+char ***prepcolseqs(char **seq, int totseqs, int maxlen, int *eachlength,
+ int (*calc_color_function)( int ), int numb_gc, int allow_lower)
+{
+int num, l, col, i, res;
+char ***colseq;
+if(totseqs == 0 || numb_gc == 1) return NULL;
+colseq=(char ***)malloc(totseqs*sizeof(char **));
+if(colseq == NULL) out_of_memory();
+for(num=0; num<totseqs; num++) {
+ colseq[num] = (char **)malloc(numb_gc * sizeof(char *));
+ if(colseq[num] == NULL) out_of_memory();
+ l = eachlength[num];
+ for(col=0; col < numb_gc; col++) {
+ colseq[num][col]=(char *)malloc(maxlen+1);
+ if(colseq[num][col] == NULL) out_of_memory();
+ memset(colseq[num][col], ' ', l);
+ colseq[num][col][l]=0;
+ }
+ for(i=0; i<l; i++) {
+ res = seq[num][i];
+ col = calc_color_function( res );
+ colseq[num][col][i] = ( allow_lower ? res : toupper(res) );
+ }
+ }
+return colseq;
+}
+
+
+char ***prepcolseqs_by_difference(char **seq, int totseqs, int ref_seq0,
+ int maxlen, int *eachlength,
+ int (*calc_color_function)( int ), int numb_gc, int allow_lower)
+{
+int num, l, col, i, res;
+char ***colseq;
+if(totseqs == 0) return NULL;
+colseq = (char ***)malloc(totseqs*sizeof(char **));
+if(colseq == NULL) return NULL;
+for(num=0; num<totseqs; num++) { /* allocation memoire */
+ colseq[num] = (char **)malloc(numb_gc * sizeof(char *));
+ if(colseq[num] == NULL) return NULL;
+ l = eachlength[num];
+ for(col=0; col < numb_gc; col++) {
+ colseq[num][col]=(char *)malloc(maxlen+1);
+ if(colseq[num][col] == NULL) return NULL;
+ memset(colseq[num][col], ' ', l);
+ colseq[num][col][l]=0;
+ }
+ }
+for(i=0; i<eachlength[ref_seq0]; i++) { /* coloration seq de reference */
+ res = seq[ref_seq0][i];
+ col = calc_color_function( res );
+ colseq[ref_seq0][col][i] = ( allow_lower ? res : toupper(res) );
+ }
+for(num=0; num<totseqs; num++) { /* coloration des autres sequences */
+ if(num == ref_seq0) continue;
+ l = eachlength[num];
+ for(i=0; i<l; i++) {
+ res = seq[num][i];
+ if(toupper(res) != toupper(seq[ref_seq0][i])) {
+ col = calc_color_function( res );
+ colseq[num][col][i] =(allow_lower ? res : toupper(res));
+ }
+ else {
+ colseq[num][0][i] = '.';
+ }
+ }
+ }
+return colseq;
+}
+
+
+void draw_cursor(Fl_Widget *ob, int on_off, int site, int seq,
+ int cursor_in_comment)
+{
+SEA_VIEW *view = (SEA_VIEW *)ob->user_data() ;
+int x, y, cursor_x, cursor_y, c, max_curs_coord;
+char *debut, *fin;
+int background, foreground;
+static char lettre[]="A";
+static char cursor_coord[100];
+
+if( (!cursor_in_comment) && (seq == 0 || site > view->each_length[seq-1] + 1) )
+ return;
+cursor_x = site - view->first_site;
+if(cursor_in_comment) {
+ if(view->tot_comment_lines == 0 || !view->show_comment_lines) return;
+ if(cursor_x < 0 || cursor_x >= view->tot_sites ) return;
+ if(seq <= 0 || seq > view->tot_comment_lines ) return;
+ y = view->y_seq + (seq + view->pos_first_comment_line - 2) *
+ view->line_height;
+ x = view->x_seq + cursor_x * view->char_width;
+ lettre[0] = view->comment_line[seq-1][site-1];
+ }
+else {
+ if(view->tot_seqs == 0) return;
+ cursor_y = seq - view->first_seq;
+ if(cursor_x < 0 || cursor_x >= view->tot_sites ) return;
+ if(cursor_y < 0 || cursor_y >= view->tot_lines ) return;
+ y = view->y_seq + cursor_y * view->line_height;
+ x = view->x_seq + cursor_x * view->char_width;
+ lettre[0] = view->sequence[seq-1][site-1];
+ }
+if(view->numb_gc == 1) { /* cas noir et blanc */
+ if(on_off) {
+ foreground = FL_WHITE;
+ background = FL_BLACK;
+ }
+ else {
+ foreground = FL_BLACK;
+ background = FL_WHITE;
+ }
+ }
+else if( (!cursor_in_comment) && view->inverted_colors) {
+ /* cas inverted colors */
+ if(site <= view->each_length[seq - 1]) {
+ for(c=0; c<view->numb_gc; c++)
+ if(view->col_seq[seq-1][c][site-1] != ' ') break;
+ if(c == 0) background = ob->color();
+ else background = view->curr_colors[c];
+ }
+ else
+ background = ob->color();
+ if(on_off) {
+ foreground = background;
+ background = FL_BLACK;
+ }
+ else {
+ if(view->active_region == NULL ||
+ view->region_line[site - 1] == 'X')
+ foreground = FL_BLACK;
+ else
+ foreground = ob->selection_color();
+ }
+ }
+else if(cursor_in_comment) { /* dans les lignes comment sur ecran couleur */
+ if(on_off) {
+ foreground = FL_WHITE; background = FL_BLACK;
+ }
+ else {
+ foreground = FL_BLACK; background = ob->color();
+ }
+ }
+else { /* cas colored letters */
+ if( site <= view->each_length[seq - 1]) {
+ for(c=0; c<view->numb_gc; c++)
+ if(view->col_seq[seq-1][c][site-1] != ' ') break;
+ lettre[0] = view->col_seq[seq-1][c][site-1];
+ foreground = view->curr_colors[c];
+ }
+ else {
+ lettre[0] = ' ';
+ foreground = FL_BLACK;
+ }
+ if(on_off) {
+ background = FL_BLACK;
+ }
+ else {
+ if( (!cursor_in_comment) && view->active_region != NULL &&
+ view->region_line[site - 1] == 'X')
+ background = ob->selection_color();
+ else
+ background = ob->color();
+ }
+ }
+fl_font(ob->labelfont(), ob->labelsize());
+fl_color(background);
+fl_rectf( x, y - view->line_height + fl_descent(),
+ view->char_width, view->line_height);
+fl_color(foreground);
+fl_draw(lettre, 1, x, y);
+if(on_off) {
+/* ecriture des coordonnees du curseur */
+ max_curs_coord = view->tot_sites - 12;
+ cursor_coord[max_curs_coord] = 0;
+ x = view->x_seq + 6 * view->char_width;
+ y = view->y_seq - view->line_height;
+ fl_font(FL_COURIER, ob->labelsize());
+ fl_color(ob->color());
+ fl_rectf( x, y - view->line_height,
+ (max_curs_coord ) * view->char_width,
+ view->line_height + fl_descent());
+ if(!cursor_in_comment) {
+ debut = view->sequence[seq-1] - 1; fin = debut + site; c = 0;
+ if(*fin == 0) fin--;
+ while(++debut <= fin) if( *debut != '-' ) c++;
+ sprintf(cursor_coord, "Seq:%d Pos:%d|%d [%s]", seq,
+ site, c, view->seqname[seq - 1]);
+ }
+ else
+ sprintf(cursor_coord, "Pos:%d", site);
+ fl_color(view->namecolor);
+ fl_draw(cursor_coord, x, y);
+ }
+}
+
+
+void draw_seq_names(Fl_Widget *ob, SEA_VIEW *view)
+{
+int x, y, num, debut, fin;
+int couleur;
+static char trunc_name[20];
+
+x = view->x_name; y = view->y_name;
+fl_font(FL_COURIER, ob->labelsize() );
+if(view->draw_names == -1) { /* ecrire tous les noms */
+ fl_color(ob->color());
+ fl_rectf( ob->x(), ob->y(), /* fond pour les noms */
+ view->x_seq - ob->x(),
+ ob->h());
+ debut = view->first_seq - 1;
+ fin = view->first_seq - 2 + view->tot_lines;
+ if(fin >= view->tot_seqs) fin = view->tot_seqs - 1;
+/* write region name */
+ if(view->active_region != NULL) {
+ fl_color(view->region_color);
+ fl_font(ob->labelfont(), ob->labelsize());
+ fl_draw(view->active_region->name,
+ FL_min(view->wid_names, strlen(view->active_region->name)),
+ view->x_name,
+ view->y_name + FL_min(view->tot_lines, view->tot_seqs) *
+ view->line_height );
+ fl_font(FL_COURIER, ob->labelsize() );
+ }
+ }
+else if(view->draw_names == -2) { /* ecrire tous les noms mais rien qu'eux */
+ debut = view->first_seq - 1;
+ fin = view->first_seq - 2 + view->tot_lines;
+ if(fin >= view->tot_seqs) fin = view->tot_seqs - 1;
+ fl_color(ob->color());
+ fl_rectf( ob->x(), /* fond pour les noms */
+ y - view->line_height + fl_descent(),
+ view->x_seq - ob->x(),
+ (fin - debut + 1) * view->line_height);
+ }
+else { /* ecrire un seul nom */
+ debut = fin = view->draw_names - 1;
+ y += view->line_height * (view->draw_names - view->first_seq);
+ if( !view->sel_seqs[view->draw_names - 1] ) {
+ fl_color(ob->color());
+ fl_rectf( x, y - view->line_height + fl_descent(),
+ (view->wid_names+1) * view->char_width,
+ view->line_height);
+ }
+ }
+if(view->tot_seqs > 0) { /* nbre de seqs selectionnees */
+ fl_color(ob->color());
+ fl_rectf( x, view->y_name - 2 * view->line_height,
+ (view->wid_names+1) * view->char_width, view->line_height);
+ sprintf(trunc_name, "sel=%d", view->tot_sel_seqs);
+ fl_color(view->namecolor);
+ fl_draw(trunc_name, x, view->y_name - view->line_height );
+ }
+/* le(s) nom(s) a ecrire */
+for(num = debut; num <= fin; num++) {
+ if(view->sel_seqs[num]) {
+ fl_color(FL_BLACK);
+ fl_rectf( x, y - view->line_height + fl_descent(),
+ (view->wid_names+1) * view->char_width,
+ view->line_height);
+ couleur = FL_WHITE;
+ }
+ else
+ couleur = view->namecolor;
+ fl_color(couleur);
+ fl_draw(view->seqname[num],
+ FL_min(view->wid_names, strlen(view->seqname[num])), x, y );
+ y += view->line_height;
+ }
+}
+
+
+void draw_header(Fl_Widget *ob, SEA_VIEW *view)
+{
+int l_line, c;
+static char site_line[300];
+
+if(view->mod_seq) return;
+if(view->tot_seqs == 0) return;
+if(view->active_region != NULL) draw_region_line(ob, view);
+/* write site numbers */
+l_line = view->tot_sites;
+if(l_line < 5) return;
+memset(site_line,' ',l_line);
+sprintf(site_line,"%d",view->first_site); c=strlen(site_line); site_line[c]=' ';
+sprintf(site_line + l_line - 5,"%5d",view->first_site + l_line - 1);
+fl_color(ob->color());
+fl_rectf( view->x_seq,
+ view->y_seq - 2 * view->line_height + fl_descent(),
+ view->tot_sites * view->char_width, view->line_height);
+fl_color(view->namecolor); fl_font(FL_COURIER, ob->labelsize() );
+fl_draw(site_line, view->x_seq, view->y_seq - view->line_height);
+}
+
+
+void draw_dna_seqs(Fl_Widget *ob, SEA_VIEW *view)
+{
+int nline, c, offset, x, y, l_line, y_back, need_back;
+char *pos;
+int debut, fin, use_region;
+list_segments *segment, *first_segment;
+
+if(view->mod_seq == 0) { /* draw all lines */
+ debut = view->first_seq - 1;
+ fin = FL_min(view->first_seq + view->tot_lines - 1, view->tot_seqs) - 1;
+ }
+else if(view->mod_seq == -1) { /* draw only selected lines */
+ debut = view->first_seq - 1;
+ fin = FL_min(view->first_seq + view->tot_lines - 1, view->tot_seqs) - 1;
+ while(fin >= debut && !view->sel_seqs[fin]) fin--;
+ if(debut > fin) return;
+ while(!view->sel_seqs[debut]) debut++;
+ }
+else { /* draw just line # view->mod_seq */
+ debut = fin = view->mod_seq - 1;
+ if(debut < view->first_seq - 1) fin = debut - 1;
+ }
+// prepare for drawing region background
+use_region = (view->active_region != NULL && view->numb_gc > 1 &&
+ (first_segment = view->active_region->list) != NULL);
+if(use_region) {
+ do {
+ if(first_segment->debut >
+ view->first_site + view->tot_sites - 1) {
+ use_region = FALSE;
+ break;
+ }
+ if(first_segment->fin >= view->first_site) break;
+ first_segment = first_segment->next;
+ }
+ while(first_segment != NULL);
+ if(first_segment == NULL) use_region = FALSE;
+ }
+need_back = TRUE;
+if(use_region) {
+ if(first_segment->debut <= view->first_site &&
+ first_segment->fin >= view->first_site + view->tot_sites - 1)
+ need_back = FALSE;
+ }
+
+/* write sequences */
+fl_font( ob->labelfont(), ob->labelsize() );
+x = view->x_seq;
+y = view->y_seq + (debut - (view->first_seq - 1)) * view->line_height;
+y_back = y - view->line_height + fl_descent();
+offset = view->first_site - 1;
+for(nline = debut; nline <= fin; nline++) {
+ if( view->mod_seq != -1 || view->sel_seqs[nline] ) {
+ if(need_back) { /* write seq background */
+ fl_color(ob->color());
+ fl_rectf( x, y_back,
+ view->tot_sites * view->char_width,
+ view->line_height);
+ }
+ if(use_region) { /* write regions background */
+ int deb_block, fin_block;
+ fl_color(ob->selection_color());
+ segment = first_segment;
+ do {
+ deb_block = FL_max(
+ segment->debut, view->first_site);
+ fin_block = FL_min(segment->fin,
+ view->first_site + view->tot_sites - 1);
+ fl_rectf(x+(deb_block - view->first_site)*
+ view->char_width,
+ y_back,
+ (fin_block - deb_block + 1) *
+ view->char_width,
+ view->line_height);
+ segment = segment->next;
+ }
+ while(segment != NULL && segment->debut <=
+ view->first_site + view->tot_sites - 1);
+ }
+ if(view->each_length[nline] > offset) {
+ l_line = FL_min( view->tot_sites,
+ view->each_length[nline] - offset );
+ for(c=0; c < view->numb_gc; c++) { /* write DNA seqs */
+ if(view->numb_gc > 1)
+ pos = view->col_seq[nline][c];
+ else
+ pos = view->sequence[nline];
+ fl_color(view->curr_colors[c]);
+ fl_draw(pos + offset, l_line, x, y );
+ }
+ }
+ }
+ y += view->line_height;
+ y_back += view->line_height;
+ }
+draw_header(ob, view);
+}
+
+
+void draw_dna_seqs_inverted(Fl_Widget *ob, SEA_VIEW *view)
+{
+int nline, c, offset, x, y, l_line, xx, yy, firstline, lastline, use_region,
+ debut, fin, der_site;
+char *lastpos, *pos;
+list_segments *segment, *first_segment;
+int save_col0;
+static char up_line[1000]; char *p, *q; int i;
+
+if(view->tot_seqs == 0) return;
+fl_font(ob->labelfont(), ob->labelsize() );
+save_col0 = view->curr_colors[0];
+view->curr_colors[0] = ob->color();
+/* write sequences */
+x = view->x_seq;
+offset= view->first_site - 1;
+if(view->mod_seq <= 0) {
+ firstline = view->first_seq-1;
+ lastline = FL_min(view->first_seq + view->tot_lines -1, view->tot_seqs);
+ }
+else {
+ firstline = view->mod_seq - 1;
+ lastline = firstline + 1;
+ if(firstline < view->first_seq - 1) lastline = firstline - 1;
+ }
+use_region = (view->active_region != NULL &&
+ (first_segment = view->active_region->list) != NULL);
+if(use_region) {
+ do {
+ if(first_segment->fin >= view->first_site) break;
+ first_segment = first_segment->next;
+ }
+ while(first_segment != NULL);
+ }
+y = view->y_seq + (firstline - view->first_seq + 1) * view->line_height;
+yy = y - view->line_height + fl_descent();
+for(nline=firstline; nline < lastline; /* ecriture des fonds de couleur */
+ nline++, y += view->line_height, yy += view->line_height ) {
+ l_line = ( offset + view->tot_sites < view->each_length[nline] ?
+ view->tot_sites : view->each_length[nline] - offset);
+ l_line = FL_max(l_line, 0); /* nbre de caract a ecrire */
+ if(l_line > 0) {
+ for(c = 0; c < view->numb_gc; c++) {
+ xx = x;
+ pos = view->col_seq[nline][c] + offset;
+ lastpos = pos + l_line;
+ fl_color(view->curr_colors[c]);
+ while(pos < lastpos) {
+ if( *(pos++) != ' ' ) {
+ fl_rectf( xx, yy,
+ view->char_width,
+ view->line_height);
+ }
+ xx += view->char_width;
+ }
+ }
+ }
+ if(l_line < view->tot_sites) { /* au dela de la fin de la seq */
+ fl_color(ob->color());
+ fl_rectf( x + l_line * view->char_width, yy,
+ view->char_width * (view->tot_sites - l_line),
+ view->line_height);
+ }
+ if(l_line == 0) continue;
+/*ecriture des seqs: regions en noir et autres en col2 */
+ fl_color( use_region ? ob->selection_color() : FL_BLACK );
+ p = view->sequence[nline] + offset;
+ if(!view->allow_lower) {
+ q = p + l_line; i = 0;
+ while( p < q) up_line[i++] = toupper(*(p++));
+ p = up_line;
+ }
+ fl_draw(p, l_line, x, y);
+ if(use_region) { /* re-ecrire les regions en noir */
+ der_site = view->first_site + l_line - 1;
+ segment = first_segment;
+ fl_color( FL_BLACK );
+ while( segment != NULL ) {
+ if(segment->debut > der_site) break;
+ debut = FL_max(segment->debut, view->first_site);
+ fin = FL_min(segment->fin, der_site);
+ if(view->allow_lower)
+ p = view->sequence[nline] + debut - 1;
+ else p = up_line + debut - offset - 1;
+ fl_draw(p,
+ fin - debut + 1,
+ x + (debut - offset - 1)*view->char_width, y);
+ segment = segment->next;
+ }
+ }
+ }
+view->curr_colors[0] = save_col0;
+draw_header(ob, view);
+}
+
+
+void set_tot_lines(SEA_VIEW *view, int new_val)
+{
+int l;
+double x;
+view->tot_lines = new_val;
+l = view->tot_seqs - view->tot_lines + 1;
+if(l<1) l=1;
+if(view->first_seq > l) {
+ view->first_seq = l;
+ }
+if(view->tot_seqs > 0) {
+ x = view->tot_lines / ( (double) view->tot_seqs );
+ if(x>1) x=1;
+ }
+else x = 1;
+view->vertsli->slider_size(x);
+view->vertsli->bounds(1, l);
+view->vertsli->Fl_Slider::value(view->first_seq);
+}
+
+
+int compute_size_params(SEA_VIEW *view, int force_recompute)
+{
+static int old_w = 0;
+static int old_h = 0;
+Fl_Widget *ob = view->DNA_obj;
+double x;
+int l, tot_lines, possible_lines;
+
+if( !force_recompute && ob->w() == old_w && ob->h() == old_h) return FALSE;
+old_w = ob->w(); old_h = ob->h();
+view->x_name = view->char_width/2 + ob->x();
+view->y_name = 2 * view->line_height + ob->y();
+view->x_seq = (view->wid_names +2) * view->char_width + ob->x();
+view->y_seq = view->y_name;
+view->tot_sites = ( ob->w() - view->x_seq + ob->x() ) / view->char_width;
+possible_lines = ( ob->h() - 4 ) / view->line_height - 1;
+tot_lines = possible_lines;
+if(view->active_region != NULL) tot_lines--;
+if(view->show_comment_lines) {
+ tot_lines -= view->tot_comment_lines;
+ view->pos_first_comment_line =
+ FL_min(tot_lines, view->tot_seqs) + 1;
+ if(view->active_region != NULL) ++(view->pos_first_comment_line);
+ }
+/* init sliders bounds and size */
+if(view->tot_seqs > 0) {
+ x = ( (double) view->tot_sites ) / ( view->seq_length + 3 );
+ if(x>1) x=1;
+ }
+else x = 1;
+view->horsli->slider_size(x);
+l = view->seq_length - view->tot_sites+3;
+if(l<1) l=1;
+view->horsli->bounds(1,l);
+if(view->first_site > l) {
+ view->first_site = l;
+ }
+view->horsli->Fl_Slider::value(view->first_site);
+set_tot_lines(view, tot_lines);
+if(view->tot_seqs +
+ (view->show_comment_lines ? view->tot_comment_lines : 0) +
+ (view->active_region != NULL ? 1 : 0) < possible_lines) {
+/* forcer effacement de tout l'alignement pour ne pas garder
+de mauvaises lignes regions ou footers en bas */
+ ob->parent()->redraw();
+ }
+return TRUE;
+}
+
+
+void init_dna_scroller(SEA_VIEW *view, int totseqs, const char *masename,
+ int protein, char *header)
+{
+int i, l;
+list_regions *mylregion;
+Fl_Menu_Button *menu_props = (Fl_Menu_Button *)view->bouton_props;
+props_menu_parts *props_parts =
+ (props_menu_parts *)menu_props->user_data();
+
+view->header = header;
+view->tot_seqs = totseqs;
+view->seq_length = 0;
+view->protein = protein;
+view->allow_seq_edit = FALSE;
+menu_props->mode(props_parts->edit, FL_MENU_TOGGLE );
+menu_props->mode(props_parts->keys, FL_MENU_RADIO);
+menu_props->mode(props_parts->keys + 1, FL_MENU_RADIO);
+menu_props->mode(props_parts->keys + 2, FL_MENU_RADIO);
+if(protein) menu_props->mode(props_parts->keys - 1,
+ FL_SUBMENU | FL_MENU_INACTIVE);
+else menu_props->mode(props_parts->keys - 1, FL_SUBMENU );
+view->hjkl = FALSE;
+view->modif_but_not_saved = FALSE;
+if(masename != NULL) {
+ view->masename = (char *)malloc(strlen(masename)+1);
+ if(view->masename == NULL) out_of_memory();
+ strcpy(view->masename, masename);
+ }
+else view->masename = NULL;
+if(totseqs > 0) {
+ view->each_length = (int *)malloc(totseqs * sizeof(int));
+ if(view->each_length == NULL) out_of_memory();
+ }
+for(i = 0; i < totseqs; i++) {
+ l = strlen(view->sequence[i]);
+ view->each_length[i] = l;
+ if(l > view->seq_length) view->seq_length = l;
+ }
+for(i = 0; i < view->tot_comment_lines; i++) {
+ l = strlen(view->comment_line[i]);
+ if(l > view->seq_length) view->seq_length = l;
+ }
+view->max_seq_length = FL_max(view->max_seq_length,
+ view->seq_length + MAX_SEQ_ALLONG);
+view->wid_names = 0;
+for(i=0; i<totseqs; i++) {
+ l=strlen(view->seqname[i]);
+ while(l > 0 && view->seqname[i][l-1] == ' ') l--;
+ view->seqname[i][l] = 0;
+ if(l > view->wid_names) view->wid_names = l;
+ }
+if(totseqs > 0 && view->wid_names < 10) view->wid_names = 10;
+if(view->wid_names > 20) view->wid_names = 20;
+allonge_seqs(view->sequence, totseqs, view->max_seq_length,
+ view->each_length, view->tot_comment_lines, view->comment_line);
+if(view->numb_dnacolors > 1 && view->bouton_props != NULL) {
+ /* DNA/prot modes useful only with colors */
+ menu_props->mode(props_parts->colors, FL_MENU_RADIO );
+ menu_props->mode(props_parts->colors + 1, FL_MENU_RADIO );
+ if(view->alt_colors != NO_ALT_COLORS) {
+ menu_props->mode(props_parts->colors + 2, FL_MENU_RADIO);
+ }
+ if(protein) {
+ if(view->alt_colors == USING_ALT_COLORS) {
+ menu_props->mode(props_parts->colors + 2,
+ FL_MENU_RADIO | FL_MENU_VALUE);
+ set_aa_color_mode(USING_ALT_COLORS);
+ view->numb_gc = view->numb_altprotcolors;
+ view->curr_colors = view->altprotcolors;
+ }
+ else {
+ menu_props->mode(props_parts->colors + 1,
+ FL_MENU_RADIO | FL_MENU_VALUE);
+ set_aa_color_mode(USING_STANDARD_COLORS);
+ view->numb_gc = view->numb_stdprotcolors;
+ view->curr_colors = view->stdprotcolors;
+ }
+ }
+ else {
+ menu_props->mode(props_parts->colors,
+ FL_MENU_RADIO | FL_MENU_VALUE);
+ view->numb_gc = view->numb_dnacolors;
+ view->curr_colors = view->dnacolors;
+ }
+ }
+if(view->numb_gc > 1) {
+ view->col_seq = prepcolseqs(view->sequence, totseqs,
+ view->max_seq_length, view->each_length,
+ ( view->protein ? get_color_for_aa : get_color_for_base ),
+ view->numb_gc, view->allow_lower);
+ view->alt_col_seq = NULL;
+ }
+view->first_seq = view->first_site = 1;
+fl_font(view->DNA_obj->labelfont(), view->DNA_obj->labelsize());
+view->line_height = (int)( LINE_HEIGHT_FACTOR * fl_height() );
+view->char_width = (int)fl_width('W');
+view->draw_names = -1;
+view->mod_cursor = FALSE;
+view->mod_seq = 0;
+view->multipl->argument(0);
+if(view->tot_seqs == 0)
+ view->cursor_seq = view->cursor_site = 0;
+else
+ view->cursor_seq = view->cursor_site = 1;
+view->old_cursor_seq = view->cursor_seq;
+view->old_cursor_site = view->cursor_site;
+view->cursor_in_comment = view->old_cursor_in_comment = FALSE;
+view->tot_sel_seqs = 0;
+if(view->menu_edit != NULL) {
+ Fl_Menu_ *obj = (Fl_Menu_ *)(view->menu_edit);
+ Fl_Menu_Item *items = (Fl_Menu_Item *)obj->menu();
+ items[RENAME_SEQ].deactivate();
+ items[EDIT_COMMENTS].deactivate();
+ items[DUPLICATE_SEQ].deactivate();
+ items[DELETE_SEQ].deactivate();
+ items[COMPLEMENT_SEQ].deactivate();
+ items[REVERSE_SEQ].deactivate();
+ items[EXCHANGE_UT].deactivate();
+ items[ALIGN_SEQS].deactivate();
+ items[DOT_PLOT].deactivate();
+ items[CONSENSUS_SEQ].deactivate();
+ items[DELETE_GAP_ONLY_SITES].activate();
+ }
+if(view->tot_seqs > 0) {
+ view->sel_seqs = (int *)calloc(view->tot_seqs, sizeof(int));
+ if(view->sel_seqs == NULL) out_of_memory();
+ }
+/* initialiser les regions et leur menu avec pas de region active */
+view->mod_region_line = FALSE;
+if(view->tot_seqs > 0) {
+ view->region_line = (char *)malloc(view->max_seq_length + 1);
+ if(view->region_line == NULL) out_of_memory();
+ }
+view->region_length = 0;
+view->active_region = NULL;
+Fl_Menu_ *menu_regions = (Fl_Menu_ *)view->menu_regions;
+if(menu_regions != NULL) {
+ menu_regions->clear();
+ if(view->tot_seqs > 0) {
+ menu_regions->add("Create set", 0, NULL, NULL, 0);
+ menu_regions->add("Save set", 0, NULL, NULL, FL_MENU_INACTIVE);
+ menu_regions->add("Rename set", 0, NULL, NULL,FL_MENU_INACTIVE);
+ menu_regions->add("Hide set", 0, NULL, NULL, FL_MENU_INACTIVE);
+ menu_regions->add("Delete set", 0, NULL, NULL,
+ FL_MENU_INACTIVE | FL_MENU_DIVIDER);
+ }
+ mylregion = view->regions;
+ i = 0;
+ while(mylregion != NULL) {
+ i++;
+ menu_regions->add(mylregion->element->name, 0, NULL, NULL, FL_MENU_RADIO);
+ mylregion = mylregion->next;
+ }
+ init_menu_taille_valeur(menu_regions, i, 0, 5);
+ }
+Fl_Menu_ *menu_species = (Fl_Menu_ *)view->menu_species;
+if(menu_species != NULL) {
+ menu_species->clear();
+ if(view->tot_seqs > 0) {
+ menu_species->add("Create group", 0, NULL, NULL, FL_MENU_INACTIVE);
+ menu_species->add("Delete group", 0, NULL, NULL, FL_MENU_INACTIVE | FL_MENU_DIVIDER);
+ }
+ for(i=0; i < view->numb_species_sets; i++) {
+ menu_species->add(view->name_species_sets[i], 0, NULL, NULL, FL_MENU_RADIO);
+ }
+ init_menu_taille_valeur(menu_species, view->numb_species_sets, 0, 2);
+ }
+view->show_comment_lines = (view->tot_comment_lines > 0);
+view->active_comment_line = 0;
+update_menu_footers(view);
+compute_size_params(view, TRUE);
+view->DNA_obj->take_focus();
+}
+
+
+void mod_multipl(SEA_VIEW *view, int newval)
+{
+Fl_Widget *obj = view->multipl;
+static char label[16];
+int old = obj->argument();
+
+if(newval == 0) sprintf(label, "%s-+_", view->movekeys);
+else sprintf(label, "mult=%d", newval);
+obj->argument(newval);
+obj->label(label);
+if(newval != old) obj->redraw();
+}
+
+
+void rename_sequence(SEA_VIEW *view)
+{
+char *new_name;
+const char *rep;
+int num;
+if(view->tot_sel_seqs != 1) return; /* only by security, should not happen */
+num = 0;
+while( ! view->sel_seqs[num] ) num++;
+rep = fl_input("Rename:",view->seqname[num]);
+if(rep == NULL) return;
+new_name = (char *)malloc(strlen(rep)+1);
+if(new_name == NULL) return;
+free(view->seqname[num]);
+strcpy(new_name, rep);
+view->seqname[num] = new_name;
+if(num+1 >= view->first_seq && num+1 <= view->first_seq+view->tot_lines-1) {
+ view->draw_names = num + 1;
+ view->DNA_obj->damage(1);
+ }
+view->modif_but_not_saved = TRUE;
+}
+
+
+void del_gap_only_sites(SEA_VIEW *view)
+{
+int position, numseq, allgaps, inrun, debut, count;
+
+view->seq_length = 0;
+for(numseq = 0; numseq < view->tot_seqs; numseq++)
+ if(view->each_length[numseq] > view->seq_length)
+ view->seq_length = view->each_length[numseq];
+inrun = FALSE;
+position = -1;
+while( ++position <= view->seq_length) {
+ for(numseq = 0; numseq < view->tot_seqs; numseq++)
+ if(position < view->each_length[numseq] &&
+ view->sequence[numseq][position] != '-') break;
+ allgaps = (numseq >= view->tot_seqs);
+ if(position >= view->seq_length) allgaps = FALSE;
+ if(inrun == allgaps) continue;
+ if(allgaps && !inrun) {
+ inrun = TRUE;
+ debut = position;
+ }
+ else {
+ inrun = FALSE;
+ count = position - debut;
+ for(numseq = 1; numseq <= view->tot_seqs; numseq++)
+ delete_gaps_before(view, numseq, debut + count + 1,
+ count);
+ view->seq_length -= count;
+ if(view->cursor_site > position) view->cursor_site -= count;
+ if(view->regions != NULL) delete_region_part(view,
+ debut + count + 1, count);
+ if(view->tot_comment_lines > 0) delete_in_all_comments(count,
+ debut + count + 1, view);
+ position -= count;
+ }
+ }
+view->seq_length = 0;
+for(numseq = 0; numseq < view->tot_seqs; numseq++)
+ if(view->each_length[numseq] > view->seq_length)
+ view->seq_length = view->each_length[numseq];
+}
+
+
+int delete_selected_seqs(SEA_VIEW *view)
+{
+void **temp_data;
+int new_tot_seqs, i, j, c, *temp_int, numset;
+new_tot_seqs = view->tot_seqs - view->tot_sel_seqs;
+temp_data = (void **)malloc(new_tot_seqs * sizeof(void *));
+if(temp_data == NULL) return TRUE;
+temp_int = (int *)malloc(new_tot_seqs * sizeof(int));
+if(temp_int == NULL) return TRUE;
+
+for(i = 0, j = 0; i< view->tot_seqs; i++) /* process sequences */
+ if( ! view->sel_seqs[i] ) temp_data[j++] = (void *) view->sequence[i];
+ else free(view->sequence[i]);
+memcpy(view->sequence , temp_data, new_tot_seqs * sizeof(char *) );
+
+for(i = 0, j = 0; i< view->tot_seqs; i++) /* process comments */
+ if( ! view->sel_seqs[i] ) temp_data[j++] = (void *) view->comments[i];
+ else free(view->comments[i]);
+memcpy(view->comments , temp_data, new_tot_seqs * sizeof(char *) );
+
+for(i = 0, j = 0; i< view->tot_seqs; i++) /* process seq names */
+ if( ! view->sel_seqs[i] ) temp_data[j++] = (void *) view->seqname[i];
+ else free(view->seqname[i]);
+memcpy(view->seqname , temp_data, new_tot_seqs * sizeof(char *) );
+
+for(i = 0, j = 0; i< view->tot_seqs; i++) /* process seq lengths */
+ if( ! view->sel_seqs[i] ) temp_int[j++]= view->each_length[i];
+memcpy(view->each_length , temp_int, new_tot_seqs * sizeof(int) );
+
+if(view->numb_gc > 1) { /* process color-coded sequences */
+ for(i = 0, j = 0; i< view->tot_seqs; i++)
+ if( ! view->sel_seqs[i] ) temp_data[j++] =
+ (void *) view->col_seq[i];
+ else {
+ for(c=0; c<view->numb_gc; c++)
+ free(view->col_seq[i][c]);
+ free(view->col_seq[i]);
+ }
+ memcpy(view->col_seq , temp_data, new_tot_seqs * sizeof(char **) );
+ }
+for(numset = 0; numset < view->numb_species_sets; numset++) {
+/* process species sets */
+ for(i = 0, j = 0; i < view->tot_seqs; i++) {
+ if( ! view->sel_seqs[i] )
+ temp_int[j++]= view->list_species_sets[numset][i];
+ }
+ memcpy(view->list_species_sets[numset], temp_int,
+ new_tot_seqs * sizeof(int) );
+ }
+
+if(! view->cursor_in_comment) view->cursor_seq = 1;
+memset(view->sel_seqs, 0, new_tot_seqs * sizeof(int));
+view->tot_seqs = new_tot_seqs;
+select_deselect_seq(view, 0);
+if(view->menu_species != NULL) {
+ numset = 0;
+ while(numset < view->numb_species_sets) { /* check for empty sets */
+ for(i = 0, j = 0; i < view->tot_seqs; i++)
+ if( view->list_species_sets[numset][i] ) j++;
+ if( j == 0 ) { /* set became empty => remove it */
+ int taille, valeur;
+ free(view->list_species_sets[numset]);
+ free(view->name_species_sets[numset]);
+ memcpy(view->list_species_sets + numset,
+ view->list_species_sets + numset + 1,
+ (view->numb_species_sets - numset - 1)*sizeof(int *) );
+ memcpy(view->name_species_sets + numset,
+ view->name_species_sets + numset + 1,
+ (view->numb_species_sets - numset - 1)*sizeof(char *) );
+ ((Fl_Menu_Button*)view->menu_species)->remove(numset + 3 - 1);
+ (view->numb_species_sets)--;
+ get_menu_taille_valeur(view->menu_species, &taille,
+ &valeur);
+ init_menu_taille_valeur(view->menu_species, taille - 1,
+ 0, 2);
+ }
+ else numset++;
+ }
+ }
+view->modif_but_not_saved = TRUE;
+return FALSE;
+}
+
+
+void vh_sliders_callback(Fl_Widget *ob, void *data)
+{
+int old, new_val, page;
+int which = ((user_data_plus *)data)->value;
+SEA_VIEW *view = (SEA_VIEW *)((user_data_plus *)data)->p;
+Fl_Scrollbar *sli = (Fl_Scrollbar *)ob;
+
+new_val = sli->value();
+if (which == 0) { /* vertical */
+ old = view->first_seq;
+ if( Fl::event_is_click() ) {
+ page = view->tot_lines - 2;
+ if(page < 1) page = 1;
+ if(new_val > old + sli->linesize() ) new_val = old + page;
+ else if(new_val < old - sli->linesize() ) new_val = old - page;
+ new_val = (int) sli->clamp(new_val);
+ ((Fl_Valuator *)sli)->value(new_val);
+ }
+ view->first_seq = new_val;
+ if(old != new_val) view->DNA_obj->redraw();
+ }
+else { /* horizontal */
+ old = view->first_site;
+ if( Fl::event_is_click() ) {
+ page = view->tot_sites - 20;
+ if(page < 10) page = 10;
+ if(new_val > old + sli->linesize() ) new_val = old + page;
+ else if(new_val < old - sli->linesize() ) new_val = old - page;
+ new_val = (int)sli->clamp(new_val);
+ ((Fl_Valuator *)sli)->value(new_val);
+ }
+ view->first_site = new_val;
+ view->draw_names = 0;
+ if(old != new_val) view->DNA_obj->damage(1);
+ }
+}
+
+
+void lrdu_button_callback(Fl_Widget *ob, void *data)
+{
+Fl_Slider *sli;
+int *pval, newval;
+int mini, maxi;
+
+int which = ((user_data_plus *)data)->value;
+SEA_VIEW *view = (SEA_VIEW *)((user_data_plus *)data)->p;
+if(which <= 3) { /* mouvement horizontal */
+ sli = view->horsli;
+ pval = &view->first_site;
+ }
+else { /* mouvement vertical */
+ sli = view->vertsli;
+ pval = &view->first_seq;
+ }
+mini = (int)(sli->minimum());
+maxi = (int)(sli->maximum());
+
+if(which == 1 || which == 5) newval = mini;
+else if(which == 3 || which == 7) newval = maxi;
+
+if(newval < mini) newval = mini;
+if(newval > maxi) newval = maxi;
+if(newval != *pval) {
+ *pval = newval;
+ sli->value(*pval);
+ if(which <= 3) view->draw_names = 0;
+ view->DNA_obj->damage(view->draw_names ? FL_DAMAGE_ALL : 1);
+ }
+}
+
+
+void font_callback(Fl_Widget *ob, void *data)
+{
+int taille;
+SEA_VIEW *view = ((props_menu_parts *)data)->view;
+sscanf( ((Fl_Menu_Button *)ob)->text(), "%d", &taille);
+if(view->DNA_obj->labelsize() == taille ) return;
+my_watch_cursor(view->dnawin);
+view->DNA_obj->labelsize(taille);
+fl_font( view->DNA_obj->labelfont(), view->DNA_obj->labelsize() );
+view->line_height = (int)( LINE_HEIGHT_FACTOR * fl_height() );
+view->char_width = (int)fl_width('W');
+compute_size_params(view, TRUE);
+view->DNA_obj->parent()->redraw();
+fl_reset_cursor(view->dnawin);
+}
+
+
+void save_as_callback(Fl_Widget *ob, void *data)
+{
+SEA_VIEW *view = ((props_menu_parts *)data)->view;
+int debut = ((props_menu_parts *)data)->saveformat;
+int reponse = ((Fl_Menu_Button *)ob)->value();
+int previous_format = view->format_for_save + debut;
+if(previous_format == reponse) return;
+view->format_for_save = (known_format)(reponse - debut);
+Fl_Menu_Item *items = (Fl_Menu_Item *) ((Fl_Menu_ *)view->menu_file)->menu();
+items[SAVE].deactivate();
+if(view->masename != NULL) {
+ free(view->masename);
+ view->masename = NULL;
+ }
+}
+
+
+void set_save_format(SEA_VIEW *view, int val)
+{
+Fl_Menu_Button *menu_props = (Fl_Menu_Button *)view->bouton_props;
+props_menu_parts *props_parts =
+ (props_menu_parts *)menu_props->user_data();
+Fl_Menu_Item *saveas_popup =
+ (Fl_Menu_Item *)menu_props->menu() + props_parts->saveformat;
+
+if(val >= nbr_formats) return;
+if( view->format_for_save == (known_format)val) return;
+saveas_popup[val].setonly();
+view->format_for_save = (known_format)val;
+Fl_Menu_Item *items = (Fl_Menu_Item *) ((Fl_Menu_ *)view->menu_file)->menu();
+items[SAVE].deactivate();
+if(view->masename != NULL) {
+ free(view->masename);
+ view->masename = NULL;
+ }
+}
+
+
+void change_format(Fl_Widget *obj, void *data)
+{
+SEA_VIEW *view = (SEA_VIEW *)data;
+int current = view->format_for_save;
+Fl_Menu_Button *menu_props = (Fl_Menu_Button *)view->bouton_props;
+props_menu_parts *props_parts =
+ (props_menu_parts *)menu_props->user_data();
+Fl_Menu_Item *saveas_popup =
+ (Fl_Menu_Item *)menu_props->menu() + props_parts->saveformat;
+const Fl_Menu_Item *reponse = saveas_popup->popup(Fl::event_x(), Fl::event_y(),
+ "Choose format");
+if(reponse == NULL) return;
+if(current == reponse - saveas_popup) return;
+current = reponse - saveas_popup;
+set_save_format(view, current);
+char *p = (char *)obj->window()->label();
+sprintf(p, "Choose a %s file name", f_format_names[current] );
+obj->window()->label(p);
+return;
+}
+
+
+void colors_callback(Fl_Widget *ob, void *data)
+{
+Fl_Menu_Button *menu_props = (Fl_Menu_Button *)ob;
+props_menu_parts *parts = (props_menu_parts *)data;
+SEA_VIEW *view = parts->view;
+int reponse = menu_props->value();
+
+/* processing inverted colors */
+if(reponse == parts->inverted) {
+ int style;
+ my_watch_cursor(view->dnawin);
+ view->inverted_colors = !view->inverted_colors;
+ if(view->inverted_colors) {
+ style = FL_COURIER;
+ }
+ else {
+ style = FL_COURIER_BOLD;
+ }
+ view->DNA_obj->labelfont(style);
+ view->DNA_obj->redraw();
+ fl_reset_cursor(view->dnawin);
+ return;
+ }
+
+/* changing DNA / protein / Alternate protein mode */
+enum {DNARNA, Protein, Alt };
+int debut = parts->colors;
+reponse -= debut;
+if(reponse == DNARNA && !view->protein) return;
+if(reponse == Protein && view->protein &&
+ ( view->alt_colors == USING_STANDARD_COLORS ||
+ view->alt_colors == NO_ALT_COLORS) ) return;
+if(reponse == Alt && view->alt_colors == USING_ALT_COLORS) return;
+view->protein = (reponse >= Protein);
+my_watch_cursor(view->dnawin);
+if(view->numb_gc > 1) { /* free col_seq */
+ int num, col;
+ for(num = 0; num < view->tot_seqs; num++) {
+ for(col = 0; col < view->numb_gc; col++)
+ free(view->col_seq[num][col]);
+ free(view->col_seq[num]);
+ }
+ }
+if(reponse == DNARNA) {
+ view->numb_gc = view->numb_dnacolors;
+ view->curr_colors = view->dnacolors;
+ menu_props->mode(parts->keys - 1, FL_SUBMENU);
+ }
+else if(reponse == Protein) {
+ set_aa_color_mode(USING_STANDARD_COLORS);
+ view->numb_gc = view->numb_stdprotcolors;
+ view->curr_colors = view->stdprotcolors;
+ menu_props->mode(parts->keys - 1, FL_SUBMENU | FL_MENU_INACTIVE);
+ }
+else if(reponse == Alt) {
+ set_aa_color_mode(USING_ALT_COLORS);
+ view->numb_gc = view->numb_altprotcolors;
+ view->curr_colors = view->altprotcolors;
+ menu_props->mode(parts->keys - 1, FL_SUBMENU | FL_MENU_INACTIVE);
+ }
+view->col_seq = prepcolseqs(view->sequence, view->tot_seqs,
+ view->max_seq_length, view->each_length,
+ (view->protein ? get_color_for_aa : get_color_for_base),
+ view->numb_gc, view->allow_lower);
+if(view->alt_colors != NO_ALT_COLORS) {
+ if(reponse >= Protein) view->alt_colors =
+ (color_choice)reponse;
+ }
+view->DNA_obj->redraw();
+fl_reset_cursor(view->dnawin);
+}
+
+
+void allow_edit_callback(Fl_Widget *ob, void *data)
+{
+props_menu_parts *parts = (props_menu_parts *)data;
+SEA_VIEW *view = parts->view;
+Fl_Menu_Button *menu_props = (Fl_Menu_Button *)ob;
+view->allow_seq_edit = !view->allow_seq_edit;
+if(view->allow_seq_edit)
+ menu_props->mode(parts->edit, FL_MENU_TOGGLE | FL_MENU_VALUE);
+else
+ menu_props->mode(parts->edit, FL_MENU_TOGGLE);
+}
+
+
+void slow_fast_callback(Fl_Widget *ob, void *data)
+{
+props_menu_parts *parts = (props_menu_parts *)data;
+SEA_VIEW *view = parts->view;
+Fl_Menu_Button *menu_props = (Fl_Menu_Button *)ob;
+view->double_buffer = !view->double_buffer;
+if(!view->double_buffer)
+ menu_props->mode(parts->slow_fast, FL_MENU_TOGGLE | FL_MENU_VALUE);
+else
+ menu_props->mode(parts->slow_fast, FL_MENU_TOGGLE);
+Fl_Window *win = (Fl_Window *)view->DNA_obj->parent();
+Fl_Group *win_parent = (Fl_Group *)win->parent();
+int x,y,w,h;
+x = win->x(); y = win->y(); w = win->w(); h = win->h();
+int size = view->DNA_obj->labelsize();
+int font = view->DNA_obj->labelfont();
+Fl_Color col = view->DNA_obj->color();
+Fl_Color sel_col = view->DNA_obj->selection_color();
+win->hide();
+win_parent->remove(*win);
+delete win;
+Fl_Group::current(win_parent);
+if(view->double_buffer)
+ win = (Fl_Window *)new Fl_Double_Window(x, y, w, h );
+else win = new Fl_Window(x,y,w,h);
+win->box(FL_DOWN_BOX);
+win->resizable(win);
+view->DNA_obj = (Fl_Widget*)new DNA_obj(3, 3, w - 6, h - 6, view);
+view->DNA_obj->labelfont(font);
+view->DNA_obj->labelsize(size);
+view->DNA_obj->color(col, sel_col);
+win->color(col);
+win->end();
+win->show();
+view->DNA_obj->take_focus();
+}
+
+
+void allow_lower_callback(Fl_Widget *ob, void *data)
+{
+Fl_Menu_Button *menu_props = (Fl_Menu_Button *)ob;
+props_menu_parts *parts = (props_menu_parts *)data;
+SEA_VIEW *view = parts->view;
+int num, col, pos; char c;
+int (*calc_color_function)(int);
+
+view->allow_lower = !view->allow_lower;
+if(view->allow_lower)
+ menu_props->mode(parts->allow_lower, FL_MENU_TOGGLE | FL_MENU_VALUE);
+else
+ menu_props->mode(parts->allow_lower, FL_MENU_TOGGLE);
+my_watch_cursor(view->dnawin);
+calc_color_function = view->protein ? get_color_for_aa : get_color_for_base;
+if(view->allow_lower) {
+ for(num = 0; num < view->tot_seqs; num++) {
+ for(pos = 0; pos < view->each_length[num]; pos++) {
+ c = view->sequence[num][pos];
+ if(islower(c)) {
+ col = calc_color_function(c);
+ view->col_seq[num][col][pos] = c;
+ }
+ }
+ }
+ }
+else {
+ for(num = 0; num < view->tot_seqs; num++) {
+ for(pos = 0; pos < view->each_length[num]; pos++) {
+ c = view->sequence[num][pos];
+ if(islower(c)) {
+ col = calc_color_function(c);
+ view->col_seq[num][col][pos] = toupper(c);
+ }
+ }
+ }
+ }
+view->DNA_obj->parent()->redraw();
+fl_reset_cursor(view->dnawin);
+}
+
+
+void toggle_reference_callback(Fl_Widget *ob, void *data)
+{
+int on, etat;
+props_menu_parts *parts = (props_menu_parts *)data;
+SEA_VIEW *view = parts->view;
+Fl_Menu_Button *menu_props = (Fl_Menu_Button *)ob;
+on = menu_props->mode(parts->reference) & FL_MENU_VALUE ;
+reference_toggle(view, on);
+if(on) {
+ etat = menu_props->mode(parts->allow_lower);
+ menu_props->mode(parts->allow_lower, etat | FL_MENU_INACTIVE );
+ }
+else {
+ etat = FL_MENU_TOGGLE;
+ if(view->allow_lower) etat |= FL_MENU_VALUE;
+ menu_props->mode(parts->allow_lower, etat );
+ }
+}
+
+
+void dnakeys_callback(Fl_Widget *ob, void *data)
+{
+props_menu_parts *parts = (props_menu_parts *)data;
+SEA_VIEW *view = parts->view;
+Fl_Menu_Button *menu_props = (Fl_Menu_Button *)ob;
+int reponse = menu_props->value() - parts->keys;
+if( ! view->hjkl ) { /* activer un choix */
+ view->hjkl = reponse + 1;
+ }
+else if(view->hjkl == reponse + 1) { /* desactiver choix courant */
+ menu_props->mode(parts->keys + reponse, FL_MENU_RADIO );
+ view->hjkl = 0;
+ }
+else { /* changer de choix */
+ view->hjkl = reponse + 1;
+ }
+}
+
+
+void clustal_opt_callback(Fl_Widget *ob, void *data)
+{
+props_menu_parts *parts = (props_menu_parts *)data;
+SEA_VIEW *view = parts->view;
+Fl_Menu_Button *menu_props = (Fl_Menu_Button *)ob;
+int reponse = menu_props->value();
+if(reponse == parts->clustalopt) { // toggle use of option
+ ; // toggle automatique
+ }
+else { // edit options
+ const char *rep;
+ int l;
+ rep = fl_input("Clustal options "
+#if defined(WIN32) || defined(__APPLE__)
+ "(ex: /gapopen=5 /quicktree)",
+#else
+ "(ex: -gapopen=5 -quicktree)",
+#endif
+ (view->clustal_options == NULL ? "": view->clustal_options) );
+ if(rep == NULL) return;
+ if(view->clustal_options != NULL) free(view->clustal_options);
+ l = strlen(rep);
+ while(l > 0 && rep[l-1] == ' ') l--;
+ if(l == 0) {
+ view->clustal_options = NULL;
+ return;
+ }
+ view->clustal_options = (char *)malloc(l+1);
+ memcpy(view->clustal_options, rep, l);
+ view->clustal_options[l] = 0;
+ menu_props->replace(parts->clustalopt, view->clustal_options);
+ menu_props->mode(parts->clustalopt,
+ FL_MENU_TOGGLE | FL_MENU_VALUE | FL_MENU_DIVIDER);
+ }
+}
+
+
+void consensus_opt_callback(Fl_Widget *ob, void *data)
+{
+props_menu_parts *parts = (props_menu_parts *)data;
+SEA_VIEW *view = parts->view;
+Fl_Menu_Button *menu_props = (Fl_Menu_Button *)ob;
+int reponse = menu_props->value();
+if(reponse != parts->consensusopt + 1) return; // securite
+const char *rep;
+char tmp[100];
+int value;
+sprintf(tmp, "%d %%", view->consensus_threshold);
+rep = fl_input("Set consensus threshold value in %%", tmp );
+if(rep == NULL) return;
+value = -1;
+sscanf(rep, "%d", &value);
+if(value <= 0 || value > 100) return;
+view->consensus_threshold = value;
+sprintf(tmp, "%d %%", view->consensus_threshold);
+menu_props->replace(parts->consensusopt, tmp);
+}
+
+
+void create_props_menu(Fl_Menu_Button *obj, SEA_VIEW *view,
+ int curr_color_choice, int inverted, int black_and_white,
+ int def_fontsize)
+{
+int defaut, mode;
+props_menu_parts *parts =(props_menu_parts *)calloc(1,sizeof(props_menu_parts));
+obj->user_data(parts);
+
+parts->view = view;
+// Ne pas utiliser d'initialisation directe (obj->menu) car edition impossible
+
+/* partie Fontsize */
+obj->add("Fontsize", 0, 0, 0, FL_SUBMENU);
+parts->fontsize =
+ obj->add("Fontsize/8", 0, font_callback, parts, FL_MENU_RADIO);
+obj->add("Fontsize/10", 0, font_callback, parts, FL_MENU_RADIO);
+obj->add("Fontsize/12", 0, font_callback, parts, FL_MENU_RADIO );
+obj->add("Fontsize/14", 0, font_callback, parts, FL_MENU_RADIO );
+obj->add("Fontsize/16", 0, font_callback, parts, FL_MENU_RADIO );
+obj->add("Fontsize/18", 0, font_callback, parts, FL_MENU_RADIO );
+for(defaut = parts->fontsize; defaut < parts->fontsize + 6; defaut++) {
+ int taille;
+ sscanf( obj->text(defaut), "%d", &taille);
+ if(taille == def_fontsize) break;
+ }
+if(defaut >= parts->fontsize + 6) defaut = parts->fontsize + 3;
+mode = obj->mode(defaut);
+obj->mode(defaut, mode | FL_MENU_VALUE);
+
+
+/* partie Save Format */
+obj->add("Save Format", 0, 0, 0, FL_SUBMENU);
+parts->saveformat = obj->add("Save Format/Save as Mase", 0, save_as_callback,
+ parts, FL_MENU_RADIO);
+obj->add("Save Format/Save as Phylip",0, save_as_callback, parts,FL_MENU_RADIO);
+obj->add("Save Format/Save as Clustal",0,save_as_callback, parts,FL_MENU_RADIO);
+obj->add("Save Format/Save as MSF", 0, save_as_callback, parts, FL_MENU_RADIO );
+obj->add("Save Format/Save as Fasta", 0, save_as_callback, parts,FL_MENU_RADIO);
+obj->add("Save Format/Save as NEXUS", 0, save_as_callback, parts,FL_MENU_RADIO);
+defaut = parts->saveformat + view->format_for_save;
+mode = obj->mode(defaut);
+obj->mode(defaut, mode | FL_MENU_VALUE);
+
+/* partie Colors */
+int submenu = obj->add("Colors", 0, 0, 0, FL_SUBMENU);
+parts->colors = obj->add("Colors/DNA-RNA colors", 0, colors_callback, parts,
+ FL_MENU_RADIO);
+obj->add("Colors/Protein colors",0, colors_callback, parts, FL_MENU_RADIO);
+int alt = obj->add("Colors/Alt. colors",0,colors_callback, parts,
+ FL_MENU_RADIO | FL_MENU_DIVIDER );
+parts->inverted = obj->add("Colors/Inverted colors", 0, colors_callback, parts, FL_MENU_TOGGLE );
+if(black_and_white) {
+ obj->mode(submenu, FL_SUBMENU | FL_MENU_INACTIVE);
+ }
+else {
+ defaut = parts->colors; if(view->protein) defaut++;
+ obj->mode(defaut, FL_MENU_RADIO | FL_MENU_VALUE);
+ if(curr_color_choice == NO_ALT_COLORS)
+ obj->mode(alt,
+ FL_MENU_RADIO | FL_MENU_DIVIDER | FL_MENU_INACTIVE );
+ if(inverted) obj->mode(parts->inverted, FL_MENU_TOGGLE | FL_MENU_VALUE);
+ }
+
+/* partie Edit */
+parts->edit = obj->add("Allow seq. edition", 0, allow_edit_callback,
+ parts, FL_MENU_TOGGLE);
+
+/* partie by reference */
+parts->reference = obj->add("by Reference", 0, toggle_reference_callback,
+ parts, FL_MENU_TOGGLE);
+if(black_and_white) obj->mode(parts->reference,
+ FL_MENU_TOGGLE | FL_MENU_INACTIVE);
+else {
+// bug: FL_ALT ne marche pas, c'est Meta qu'il faut taper a la place
+ obj->shortcut(parts->reference, FL_CTRL | 'r');
+ }
+
+/* partie keys */
+obj->add("DNA keys", 0, 0, 0, FL_SUBMENU);
+parts->keys = obj->add("DNA keys/hjkl<space> => GATCN", 0, dnakeys_callback,
+ parts, FL_MENU_RADIO);
+obj->add("DNA keys/hjkl<space> => TCGAN", 0, dnakeys_callback,
+ parts, FL_MENU_RADIO);
+obj->add("DNA keys/hjkl<space> => ACGTN", 0, dnakeys_callback,
+ parts, FL_MENU_RADIO);
+
+/* partie clustal options */
+obj->add("Clustalw options", 0, 0, 0, FL_SUBMENU);
+parts->clustalopt = obj->add("Clustalw options/<none>", 0, clustal_opt_callback,
+ parts, FL_MENU_DIVIDER | FL_MENU_INACTIVE);
+obj->add("Clustalw options/Edit options", 0, clustal_opt_callback,
+ parts, 0);
+
+/* partie consensus options */
+obj->add("Consensus options", 0, 0, 0, FL_SUBMENU);
+char tmp[50];
+sprintf(tmp, "Consensus options/%d %%", view->consensus_threshold);
+parts->consensusopt = obj->add(tmp, 0, NULL, parts, FL_MENU_DIVIDER);
+obj->add("Consensus options/Edit options", 0, consensus_opt_callback, parts, 0);
+
+/* partie Fast/Slow */
+parts->slow_fast = obj->add("Fast-Rough", 0, slow_fast_callback, parts,
+ view->double_buffer ? FL_MENU_TOGGLE : FL_MENU_TOGGLE | FL_MENU_VALUE );
+
+/* partie allow lower case */
+parts->allow_lower = obj->add("Allow lowercase", 0, allow_lower_callback, parts,
+ view->allow_lower ? FL_MENU_TOGGLE | FL_MENU_VALUE : FL_MENU_TOGGLE );
+if(black_and_white) obj->mode(parts->allow_lower, FL_MENU_INACTIVE);
+}
+
+
+void edit_menu_callback(Fl_Widget *ob, long which)
+{
+SEA_VIEW *view;
+int reponse = ((Fl_Menu_Button*)ob)->value();
+view = (SEA_VIEW *) ob->user_data();
+if(reponse == RENAME_SEQ) { /* rename the selected sequence */
+ rename_sequence(view);
+ }
+else if(reponse == EDIT_COMMENTS) {
+ edit_comments_dialog(view);
+ }
+else if(reponse == DELETE_SEQ) { /* delete selected sequences from alignment */
+ char temp[100];
+ sprintf(temp,"Confirm request of deletion of %d sequence(s)",
+ view->tot_sel_seqs);
+ if( fl_ask(temp) ) {
+ if( delete_selected_seqs(view) )
+ fl_alert("Not enough memory for this operation");
+ else {
+ compute_size_params(view, TRUE);
+ update_menu_footers(view);
+ view->DNA_obj->redraw();
+ view->vertsli->redraw();
+ }
+ }
+ }
+else if(reponse == CREATE_SEQ) { /* create a new sequence */
+ char *newname;
+ newname = (char *) fl_input("Name of the new sequence?", "");
+ if(newname == NULL || strlen(newname) == 0) return;
+ add_seq_to_align(view, newname, "-", 1);
+ }
+else if(reponse == LOAD_SEQ) { /* load a new sequence */
+ load_seq_dialog(view);
+ }
+else if(reponse == DUPLICATE_SEQ || reponse == COMPLEMENT_SEQ ||
+ reponse == REVERSE_SEQ) {
+ int num, lenseq, old_first_seq;
+ char *newseq, *p, *q, newname[100];
+ if(view->tot_sel_seqs != 1 ) return; /* par securite */
+ if(reponse != DUPLICATE_SEQ && view->protein) return; /* par securite */
+ for(num = 0; num < view->tot_seqs; num++)
+ if(view->sel_seqs[num]) break;
+ lenseq = view->each_length[num];
+ newseq = (char *)malloc(lenseq + 1);
+ if(newseq == NULL) {
+ fl_alert("Not enough memory\nto create a new sequence");
+ Fl_Menu_Item *items = (Fl_Menu_Item *) ((Fl_Menu_ *)ob)->menu();
+ items[reponse-1].deactivate();
+ return;
+ }
+ if(reponse == DUPLICATE_SEQ) {
+ strcpy(newseq, view->sequence[num]);
+ }
+ else {
+ p = view->sequence[num]; q = newseq + lenseq - 1;
+ while( *p != 0) {
+ if(reponse == COMPLEMENT_SEQ) *q = complement_base(*p);
+ else *q = *p;
+ p++; q--;
+ }
+ newseq[lenseq] = 0;
+ }
+ if(reponse == COMPLEMENT_SEQ) strcpy(newname,"C_");
+ else if(reponse == REVERSE_SEQ) strcpy(newname,"R_");
+ else strcpy(newname,"D_");
+ strcat(newname,view->seqname[num]);
+ old_first_seq = view->first_seq;
+ add_seq_to_align(view, newname , newseq, lenseq);
+ free(newseq);
+/* placer la nouvelle seq apres celle de depart */
+ view->sel_seqs[num] = FALSE;
+ view->sel_seqs[view->tot_seqs - 1] = TRUE;
+ deplacer_grp_seqs( view, FL_min(num + 2, view->tot_seqs) );
+/* montrer les 2 seqs concernees */
+ if(old_first_seq > num + 1) view->first_seq =
+ FL_min(num + 1, view->tot_seqs - view->tot_lines + 1);
+ else if(old_first_seq + view->tot_lines - 1 < num + 2)
+ view->first_seq = FL_min(num + 2,
+ view->tot_seqs - view->tot_lines + 1);
+ else
+ view->first_seq = old_first_seq;
+ view->vertsli->Fl_Slider::value(view->first_seq);
+ }
+else if(reponse == EXCHANGE_UT) { /* exchange Us and Ts */
+ int num, col; char *p, *q;
+ if(view->tot_sel_seqs == 0 || view->protein) return; /* par securite */
+ my_watch_cursor(view->dnawin);
+ col = get_color_for_base('T');
+ for(num = 0; num < view->tot_seqs; num++) {
+ if( ! view->sel_seqs[num] ) continue;
+ p = view->sequence[num] - 1;
+ q = view->col_seq[num][col] - 1;
+ while( *(++p) != 0 ) {
+ ++q;
+ if( *p == 'U' ) {
+ *p = *q = 'T';
+ }
+ else if( *p == 'T' ) {
+ *p = *q = 'U';
+ }
+ else if( *p == 't' ) {
+ *p = 'u';
+ *q = (view->allow_lower ? 'u' : 'U');
+ }
+ else if( *p == 'u' ) {
+ *p = 't';
+ *q = (view->allow_lower ? 't' : 'T');
+ }
+ }
+ }
+ view->modif_but_not_saved = TRUE;
+ view->draw_names = 0;
+ view->DNA_obj->damage(1);
+ fl_reset_cursor(view->dnawin);
+ }
+else if(reponse == ALIGN_SEQS) { /* align selected sites */
+ align_selected_parts(view);
+ view->DNA_obj->redraw();
+ view->horsli->redraw();
+ fl_reset_cursor(view->dnawin);
+ }
+else if(reponse == DOT_PLOT) { /* dot plot */
+ int num1, num2;
+ extern void show_dot_plot(char *seq1, char *seq2, char *seqname1,
+ char *seqname2, int l1, int l2, int maxseqlength,
+ void *seaview_data);
+
+ if(view->tot_sel_seqs != 2) return;
+ for(num1 = 0; num1 < view->tot_seqs; num1++)
+ if(view->sel_seqs[num1]) break;
+ for(num2 = num1 + 1; num2 < view->tot_seqs; num2++)
+ if(view->sel_seqs[num2]) break;
+ show_dot_plot(view->sequence[num1], view->sequence[num2],
+ view->seqname[num1], view->seqname[num2],
+ view->each_length[num1], view->each_length[num2],
+ view->max_seq_length, (void *)view);
+ }
+else if (reponse == CONSENSUS_SEQ) {
+ char *newseq, newname[100];
+ int old_total, *tmp, new_pos, i, old_first_seq;
+
+ if(view->tot_sel_seqs <= 1 ) return; /* par securite */
+ newseq = cre_consensus(view, newname);
+ if(newseq == NULL) {
+ fl_alert("Not enough memory\nto create a new sequence");
+ Fl_Menu_Item *items = (Fl_Menu_Item *) ((Fl_Menu_ *)ob)->menu();
+ items[reponse-1].deactivate();
+ return;
+ }
+ old_first_seq = view->first_seq;
+ old_total = view->tot_seqs;
+ add_seq_to_align(view, newname , newseq, strlen(newseq));
+ free(newseq);
+ for(i=0; i < view->tot_seqs; i++)
+ if(view->sel_seqs[i]) new_pos = i;
+ new_pos += 2;
+ if(view->tot_seqs == old_total || new_pos == view->tot_seqs) {
+ return;
+ }
+/* placer la nouvelle seq apres la derniere des selectionnees */
+ tmp = (int *)calloc(view->tot_seqs, sizeof(int));
+ if(tmp == NULL) {
+ return;
+ }
+ memcpy(tmp, view->sel_seqs, view->tot_seqs * sizeof(int) );
+ memset(view->sel_seqs, 0, view->tot_seqs * sizeof(int) );
+ view->sel_seqs[view->tot_seqs - 1] = TRUE;
+ old_total = view->tot_sel_seqs;
+ view->tot_sel_seqs = 1;
+ deplacer_grp_seqs( view, new_pos );
+ memcpy(view->sel_seqs, tmp, view->tot_seqs * sizeof(int) );
+ view->tot_sel_seqs = old_total;
+ free(tmp);
+/* montrer la seq concernee */
+ if(old_first_seq > new_pos ) view->first_seq =
+ FL_min(new_pos - 2, 1);
+ else if(old_first_seq + view->tot_lines - 1 < new_pos)
+ view->first_seq = FL_min(new_pos - 2,
+ view->tot_seqs - view->tot_lines + 1);
+ else
+ view->first_seq = old_first_seq;
+ view->vertsli->Fl_Slider::value(view->first_seq);
+ }
+else if(reponse == DELETE_GAP_ONLY_SITES) {
+ if( !fl_ask("Confirm remove all gap_containing sites?") )
+ return;
+ my_watch_cursor(view->dnawin);
+ del_gap_only_sites(view);
+ compute_size_params(view, TRUE);
+ view->DNA_obj->redraw();
+ view->horsli->redraw();
+ fl_reset_cursor(view->dnawin);
+ }
+}
+
+
+void set_and_show_new_cursor_site(SEA_VIEW *view, int new_pos, int center,
+ int force_redraw)
+{
+int old_pos;
+old_pos = view->cursor_site;
+if(new_pos != old_pos)
+ view->cursor_site = new_pos;
+if(new_pos >= view->first_site && new_pos < view->first_site +
+ view->tot_sites - 1) {
+ if( !force_redraw &&
+ ( (view->cursor_in_comment && view->mod_comment_line == 0) ||
+ (!view->cursor_in_comment && view->mod_seq == 0) ) )
+ view->mod_cursor = TRUE;
+ }
+else {
+ if(center)
+ view->first_site =
+ view->cursor_site - view->tot_sites/2;
+ else {
+ if(new_pos >= old_pos)
+ view->first_site = view->cursor_site + 10 -
+ view->tot_sites;
+ else
+ view->first_site = view->cursor_site - 10;
+ }
+ if(view->first_site + view->tot_sites - 1 >
+ view->seq_length + 1 )
+ view->first_site = view->seq_length - view->tot_sites + 2;
+ if(view->first_site <=0 )
+ view->first_site = 1;
+ view->horsli->Fl_Slider::value(view->first_site);
+ view->mod_seq = 0;
+ view->mod_comment_line = 0;
+ }
+view->draw_names = 0;
+view->DNA_obj->damage(1);
+}
+
+
+void set_and_show_new_cursor_seq(SEA_VIEW *view, int new_pos)
+{
+if(view->cursor_in_comment) {
+ if(view->comment_length[new_pos - 1] + 1 < view->cursor_site) {
+ fl_ringbell(0);
+ return;
+ }
+ if(new_pos == view->cursor_seq) return;
+ view->cursor_seq = new_pos;
+ view->mod_cursor = TRUE;
+ view->draw_names = 0;
+ view->DNA_obj->damage(1);
+ return;
+ }
+if(view->each_length[new_pos - 1] + 1 < view->cursor_site) {
+ fl_ringbell(0); return;
+ }
+if(new_pos != view->cursor_seq || new_pos < view->first_seq ||
+ view->cursor_site != view->old_cursor_site ||
+ new_pos >= view->first_seq + view->tot_lines) {
+ view->cursor_seq = new_pos;
+ if(new_pos >= view->first_seq && new_pos < view->first_seq +
+ view->tot_lines) {
+ view->mod_cursor = TRUE;
+ view->draw_names = 0;
+ view->DNA_obj->damage(1);
+ }
+ else {
+ view->first_seq = view->cursor_seq - view->tot_lines/2;
+ if(view->first_seq + view->tot_lines >=
+ view->tot_seqs )
+ view->first_seq = view->tot_seqs - view->tot_lines + 1;
+ if(view->first_seq <=0 )
+ view->first_seq = 1;
+ view->vertsli->Fl_Slider::value(view->first_seq);
+ view->draw_names = -1;
+ view->DNA_obj->redraw();
+ }
+ }
+}
+
+
+void goto_callback(Fl_Widget *ob, void *data)
+{
+Fl_Input *input;
+SEA_VIEW *view;
+int l, maxi, num, new_pos = -1, numerique = TRUE;
+char *p, *q, target[50];
+static char *upname;
+static int l_upname = 0;
+
+user_data_plus *data_plus = (user_data_plus *)data;
+int which = data_plus->value;
+if(which == 0) { /* appele par bouton goto */
+ input = (Fl_Input *)data_plus->p;
+ data_plus = (user_data_plus *)input->user_data();
+ }
+else input = (Fl_Input*)ob;
+view = (SEA_VIEW *)data_plus->p;
+if(view->tot_seqs == 0) return;
+p = (char *)input->value();
+q = p - 1; while(*(++q) != 0) {
+ if(!isdigit(*q)) numerique = FALSE;
+ }
+if(numerique) { /* aller a une position de l'alignement */
+ sscanf(p,"%d",&new_pos);
+ if(view->cursor_in_comment)
+ maxi = view->comment_length[view->cursor_seq - 1];
+ else
+ maxi = view->each_length[view->cursor_seq - 1];
+ if( new_pos <= 0 || new_pos > maxi ) {
+ input->value("");
+ fl_ringbell(0);
+ }
+ else {
+ set_and_show_new_cursor_site(view, new_pos, TRUE, FALSE);
+ }
+ }
+else { /* recherche d'une seq par son nom */
+ l = strlen(p);
+ if(l > sizeof(target) - 1) l = sizeof(target) - 1;
+ strncpy(target, p, l); target[l] = 0; majuscules(target);
+ if(view->wid_names > l_upname) {
+ if(l_upname > 0) free(upname);
+ upname = (char *)malloc(view->wid_names + 1);
+ l_upname = view->wid_names;
+ }
+ for(num = 0; num < view->tot_seqs; num++) {
+ strncpy(upname, view->seqname[num], l_upname);
+ upname[l_upname] = 0; majuscules(upname);
+ if(strstr(upname, target) != NULL) break;
+ }
+ if(num >= view->tot_seqs) {
+ fl_ringbell(0);
+ return;
+ }
+ if(view->cursor_site < view->first_site ||
+ view->cursor_site >= view->first_site + view->tot_sites)
+ view->cursor_site = view->first_site;
+ set_and_show_new_cursor_seq(view, num + 1);
+ }
+view->DNA_obj->take_focus();
+}
+
+
+char *search_with_gaps(char *target, char *debut)
+{
+char *cherche, *trouve = debut - 1;
+do {
+ debut = trouve + 1;
+ trouve = NULL;
+ cherche = target;
+ do {
+ while( *debut == '-' ) debut++;
+ if(trouve == NULL) trouve = debut;
+ if ( toupper(*debut) != *cherche ) break;
+ cherche++; debut++;
+ }
+ while( *cherche != 0 );
+ }
+while( *trouve != 0 && *cherche != 0);
+return ( *cherche == 0 ? trouve : (char*)NULL );
+}
+
+
+void search_callback(Fl_Widget *ob, void *data)
+{
+SEA_VIEW *view;
+char target[50], *pos, *debut;
+int new_pos;
+int l = -1;
+
+user_data_plus *data_plus = (user_data_plus *)data;
+int which = data_plus->value;
+if(which == 1) { /* appele par champ input */
+ pos = (char *)((Fl_Input*)ob)->value() - 1;
+ }
+else { /* appele par bouton search */
+ Fl_Input *champ = (Fl_Input *)data_plus->p;
+ pos = (char *)champ->value() - 1;
+ data_plus = (user_data_plus *) champ->user_data();
+ }
+view = (SEA_VIEW *)data_plus->p;
+if(view->tot_seqs == 0) return;
+while( *++pos && l+1 < sizeof(target) )
+ target[++l] = toupper(*pos);
+target[++l] = 0;
+if( l == 0 ) return;
+if(view->cursor_in_comment)
+ debut = view->comment_line[view->cursor_seq - 1] + view->cursor_site;
+else
+ debut = view->sequence[view->cursor_seq - 1] + view->cursor_site;
+pos = search_with_gaps(target, debut);
+if(pos == NULL) fl_ringbell(0);
+else {
+ if(view->cursor_in_comment)
+ new_pos = pos - view->comment_line[view->cursor_seq - 1] + 1;
+ else
+ new_pos = pos - view->sequence[view->cursor_seq - 1] + 1;
+ set_and_show_new_cursor_site(view, new_pos, TRUE, FALSE);
+ }
+view->DNA_obj->take_focus();
+}
+
+
+void free_alignment(SEA_VIEW *view)
+{
+int num, c;
+if(view->header!=NULL) { free(view->header); view->header = NULL; }
+for(num = 0; num < view->tot_seqs; num++) {
+ free(view->sequence[num]);
+ free(view->seqname[num]);
+ if(view->comments[num] != NULL) {
+ free(view->comments[num]);
+ view->comments[num] = NULL;
+ }
+ if(view->numb_gc > 1) {
+ for(c = 0; c < view->numb_gc; c++) free(view->col_seq[num][c]);
+ free(view->col_seq[num]);
+ }
+ }
+if( view->tot_seqs > 0 ) {
+ free(view->sequence);
+ free(view->seqname);
+ free(view->comments);
+ }
+if( view->numb_gc > 1 && view->tot_seqs > 0 ) free(view->col_seq);
+if(view->masename != NULL) {
+ free(view->masename);
+ view->masename = NULL;
+ }
+if( view->tot_seqs >= 1 ) {
+ free(view->each_length);
+ free(view->sel_seqs);
+ free(view->region_line);
+ }
+while (view->regions != NULL)
+ delete_region(view, 1);
+for(num = 0; num < view->numb_species_sets; num++) {
+ free(view->list_species_sets[num]);
+ free(view->name_species_sets[num]);
+ }
+view->numb_species_sets = 0;
+view->tot_seqs = 0;
+view->tot_sel_seqs = 0;
+free_region(view->active_region);
+view->active_region = NULL;
+if(view->menu_file != NULL) {
+ Fl_Menu_Item *items =
+ (Fl_Menu_Item *) ((Fl_Menu_ *)view->menu_file)->menu();
+ items[SAVE].deactivate();
+ items[SAVE_AS].deactivate();
+ items[SAVE_REGIONS].deactivate();
+ }
+if(view->tot_comment_lines > 0) {
+ for(num = 0; num < view->tot_comment_lines; num++) {
+ free(view->comment_name[num]);
+ free(view->comment_line[num]);
+ }
+ free(view->comment_name);
+ free(view->comment_line);
+ free(view->comment_length);
+ view->tot_comment_lines = 0;
+ view->show_comment_lines = FALSE;
+ }
+}
+
+
+void load_alignment_file(SEA_VIEW *view, char *filename, char *message,
+ char *pattern, known_format file_format)
+{
+char *err_message, *p;
+int protein;
+if(view->tot_seqs > 0 && view->modif_but_not_saved) {
+ if( ! fl_ask("Alignment was modified but not saved\n"
+ "Do you want to read a new alignment?") ) return;
+ }
+if(filename == NULL) {
+ filename = (char *)fl_file_chooser(message,pattern,"");
+ if(filename==NULL) return;
+ }
+my_watch_cursor(view->dnawin);
+if(view->alt_col_seq != NULL) {
+ reference_toggle(view, FALSE);
+ }
+free_alignment(view);
+if(file_format == MASE_FORMAT) {
+ view->tot_seqs = read_mase_seqs_header(filename, &view->sequence,
+ &view->seqname, &view->comments, &view->header,
+ &err_message);
+/* interpreter les regions du header du fichier mase */
+ view->regions = parse_regions_from_header(view->header);
+/* interpreter les species sets du fichier mase */
+ view->numb_species_sets = parse_species_sets_from_header(view->header,
+ view->list_species_sets, view->name_species_sets, view->tot_seqs);
+/* interpreter les comment lines du header */
+view->tot_comment_lines = parse_comment_lines_from_header(view->header,
+ &(view->comment_line), &(view->comment_name),
+ &(view->comment_length) , &(view->max_seq_length));
+ }
+else if(file_format == FASTA_FORMAT)
+ view->tot_seqs = read_fasta_align(filename, &view->sequence,
+ &view->seqname, &view->comments, &view->header, &err_message);
+else if(file_format == PHYLIP_FORMAT)
+ view->tot_seqs = read_phylip_align(filename, &view->sequence,
+ &view->seqname, &view->comments, &view->header, &err_message);
+else if(file_format == CLUSTAL_FORMAT)
+ view->tot_seqs = read_clustal_align(filename, &view->sequence,
+ &view->seqname, &view->comments, &view->header, &err_message);
+else if(file_format == MSF_FORMAT)
+ view->tot_seqs = read_msf_align(filename, &view->sequence,
+ &view->seqname, &view->comments, &view->header, &err_message);
+else if(file_format == NEXUS_FORMAT) {
+ int **list_sp = NULL; char **name_sp = NULL; int i;
+ view->tot_seqs = read_nexus_align(filename, &view->sequence,
+ &view->seqname, &view->comments, &view->header,
+ &err_message, &view->regions, &view->numb_species_sets,
+ &list_sp, &name_sp, &view->tot_comment_lines,
+ &view->comment_name, &view->comment_line,
+ &view->comment_length);
+ for(i= 0; i < view->numb_species_sets; i++) {
+ view->list_species_sets[i] = list_sp[i];
+ view->name_species_sets[i] = name_sp[i];
+ }
+ if(list_sp != NULL) free(list_sp);
+ if(name_sp != NULL) free(name_sp);
+ }
+if(view->tot_seqs == 0) {
+ fl_reset_cursor(view->dnawin);
+ fl_alert("Error while reading file %s\n%s", filename,
+ err_message);
+ view->DNA_obj->parent()->redraw();
+ return;
+ }
+protein = is_a_protein_seq(view->sequence[0]);
+p = extract_filename(filename);
+view->dnawin->label(p, p);
+if(view->menu_file != NULL) {
+ Fl_Menu_Item *items =
+ (Fl_Menu_Item *) ((Fl_Menu_ *)view->menu_file)->menu();
+ if(file_format == view->format_for_save) {
+ items[SAVE].activate();
+ items[SAVE_AS].activate();
+ }
+ else {
+ items[SAVE_AS].activate();
+ if(view->masename != NULL) {
+ free(view->masename);
+ view->masename = filename = NULL;
+ }
+ }
+ }
+init_dna_scroller(view, view->tot_seqs, filename, protein, view->header);
+view->DNA_obj->parent()->redraw();
+fl_reset_cursor(view->dnawin);
+return;
+}
+
+
+void mainwin_close_callback(Fl_Widget *form, void *data)
+{
+SEA_VIEW *view = (SEA_VIEW *)data;
+if(view->modif_but_not_saved) {
+ if( ! fl_ask(
+ "Alignment was modified but not saved\n"
+ "Do you want to quit anyway?") ) return;
+ }
+exit(0);
+}
+
+
+void file_menu_callback(Fl_Widget *ob, long which)
+{
+SEA_VIEW *view;
+static char *pattern[] = {
+#ifdef WIN32
+ "*.mas"
+#else
+ "*.mase"
+#endif
+ , "*", "*.aln", "*.msf", "*", "*.nx"};
+static char fsel_message[50];
+char *filename;
+int reponse = ((Fl_Menu_Button*)ob)->value();
+view = (SEA_VIEW *) ob->user_data();
+if(reponse == QUIT) { /* quit */
+ mainwin_close_callback(view->dnawin, view);
+ }
+else if(reponse == OPEN_MASE) {
+ load_alignment_file(view, NULL,
+#ifdef WIN32
+ "Choose a .mas file",
+#else
+ "Choose a .mase file",
+#endif
+ pattern[0], MASE_FORMAT);
+ }
+else if(reponse == OPEN_PHYLIP ) {
+ load_alignment_file(view, NULL,
+ "Choose a Phylip file" ,"*", PHYLIP_FORMAT );
+ }
+else if(reponse == OPEN_FASTA ) {
+ load_alignment_file(view, NULL,
+ "Choose a Fasta file" ,"*", FASTA_FORMAT );
+ }
+else if(reponse == OPEN_CLUSTAL ) {
+ load_alignment_file(view, NULL,
+ "Choose a Clustal file" ,"*.aln", CLUSTAL_FORMAT );
+ }
+else if(reponse == OPEN_MSF ) {
+ load_alignment_file(view, NULL,
+ "Choose an MSF file" ,"*.msf", MSF_FORMAT );
+ }
+else if(reponse == OPEN_NEXUS ) {
+ load_alignment_file(view, NULL,
+ "Choose a NEXUS file" ,"*.nx", NEXUS_FORMAT );
+ }
+else if(reponse == SAVE || reponse == SAVE_AS) {
+ char *err;
+ if(reponse == SAVE_AS) { /* Save as */
+ FILE *in;
+ sprintf(fsel_message,"Choose a %s file name",
+ f_format_names[view->format_for_save]);
+ filename = fl_file_chooser_save_as(fsel_message,
+ pattern[view->format_for_save],
+ extract_filename(view->masename), view);
+ if(filename==NULL) return;
+#ifndef __APPLE__
+ in = fopen(filename,"r");
+ if(in != NULL) {
+ char tmp[200];
+ fclose(in);
+ sprintf(tmp, "This file already exists\n%s\n"
+ "Do you want to overwrite it?", filename);
+ if( ! fl_ask(tmp) )
+ return;
+ }
+#endif
+ }
+ else filename = view->masename;
+ my_watch_cursor(view->dnawin);
+ save_active_region(view, TRUE);
+ err = save_alignment_or_region(filename, view->sequence, view->comments,
+ view->header, view->seqname, view->tot_seqs, view->each_length,
+ view->regions, NULL, view->format_for_save,
+ view->numb_species_sets, view->list_species_sets,
+ view->name_species_sets, NULL, 0, view->protein,
+ view->tot_comment_lines, view->comment_name,
+ view->comment_line);
+ fl_reset_cursor(view->dnawin);
+ if(err != NULL) fl_alert(err);
+ else {
+ if(reponse == SAVE_AS) {
+ if(view->masename != NULL) free(view->masename);
+ view->masename=(char *)malloc(strlen(filename)+1);
+ if(view->masename == NULL) out_of_memory();
+ strcpy(view->masename,filename);
+ view->dnawin->label(extract_filename(filename));
+ Fl_Menu_Item *items =
+ (Fl_Menu_Item *) ((Fl_Menu_ *)ob)->menu();
+ items[SAVE].activate();
+ }
+ view->modif_but_not_saved = FALSE;
+ }
+ }
+else if(reponse == SAVE_REGIONS) { /* save current regions choice */
+ char *err;
+ static char regions_only_filename[200];
+ static int first = TRUE;
+ if(first) {
+ strcpy(regions_only_filename, "regions");
+ if( strchr(pattern[view->format_for_save],'.') != NULL)
+ strcat(regions_only_filename,
+ pattern[view->format_for_save]+1);
+ first = FALSE;
+ }
+ if(view->active_region == NULL) return;
+ sprintf(fsel_message,"Choose a %s file name",
+ f_format_names[view->format_for_save]);
+ filename = fl_file_chooser_save_as(fsel_message,
+ pattern[view->format_for_save],
+ regions_only_filename, view);
+ if(filename==NULL) return;
+ my_watch_cursor(view->dnawin);
+ err = save_alignment_or_region(filename, view->sequence, view->comments,
+ view->header, view->seqname, view->tot_seqs, view->each_length,
+ NULL, view->active_region, view->format_for_save,
+ 0, NULL, NULL, view->sel_seqs, view->tot_sel_seqs,
+ view->protein, 0, NULL, NULL);
+ fl_reset_cursor(view->dnawin);
+ if(err != NULL) fl_alert(err);
+ else strcpy(regions_only_filename, extract_filename(filename));
+ }
+else if(reponse == PRINTOUT && view->tot_seqs > 0) {
+ int anerr;
+ FILE *in;
+
+ if( view->alt_col_seq != NULL ) {
+ for(anerr = 0; anerr < view->tot_seqs; anerr++)
+ if(view->sel_seqs[anerr]) break;
+ }
+ else anerr = -1;
+ filename = (char *) fl_file_chooser_plus(
+ "Enter a printout file name", "", "",
+ (anerr >= 0 ? TRUE : FALSE) );
+ if(filename==NULL) return;
+#ifndef __APPLE__
+ in = fopen(filename,"r");
+ if(in != NULL) {
+ char tmp[200];
+ fclose(in);
+ sprintf(tmp, "This file already exists\n%s\n"
+ "Do you want to overwrite it?", filename);
+ if( ! fl_ask(tmp) )
+ return;
+ }
+#endif
+ my_watch_cursor(view->dnawin);
+ anerr = prepare_printout(filename, view->sequence, view->tot_seqs,
+ view->seqname, view->each_length, printout_cpl,
+ printout_block, printout_lpp, printout_vary,
+ view->masename, anerr);
+ fl_reset_cursor(view->dnawin);
+ if( anerr ) fl_alert("Error while writing to file %s",
+ filename);
+ }
+}
+
+
+
+#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;
+}
+
+#else
+
+#define read_next_help_line(a,b,c) fgets(a,b,(FILE *)c)
+
+#endif
+
+/*
+char *get_next_help_line(void *in, char *line, int lline)
+{
+#ifdef WIN32
+static const int win32=TRUE;
+#else
+static const int win32=FALSE;
+#endif
+static int accept = TRUE;
+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)
+ accept = win32;
+else if(strncmp(line, "#ifndef", 7) == 0)
+ accept = !win32;
+else if(strncmp(line, "#else", 5) == 0)
+ accept = !accept;
+else if(strncmp(line, "#endif", 6) == 0)
+ accept = TRUE;
+else
+ accept = TRUE; // should not occur
+return get_next_help_line(in, line, lline);
+}
+*/
+
+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 in_if = 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 ) ;
+ in_if = TRUE;
+ }
+/*
+else if(strncmp(line, "#ifndef", 7) == 0)
+ accept = !win32;
+*/
+else if(strncmp(line, "#elif", 5) == 0) {
+ accept = ( strstr(line, match) != NULL ) ;
+ if(in_if && !accept) in_if = FALSE;
+ else in_if = TRUE;
+ }
+else if(strncmp(line, "#else", 5) == 0) {
+ if(in_if) accept = !accept;
+ }
+else if(strncmp(line, "#endif", 6) == 0) {
+ accept = TRUE;
+ in_if = FALSE;
+ }
+else
+ accept = TRUE; // should not occur
+return get_next_help_line(in, line, lline);
+}
+
+
+typedef struct {
+ Fl_Widget *br_item, *box;
+ void *in;
+ } browser_struct;
+
+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 free_colseqs_by_difference(char ***alt_col_seq, int total, int numb_gc)
+{
+int num, c;
+
+if(alt_col_seq == NULL) return;
+for(num = 0; num < total; num++) {
+ for(c = 0; c < numb_gc; c++) free(alt_col_seq[num][c]);
+ free(alt_col_seq[num]);
+ }
+if( total > 0 ) free(alt_col_seq);
+}
+
+
+void reference_toggle(SEA_VIEW *view, int on)
+{
+char ***tmp;
+static int old_pos;
+
+if(view->numb_gc == 1) return;
+Fl_Menu_Button *menu_props = (Fl_Menu_Button *)view->bouton_props;
+props_menu_parts *props_parts = (props_menu_parts *)menu_props->user_data();
+if(on) { /* tenter de passer en mode par reference */
+ if(view ->inverted_colors || view->tot_sel_seqs != 1 ||
+ view->numb_gc == 1) {
+ menu_props->mode(props_parts->reference, FL_MENU_TOGGLE);
+ return;
+ }
+ my_watch_cursor(view->dnawin);
+ for(old_pos = 0; old_pos < view->tot_seqs; old_pos++)
+ if(view->sel_seqs[old_pos]) break;
+ deplacer_grp_seqs(view, 1);
+ view->first_seq = 1;
+ view->vertsli->Fl_Slider::value(1);
+ view->alt_col_seq = prepcolseqs_by_difference(view->sequence,
+ view->tot_seqs, 0,
+ view->max_seq_length,
+ view->each_length,
+ ( view->protein ? get_color_for_aa : get_color_for_base ),
+ view->numb_gc, view->allow_lower);
+ fl_reset_cursor(view->dnawin);
+ if(view->alt_col_seq == NULL) {
+ view->DNA_obj->redraw();
+ menu_props->mode(props_parts->reference, FL_MENU_TOGGLE);
+ return;
+ }
+ tmp = view->alt_col_seq;
+ view->alt_col_seq = view->col_seq;
+ view->col_seq = tmp;
+ view->DNA_obj->redraw();
+ menu_props->mode(props_parts->colors - 1,
+ FL_SUBMENU | FL_MENU_INACTIVE);
+ menu_props->mode(props_parts->reference,
+ FL_MENU_TOGGLE | FL_MENU_VALUE);
+ view->menu_edit->labelcolor(FL_INACTIVE_COLOR);
+ view->menu_edit->deactivate();
+ view->menu_species->labelcolor(FL_INACTIVE_COLOR);
+ view->menu_species->deactivate();
+ }
+else { /* retour mode normal */
+ my_watch_cursor(view->dnawin);
+ tmp = view->alt_col_seq;
+ view->alt_col_seq = view->col_seq;
+ view->col_seq = tmp;
+ free_colseqs_by_difference(view->alt_col_seq, view->tot_seqs,
+ view->numb_gc);
+ view->alt_col_seq = NULL;
+ deplacer_grp_seqs(view, old_pos + 1);
+ view->DNA_obj->redraw();
+ menu_props->mode(props_parts->colors - 1, FL_SUBMENU);
+ menu_props->mode(props_parts->reference, FL_MENU_TOGGLE);
+ view->menu_edit->labelcolor(FL_BLACK);
+ view->menu_edit->activate();
+ view->menu_species->labelcolor(FL_BLACK);
+ view->menu_species->activate();
+ fl_reset_cursor(view->dnawin);
+ }
+}
+
+
+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 *)open_path( (char *)data );
+#endif
+ if(data == NULL) {
+ fl_alert(
+#ifdef __APPLE__
+ "No help information in program resources"
+#else
+ "Help file %s\nnot found in PATH directories nor in current directory", (char *)data
+#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_Browser(5, 20, titres_width,
+ help_form->h() - 50, "Choose help item");
+ browser_titres->type(FL_HOLD_BROWSER);
+ 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->type(FL_NORMAL_BROWSER);
+ 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();
+}
+
+
+int insert_gaps_at(SEA_VIEW *view, int seq, int site, int total)
+{
+char *pos, **psequence;
+int l, c, gapcolor, *plength;
+if(view->cursor_in_comment) {
+ psequence = view->comment_line;
+ plength = view->comment_length;
+ }
+else {
+ psequence = view->sequence;
+ plength = view->each_length;
+ gapcolor = ( view->protein ?
+ get_color_for_aa('-') : get_color_for_base('-') );
+ }
+l = plength[seq-1];
+if(site > l + 1) return total;
+if( l + total > view->max_seq_length) total = view->max_seq_length - l;
+pos = psequence[seq-1] + site - 1;
+memmove(pos+total, pos, l - site + 2);
+memset(pos, '-', total);
+if( (!view->cursor_in_comment) && view->numb_gc > 1) {
+ for (c=0; c<view->numb_gc; c++) {
+ pos= &view->col_seq[seq-1][c][site-1];
+ memmove(pos+total, pos, l - site + 2);
+ memset(pos,' ',total);
+ }
+ memset(view->col_seq[seq-1][gapcolor] + site - 1, '-', total);
+ }
+plength[seq-1] += total;
+view->modif_but_not_saved = TRUE;
+return total;
+}
+
+
+int delete_gaps_before(SEA_VIEW *view, int numseq, int numsite, int total)
+{
+char *site, *finseq, **psequence;
+int c, count = -1, l, retval, *plength;
+
+psequence = view->sequence;
+plength = view->each_length;
+site = psequence[numseq-1] + numsite - 1;
+finseq = psequence[numseq-1] + plength[numseq-1] - 1;
+do { site--; count++; }
+while ( count < total && site >= psequence[numseq-1] &&
+ ( view->allow_seq_edit || *site == '-' || site > finseq) );
+if(count == 0) return 0;
+/* ne rien faire si on efface au dela de la fin de la seq */
+if(numsite - count > plength[numseq-1]) return count;
+l = plength[numseq-1];
+retval = count;
+if(numsite > l) { /* effacer depuis au dela fin jusqu'a interieur seq */
+ count -= (numsite - l - 1);
+ numsite = l + 1;
+ }
+site = psequence[numseq-1] + numsite - 1;
+memmove(site-count, site, l - numsite + 2);
+if( view->numb_gc > 1) {
+ for (c=0; c < view->numb_gc; c++) {
+ site= view->col_seq[numseq-1][c] + numsite - 1;
+ memmove(site-count,site, l - numsite + 2);
+ }
+ }
+plength[numseq-1] -= count;
+view->modif_but_not_saved = TRUE;
+return retval;
+}
+
+
+void adjust_menu_edit_modes(SEA_VIEW *view)
+{
+if(view->menu_edit != NULL) {
+ Fl_Menu_Item *items = (Fl_Menu_Item *) ((Fl_Menu_ *)view->menu_edit)->menu();
+ if(view->tot_sel_seqs != 0) {
+ items[DELETE_SEQ].activate();
+ items[CONSENSUS_SEQ].activate();
+ if(!view->protein) items[EXCHANGE_UT].activate();
+ }
+ else {
+ items[DELETE_SEQ].deactivate();
+ items[EXCHANGE_UT].deactivate();
+ }
+ if(view->tot_sel_seqs == 1) {
+ items[RENAME_SEQ].activate();
+ items[DUPLICATE_SEQ].activate();
+ items[EDIT_COMMENTS].activate();
+ if(!view->protein) {
+ items[COMPLEMENT_SEQ].activate();
+ items[REVERSE_SEQ].activate();
+ }
+ }
+ else {
+ items[RENAME_SEQ].deactivate();
+ items[DUPLICATE_SEQ].deactivate();
+ items[EDIT_COMMENTS].deactivate();
+ items[COMPLEMENT_SEQ].deactivate();
+ items[REVERSE_SEQ].deactivate();
+ }
+ if(view->tot_sel_seqs == 2)
+ items[DOT_PLOT].activate();
+ else
+ items[DOT_PLOT].deactivate();
+ if(view->tot_sel_seqs >= 2) {
+ items[ALIGN_SEQS].activate();
+ items[CONSENSUS_SEQ].activate();
+ }
+ else {
+ items[ALIGN_SEQS].deactivate();
+ items[CONSENSUS_SEQ].deactivate();
+ }
+ }
+}
+
+
+void select_deselect_seq(SEA_VIEW *view, int new_seq)
+{
+/* new_seq = # seq a select/deselect; si 0: tout deselectionner;
+ si -1: tout selectionner
+ si -2: ne pas changer la selection mais ajuster l'interface selon son etat
+*/
+if(new_seq > 0) { /* traiter une sequence */
+ view->sel_seqs[new_seq-1] = !view->sel_seqs[new_seq-1];
+ if(view->sel_seqs[new_seq-1])
+ ++view->tot_sel_seqs;
+ else
+ --view->tot_sel_seqs;
+ }
+else if(new_seq == 0) { /* tout deselectionner */
+ view->tot_sel_seqs = 0;
+ memset(view->sel_seqs, 0, view->tot_seqs * sizeof(int));
+ }
+else if(new_seq == -1) { /* tout selectionner */
+ int i;
+ view->tot_sel_seqs = view->tot_seqs;
+ for(i=0; i < view->tot_seqs; i++) view->sel_seqs[i] = TRUE;
+ }
+adjust_menu_edit_modes(view);
+if(view->menu_species != NULL) {
+ int taille, valeur;
+ Fl_Menu_Item *items =
+ (Fl_Menu_Item *)((Fl_Menu_*)view->menu_species)->menu();
+ if(view->tot_sel_seqs == 0)
+ items[0].deactivate();
+ else
+ items[0].activate();
+ items[1].deactivate();
+ get_menu_taille_valeur(view->menu_species, &taille, &valeur);
+ if(valeur != 0)
+ update_menu_taille_valeur(view->menu_species, taille, 0, 2);
+ }
+}
+
+
+void deplacer_grp_seqs(SEA_VIEW *view, int target)
+{
+/* deplacer toutes les seqs selectionnees pour positionner la premiere
+d'entre elles en position target */
+int *new_rank, *old_rank, old, new_val, numset;
+char **aux;
+-- target;
+new_rank = (int *)malloc(view->tot_seqs * sizeof(int));
+old_rank = (int *)malloc(view->tot_seqs * sizeof(int));
+aux = (char **)malloc( view->tot_seqs * sizeof(char *) );
+if(new_rank == NULL || old_rank == NULL || aux == NULL) out_of_memory();
+/* compute old_rank[new_val] = old */
+new_val = -1;
+/* place first all non selected seqs */
+for(old = 0; old < view->tot_seqs; old++) {
+ if(!view->sel_seqs[old]) old_rank[++new_val] = old;
+ }
+/* allocate room for selected seqs */
+if(target + view->tot_sel_seqs > view->tot_seqs)
+ target = view->tot_seqs - view->tot_sel_seqs;
+old = view->tot_seqs - view->tot_sel_seqs - target;
+if(old != 0)
+ memmove(old_rank + target + view->tot_sel_seqs, old_rank + target,
+ old * sizeof(int));
+/* insert selected seqs */
+for(old = 0; old < view->tot_seqs; old++)
+ if(view->sel_seqs[old]) old_rank[target++] = old;
+/* compute new_rank[old] = new_val */
+for(new_val = 0; new_val < view->tot_seqs; new_val++)
+ new_rank[old_rank[new_val]] = new_val;
+/* displace all sequence order-dependent ingredients */
+/* deplacer la position du curseur */
+if(!view->cursor_in_comment) {
+ view->cursor_seq = new_rank[view->cursor_seq - 1] + 1;
+ view->old_cursor_seq = view->cursor_seq;
+ }
+/* deplacer les seqs */
+for(old = 0; old < view->tot_seqs; old++)
+ aux[new_rank[old]] = view->sequence[old];
+memcpy(view->sequence, aux, view->tot_seqs * sizeof(char *) );
+/* deplacer les noms */
+for(old = 0; old < view->tot_seqs; old++)
+ aux[new_rank[old]] = view->seqname[old];
+memcpy(view->seqname, aux, view->tot_seqs * sizeof(char *) );
+/* deplacer les commentaires */
+for(old = 0; old < view->tot_seqs; old++)
+ aux[new_rank[old]] = view->comments[old];
+memcpy(view->comments, aux, view->tot_seqs * sizeof(char *) );
+/* deplacer les seqs en couleurs */
+if(view->numb_gc > 1) {
+ for(old = 0; old < view->tot_seqs; old++)
+ aux[new_rank[old]] = (char *) view->col_seq[old];
+ memcpy(view->col_seq, aux, view->tot_seqs * sizeof(char *) );
+ }
+/* deplacer les sequences selectionnees */
+for(old = 0; old < view->tot_seqs; old++)
+ old_rank[new_rank[old]] = view->sel_seqs[old];
+memcpy(view->sel_seqs, old_rank, view->tot_seqs * sizeof(int) );
+/* deplacer les longueurs de sequences */
+for(old = 0; old < view->tot_seqs; old++)
+ old_rank[new_rank[old]] = view->each_length[old];
+memcpy(view->each_length, old_rank, view->tot_seqs * sizeof(int) );
+/* process species sets */
+for(numset = 0; numset < view->numb_species_sets; numset++) {
+ for(old = 0; old < view->tot_seqs; old++)
+ old_rank[new_rank[old]] = view->list_species_sets[numset][old];
+ memcpy(view->list_species_sets[numset], old_rank,
+ view->tot_seqs * sizeof(int) );
+ }
+free(aux); free(old_rank); free(new_rank);
+view->modif_but_not_saved = TRUE;
+}
+
+
+void update_current_seq_length(int newlength, SEA_VIEW *view)
+{
+double x; int l;
+if(newlength > view->seq_length) {
+ view->seq_length =
+ ( newlength+20 < view->max_seq_length ?
+ newlength+20 : view->max_seq_length );
+ l = view->seq_length - view->tot_sites+3;
+ if(l<1) l=1;
+ view->horsli->bounds(1,l);
+ x = ( (double) view->tot_sites ) /
+ ( view->seq_length + 3 ) ;
+ if(x>1) x=1;
+ view->horsli->slider_size(x);
+ }
+}
+
+
+int insert_char_in_seq( int key, int total, SEA_VIEW *view)
+/* to insert the typed key in the sequence at cursor location if it is visible
+returns # of inserted chars if ok, 0 if error (= cursor not visible or
+max seq size is reached)
+*/
+{
+char *pos;
+int l, c, *plength;
+if(view->cursor_in_comment) {
+ if( view->cursor_seq < 1 ||
+ view->cursor_seq >= view->tot_comment_lines ||
+ view->cursor_site < view->first_site ||
+ view->cursor_site >= view->first_site + view->tot_sites ) return 0;
+ l = view->comment_length[view->cursor_seq - 1];
+ }
+else {
+ if( view->cursor_seq < view->first_seq ||
+ view->cursor_seq >=view->first_seq+view->tot_lines ||
+ view->cursor_site < view->first_site ||
+ view->cursor_site >= view->first_site + view->tot_sites ) return 0;
+ l = view->each_length[view->cursor_seq-1];
+ }
+if(view->cursor_site > l + 1) return 0;
+if( l + total > view->max_seq_length) total = view->max_seq_length - l;
+if(total <= 0) return 0;
+if(view->cursor_in_comment)
+ pos = view->comment_line[view->cursor_seq - 1] + view->cursor_site - 1;
+else
+ pos = view->sequence[view->cursor_seq - 1] + view->cursor_site - 1;
+memmove(pos+total, pos, l - view->cursor_site + 2);
+memset(pos, view->cursor_in_comment || view->allow_lower ? key : toupper(key) ,
+ total);
+if( (!view->cursor_in_comment) && view->numb_gc > 1) {
+ for (c=0; c<view->numb_gc; c++) {
+ pos= &view->col_seq[view->cursor_seq-1][c][view->cursor_site-1];
+ memmove(pos+total, pos, l - view->cursor_site + 2);
+ memset(pos, ' ' ,total);
+ }
+ c = (view->protein ?
+ get_color_for_aa(key) : get_color_for_base(key) );
+ memset(view->col_seq[view->cursor_seq-1][c] + view->cursor_site - 1,
+ view->allow_lower ? key : toupper(key), total);
+ }
+if(view->cursor_in_comment)
+ plength = &(view->comment_length[view->cursor_seq-1]);
+else
+ plength = &(view->each_length[view->cursor_seq-1]);
+(*plength) += total;
+update_current_seq_length(*plength, view);
+view->modif_but_not_saved = TRUE;
+return total;
+}
+
+
+/* The routine that does drawing */
+void DNA_obj::draw(void)
+{
+SEA_VIEW *view = (SEA_VIEW *)this->user_data();
+
+/* returns TRUE if window size was changed by user */
+if( compute_size_params( view, FALSE) ) {
+ view->horsli->redraw();
+ view->vertsli->redraw();
+ }
+if( ( this->damage() & FL_DAMAGE_ALL ) != 0 ) {
+// appel autre que uniquement par damage partiel
+ view->draw_names = -1;
+ view->mod_cursor = view->mod_region_line = view->mod_comment_line =
+ FALSE;
+ view->mod_seq = 0;
+ }
+if(view->draw_names) { /* soit tous (<= -1) soit un seul ( >= 1) */
+ draw_seq_names(view->DNA_obj, view);
+ if(view->draw_names > 0 || view->draw_names == -2){
+ /* si > 0 ou -2, ne pas ecrire les seqs*/
+ view->draw_names = -1;
+ return;
+ }
+ }
+if(view->mod_cursor) {
+ /* effacer old_cursor en ecrivant dessus */
+ draw_cursor(view->DNA_obj, FALSE, view->old_cursor_site,
+ view->old_cursor_seq, view->old_cursor_in_comment);
+ view->mod_cursor = FALSE;
+ }
+else if(view->mod_region_line) {
+ draw_region_line(view->DNA_obj, view);
+ view->mod_region_line = FALSE;
+ }
+else if(view->mod_comment_line) {
+ draw_comment_lines(view->DNA_obj, view);
+ view->mod_comment_line = FALSE;
+ }
+else {
+ if(view->inverted_colors)
+ draw_dna_seqs_inverted(view->DNA_obj, view);
+ else
+ draw_dna_seqs(view->DNA_obj, view);
+ draw_comment_lines(view->DNA_obj, view);
+ }
+view->mod_seq = 0;
+view->draw_names = -1;
+draw_cursor(view->DNA_obj, TRUE , view->cursor_site, view->cursor_seq,
+ view->cursor_in_comment);
+view->old_cursor_seq = view->cursor_seq;
+view->old_cursor_site = view->cursor_site;
+view->old_cursor_in_comment = view->cursor_in_comment;
+}
+
+
+int my_event_button(void)
+{
+int key;
+
+key = Fl::event_button(); /* key: 1=gauche, 2=centre, 3=droit souris */
+if(emul_3_buttons) {
+#ifdef __APPLE__
+ if(Fl::event_state(FL_META)) key = 2;// bouton du milieu sur Mac controlKey ==> FL_META
+#else
+ if(Fl::event_state(FL_CTRL)) key = 2;// bouton du milieu par Ctrl-Click
+#endif
+ else if(Fl::event_state(FL_SHIFT)) key = 3;// bouton droit par Shift-Click
+ }
+return key;
+}
+
+
+
+int DNA_obj::handle(int event)
+{
+SEA_VIEW *view;
+/* numero courant de la derniere seq selectionnee pendant selection de seqs
+par glissement de la souris
+*/
+static int selecting_seqs = 0, sel_seq_move = 0;
+static int modifying_segment = 0;
+int mx = Fl::event_x();
+int my = Fl::event_y();
+
+view = (SEA_VIEW *) ( this->user_data() );
+if(view == NULL) return 1;
+ switch (event)
+ {
+ case FL_FOCUS:
+ return 1;
+ case FL_PUSH:
+ int key;
+ key = my_event_button();
+ if( Fl::event_clicks() ) { /* double click */
+ int new_seq;
+ Fl::event_clicks(0);
+ new_seq = (my + view->line_height/2 -
+ view->y_seq)/view->line_height + view->first_seq;
+ if( new_seq < view->first_seq || new_seq > view->tot_seqs ||
+ new_seq >= view->first_seq + view->tot_lines ) break;
+ if(mx < view->x_name || mx >= view->x_seq - view->char_width ||
+ key != 1) break;
+ /* double click sur nom de seq: selection de toutes les seqs */
+ if(view->alt_col_seq != NULL) break;
+ if(view->multipl->argument() > 0) mod_multipl(view,0);
+ select_deselect_seq(view, -1);
+ selecting_seqs = 0;
+ view->draw_names = -2;
+// ceci signifie redraw partiel commande' par draw_names, mod_cursor, ...
+ this->damage(1);
+ }
+ else { /* simple click */
+ Fl::focus(this);
+ handle_push(view, mx, my, key, &modifying_segment,
+ &selecting_seqs, &sel_seq_move);
+ }
+ break;
+ case FL_DRAG: /* mouvement avec souris enfoncee */
+ handle_mouse(view, mx, my, &selecting_seqs, &sel_seq_move,
+ &modifying_segment);
+ break;
+ case FL_RELEASE:
+ case FL_LEAVE:
+ if(selecting_seqs) {
+ if(sel_seq_move) {
+ select_deselect_seq(view, sel_seq_move);
+ view->draw_names = sel_seq_move;
+ this->damage(1);
+ }
+ else
+ select_deselect_seq(view, -2);
+ selecting_seqs = 0;
+ }
+ else if(modifying_segment) {
+ end_change_segment(view);
+ view->draw_names = 0;
+ this->damage(1);
+ modifying_segment = 0;
+ }
+ break;
+ case FL_KEYBOARD:
+ if( Fl::event_state(FL_CTRL) ) { /* vrai si touche ctrl */
+ return 0; /* ne pas traiter ici car shortcut d'autres widgets */
+ }
+ if(Fl::event_length() > 0) { /* du vrai texte */
+ handle_keyboard(view, Fl::event_text()[0], TRUE );
+ }
+ else { /* une touche genre fleche ou fonction */
+ handle_keyboard(view, Fl::event_key(), FALSE );
+ }
+ break;
+ default :
+ return 0;
+ }
+ return 1;
+}
+
+
+void handle_mouse(SEA_VIEW *view, int mx, int my,
+ int *p_selecting_seqs, int *p_sel_seq_move, int *p_modifying_segment)
+{ /* mouvement avec souris enfoncee */
+int debut, fin, step, num, new_seq, new_site;
+
+if(*p_selecting_seqs != 0) {
+ new_seq = (my + view->line_height/2 -
+ view->y_seq)/view->line_height + view->first_seq;
+ if(new_seq == *p_selecting_seqs) return;
+ if( new_seq < view->first_seq || new_seq > view->tot_seqs ||
+ new_seq >= view->first_seq + view->tot_lines ) return;
+ if(!view->sel_seqs[new_seq - 1])
+ { debut= new_seq; fin = *p_selecting_seqs; }
+ else
+ { debut= *p_selecting_seqs; fin = new_seq; }
+ if(debut < fin) step = 1;
+ else step = -1;
+ *p_selecting_seqs = new_seq;
+ for(num = debut; num != fin; num += step) {
+ new_seq = debut + fin - step - num - 1;
+ if(view->sel_seqs[new_seq]) {
+ view->sel_seqs[new_seq] = FALSE;
+ --(view->tot_sel_seqs);
+ }
+ else {
+ view->sel_seqs[new_seq] = TRUE;
+ ++(view->tot_sel_seqs);
+ }
+ if(*p_sel_seq_move == new_seq + 1) *p_sel_seq_move = 0;
+ }
+ if(*p_sel_seq_move) {
+ if( view->sel_seqs[*p_sel_seq_move - 1] ) {
+ view->sel_seqs[*p_sel_seq_move - 1] = FALSE;
+ --(view->tot_sel_seqs);
+ }
+ else {
+ view->sel_seqs[*p_sel_seq_move - 1] = TRUE;
+ ++(view->tot_sel_seqs);
+ }
+ *p_sel_seq_move = 0;
+ }
+ view->draw_names = -2;
+ view->DNA_obj->damage(1);
+ }
+else if(*p_modifying_segment != 0) {
+ new_site = (mx - view->x_seq )/view->char_width +
+ view->first_site;
+ if(new_site == *p_modifying_segment) return;
+ if( new_site < view->first_site ||
+ new_site > view->first_site + view->tot_sites ||
+ new_site > view->region_length ) return;
+ if( continue_change_segment(view, new_site) ) {
+ *p_modifying_segment = new_site;
+ view->draw_names = 0;
+ view->mod_region_line = TRUE;
+ view->DNA_obj->damage(1);
+ }
+ }
+}
+
+
+void handle_push(SEA_VIEW *view, int mx, int my, int key,
+ int *p_modifying_segment, int *p_selecting_seqs, int *p_sel_seq_move)
+/* key: 1=bouton gauche, 2=centre, 3=droit de la souris */
+{
+int new_site, new_seq, new_line;
+
+if(view->multipl->argument() > 0) mod_multipl(view,0);
+new_seq = (my + view->line_height/2 - view->y_seq)/view->line_height +
+ view->first_seq;
+new_line = new_seq - view->first_seq + 1;
+new_site = (mx - view->x_seq )/view->char_width +
+ view->first_site;
+if(view->active_region != NULL &&
+ new_seq == view->first_seq + FL_min(view->tot_lines,view->tot_seqs) &&
+ new_site >= view->first_site &&
+ new_site < view->first_site + view->tot_sites &&
+ new_site <= view->region_length ) {
+/* work with segments: extend, or create, or delete */
+ if(key == 2) { /* middle button:extend left neighbor segment */
+ new_seq = extend_segment_at_left(view, new_site);
+ if(new_seq) fl_ringbell(0);
+ else {
+ view->draw_names = 0;
+ }
+ }
+ else if(key == 3) { /* right button=>delete segment */
+ new_seq = suppr_segment(view->active_region, new_site,
+ view->region_line);
+ if(new_seq) fl_ringbell(0);
+ else {
+ view->draw_names = 0;
+ }
+ }
+ else { /* left button=>extend or create segment */
+ new_seq = begin_change_segment(view, new_site);
+ if(new_seq) {
+ view->mod_region_line = TRUE;
+ *p_modifying_segment = new_site;
+ }
+ view->draw_names = 0;
+ }
+ if(view->draw_names == 0) {
+ view->DNA_obj->damage(1);
+ }
+ return;
+ }
+if( view->show_comment_lines && new_line >= view->pos_first_comment_line &&
+ new_line < view->pos_first_comment_line + view->tot_comment_lines ) {
+/* dans les comment lines */
+ int num, old;
+ if(key != 1) return;
+ num = new_line - view->pos_first_comment_line + 1;
+ if(mx >= view->x_name && mx < view->x_seq - view->char_width) {
+ /* click sur nom de comment line: selection/deselection */
+ old = view->active_comment_line;
+ if(old == num)
+ view->active_comment_line = 0;
+ else
+ view->active_comment_line = num;
+ if(old == num || old == 0)
+ view->mod_comment_line = num;
+ else {
+ view->mod_comment_line = 0;
+ view->mod_seq = 1; // astuce
+ }
+ view->draw_names = 0;
+ update_menu_footers(view);
+ view->DNA_obj->damage(1);
+ }
+ else if( new_site >= view->first_site &&
+ new_site < view->first_site + view->tot_sites &&
+ new_site <= view->comment_length[num - 1] + 1 ) {
+ /* click sur comment: positionnement du curseur */
+ view->cursor_site = new_site;
+ view->cursor_seq = num;
+ view->draw_names = 0;
+ view->mod_cursor = TRUE;
+ view->cursor_in_comment = TRUE;
+ view->DNA_obj->damage(1);
+ }
+ return;
+ }
+
+if( new_seq < view->first_seq || new_seq > view->tot_seqs ||
+ new_seq >= view->first_seq + view->tot_lines ) return;
+if(mx >= view->x_name && mx < view->x_seq - view->char_width) {
+/* click sur nom de seq: selection/deselection */
+ if(view->alt_col_seq != NULL) return;
+ if(key == 1) {
+ *p_selecting_seqs = new_seq;
+ *p_sel_seq_move = new_seq;
+ return;
+ }
+ else if(key == 3) {
+ select_deselect_seq(view, 0);
+ view->draw_names = -2;
+ view->DNA_obj->damage(1);
+ return;
+ }
+ else { /* milieu: depl des seqs selectionnees */
+ if(view->tot_sel_seqs == 0 ||
+ view->sel_seqs[new_seq - 1])
+ { fl_ringbell(0); return; }
+ deplacer_grp_seqs(view, new_seq);
+ view->DNA_obj->redraw();
+ }
+ return;
+ }
+if(key != 1) return;
+/* click sur seq: positionnement du curseur */
+if( new_site >= view->first_site &&
+ new_site < view->first_site + view->tot_sites &&
+ new_site <= view->each_length[new_seq-1] + 1 ) {
+ view->cursor_site = new_site;
+ view->cursor_seq = new_seq;
+ view->cursor_in_comment = FALSE;
+ view->draw_names = 0;
+ view->mod_cursor = TRUE;
+ view->DNA_obj->damage(1);
+ }
+return;
+}
+
+
+void handle_keyboard(SEA_VIEW *view, unsigned int key, int istext)
+{
+int new_pos, multipl, num;
+
+multipl = view->multipl->argument();
+if(multipl == 0) multipl = 1;
+if(key == FL_Right) { /* right arrow */
+ new_pos = view->cursor_site + multipl;
+ if(view->cursor_in_comment) {
+ if(new_pos > view->comment_length[view->cursor_seq-1]+1)
+ new_pos = view->comment_length[view->cursor_seq-1]+1;
+ }
+ else {
+ if(new_pos > view->each_length[view->cursor_seq-1] + 1)
+ new_pos = view->each_length[view->cursor_seq-1] + 1;
+ }
+ set_and_show_new_cursor_site(view, new_pos,FALSE,FALSE);
+ }
+else if(key == FL_Left) { /* left arrow */
+ new_pos = FL_max(1, view->cursor_site - multipl);
+ set_and_show_new_cursor_site(view, new_pos,FALSE,FALSE);
+ }
+else if(key == FL_Up) { /* up arrow */
+ new_pos = FL_max(1, view->cursor_seq - multipl);
+ set_and_show_new_cursor_seq(view, new_pos);
+ }
+else if(key == FL_Down){ /* down arrow */
+ new_pos = view->cursor_seq + multipl;
+ if(view->cursor_in_comment) {
+ if(new_pos > view->tot_comment_lines)
+ new_pos = view->tot_comment_lines;
+ }
+ else {
+ if(new_pos > view->tot_seqs)
+ new_pos = view->tot_seqs;
+ }
+ set_and_show_new_cursor_seq(view, new_pos);
+ }
+else if(view->cursor_in_comment &&
+ view->active_comment_line == view->cursor_seq) {
+ unsigned char c_key = (unsigned)key;
+ if(view->alt_col_seq != NULL) return;
+ if( key == 0x7f || key == 0x8 || key == FL_Delete || key == FL_BackSpace ) /* del or BS */
+ delete_char_in_comment(view, 1,
+ view->active_comment_line,
+ view->cursor_site, FALSE);
+ else if( istext && ( ( c_key >= 32 && c_key <= 126 ) ||
+ ( c_key >= 160 && c_key <= 255 ) ) )
+ insert_char_in_comment(c_key, 1, view);
+ else
+ return;
+ }
+else if(strchr(view->movekeys, key) != NULL) {
+ /* ][>< touches depl droite/gauche */
+ int oldpos;
+ int upper_step=50, bracket_step=5 ;
+ int max_w;
+ max_w = (int)(view->horsli->maximum());
+ oldpos = (int)( view->horsli->value() );
+ new_pos = oldpos;
+ upper_step *= multipl;
+ bracket_step *= multipl;
+ if(key == view->movekeys[2] /* > */ ) {
+ new_pos=oldpos+upper_step;
+ if(new_pos>max_w) new_pos=max_w;
+ }
+ else if(key == view->movekeys[3] /* < */ ) {
+ new_pos=oldpos-upper_step;
+ if(new_pos<1) new_pos=1;
+ }
+ else if(key == view->movekeys[0] /* ] */ ) {
+ new_pos=oldpos+bracket_step;
+ if(new_pos>max_w) new_pos=max_w;
+ }
+ else if(key == view->movekeys[1] /* [ */ ) {
+ new_pos=oldpos-bracket_step;
+ if(new_pos<1) new_pos=1;
+ }
+ if(new_pos!=oldpos) {
+ view->horsli->Fl_Slider::value(new_pos);
+ view->draw_names = 0;
+ view->first_site = new_pos;
+ view->DNA_obj->damage(1);
+ }
+ }
+else if(key == 0x7f || key == 0x8 || key == FL_Delete || key == FL_BackSpace ) { /* delete or backspace */
+ int count, count_each, debut, fin, test;
+ if(view->multipl->argument() > 0)
+ mod_multipl(view,0);
+ if(view->cursor_in_comment)
+ test = view->cursor_seq < 1 ||
+ view->cursor_seq > view->tot_comment_lines;
+ else
+ test = view->cursor_seq < view->first_seq ||
+ view->cursor_seq >= view->first_seq+view->tot_lines;
+ if( test ||
+ view->cursor_site < view->first_site ||
+ view->cursor_site >=view->first_site+view->tot_sites)
+ { fl_ringbell(0); return; }
+ if(view->cursor_in_comment) {
+ if( delete_char_in_comment(view, multipl,
+ view->cursor_seq, view->cursor_site,
+ TRUE) != multipl) fl_ringbell(0);
+ return;
+ }
+ if(view->alt_col_seq != NULL) return;
+ if(view->tot_sel_seqs > 1 &&
+ view->sel_seqs[view->cursor_seq - 1])
+ { debut = 1; fin = view->tot_seqs; test = TRUE;}
+ else
+ { debut = fin = view->cursor_seq; test = FALSE;}
+ for(num = debut; num<=fin; num++)
+ {
+ if(test && !view->sel_seqs[num-1]) continue;
+ count_each = delete_gaps_before(view,
+ num,
+ view->cursor_site, multipl);
+ if(count_each < multipl) fl_ringbell(0);
+ if(num == view->cursor_seq) count = count_each;
+ }
+ /* si ttes seqs selectionnees, traiter aussi regions et comments */
+ if(count_each == multipl &&
+ (!view->cursor_in_comment) &&
+ view->tot_sel_seqs == view->tot_seqs ) {
+ if(view->regions != NULL)
+ delete_region_part(view,
+ view->cursor_site,multipl);
+ if(view->tot_comment_lines > 0)
+ delete_in_all_comments(multipl,
+ view->cursor_site, view);
+ }
+ new_pos = view->cursor_site - count;
+ if(new_pos <= 0) new_pos = 1;
+ if(view->cursor_in_comment) {
+ view->mod_comment_line = view->cursor_seq;
+ }
+ else {
+ if(view->tot_sel_seqs > 1 &&
+ view->tot_sel_seqs != view->tot_seqs &&
+ view->sel_seqs[view->cursor_seq - 1])
+ view->mod_seq = -1;
+ else if(view->tot_sel_seqs <= 1 ||
+ !view->sel_seqs[view->cursor_seq - 1])
+ view->mod_seq = view->cursor_seq;
+ }
+ set_and_show_new_cursor_site(view, new_pos,
+ FALSE,TRUE);
+ }
+else if(key == '_' ) { /* del gap in all but current seq(s) */
+ int count_each;
+ if(view->multipl->argument() > 0)
+ mod_multipl(view,0);
+ if(view->cursor_in_comment) return;
+ if( view->cursor_seq < view->first_seq ||
+ view->cursor_seq >=view->first_seq+view->tot_lines ||
+ view->cursor_site < view->first_site ||
+ view->cursor_site >=
+ view->first_site + view->tot_sites ||
+ view->tot_sel_seqs == view->tot_seqs )
+ { fl_ringbell(0); return; }
+ if(view->alt_col_seq != NULL) return;
+ for( num = 1; num <= view->tot_seqs; num++) {
+ if(num == view->cursor_seq ||
+ (view->sel_seqs[view->cursor_seq-1] &&
+ view->sel_seqs[num-1] ) ) continue;
+ count_each = delete_gaps_before(view,
+ num, view->cursor_site, multipl);
+ if(count_each < multipl) {
+ fl_ringbell(0);
+ return;
+ }
+ }
+ if(count_each == multipl && view->regions != NULL)
+ delete_region_part(view, view->cursor_site, multipl);
+ if(count_each == multipl && view->tot_comment_lines > 0)
+ delete_in_all_comments(multipl, view->cursor_site, view);
+ new_pos = view->cursor_site - multipl;
+ if(new_pos <= 0) new_pos = 1;
+ set_and_show_new_cursor_site(view, new_pos, FALSE, TRUE);
+ }
+else if( key == '-' || (key == ' ' && !view->hjkl)
+ /* gap key = - or space */
+ || key == '+' ) { /* insert gap in other seqs key */
+ int newlength = 0, count = 0, count_each, debut, fin, test;
+ if(view->multipl->argument() > 0)
+ mod_multipl(view,0);
+ if(view->cursor_in_comment && key == '+') return;
+ if(view->cursor_in_comment)
+ test = FALSE;
+ else
+ test = view->cursor_seq < view->first_seq ||
+ view->cursor_seq >=view->first_seq+view->tot_lines;
+ if( test || view->cursor_site < view->first_site ||
+ view->cursor_site >=
+ view->first_site + view->tot_sites )
+ { fl_ringbell(0); return; }
+ if(view->alt_col_seq != NULL) return;
+ if(key != '+') { /* gap key */
+ if(view->tot_sel_seqs > 1 &&
+ (!view->cursor_in_comment) &&
+ view->sel_seqs[view->cursor_seq - 1])
+ { debut = 1; fin = view->tot_seqs; test = TRUE;}
+ else
+ { debut = fin = view->cursor_seq; test = FALSE;}
+ for(num = debut; num<=fin; num++)
+ {
+ if(test && !view->sel_seqs[num-1]) continue;
+ count_each = insert_gaps_at(view, num,
+ view->cursor_site, multipl);
+ if(count_each < multipl) fl_ringbell(0);
+ if(num == view->cursor_seq) count = count_each;
+ if(view->cursor_in_comment) {
+ if(newlength < view->comment_length[num-1])
+ newlength = view->comment_length[num-1];
+ }
+ else {
+ if(newlength < view->each_length[num-1])
+ newlength = view->each_length[num-1];
+ }
+ }
+/* si ttes seqs selectionnees, traiter aussi regions et comments */
+ if(count_each == multipl &&
+ (!view->cursor_in_comment) &&
+ view->tot_sel_seqs == view->tot_seqs) {
+ if(view->regions != NULL)
+ insert_region_part(view, view->cursor_site, multipl);
+ if(view->tot_comment_lines > 0)
+ insert_gap_all_comments(multipl,view->cursor_site,
+ view);
+ }
+ }
+ else { /* + ==> gap in other sequences */
+ if(view->tot_sel_seqs == view->tot_seqs) {
+ fl_ringbell(0); return;
+ }
+ for( num = 1; num <= view->tot_seqs; num++) {
+ if(num == view->cursor_seq ||
+ (view->sel_seqs[view->cursor_seq-1] &&
+ view->sel_seqs[num-1] ) ) continue;
+ count_each = insert_gaps_at(view,
+ num, view->cursor_site, multipl);
+ if(count_each < multipl) {
+ fl_ringbell(0); return;
+ }
+ if(newlength < view->each_length[num-1])
+ newlength = view->each_length[num-1];
+ }
+ count = multipl;
+ if(count_each == multipl &&
+ view->regions != NULL)
+ insert_region_part(view, view->cursor_site, multipl);
+ if(count_each == multipl &&
+ view->tot_comment_lines > 0) {
+ insert_gap_all_comments(multipl,view->cursor_site,
+ view);
+ }
+ }
+ new_pos = view->cursor_site + count;
+ if(view->cursor_in_comment) {
+ if(new_pos> view->comment_length[view->cursor_seq-1]+1)
+ new_pos= view->comment_length[view->cursor_seq-1]+1;
+ }
+ else {
+ if(new_pos > view->each_length[view->cursor_seq-1] + 1)
+ new_pos = view->each_length[view->cursor_seq-1] + 1;
+ }
+ if(view->cursor_in_comment)
+ view->mod_comment_line = view->cursor_seq;
+ else if(key != '+' ) {
+ if(view->tot_sel_seqs > 1 &&
+ view->tot_sel_seqs != view->tot_seqs &&
+ view->sel_seqs[view->cursor_seq - 1])
+ view->mod_seq = -1;
+ else if(view->tot_sel_seqs <= 1 ||
+ !view->sel_seqs[view->cursor_seq - 1] )
+ view->mod_seq = view->cursor_seq;
+ }
+ update_current_seq_length(newlength, view);
+ set_and_show_new_cursor_site(view, new_pos, FALSE,TRUE);
+ }
+else if( key >= '0' && key <= '9' ) { /* multiplicateur */
+ multipl = view->multipl->argument() * 10;
+ multipl += (key - '0');
+ mod_multipl(view, multipl);
+ return;
+ }
+else if( view->allow_seq_edit && (view->alt_col_seq == NULL) &&
+ (!view->cursor_in_comment) &&
+ ( (key>='a' && key<='z') || (key>='A' && key<='Z') || key == ' ' ) ) {
+ if(view->hjkl) {
+ static char typedkey[]= "hjklHJKL ";
+ static char dnaequivs[3][10]={
+ "gatcGATCN", "tcgaTCAGN", "acgtACGTN"};
+ char *p;
+ p = strchr(typedkey, key);
+ if(p != NULL)
+ key = *( dnaequivs[view->hjkl - 1] + (p - typedkey) );
+ }
+ if(key == ' ') num = 0;
+ else num = insert_char_in_seq(key, multipl, view);
+ if( num == 0 ) fl_ringbell(0);
+ else {
+ view->mod_seq = view->cursor_seq;
+ set_and_show_new_cursor_site(view,
+ view->cursor_site + num, FALSE, TRUE);
+ }
+ }
+else return;
+if(view->multipl->argument() > 0) mod_multipl(view, 0);
+}
+
+
+Fl_Group *create_dna_scroller(SEA_VIEW *view, int x, int y, int w, int h,
+ int double_buffer)
+{
+ Fl_Group *dna_group;
+ Fl_Widget *obj;
+ int wmultipl, x_pos;
+ user_data_plus *data;
+dna_group = new Fl_Group(x,y,w,h);
+int scroll_w = 15;
+/* screen move haut */
+view->up_screen_move = obj =
+(Fl_Widget*)new Fl_Repeat_Button(x+3, y,scroll_w,scroll_w,"@8>>");
+obj->labeltype(FL_SYMBOL_LABEL);
+data = new user_data_plus;
+data->p = view;
+data->value = 5;
+obj->callback(lrdu_button_callback, data);
+/* ascenc. vertical */
+view->vertsli = new Fl_Scrollbar(x+3, y + scroll_w + 2, scroll_w,
+ h - 3*scroll_w - 12, "");
+view->vertsli->box(FL_DOWN_BOX);
+data = new user_data_plus;
+data->p = view;
+data->value = 0;
+((Fl_Scrollbar *)view->vertsli)->linesize(1);
+view->vertsli->callback(vh_sliders_callback, data);
+ view->vertsli->bounds(1,1);
+ view->vertsli->slider_size(1);
+ view->vertsli->Fl_Slider::value(1);
+ view->vertsli->step(1);
+view->vertsli->when(FL_WHEN_CHANGED);
+/* screen move bas */
+view->down_screen_move = obj =
+(Fl_Widget*)new Fl_Repeat_Button(x+3,
+ y + h - 2 * scroll_w - 8, scroll_w, scroll_w, "@2>>");
+obj->labeltype(FL_SYMBOL_LABEL);
+data = new user_data_plus;
+data->p = view;
+data->value = 7;
+obj->callback(lrdu_button_callback, data);
+
+int y_scroll = y + h - scroll_w - 3;
+/* valeur du multiplicateur */
+fl_font(FL_HELVETICA, FL_NORMAL_SIZE);
+ wmultipl = (int)fl_width("mult=9999");
+ x_pos = 5;
+ view->multipl = obj = (Fl_Widget*)new Fl_Box(FL_FLAT_BOX,
+ x+x_pos, y_scroll - 2, wmultipl, FL_NORMAL_SIZE + 4, "");
+ x_pos += wmultipl + 5;
+ obj->labelfont(FL_HELVETICA);
+ obj->labelsize(FL_NORMAL_SIZE);
+ obj->align(FL_ALIGN_CENTER);
+
+
+/* screen move gauche */
+ view->left_screen_move = obj =
+(Fl_Widget*)new Fl_Repeat_Button(x+x_pos,y_scroll,scroll_w,scroll_w,"@<<");
+obj->labeltype(FL_SYMBOL_LABEL);
+ x_pos += scroll_w + 2;
+data = new user_data_plus;
+data->p = view;
+data->value = 1;
+obj->callback(lrdu_button_callback, data);
+/* ascens. horizontal */
+view->horsli =
+new Fl_Scrollbar(x + x_pos, y_scroll, w - x_pos - scroll_w - 2, scroll_w,"");
+view->horsli->type(FL_HORIZONTAL);
+view->horsli->box(FL_DOWN_BOX);
+((Fl_Scrollbar *)view->horsli)->linesize(1);
+data = new user_data_plus;
+data->p = view;
+data->value = 1;
+view->horsli->callback(vh_sliders_callback, data);
+view->horsli->bounds(1,1);
+view->horsli->slider_size(1);
+view->horsli->Fl_Slider::value(1);
+view->horsli->step(1);
+view->horsli->when(FL_WHEN_CHANGED);
+/* screen move a droite */
+ view->right_screen_move = obj =
+(Fl_Widget*)new Fl_Repeat_Button(x+w - scroll_w, y_scroll, scroll_w, scroll_w,"@>>");
+obj->labeltype(FL_SYMBOL_LABEL);
+data = new user_data_plus;
+data->p = view;
+data->value = 3;
+obj->callback(lrdu_button_callback, data);
+
+/* noms + sequences */
+Fl_Window *viewer;
+if(double_buffer)
+ viewer = (Fl_Window *)new Fl_Double_Window(
+ x+25-3, y, w - 25 - 1 + 6, h - 30 + 6);
+else
+ viewer = new Fl_Window(x+25, y+3, w - 25 - 1, h - 30);
+viewer->box(FL_DOWN_BOX);
+viewer->resizable(viewer);
+view->double_buffer = double_buffer;
+view->DNA_obj = (Fl_Widget*)new DNA_obj(3, 3, w - 25 - 1, h - 30, view);
+view->DNA_obj->labelfont(FL_COURIER_BOLD);
+viewer->end();
+
+dna_group->end();
+dna_group->add_resizable(
+ *new Fl_Box(x + x_pos, y + scroll_w + 2, w - x_pos - scroll_w - 2,
+ h - 3*scroll_w - 12) );
+view->menu_regions = view->menu_file = view->menu_edit =
+ view->bouton_props = view->menu_species = NULL;
+return dna_group;
+}
+
+
+SEA_VIEW *create_the_form(int double_buffer, int inverted,
+ known_format default_format, int numb_dnacolors,
+ int *dnacolors,
+ int numb_stdprotcolors, int *stdprotcolors,
+ int numb_altprotcolors, int *altprotcolors,
+ color_choice curr_color_choice, char *progname, char *movekeys,
+ char *win_size, int allow_lower, char *help_file)
+{
+Fl_Group *dna_group;
+Fl_Window *my_form;
+Fl_Widget *obj, *bouton_search, *champ_search, *bouton_goto, *champ_goto,
+ *bouton_props, *menu_regions, *menu_edit, *menu_species,
+ *menu_footers, *bouton_help;
+Fl_Menu_Button *menu_file;
+int black_and_white;
+SEA_VIEW *view;
+user_data_plus *data;
+int labelSize = 12;
+int borderWidth = 2;
+int w_w = 700, w_h = 500;
+
+sscanf(win_size, "%dx%d", &w_w, &w_h);
+my_form = new Fl_Window(w_w, w_h);
+my_form->color(FL_LIGHT1);
+my_form->label(progname);
+my_form->box(FL_FLAT_BOX);
+int extra_menu_width = 2*(labelSize - 3);//largeur symbole menu
+#define calc_width(nom) \
+ (fl_font(FL_HELVETICA, labelSize), (int)fl_width(nom) + 4 * borderWidth)
+#define add_menu(nom) \
+ new Fl_Menu_Button(0,0,calc_width(nom)+extra_menu_width,25,nom)
+#define add_button(nom) \
+ new Fl_Button(0,0,calc_width(nom),25,nom)
+
+Fl_Pack *menus = new Fl_Pack(5,5,0,25); /* groupe fixe des menus */
+menus->type(FL_HORIZONTAL);
+menus->spacing(2);
+
+/* menu File */
+menu_file = add_menu("File");
+((Fl_Menu_Button*)menu_file)->add(
+ "Open Mase|Open Phylip|Open Clustal|Open MSF|Open Fasta|Open NEXUS|"
+ "Save|Save as...|Save current sites|Prepare printout|"
+ "Quit");
+menu_file->labelsize(labelSize);
+menu_file->mode(OPEN_NEXUS, FL_MENU_DIVIDER);
+menu_file->mode(SAVE, FL_MENU_INACTIVE);
+menu_file->shortcut(SAVE, FL_CTRL | 's');
+menu_file->mode(SAVE_AS, FL_MENU_INACTIVE);
+menu_file->mode(SAVE_REGIONS, FL_MENU_DIVIDER | FL_MENU_INACTIVE);
+menu_file->mode(PRINTOUT, FL_MENU_DIVIDER);
+menu_file->shortcut(QUIT, FL_CTRL | 'q');
+menu_file->callback(file_menu_callback, 0);
+menu_file->align((Fl_Align) (FL_ALIGN_INSIDE | FL_ALIGN_LEFT) );
+menu_file->box(FL_UP_BOX);
+
+/* menu Props */
+bouton_props = obj = add_menu("Props");
+obj->labelsize(labelSize);
+obj->align((Fl_Align) (FL_ALIGN_INSIDE | FL_ALIGN_LEFT) );
+
+/* menu regions */
+menu_regions = obj = add_menu("Sites");
+data = new user_data_plus;
+obj->labelsize(labelSize);
+obj->callback(regions_menu_callback, data);
+obj->align((Fl_Align) (FL_ALIGN_INSIDE | FL_ALIGN_LEFT) );
+obj->box(FL_UP_BOX);
+
+/* menu species */
+menu_species = obj = add_menu("Species");
+data = new user_data_plus;
+obj->labelsize(labelSize);
+obj->callback(species_menu_callback, data);
+obj->align((Fl_Align) (FL_ALIGN_INSIDE | FL_ALIGN_LEFT) );
+obj->box(FL_UP_BOX);
+
+/* menu footers */
+menu_footers = obj = add_menu("Footers");
+((Fl_Menu_Button*)obj)->add("Show footers|Create footer|Delete footer");
+((Fl_Menu_ *)obj)->mode(SHOW_HIDE_FOOTERS, FL_MENU_INACTIVE);
+obj->labelsize(labelSize);
+obj->callback(footers_menu_callback, 0);
+obj->align((Fl_Align) (FL_ALIGN_INSIDE | FL_ALIGN_LEFT) );
+obj->box(FL_UP_BOX);
+
+/* bouton search + champ Search */
+bouton_search = obj = add_button("Search:");
+obj->labelsize(labelSize);
+data = new user_data_plus;
+data->value = 0;
+obj->callback(search_callback, data);
+champ_search = obj = (Fl_Widget*)new Fl_Input(0,0, 80, 25, "");
+((Fl_Input*)obj)->type(FL_NORMAL_INPUT);
+((Fl_Input*)obj)->when(FL_WHEN_ENTER_KEY);
+data = new user_data_plus;
+data->value = 1;
+champ_search->callback(search_callback, data);
+data = (user_data_plus *)bouton_search->user_data();
+data->p = champ_search;
+
+/* bouton + champ Goto */
+bouton_goto = obj = add_button("Goto:");
+obj->labelsize(labelSize);
+data = new user_data_plus;
+data->value = 0;
+obj->callback(goto_callback, data);
+champ_goto = obj = (Fl_Widget*)new Fl_Input(0, 0, 80, 25, "");
+((Fl_Input*)obj)->type(FL_NORMAL_INPUT);
+data = new user_data_plus;
+data->value = 1;
+champ_goto->callback(goto_callback, data);
+data = (user_data_plus *)bouton_goto->user_data();
+data->p = champ_goto;
+((Fl_Input*)obj)->when(FL_WHEN_ENTER_KEY);
+
+/* menu Edit */
+menu_edit = obj = add_menu("Edit");
+((Fl_Menu_Button*)obj)->add(
+ "Rename sequence|Edit comments|Delete sequence(s)|Create sequence|"
+ "Load sequence|Duplicate sequence|"
+ "Complement sequence|Reverse sequence|Exchange Us and Ts|Align sites|"
+ "Dot plot|Consensus sequence|Del. gap-only sites");
+obj->labelsize(labelSize);
+obj->callback(edit_menu_callback, 0);
+obj->align((Fl_Align) (FL_ALIGN_INSIDE | FL_ALIGN_LEFT) );
+obj->box(FL_UP_BOX);
+
+/* bouton help */
+bouton_help = add_button("Help");
+bouton_help->labelsize(labelSize);
+bouton_help->callback(help_callback, help_file);
+#undef add_menu
+#undef add_button
+#undef calc_width
+
+menus->end();
+menus->resizable(NULL);
+
+view = (SEA_VIEW *)calloc(1, sizeof(SEA_VIEW));
+if(view == NULL) out_of_memory();
+
+/* tout le groupe scroller */
+dna_group = create_dna_scroller(view,
+ 0, 35, my_form->w() - 5, my_form->h() - 35, double_buffer);
+my_form->resizable( dna_group );
+my_form->end();
+my_form->callback(mainwin_close_callback, view);
+my_form->position((Fl::w() - my_form->w())/2, (Fl::h() - my_form->h())/2);
+
+/* initialisation independantes des sequences */
+view->movekeys = movekeys;
+view->menu_regions = menu_regions;
+view->menu_species = menu_species;
+view->menu_file = menu_file;
+view->menu_edit = menu_edit;
+view->menu_footers = menu_footers;
+view->bouton_props = bouton_props;
+menu_file->user_data( view );
+data = (user_data_plus *)menu_regions->user_data();
+data->p = view;
+data = (user_data_plus *)menu_species->user_data();
+data->p = view;
+menu_edit->user_data( view );
+menu_footers->user_data( view );
+data = (user_data_plus *)champ_search->user_data();
+data->p = view;
+data = (user_data_plus *)champ_goto->user_data();
+data->p = view;
+view->format_for_save = default_format; /* default format for saving */
+view->tot_seqs = 0;
+view->first_seq = 1; view->tot_sites = 1;
+view->numb_gc = 1;
+view->line_height = 1;
+view->char_width = 1;
+view->draw_names = -1;
+view->mod_seq = 0;
+view->mod_comment_line = 0;
+view->consensus_threshold = 60;
+view->dnawin = my_form;
+view->max_seq_length = MINI_MAX_LENGTH;
+mod_multipl(view, 0);
+
+#ifdef WIN32
+black_and_white = FALSE;
+#elif defined(__APPLE__)
+black_and_white = FALSE;
+#else
+black_and_white = (fl_xpixel(FL_BLACK) == fl_xpixel(FL_RED));
+#endif
+if ( ! black_and_white) {
+ /* couleurs du fond pour seqs */
+#ifdef WIN32
+ view->DNA_obj->color(FL_DARK1, 43);
+#else
+ view->DNA_obj->color(FL_GRAY, FL_DARK1);
+#endif
+ view->region_color = FL_WHITE;
+ view->inverted_colors = inverted;
+ if(inverted) {
+ view->DNA_obj->labelfont( FL_COURIER);
+ }
+ view->allow_lower = allow_lower;
+ }
+else { /* the Black and White case */
+ numb_dnacolors = numb_stdprotcolors = numb_altprotcolors = 1;
+ dnacolors[0] = FL_BLACK;
+ /* couleur du fond pour seqs */
+ view->DNA_obj->color(FL_WHITE, FL_WHITE);
+ view->region_color = FL_BLACK;
+ view->numb_gc = 1;
+ view->curr_colors = dnacolors;
+ view->inverted_colors = FALSE;
+ view->allow_lower = TRUE;
+ }
+view->DNA_obj->parent()->color( view->DNA_obj->color() );
+/* taille par defaut des lettres des sequences */
+#ifdef WIN32
+view->DNA_obj->labelsize(12);
+#else
+view->DNA_obj->labelsize(14);
+#endif
+/* creation du menu Props et de ses sous-menus */
+create_props_menu((Fl_Menu_Button *)bouton_props, view,
+ curr_color_choice, inverted, black_and_white,
+ view->DNA_obj->labelsize());
+view->dnacolors = dnacolors;
+view->numb_dnacolors = numb_dnacolors;
+view->stdprotcolors = stdprotcolors;
+view->numb_stdprotcolors = numb_stdprotcolors;
+view->altprotcolors = altprotcolors;
+view->numb_altprotcolors = numb_altprotcolors;
+view->namecolor = FL_BLACK;
+view->alt_colors = curr_color_choice;
+view->clustal_options = NULL;
+view->show_comment_lines = FALSE;
+view->tot_comment_lines = 0;
+return view;
+}
Added: trunk/packages/seaview/branches/upstream/current/seaview.h
===================================================================
--- trunk/packages/seaview/branches/upstream/current/seaview.h (rev 0)
+++ trunk/packages/seaview/branches/upstream/current/seaview.h 2006-09-19 14:20:14 UTC (rev 111)
@@ -0,0 +1,272 @@
+#ifndef SEAVIEW_H
+#define SEAVIEW_H
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <limits.h>
+#include "FL/Fl.H"
+#include "FL/Fl_Window.H"
+#include "FL/Fl_Menu_Item.H"
+#include "FL/Fl_Menu_Button.H"
+#include "FL/Fl_Browser.H"
+#include "FL/Fl_Input.H"
+#include "FL/Fl_Box.H"
+#include "FL/Fl_Return_Button.H"
+#include "FL/Fl_Repeat_Button.H"
+#include "FL/Fl_Choice.H"
+#include "FL/fl_draw.H"
+#include "FL/fl_ask.H"
+#ifndef FALSE
+#define FALSE 0
+#define TRUE (!FALSE)
+#endif
+
+
+#ifdef WIN32
+extern "C" { void my_bell(void); }
+#define fl_ringbell(a) my_bell()
+#elif defined __APPLE__
+#define fl_ringbell(a) SysBeep(a)
+#define fgets(a,b,c) my_fgets(a,b,c)
+extern "C" { char *my_fgets(char *s, int n, FILE *f); }
+#else
+#include "FL/x.H"
+#define fl_ringbell(a) XBell(fl_display, a)
+#endif
+#define FL_max(a,b) ( (a) > (b) ? (a):(b) )
+#define FL_min(a,b) ( (a) < (b) ? (a):(b) )
+/* proto manque parfois */
+extern "C" { void *memccpy(void *s1, const void *s2, int c, size_t n); }
+typedef struct _user_data_plus {
+ void *p;
+ int value;
+ } user_data_plus;
+extern void fl_reset_cursor(Fl_Window *win);
+
+
+#define MAXLENCOM 50000 /* long max des commentaires sous mase */
+#define MAX_SPECIES_SETS 50 /* nbre max de species sets */
+#define PHYNAME 10
+#define CLU_WID_NAME 16
+#define MSF_WID_NAME 15
+#define CLU_BLOCK_LEN 5000 /* block pour allocation mem format Clustal */
+#define MAX_GAP_SITES 1000
+
+typedef struct _list_segments { /* one segment + pointer to its successor */
+ int debut, fin;
+ struct _list_segments *next;
+ } list_segments;
+
+typedef struct { /* one region = name + pointer to list of segments */
+ char *name;
+ list_segments *list;
+ } region;
+
+typedef struct _list_regions { /* region list = pointer to region +
+ pointer to successor in list */
+ region *element;
+ struct _list_regions *next;
+ } list_regions;
+
+typedef struct {
+ int pos;
+ int l[2];
+ } gap_site;
+
+typedef enum {MASE_FORMAT, PHYLIP_FORMAT, CLUSTAL_FORMAT, MSF_FORMAT,
+ FASTA_FORMAT, NEXUS_FORMAT }
+ known_format;
+
+typedef enum {OPEN_MASE, OPEN_PHYLIP, OPEN_CLUSTAL, OPEN_MSF, OPEN_FASTA,
+ OPEN_NEXUS, SAVE, SAVE_AS, SAVE_REGIONS, PRINTOUT,
+ QUIT} file_menu_choice;
+
+typedef enum {NO_ALT_COLORS, USING_STANDARD_COLORS, USING_ALT_COLORS}
+ color_choice;
+
+typedef enum {RENAME_SEQ, EDIT_COMMENTS, DELETE_SEQ, CREATE_SEQ, LOAD_SEQ,
+ DUPLICATE_SEQ,
+ COMPLEMENT_SEQ, REVERSE_SEQ, EXCHANGE_UT, ALIGN_SEQS, DOT_PLOT,
+ CONSENSUS_SEQ, DELETE_GAP_ONLY_SITES}
+ edit_choice;
+
+typedef enum {SHOW_HIDE_FOOTERS, CREATE_FOOTER, DELETE_FOOTER }
+ footers_menu_choice;
+
+typedef struct {
+ Fl_Widget *DNA_obj; /* free object for names + seqs */
+ Fl_Scrollbar *horsli; /* horizontal scrollbar */
+ Fl_Scrollbar *vertsli; /* vertical scrollbar */
+ Fl_Widget *right_screen_move, *left_screen_move, *up_screen_move,
+ *down_screen_move; /* 4 big jump arrows */
+ Fl_Widget *multipl; /* box displaying the multiplier value */
+ Fl_Widget *menu_regions; /* menu of region operations */
+ Fl_Widget *menu_file; /* menu of file operations */
+ Fl_Widget *menu_edit; /* menu of edit operations */
+ Fl_Widget *bouton_props; /* menu of properties */
+ Fl_Widget *menu_species; /* menu of species */
+ Fl_Widget *menu_footers; /* menu of footers */
+ Fl_Widget *bouton_reference; /* bouton_reference */
+ char **sequence; /* array of sequences */
+ char **comments; /* array of sequence comments */
+ char *header; /* header of mase file */
+ char ***col_seq; /* array of sequences split by color */
+ char ***alt_col_seq; /* alternate array of sequences split by color */
+ char **seqname; /* array of sequence names */
+ char *masename; /* mase file name */
+ int protein; /* TRUE iff protein data */
+ known_format format_for_save; /* what file format used when saving */
+ int wid_names; /* width of largest sequence name */
+ int first_seq, first_site; /* first seq and site currently displayed */
+ int tot_seqs; /* total number of sequences in memory */
+ int seq_length; /* current length of longest sequence */
+ int max_seq_length; /*max length allowed for longest sequence to grow */
+ int *each_length; /* array of each individual sequence length */
+ int tot_sites, tot_lines; /* sites and lines fitting in DNA_obj */
+ int x_name, y_name, x_seq, y_seq; /* top left to start writing
+ names and sequences */
+ int draw_names; /*controle ecriture noms 0: pas ecrits;
+ -1: tous ecrits puis aussi les seqs;
+ -2: tous ecrits mais pas les seqs;
+ >=1: 1 seul ecrit et pas de seq ni de curseur ecrit*/
+ int mod_seq; /* -1: seqs selectionnees;
+ 0: normal;
+ >= 1: 1 seul seq ecrite */
+ int mod_cursor; /* FALSE: cursor ancien ignore; TRUE: ancien efface */
+ int char_width, line_height; /* taille en pixels des caracteres */
+ int cursor_seq, cursor_site; /* position courante du curseur */
+ int old_cursor_seq, old_cursor_site; /* position precedente du curseur*/
+ int tot_sel_seqs; /* nbre courant de seqs selectionnees */
+ int *sel_seqs; /* tableau des seqs selectionnees: T/F pour chacune */
+ int *curr_colors; /*tableau des couleurs pour chaque elt col_seq*/
+ int inverted_colors; /* TRUE iff use black letters on colored square */
+ int namecolor; /* couleur utilisee pour les noms */
+ int numb_gc; /* 1 en N&B, >1 en couleurs */
+ int *dnacolors; /* tableau des couleurs pour DNA/RNA */
+ int numb_dnacolors; /* nbre de couleurs pour DNA/RNA */
+ int *stdprotcolors; /*tableau des couleurs standard pour prots*/
+ int numb_stdprotcolors; /* nbre de couleurs standard pour prots */
+ int *altprotcolors;/*tableau des couleurs alternatives pour prots*/
+ int numb_altprotcolors; /*nbre de couleurs alternatives pour prots*/
+ color_choice alt_colors; /* current aa color use */
+ list_regions *regions; /* list of known regions */
+ region *active_region; /* active region (NULL when none) */
+ char *region_line; /* region line (of length region_length) */
+ int region_color; /* color used to display region line */
+ int region_length; /* length of region_line (==seq_length) */
+ int mod_region_line; /* TRUE region line changed=>redraw only it */
+ int numb_species_sets; /* number of known species sets */
+ int *list_species_sets[MAX_SPECIES_SETS];/*list of known species sets*/
+ char *name_species_sets[MAX_SPECIES_SETS];/*names of species sets*/
+ int allow_seq_edit; /* when TRUE can type sequence data in */
+ int hjkl; /* when TRUE, keys hjklHJKL produce TCGA */
+ int modif_but_not_saved;
+ Fl_Window *dnawin; /* window of DNA_obj */
+ int reducefonts; /* TRUE when need smaller fonts (e.g. 100dpi) */
+ int double_buffer; /* true iff DNA_obj is double buffered */
+ char *clustal_options; /* options for clustalw if != NULL */
+ int consensus_threshold; /* min threshold (%) for residue in consensus*/
+ int tot_comment_lines; /* number of comment lines */
+ char **comment_line; /* array of comment lines */
+ char **comment_name; /* array of comment names */
+ int *comment_length; /* array of comment lengths */
+ int show_comment_lines; /* TRUE when displayed */
+ int pos_first_comment_line; /* rank on screen of this line */
+ int mod_comment_line; /* 0: normal, >=1 celle-ci ecrite */
+ int active_comment_line; /* 0: none, >=1 target of keyboard */
+ int cursor_in_comment; /* TRUE when cursor is in comments not in seqs */
+ int old_cursor_in_comment; /*previous place of cursor seq vs. comments*/
+ char *movekeys; /* default ][>< keys to move seq right or left */
+ int allow_lower; /* TRUE iff lowercase displayed in seqs */
+ } SEA_VIEW;
+
+
+typedef struct _props_menu_parts {
+ int fontsize, saveformat, colors, inverted, edit, reference, keys,
+ clustalopt, consensusopt, slow_fast, allow_lower;
+ SEA_VIEW *view;
+ } props_menu_parts;
+
+
+extern void out_of_memory(void);
+extern char *majuscules(char *s);
+extern void init_dna_scroller(SEA_VIEW *view, int totseqs,
+ const char *masename, int protein, char *header);
+extern char *extract_filename( char *fname);
+extern void draw_region_line(Fl_Widget *ob, SEA_VIEW *view);
+extern void props_button_callback(Fl_Widget *ob, long mainpop);
+extern void regions_menu_callback(Fl_Widget *ob, void *extra);
+extern void species_menu_callback(Fl_Widget *ob, void *extra);
+extern void footers_menu_callback(Fl_Widget *ob, long which);
+extern int suppr_segment(region *maregion, int site, char *line);
+extern int begin_change_segment(SEA_VIEW *view, int new_site);
+extern int continue_change_segment(SEA_VIEW *view, int new_site);
+extern void end_change_segment(SEA_VIEW *view);
+extern int extend_segment_at_left(SEA_VIEW *view, int new_site);
+extern void delete_region_part(SEA_VIEW *view, int numsite, int total);
+extern void insert_region_part(SEA_VIEW *view, int numsite, int total);
+extern void delete_region(SEA_VIEW *view, int rang);
+extern list_regions *parse_regions_from_header(char *header);
+extern int parse_species_sets_from_header(char *header, int **list_species_sets,
+ char **name_species_sets, int totseqs);
+extern void set_tot_lines(SEA_VIEW *view, int new_val);
+extern int read_mase_seqs_header(const char *, char ***pseq,char ***pseqname,
+ char ***pcomments, char **pheader, char **err_message);
+extern int read_fasta_align(const char *fname, char ***pseq, char ***pseqname,
+ char ***pcomments, char **pheader, char **err_message);
+extern int read_phylip_align(const char *fname, char ***pseq, char ***pseqname,
+ char ***pcomments, char **pheader, char **);
+extern int read_clustal_align(const char *fname, char ***pseq, char ***pseqname,
+ char ***pcomments, char **pheader, char **err_message);
+extern int read_msf_align(const char *fname, char ***pseq, char ***pseqname,
+ char ***pcomments, char **pheader, char **err_message);
+extern int read_nexus_align(char *fname, char ***pseqs, char ***pseqnames,
+ char ***pcomments, char **pheader, char **err_message,
+ list_regions **charsets, int *pnum_species_sets,
+ int ***list_species_sets, char ***name_species_sets,
+ int *ptot_comment_lines, char ***comment_name, char ***comment_line,
+ int **comment_length);
+extern char *save_alignment_or_region(const char *fname, char **seq,
+ char **comments,
+ char *header, char **seqname, int totseqs, int *eachlength,
+ list_regions *regions, region *region_used, known_format format,
+ int numb_species_sets, int **list_species_sets,
+ char **name_species_sets, int *sel_seqs, int tot_sel_seqs, int protein,
+ int tot_comment_lines, char **comment_name, char **comment_line);
+extern void load_alignment_file(SEA_VIEW *view, char *filename,
+ char *message, char *pattern, known_format file_format);
+extern int is_a_protein_seq(char *seq);
+extern int prepare_printout(const char *filename, char **seq, int totseqs,
+ char **seqname,
+ int *eachlength, int char_per_line,
+ int block_size, int lines_per_page, int printout_vary,
+ char *align_name, int ref0);
+extern FILE *open_path(char *fname);
+extern int check_path(char *fname);
+extern void draw_region_background(SEA_VIEW *view, int f_seq0, int l_seq0);
+extern void load_seq_dialog(SEA_VIEW *view);
+extern void edit_comments_dialog(SEA_VIEW *view);
+extern void add_seq_to_align(SEA_VIEW *view, char *newname, char *newseq,
+ int lenseq);
+extern int get_color_for_base( int key );
+extern int get_color_for_aa( int key );
+extern char ***prepcolseqs(char **seq, int totseqs, int maxlen, int *eachlength,
+ int (*calc_color_function)( int ), int numb_gc, int allow_lower);
+extern char complement_base(char old);
+extern void select_deselect_seq(SEA_VIEW *view, int new_seq);
+extern void save_active_region(SEA_VIEW *view, int ask_confirm);
+extern void align_selected_parts(SEA_VIEW *view);
+extern void free_region(region *reg);
+extern void my_watch_cursor(Fl_Window *win);
+extern void update_current_seq_length(int newlength, SEA_VIEW *view);
+extern char *cre_consensus(SEA_VIEW *view, char *newname);
+extern int parse_comment_lines_from_header(char *header, char ***plines,
+ char ***pnames, int **plengths, int *pmax_seq_length);
+extern int insert_char_in_comment(int key, int num, SEA_VIEW *view);
+extern int delete_char_in_comment(SEA_VIEW *view, int count, int comnum,
+ int depart, int protect);
+extern void update_menu_footers(SEA_VIEW *view);
+extern int insert_gap_all_comments(int numgaps, int pos, SEA_VIEW *view);
+extern int delete_in_all_comments(int numdels, int pos, SEA_VIEW *view);
+extern char* fl_file_chooser(const char* message, const char* pat, const char* fname);
+#endif
Added: trunk/packages/seaview/branches/upstream/current/seaview.help
===================================================================
--- trunk/packages/seaview/branches/upstream/current/seaview.help (rev 0)
+++ trunk/packages/seaview/branches/upstream/current/seaview.help 2006-09-19 14:20:14 UTC (rev 111)
@@ -0,0 +1,521 @@
+>>>About seaview
+Program seaview was published in:
+Galtier, N., Gouy, M. & Gautier, C. (1996) SEAVIEW and PHYLO_WIN: two graphic
+tools for sequence alignment and molecular phylogeny. Comput. Appl. Biosci.,
+12:543-548.
+
+Seaview is available by anonymous FTP at pbil.univ-lyon1.fr in directory
+/pub/mol_phylogeny/seaview for several unix platforms and for Windows95/98.
+
+Seaview uses the FLTK library by Bill Spitzak and others.
+>>>Alignment panel
+Mouse Use:
+
+o Click on a site to position cursor (current cursor position -- sequence
+ number, positions in alignment and in sequence -- appears at panel top center)
+o Click or drag mouse on several sequence names to group them (names will appear
+ in black background). Alignment operations (gap insertions/deletions) will
+ operate on all grouped sequences simultaneously.
+o Double-click on any name to group all sequences.
+#ifdef WIN32
+o Ctrl-Click somewhere in sequence names to move grouped sequences to another
+ place in alignment.
+o Shift-Click to deactivate the current grouping; names return in normal print.
+#else
+o Click with middle mouse button somewhere in sequence names to move grouped
+ sequences to another place in alignment.
+o Click with right mouse button to deactivate the current grouping; all names
+ return in normal print.
+#endif
+
+Active keys:
+
+o The 4 keyboard arrows move the cursor
+o > < move the view by 50 sites to right and left (other keys can be used)
+o ] [ move the view by 5 sites to right and left (other keys can be used)
+ see "Miscellaneous options" for how to use other keys for same purpose
+o - <space> insert a gap in the cursor sequence and members of its group if any
+o <delete> or <backspace> delete a gap at left of cursor
+o + inserts a gap in all sequences but that under the cursor and members of its
+ group if any
+o _ ("underscore") deletes a gap in all sequences but that under the cursor
+ and members of its group if any
+o 1234567890 (digit keys) allow to compose a number (appearing under
+ mult=number at bottom left of panel) used as a multiplier to an operation
+ to follow (e.g., keys 4, 5, and - in sequence will insert 45 gaps)
+o Alt+S (both keys together) save the alignment in the current filename using
+ the current file saving format displayed by menu "Props". If format of
+ the last loaded file does not match the current saving format, this key
+ is not active.
+
+Mouse use on the site line (when there is one, white line at bottom):
+
+#ifdef WIN32
+o Click mouse to select/unselect a site.
+o Drag with the mouse button an extremity of a block of sites to extend or
+ reduce it.
+o Ctrl-Click to extend the block of sites at left.
+o Shift-Click on a block of sites to delete it.
+#else
+o Click with the left mouse button to select/unselect a site.
+o Drag with the left mouse button an extremity of a block of sites to extend
+ or reduce it.
+o Click with the middle mouse button to extend the block of sites at left.
+o Click with the right mouse button on a block of sites to delete it.
+#endif
+>>>File menu
+Open Mase, Open Phylip, Open Clustal, Open MSF, Open Fasta, Open NEXUS
+ to load an alignment in one of these formats
+ Mase and Nexus formats have the useful feature of allowing extra
+ data beyond sequences and names (comments, accession numbers are
+ really useful!). They can also store site sets [see
+ item `Sites menu'].
+
+<Ctrl>S Save when active, saves the alignment in the current file (which
+ name appears as window title), and indicates that keys
+ <Ctrl> + S pressed together will perform this operation.
+
+Save as... allows to save the alignment under a filename to be chosen
+ in the file selector appearing next [Pressing button Rescan
+ therein may be necessary to have all files appear].
+
+Save current sites
+ only active when a site line is displayed; allows to save
+ in a file only those sites of the sequences where an X is in the
+ site line. If some sequences are selected, only these are saved.
+
+Prepare printout
+ Prepares a file adequate for alignment printout on a printer. The
+ file selector appearing next allows to specify 3 parameters:
+ block size alignment lines may be divided in blocks (e.g. of size 10
+ for DNA/RNA sequences or 3 for protein coding sequences)
+ to ease alignment reading.
+ chars/line the max number of characters that fit on a printer line
+ (not the desired number of residues per line, which is
+ set to the largest fitting value by the program).
+ lines/page the number of lines that fit on a printer page (in order
+ that blocks of alignment lines are not divided by page
+ borders).
+
+Quit guess what?
+>>>Props menu
+Fontsize > Tiny, Small, ..., Huge
+ Sets the font size used to display sequences.
+
+Save format> Save as Mase, as Phylip, as Clustal, as MSF, as Fasta, as NEXUS
+ Sets the file format used to save alignments
+ [`Miscellaneous options' topic explains how to set default format]
+
+Colors > DNA/RNA colors
+ Forces sequences to be colored as DNA/RNA in case they were
+ erroneously recognized as protein data.
+ > Protein colors
+ Forces sequences to be colored as proteins in case they were
+ erroneously recognized as DNA/RNA data.
+ > Alt. colors
+ Uses alternate coloring rules defined for protein sequences
+ [`Coloring schemes' topic below explains how to define them].
+ > Inverted colors
+ Display residues as black letters on colored background instead
+ of as colored letters on grey background.
+
+Allow seq. edition
+ When ON, residues can be deleted/inserted.
+ when OFF (normally), only gaps can be deleted/inserted.
+
+by Reference To display the alignment by reference to a particular sequence:
+ residues identical to that of the ref. seq. are displayed as dots.
+ Possible only when one sequence, the reference, is selected.
+ Alignment edition is impossible while in the reference mode.
+ When used, File:Prepare printout produces a printout by reference.
+ Combination <Ctrl>+R is a shortcut for calling/exiting this mode.
+
+DNA keys Allows to use keys "hjkl" to enter DNA sequences
+ "Allow seq. edition" should be ON for this item to be usable.
+ Choose in the submenu what bases will be mapped to these keys
+ > hjkl => GATC, hjkl => TCGA, hjkl => ACGT
+ Also, the space bar will be mapped to base N.
+
+Clustalw options
+ Allows to specify options sent to the clustalw alignment program
+ in order to set, e.g., specific alignement parameter values.
+ Go to submenu "Edit options" and type desired options in the
+ dialog window that appears.
+#ifdef WIN32
+ An example is to type /gapopen=5
+#else
+ An example is to type -gapopen=5
+#endif
+ When an option has been typed it is active unless you switch it off
+ by calling again "Clustalw options" and sliding to the check box.
+ Thus a set of options can be memorized and turned on and off.
+
+Consensus option
+ Allows to set the percent of identical residues needed to define
+ a residue when building a consensus sequence. Sites where this
+ fraction is not reached are filled with N or X.
+
+Fast-Rough Allows to switch between smooth-slow or rough-fast display.
+
+Allow lowercase
+ If set, lowercase residues will be apparent. If not set, lowercase
+ residues in sequence files display as uppercase.
+
+>>>Sites menu
+Site sets allow to specify parts of a multiple alignment to be retained for
+further analyses (typically, those parts of the alignment taken as
+reliably aligned). Retained sites are depicted as series of Xs on a special
+line at bottom of the alignment panel. On color screens, they are also
+displayed by a dark background. Mouse clicks and drags on this line allow to
+construct/alter the set.
+
+Several sets of sites can be created and stored with the alignment if the Mase
+or NEXUS formats of alignment files are used. Each set has a name chosen by the
+user. One set of sites at most can be displayed at any time through this menu.
+
+Item "Save current sites" of menu "File" allows to save in an alignment
+file only those sites of the alignment pertaining to the currently displayed
+set. The resulting file may then be processed by, e.g., tree building
+programs.
+
+Create set creates a line at bottom of alignment to hold the location
+ of alignment sites.
+
+Save set stores changes done to the current set of sites
+
+Rename set stores the current set of sites under a new name
+
+Hide set hides (but remembers except unsaved changes) the current set of
+ sites
+
+Delete set removes the currently displayed set of sites from list of known
+ sets
+
+<name> shows a sites line of name <name> constructed from data stored
+ in the alignment, or previously created
+>>>Species menu
+Species sets can be created and stored with the alignment if the Mase or NEXUS
+formats of alignment files are used.
+
+To select one or several species, click or drag on their names; they will
+appear in black background.
+
+To memorize the current set of selected species, choose "Create set" from
+this menu. The program will ask for a name for this set.
+
+Delete set deletes (just from memory) the current set of species.
+
+<name> Displays with black background the set of species memorized
+ under that name.
+>>>Footers menu
+Comment lines can be created and displayed at bottom of the screen. These
+lines can contain any text and the program will maintain the vertical
+alignment between this text and sequences. This text can be saved using the
+mase or NEXUS file formats only.
+
+To edit this text, click on the line name, position the cursor, and type text.
+Click again on the line name to stop editing this text.
+
+Show / Hide footers To show / hide all footer lines
+
+Create footer To create a new footer line
+
+Delete footer To delete the currently selected footer line
+
+
+>>>Search button & box
+Type a string in box at right and strike <return> key or push button to
+position the cursor in the next occurence of this string from its current
+place.
+
+Push button to position the cursor at next occurence of the current
+search string.
+
+Sequence gaps are ignored by the search procedure.
+>>>Goto button & box
+
+ Moves the cursor to desired position or sequence
+
+Position:
+Type a number in box at right and hit <return> key or push button to
+position the cursor at that position of the alignment.
+
+Sequence:
+Type a (fragment of) sequence name in box at right and hit <return> key or
+push button to position the cursor in that sequence. Case is not significant.
+>>>Edit menu
+Rename sequence To rename the currently selected (= name in black
+ background) sequence.
+
+Edit comments To see or change comments of the currently selected
+ sequence (Comments can only be saved in mase/NEXUS).
+
+Delete sequence(s) Deletes all selected sequences from the alignment.
+
+Create sequence Allows to create a new-empty sequence in the alignment;
+ set "Allow seq. edition" from "Props" menu ON
+ to be able to type the sequence in.
+
+Load sequence Allows to load a new sequence in the alignment.
+ The sequence can be typed in or pasted from a
+ selection made in another window: drag on the
+ sequence data, and paste it with the middle mouse
+ button in the `Sequence loading' window.
+
+Duplicate sequence Allows to duplicate the currently selected sequence
+ wih prefix D_ in its name.
+
+Complement sequence Creates a new sequence equal to the complementary
+ strand of the currently selected sequence with prefix
+ C_ in its name.
+
+Reverse sequence Creates a new sequence by reading 3' -> 5' the
+ currently selected sequence and named with prefix R_
+
+Exchange Us and Ts Exchange bases Us and Ts in all currently selected
+ sequences.
+
+Align sites Runs the clustalw alignment program on the block of
+ selected sites and the set of selected sequences.
+ A window will ask for choosing the reference sequence:
+ gaps present before clustalw alignment in the chosen
+ sequence will be preserved in the new alignment.
+#ifdef WIN32
+ Program clustalw will be searched in the directory
+ of the seaview program, the current directory and
+ in directories of your PATH variable.
+#else
+ Your PATH should contain the directories of
+ programs clustalw, xterm and seaview_align.sh.
+#endif
+
+Dot plot Performs a "dot plot" analysis of the two selected
+ sequences. See "Dot plot" item of the help data.
+
+Consensus sequence Computes the consensus of all currently selected
+ sequences. At any site, the consensus residue is the
+ most frequent one if its frequency is above a threshold
+ value. This threshold (60 % by default) can be changed
+ through item "Consensus threshold" of menu "Props".
+ Below threshold, N or X is used.
+>>>Dot plot
+ Performs a "dot plot" analysis of two sequences
+
+Enter desired values for the window size and # of matches/window, and click
+on button "Compute", the dot plot will appear.
+
+Click in the dot plot, the corresponding sequence regions appear in
+the alignment panel above the dot plot. Use "Magnify" to take a close look.
+Click on arrows at left to move the hit point by one residue in either of
+six directions.
+Move the slider below the alignment panel to control the number of displayed
+residues.
+
+Fit to window, Reduce, Magnify: perform zoom in and out operations
+Write Postcript: saves the dot plot in a file called from the alignment name
+ with extension .ps
+Close: closes the dot plot window
+
+ To perform a dot plot-guided alignment
+ --------------------------------------
+Click on a diagonal representing two sequence parts to be aligned, then click
+on button "align".
+Repeat this for each sequence parts you want to be aligned to each other.
+To transfer into the multiple alignment the result of these operations, click on
+button "Record alignment".
+Most often, one of the two compared sequences is already aligned to other
+sequences of the multiple alignment, while the other one is not. Choose which
+of the two sequences is already aligned by clicking on the arrow next to
+"Ref. sequence".
+>>>Mase file format
+Mase files follow the following format:
+
+Zero or more header lines each beginning with ;;
+Next, for each sequence in the alignment:
+One or more comment lines each beginning with ;
+Sequence name alone on a line (may be long and may contain spaces)
+Sequence data in free form, possibly with numbers and spaces ignored while
+reading the file. Dashes denote gaps.
+
+Header lines may contain any text and also contain descriptions of site sets and
+of species groups when such data have been defined.
+
+Site sets are written as in this example:
+;;# of segments=10 mychoice
+;; 14,74 221,256 416,449 990,1148 1363,1384 1474,1483 1556,1668 2034,2062
+;; 2114,2139 2756,2859
+where "mychoice" is the name of the set of sites and where the series of pairs
+of numbers lists the endpoints of successive block of sites.
+
+Species groups are written as in this example:
+;;@ of species = 4 distant outgroup
+;; 2, 3, 4, 5
+where "distant outgroup" is the name of the species group and where the series
+of numbers lists the ranks of sequences members of the species group.
+>>>Program arguments
+#ifdef WIN32
+Arguments can be used to associate files with the seaview program.
+#endif
+Program is run by command
+seaview [options] [filename]
+
+where options may be
+-save <format_name>
+ [format_name, either mase, clustal, phylip, msf, nexus or fasta sets
+ the initial file format for saving operations and for opening the file
+ given on command line; default is mase]
+-fast
+ [sequences will be displayed faster but less smoothly]
+-inverted
+ [residues will appear as black letters on a colored background]
+
+and filename
+is an optional alignment file to be loaded. The expected format for this file
+is that of the default format for saving operations.
+
+See `Program customization' topic to know how to further customize the program.
+>>>Program customization
+#ifdef WIN32
+Seaview can be customized through several options to be put in a text file
+called "seaview.ini" located in the same directory as program seaview itself.
+Next help items describe all these options.
+Each option is specified by a line in this file of the form
+<option-name> = <option-value>
+
+Examples:
+stdcolorgroups = AC,DEFGHIK,LMNPQRS,WY,TV
+save = clustal
+printoutcpl = 90
+inverted = True
+#else
+Seaview can be customized by several options specified as program resources.
+Next help items describe all these options.
+Each resource is specified by a line of the form
+Seaview.<resource-name>: <resource-value>
+
+Examples:
+Seaview.dnacolors: blue,yellow,green,255 0 0
+Seaview.altcolorgroups: AC,DEFGHIK,LMNPQRS,WY,TV
+Seaview.save: clustal
+Seaview.printoutcpl: 90
+Seaview.inverted: True
+
+Resource lines are added by any of 4 means:
+1) in a file called Seaview in directory /usr/lib/X11/app-defaults
+2) in a file called Seaview in any directory pointed to by environment variable
+XAPPLRESDIR
+3) in your $HOME/.Xdefaults file
+(note that this is effective only if this file is read by your login procedure)
+4) interactively loaded by command
+xrdb -merge fname
+where "fname" is a file containing resource lines
+and checked by command
+xrdb -query
+#endif
+>>>Miscellaneous options
+See 'Program customization' topic for how to set these options.
+
+ MISCELLANEOUS OPTIONS
+
+Purpose (note)| Name | Default value | Example of possible value
+---------------------|-----------|---------------|-----------------------------
+saving format (1)| save | mase | clustal
+#ifdef WIN32
+name of help file (2)| helpfile | seaview.hlp | seaview.aide
+#else
+name of help file (2)| helpfile | seaview.help | seaview.aide
+#endif
+fast, rough display | fast | false | true
+colored background | inverted | false | True
+keys to move view | movekeys | ][>< | }{.,
+allow lowercase | lowercase | false | TRUE
+#ifdef WIN32
+window size | window | 900x550 | 800x400
+#else
+window size | window | 1000x700 | 800x400
+emul. 3-button mouse |emulate_3_b| false | True
+ (3)| | |
+#endif
+
+Notes:
+1) Possible file formats are mase, clustal, phylip, msf, fasta, nexus.
+#ifdef WIN32
+2) The help file is sought in the directory containing program seaview.
+#else
+2) The help file is sought in all directories listed in the PATH variable
+and in the current directory.
+3) if yes, use CTRL-click for middle button & SHIFT-click for right button
+#endif
+
+>>>Coloring schemes
+See 'Program customization' topic for how to set these options.
+
+ SETTING GROUPS OF AMINO ACIDS DISPLAYED WITH THE SAME COLOR
+
+By default, amino acids are split in 5 families each displayed in a different
+color. These families can be customized, up to a maximum of 10 families.
+Also, an alternative coloring scheme can be defined, and seaview will
+allow to switch between the first and the alternative coloring schemes.
+
+Purpose | Name | Default value | Example of value
+--------------------|----------------|-----------------|-----------------
+standard coloring | stdcolorgroups | EDQNHRKBZ,ILMV, | DEBZ,ACWY,FGH
+scheme of aminoacids| | APSGT,FY,WC | IK,LMNPQRSTV
+ | | |
+alternate coloring | altcolorgroups | <none> | ILMV,ACGPST,DEN
+scheme of aminoacids| | | QBZ,HKR,FWY
+
+Note: Default colors are red, green, yellow, blue, cyan, magenta, salmon,
+purple, aquamarine, and dark-gray. These can be changed (see 'Defining colors').
+White is used for gaps and for unlisted residues.
+The above 2 options allow to set which aminoacids will be painted in what
+of the above colors. The format for these is, e.g.,
+EDQNHRKBZ,ILMV,APSGT,FY,WC
+to specify
+aminoacids | EDQNHRKBZ | ILMV | APSGT | FY | WC | others + gaps |
+color | red | green | yellow | blue | cyan | white |
+The number of listed groups of aminoacids determines the number of colors used.
+>>>Defining colors
+See 'Program customization' topic for how to set these options.
+
+ CHANGING COLORS USED TO DISPLAY SEQUENCES
+
+Purpose | Name | Default value | Example of value
+----------------|------------|----------------------------|---------------------
+#ifdef WIN32
+set DNA colors | dnacolors | red,green,yellow,blue | 100 0 0,0 100 0,0 0
+ | | | 100,100 100 0
+ | | |
+set prot. colors| protcolors | red,green,yellow,blue, | 100 0 0,0 100 0,
+ | | cyan,magenta,salmon,purple,| 0 0 100,100 100 0,
+ | | aquamarine,dark-gray | 0 100 100,100 0 100
+#else
+set DNA colors | dnacolors | red,green,yellow,blue | blue,yellow,255 0 0,
+ | | | green
+ | | |
+set prot. colors| protcolors | red,green,yellow,blue, | salmon,154 255 154,
+ | | cyan,magenta,salmon,purple,| lightyellow,lavender
+ | | aquamarine,dark-gray |
+#endif
+
+Notes:
+#ifdef WIN32
+Colors are defined by 3 RGB numbers in range 0-255.
+#else
+Colors are defined either by a name from your rgb.txt file
+ or by 3 RGB numbers in range 0-255.
+#endif
+For DNA/RNA, the 4 listed colors apply to A, C, G, and T/U, respectively.
+For proteins, at most 10 colors can be listed.
+>>>Printout options
+See 'Program customization' topic for how to set these options.
+
+ CONTROLING PRINTOUT OPERATION
+
+Purpose | Name | Default value | Example of possible value
+--------------|---------------|---------------|--------------------------
+block size | printoutblock | 10 | 3
+chars/line | printoutcpl | 80 | 90
+lines/page | printoutlpp | 66 | 60
+
+Note: the value of printoutcpl stands for the full page width.
Added: trunk/packages/seaview/branches/upstream/current/seaview_align.sh
===================================================================
--- trunk/packages/seaview/branches/upstream/current/seaview_align.sh (rev 0)
+++ trunk/packages/seaview/branches/upstream/current/seaview_align.sh 2006-09-19 14:20:14 UTC (rev 111)
@@ -0,0 +1,20 @@
+#!/bin/sh
+arg1=$1
+shift 1
+args=$*
+if [ $# -gt 4 ]; then
+ shift 4
+ echo used clustalw options: $*
+fi
+clustalw $args
+echo ' '
+echo ' '
+echo ' '
+echo 'Program clustalw terminated.'
+echo 'Load new alignment? [(y)/n] \c'
+read rep
+if [ "$rep" = "n" ]; then
+ echo aborted > $arg1.status
+else
+ echo success > $arg1.status
+fi
Property changes on: trunk/packages/seaview/branches/upstream/current/seaview_align.sh
___________________________________________________________________
Name: svn:executable
+
Added: trunk/packages/seaview/branches/upstream/current/use_mase_files.cxx
===================================================================
--- trunk/packages/seaview/branches/upstream/current/use_mase_files.cxx (rev 0)
+++ trunk/packages/seaview/branches/upstream/current/use_mase_files.cxx 2006-09-19 14:20:14 UTC (rev 111)
@@ -0,0 +1,1562 @@
+#include "seaview.h"
+#include <ctype.h>
+#include <time.h>
+
+/* included functions */
+int read_mase_seqs_header(const char *masefname, char ***pseq, char ***pseqname,
+ char ***pcomments, char **pheader, char **err_message);
+int one_more_seq_found(int count1, char ***pseq, char ***pseqname, char ***pcomments);
+int read_fasta_align(const char *fname, char ***pseq, char ***pseqname,
+ char ***pcomments, char **pheader, char **err_message);
+int read_phylip_align(const char *fname, char ***pseq, char ***pseqname,
+ char ***pcomments, char **pheader, char **err_message);
+int read_clustal_align(const char *fname, char ***pseq, char ***pseqname,
+ char ***pcomments, char **pheader, char **err_message);
+int read_msf_align(const char *fname, char ***pseq, char ***pseqname,
+ char ***pcomments, char **pheader, char **err_message);
+int is_a_protein_seq(char *seq);
+int save_fasta_file(const char *fname, char **seq,
+ char **seqname, int totseqs, int *eachlength, region *region_used,
+ int *sel_seqs, int tot_sel_seqs);
+int save_phylip_file(const char *fname, char **seq,
+ char **seqname, int totseqs, int *eachlength, region *region_used,
+ int *sel_seqs, int tot_sel_seqs);
+int output_next_res_from_region(char *seq, int lenseq,
+ list_segments **segment, int *current, FILE *out, int total,
+ int use_dots);
+void save_regions(list_regions *regions, FILE *out);
+int save_mase_file(const char *fname, char **seq, char **comments,
+ char *header, char **seqname, int totseqs, int *eachlength,
+ list_regions *regions, region *region_used, int numb_species_sets,
+ int **list_species_sets, char **name_species_sets,
+ int *sel_seqs, int tot_sel_seqs, int tot_comment_lines,
+ char **comment_name, char **comment_line);
+int save_clustal_file(const char *fname, char **seq,
+ char **seqname, int totseqs, int *eachlength, region *region_used,
+ int *sel_seqs, int tot_sel_seqs);
+int calc_gcg_check(list_segments *psegment, char *seq);
+int save_msf_file(const char *fname, char **seq,
+ char **seqname, int totseqs, int *eachlength, region *region_used,
+ int protein, int *sel_seqs, int tot_sel_seqs);
+char *save_alignment_or_region(const char *fname, char **seq, char **comments,
+ char *header, char **seqname, int totseqs, int *eachlength,
+ list_regions *regions, region *region_used, known_format format,
+ int numb_species_sets, int **list_species_sets,
+ char **name_species_sets, int *sel_seqs, int tot_sel_seqs, int protein,
+ int tot_comment_lines, char **comment_name, char **comment_line);
+int prepare_printout(const char *filename, char **seq, int totseqs,
+ char **seqname,
+ int *eachlength, int char_per_line,
+ int block_size, int lines_per_page, int vary_only,
+ char *align_name, int ref0);
+int calc_vary_lines(int *vary_pos, int widpos);
+void out_vary_pos(int *vary_pos, int widnames, int widpos, int nl, FILE *out);
+FILE *open_path(char *fname);
+int check_path(char *fname);
+static void save_species_sets(int numb_species_sets, int **list_species_sets,
+ char **name_species_sets, int totseqs, FILE *out);
+void save_comment_lines(int tot_comment_lines, char **names, char **lines,
+ FILE *out);
+known_format what_format(const char *filename);
+
+
+
+/* external */
+int save_nexus_file(const char *fname, int ntaxa, int protein,
+ char **seqs, char **taxnames, char **notes, char *header,
+ int num_species_sets, int **list_species_sets,
+ char **name_species_sets,
+ list_regions *charsets,
+ int tot_comment_lines, char **comment_name, char **comment_line,
+ region *region_used, int *sel_seqs, int tot_sel_seqs, int *eachlength);
+
+
+
+int read_mase_seqs_header(const char *masefname, char ***pseq, char ***pseqname,
+ char ***pcomments, char **pheader, char **err_message)
+{
+#define MAXLENSEQ 10000 /* unite d'allocation de memoire */
+#define lline 2000
+FILE *masef;
+char line[lline], *i, *base, *header = NULL, *provseq = NULL, *p;
+int l, lenseqs, lpre, lseq, l2, totseqs = -1, want_header, curr_max_header;
+static char ret_message[200];
+char **seq, **seqname, **comments;
+
+*ret_message = 0;
+*err_message = ret_message;
+if( (masef=fopen(masefname,"r")) == NULL) {
+ sprintf(ret_message,"File not found:%s",masefname);
+ return 0;
+ }
+want_header = (pheader != NULL);
+
+if(fgets(line, lline, masef)==NULL)goto fini;
+if(strncmp(line,";;",2)==0) {
+ if(want_header) {
+ if( (header=(char *)malloc(MAXLENCOM+1)) ==
+ NULL)goto nomem;
+ curr_max_header = MAXLENCOM;
+ strcpy(header,line);
+ lpre=strlen(line);
+ }
+ do {
+ if( fgets(line,lline,masef)==NULL ) goto fini;
+ if(strncmp(line,";;",2)!=0) break;
+ if(header != NULL) {
+ lseq=strlen(line);
+ if(lpre+lseq > curr_max_header) {
+ curr_max_header += MAXLENCOM;
+ if( (p=(char *)malloc(curr_max_header+1))
+ == NULL ) goto nomem;
+ memcpy(p, header, lpre);
+ free(header);
+ header = p;
+ }
+ memcpy(header+lpre,line, lseq);
+ lpre += lseq;
+ }
+ }
+ while (1);
+ if( want_header ) {
+ header[lpre] = 0;
+ header=(char *)realloc(header,lpre+1);
+ }
+ }
+if(*line != ';' ) {
+ strcpy(ret_message,"Not a mase file!");
+ goto fini;
+ }
+
+lenseqs=MAXLENSEQ;
+if( (provseq=(char *)malloc(lenseqs+1)) ==NULL)goto nomem;
+
+i=line;
+while(i!=NULL){
+ totseqs = one_more_seq_found(totseqs, &seq, &seqname, &comments);
+ if(totseqs == -1) goto nomem;
+ if(comments!=NULL) {
+ if( (comments[totseqs]=(char *)malloc(MAXLENCOM+1)) ==
+ NULL)goto nomem;
+ strcpy(comments[totseqs],line);
+ lpre=strlen(line); l=MAXLENCOM;
+ while(*fgets(line,lline,masef)==';') {
+ lseq=strlen(line);
+ if(lpre+lseq <= l) {
+ strcpy(comments[totseqs]+lpre,line);
+ lpre += lseq;
+ }
+ else l=lpre-1;
+ }
+ if(lpre<MAXLENCOM)
+ comments[totseqs]=(char *)realloc(comments[totseqs],lpre+1);
+ }
+ else while(*fgets(line,lline,masef)==';');
+ l = strlen(line);
+ while((line[l-1] == ' ' || line[l-1] == '\n') && l>0 ) l--; line[l] = 0;
+ if( (seqname[totseqs]=(char *)malloc(l+1)) == NULL)goto nomem;
+ strcpy(seqname[totseqs],line);
+ lseq = 0; /* what is already put in provseq */
+ while( (i=fgets(line,lline,masef))!= NULL && *i != ';' ) {
+ l2 = strlen(line);
+ if( line[l2 - 1] == '\n' ) l2--;
+ while(l2>0 && line[l2-1]==' ')l2--;
+ if(lseq + l2 > lenseqs) {
+ char *temp;
+ lenseqs += MAXLENSEQ;
+ temp = (char *)malloc(lenseqs+1);
+ if(temp == NULL) goto nomem;
+ memcpy(temp, provseq, lseq);
+ free(provseq);
+ provseq = temp;
+ }
+ memcpy(provseq+lseq, line, l2);
+ lseq += l2;
+ }
+ provseq[lseq]='\0';
+ seq[totseqs] = (char *)malloc(lseq+1);
+ if(seq[totseqs] == NULL) goto nomem;
+/* ignore space or non printable characters */
+ base=provseq - 1; p = seq[totseqs] - 1;
+ while ( *(++base) != 0) {
+ if(isprint(*base) && ! isspace(*base) ) {
+// *(++p) = toupper(*base);
+ *(++p) = *base;
+ }
+ }
+ *(++p) = 0;
+ }
+seq = (char **)realloc(seq, (totseqs + 1)*sizeof(char *));
+seqname = (char **)realloc(seqname, (totseqs + 1)*sizeof(char *));
+comments = (char **)realloc(comments, (totseqs + 1)*sizeof(char *));
+*pseq = seq; *pseqname = seqname; *pcomments = comments;
+fini:
+fclose(masef);
+if(want_header) *pheader = header;
+if(provseq != NULL) free(provseq);
+return totseqs+1;
+nomem:
+sprintf(ret_message,"Error: Not enough memory!");
+totseqs = -1;
+goto fini;
+}
+
+
+int one_more_seq_found(int count1, char ***pseq, char ***pseqname, char ***pcomments)
+{
+static int max_count;
+char **seq, **seqname, **comments;
+
+if(count1 == -1) max_count = 0;
+
+if(count1 + 1 < max_count) return count1 + 1;
+
+count1++;
+if(max_count == 0) {
+ max_count = 100;
+ seq = (char **)malloc(max_count * sizeof(char *));
+ if(seq == NULL) return -1;
+ seqname = (char **)malloc(max_count * sizeof(char *));
+ if(seqname == NULL) return -1;
+ comments = (char **)malloc(max_count * sizeof(char *));
+ if(comments == NULL) return -1;
+ }
+else {
+ seq = *pseq; seqname = *pseqname; comments = *pcomments;
+ max_count = 3 * max_count;
+ seq = (char **)realloc(seq, max_count * sizeof(char *));
+ if(seq == NULL) return -1;
+ seqname = (char **)realloc(seqname, max_count * sizeof(char *));
+ if(seqname == NULL) return -1;
+ comments = (char **)realloc(comments, max_count * sizeof(char *));
+ if(comments == NULL) return -1;
+ }
+
+*pseq = seq; *pseqname = seqname; *pcomments = comments;
+return count1;
+}
+
+int read_fasta_align(const char *fname, char ***pseq, char ***pseqname,
+ char ***pcomments, char **pheader, char **err_message)
+{
+FILE *in;
+int totseqs, lseq, l2, l, lenseqs;
+char line[200], *p, *i, *provseq = NULL;
+static char ret_message[200];
+char **seq, **seqname, **comments;
+
+*ret_message = 0;
+*err_message = ret_message;
+if( (in=fopen(fname,"r")) == NULL) {
+ sprintf(ret_message,"File not found:%s", fname);
+ return 0;
+ }
+
+/* calcul du nombre de sequences dans le fichier */
+totseqs = 0;
+while(fgets(line, sizeof(line), in) != NULL) {
+ if(*line == '>') totseqs++;
+ }
+rewind(in);
+seq = (char **)malloc(totseqs * sizeof(char *));
+if(seq == NULL) goto nomem;
+comments = (char **)malloc(totseqs * sizeof(char *));
+if(comments == NULL) goto nomem;
+seqname = (char **)malloc(totseqs * sizeof(char *));
+if(seqname == NULL) goto nomem;
+*pseq = seq; *pcomments = comments; *pseqname = seqname;
+
+lenseqs = MAXLENSEQ;
+totseqs = -1;
+i = fgets(line, sizeof(line), in);
+if(line[0] != '>') {
+ strcpy(ret_message,"File not in Fasta format!");
+ totseqs = -1; goto fini;
+ }
+while( i != NULL ){
+ totseqs++;
+ comments[totseqs] = NULL;
+ p = line + 1; while(*p != ' ' && *p != '\n') p++;
+ l = p - line - 1;
+ if( (seqname[totseqs] = (char *)malloc(l+1)) == NULL)goto nomem;
+ memcpy(seqname[totseqs], line + 1, l); seqname[totseqs][l] = 0;
+ seq[totseqs] = (char *)malloc(lenseqs+1);
+ if(seq[totseqs] == NULL) goto nomem;
+ lseq = 0;
+ while( (i=fgets(line, sizeof(line), in))!= NULL && *i != '>' ) {
+ l2 = strlen(line);
+ if( line[l2 - 1] == '\n' ) l2--;
+ while(l2>0 && line[l2-1]==' ')l2--;
+ if(lseq + l2 > lenseqs) {
+ char *temp;
+ lenseqs += MAXLENSEQ;
+ temp = (char *)malloc(lenseqs+1);
+ if(temp == NULL) goto nomem;
+ memcpy(temp, seq[totseqs], lseq);
+ free(seq[totseqs]);
+ seq[totseqs] = temp;
+ }
+ memcpy(seq[totseqs]+lseq, line, l2);
+ lseq += l2;
+ }
+ seq[totseqs][lseq]='\0';
+/* convert all to upper case */
+ p = seq[totseqs] - 1; while( *(++p) != 0 ) *p = toupper(*p);
+ }
+fini:
+fclose(in);
+if(provseq != NULL) free(provseq);
+*pheader = NULL;
+return totseqs+1;
+nomem:
+sprintf(ret_message,"Error: Not enough memory!");
+totseqs = -1;
+goto fini;
+}
+
+
+int read_phylip_align(const char *fname, char ***pseq, char ***pseqname,
+ char ***pcomments, char **pheader, char **err_message)
+{
+FILE *in;
+char *p, *q, line[PHYNAME + 200];
+char **seq, **comments, **seqname;
+int totseqs, lenseqs, i, l;
+static char ret_message[200];
+*ret_message = 0;
+*err_message = ret_message;
+in=fopen(fname,"r");
+if(in==NULL) {
+ sprintf(ret_message,"File not found:%s",fname);
+ return 0;
+ }
+fgets(line,sizeof(line),in);
+if( sscanf(line, "%d%d", &totseqs, &lenseqs) != 2) {
+ sprintf(ret_message,"Not a PHYLIP file");
+ totseqs = 0;
+ goto fini;
+ }
+seq = (char **)malloc(totseqs * sizeof(char *));
+if(seq == NULL) goto nomem;
+seqname = (char **)malloc(totseqs * sizeof(char *));
+if(seqname == NULL) goto nomem;
+comments = (char **)malloc(totseqs * sizeof(char *));
+if(comments == NULL) goto nomem;
+for(i=0; i<totseqs; i++) {
+ if( (seq[i] = (char *)malloc(lenseqs+1) ) == NULL ) goto nomem;
+ if( (seqname[i] = (char *)malloc(PHYNAME+1) ) == NULL ) goto nomem;
+ comments[i] = NULL;
+ }
+for(i=0; i<totseqs; i++) {
+ fgets(line,sizeof(line),in);
+ memcpy(seqname[i],line,PHYNAME); seqname[i][PHYNAME] = 0;
+ p = line+PHYNAME; q = seq[i];
+ while(*p != '\n') {
+ if(*p != ' ') *(q++) = *p;
+ p++;
+ }
+ }
+l = q - seq[totseqs - 1];
+while( l < lenseqs) {
+ fgets(line,sizeof(line),in);
+ for(i=0; i<totseqs; i++) {
+ fgets(line,sizeof(line),in);
+ p = line; q = seq[i] + l;
+ while(*p != '\n') {
+ if(*p != ' ') *(q++) = *p;
+ p++;
+ }
+ }
+ l = q - seq[totseqs - 1];
+ }
+for(i=0; i<totseqs; i++) seq[i][l] = 0;
+fini:
+*pheader = NULL;
+fclose(in);
+*pseq = seq; *pseqname = seqname; *pcomments = comments;
+return totseqs;
+nomem:
+sprintf(ret_message,"Error: Not enough memory!");
+totseqs = 0;
+goto fini;
+}
+
+
+int read_clustal_align(const char *fname, char ***pseq, char ***pseqname,
+ char ***pcomments, char **pheader, char **err_message)
+{
+FILE *in;
+char line[200], *p;
+int i, l, curr_spec, first=TRUE, curr_len, next_len, tot_spec, curr_max_len,
+ carac, wid_name;
+static char ret_message[200];
+char **seq, **comments, **seqname;
+
+*ret_message = 0;
+*err_message = ret_message;
+in=fopen(fname,"r");
+if(in==NULL) {
+ sprintf(ret_message,"File not found:%s",fname);
+ return 0;
+ }
+fgets(line,sizeof(line),in);
+if(strncmp(line,"CLUSTAL",7) != 0) { /* skip 1st line with CLUSTAL in it */
+ strcpy(ret_message,"File not in CLUSTAL format!");
+ tot_spec = -1; goto fini;
+ }
+/* skip next empty lines */
+do {
+ carac = getc(in);
+ if(carac == ' ') {
+ fgets(line,sizeof(line),in);
+ carac = getc(in);
+ }
+ }
+while(carac == '\n');
+ungetc(carac, in); /* back to start of 1st non-empty line */
+tot_spec = curr_spec = -1; curr_len = next_len = 0;
+while( fgets(line, sizeof(line), in) != NULL ) {
+ if(*line == '\n' || *line == ' ') {
+ curr_spec = -1;
+ curr_len = next_len;
+ first = FALSE;
+ continue;
+ }
+ else if(tot_spec >= 0 && curr_spec == -1 &&
+ strncmp(line, seqname[0], strlen(seqname[0]) ) != 0) {
+ break;
+ }
+ else {
+ if(first) {
+ curr_spec = one_more_seq_found(curr_spec, &seq, &seqname, &comments);
+ if(curr_spec == -1) goto nomem;
+ }
+ else curr_spec++;
+ }
+ if(first && curr_spec == 0) {
+/* calcul long partie nom: enlever tout ce qui n'est pas espace en fin */
+ p = line + strlen(line) - 2;
+ while(*p == ' ' || isdigit(*p) ) p--;
+ while (*p != ' ') p--;
+ wid_name = p - line + 1;
+ }
+ if(first) {
+ seqname[curr_spec] = (char *)malloc(wid_name+1);
+ if(seqname[curr_spec]==NULL) {
+ goto nomem;
+ }
+ memcpy(seqname[curr_spec], line, wid_name);
+ p = seqname[curr_spec] + wid_name - 1;
+ while(*p==' ') p--; *(p+1)=0;
+ if(curr_spec > tot_spec) tot_spec = curr_spec;
+ seq[curr_spec] = (char *)malloc(CLU_BLOCK_LEN+1);
+ curr_max_len = CLU_BLOCK_LEN;
+ if(seq[curr_spec]==NULL) {
+ goto nomem;
+ }
+ comments[curr_spec] = NULL;
+ }
+ if(curr_spec == 0) {
+ l = strlen(line) - 1;
+ p = line + l - 1;
+ while(*p == ' ' || isdigit(*p) ) { p--; l--; }
+ l -= wid_name;
+ if(curr_len + l > curr_max_len) {
+ curr_max_len += CLU_BLOCK_LEN;
+ for(i=0; i<=tot_spec; i++) {
+ p = (char *)malloc(curr_max_len+1);
+ if(p == NULL) goto nomem;
+ memcpy(p, seq[i], curr_len);
+ free(seq[i]);
+ seq[i] = p;
+ }
+
+ }
+ next_len = curr_len + l;
+ }
+ memcpy(seq[curr_spec]+curr_len, line + wid_name, l);
+ }
+for(i=0; i<=tot_spec; i++) seq[i][next_len] = 0;
+seq = (char **)realloc(seq, (tot_spec + 1)*sizeof(char *));
+seqname = (char **)realloc(seqname, (tot_spec + 1)*sizeof(char *));
+comments = (char **)realloc(comments, (tot_spec + 1)*sizeof(char *));
+*pseq = seq; *pseqname = seqname; *pcomments = comments;
+fini:
+*pheader = NULL;
+fclose(in);
+return tot_spec + 1;
+nomem:
+sprintf(ret_message,"Error: Not enough memory!");
+tot_spec = -1;
+goto fini;
+}
+
+
+int read_msf_align(const char *fname, char ***pseq, char ***pseqname,
+ char ***pcomments, char **pheader, char **err_message)
+{
+FILE *in;
+char line[100], *p, *q;
+int l, curr_spec, maxwidname=0, curr_len, tot_spec, wid_1_line, wid_block;
+static char ret_message[200];
+char **seq, **seqname, **comments;
+
+*ret_message = 0;
+*err_message = ret_message;
+in=fopen(fname,"r");
+if(in==NULL) {
+ sprintf(ret_message,"File not found:%s",fname);
+ return 0;
+ }
+
+/* compter le nbre de seqs dans le fichier */
+tot_spec = 0;
+while(fgets(line, sizeof(line), in) != NULL) {
+ if(strncmp(line, "//", 2) == 0) break;
+ if(strncmp(line, " Name: ", 7) == 0) tot_spec++;
+ }
+rewind(in);
+seq = (char **)malloc(tot_spec * sizeof(char *));
+if(seq == NULL) goto nomem;
+comments = (char **)malloc(tot_spec * sizeof(char *));
+if(comments == NULL) goto nomem;
+seqname = (char **)malloc(tot_spec * sizeof(char *));
+if(seqname == NULL) goto nomem;
+*pseq = seq; *pcomments = comments; *pseqname = seqname;
+
+p = NULL;
+while( fgets(line,sizeof(line),in) != NULL) {
+ if( (p = strstr(line, "MSF: ")) != NULL) break;
+ }
+if(p == NULL) {
+ strcpy(ret_message,"File not in MSF format!");
+ tot_spec = -1; goto fini;
+ }
+tot_spec = -1;
+do {
+ fgets(line,sizeof(line),in);
+ if( (p = strstr(line, "Name:") ) == NULL) continue;
+ tot_spec++;
+ q = strstr(p, " Len: ");
+ sscanf(q + 5, "%d", &l);
+ seq[tot_spec] = (char *)malloc(l + 1);
+ if(seq[tot_spec]==NULL) goto nomem;
+ p += 5; while(*p == ' ') p++;
+ q = p; while(*q != ' ') q++;
+ l = q - p;
+ seqname[tot_spec] = (char *)malloc(l + 1);
+ if(seqname[tot_spec]==NULL) goto nomem;
+ memcpy(seqname[tot_spec], p, l); seqname[tot_spec][l] = 0;
+ if(l > maxwidname) maxwidname = l;
+ comments[tot_spec] = NULL;
+ }
+while(strncmp(line, "//", 2) != 0);
+curr_spec = 0; curr_len = 0; wid_block = 0;
+while( fgets(line, sizeof(line), in) != NULL ) {
+ p = line; while(*p == ' ') p++;
+ l = strlen(seqname[curr_spec]);
+ if(strncmp(p, seqname[curr_spec], l) != 0) continue;
+ p += l; while(*p == ' ') p++; p--;
+ q = seq[curr_spec] + curr_len;
+ while( *(++p) != '\n') {
+ if( *p == ' ') continue;
+ if(*p == '.') *p = '-';
+ *(q++) = *p;
+ }
+ *q = 0;
+ wid_1_line = q - (seq[curr_spec] + curr_len);
+ wid_block = (wid_1_line > wid_block ? wid_1_line : wid_block);
+ if(curr_spec == tot_spec) {
+ curr_len += wid_block;
+ curr_spec = 0;
+ wid_block = 0;
+ }
+ else curr_spec++;
+ }
+fini:
+*pheader = NULL;
+fclose(in);
+return tot_spec + 1;
+nomem:
+sprintf(ret_message,"Error: Not enough memory!");
+tot_spec = -1;
+goto fini;
+}
+
+
+int is_a_protein_seq(char *seq)
+/* returns TRUE if seq looks like a protein sequence (less than 80% ACGTU) */
+{
+static char dna[]="ACGTU";
+int total=0, length=0;
+while(*seq != 0) {
+ if(*seq != '-') {
+ if( strchr(dna, toupper(*seq)) != NULL ) total++;
+ length++;
+ }
+ seq++;
+ }
+return ( (float)(total) / length ) <= 0.8 ;
+}
+
+
+int save_phylip_file(const char *fname, char **seq,
+ char **seqname, int totseqs, int *eachlength, region *region_used,
+ int *sel_seqs, int tot_sel_seqs)
+/* sauver des sequences ou des regions au format phylip
+region_used pointe vers la region a sauver
+si region_used == NULL, toutes les sequences sont sauvees
+rend 0 si ok,
+ 1 si erreur d'ecriture dans le fichier
+ 2 si tentative de depasser la longueur d'une sequence
+*/
+{
+const int widphylin = 50;
+FILE *out;
+int lenseqs, i, j, retval = 1, current, save_current, err, vtotseqs;
+list_segments *psegment, all_sequence, *curr_segment;
+region maregion;
+
+if(totseqs == 0) return 0;
+if( (out = fopen(fname,"w")) == NULL) return 1;
+if(region_used == NULL) { /* on veut tout sauver */
+ tot_sel_seqs = 0;
+ all_sequence.debut = 1;
+ all_sequence.fin = eachlength[0];
+ for(i = 1; i < totseqs; i++) /* calcul long max des seqs */
+ if( eachlength[i] > all_sequence.fin )
+ all_sequence.fin = eachlength[i];
+ all_sequence.next = NULL;
+ maregion.list = &all_sequence;
+ region_used = &maregion;
+ }
+/* calcul longueur des regions */
+lenseqs = 0;
+psegment = region_used->list;
+while(psegment != NULL) {
+ lenseqs += psegment->fin - psegment->debut + 1;
+ psegment = psegment->next;
+ }
+vtotseqs = 0;
+for(i=0; i < totseqs; i++)
+ if(tot_sel_seqs == 0 || sel_seqs[i]) ++vtotseqs;
+fprintf(out,"%d %d\n", vtotseqs, lenseqs);
+for(i=0; i < totseqs; i++) {
+ if(tot_sel_seqs != 0 && ! sel_seqs[i]) continue;
+ psegment = region_used->list; current = 0;
+ for(j = 0; j < PHYNAME; j++) {
+ if(seqname[i][j] == 0) break;
+ putc(seqname[i][j],out);
+ }
+ while(j < PHYNAME) { putc( ' ', out ); j++; }
+ err = output_next_res_from_region(seq[i], eachlength[i], &psegment,
+ ¤t, out, widphylin, FALSE);
+ putc('\n', out);
+ if(err == -1) { retval = 2; goto fin; }
+ if(ferror(out)) goto fin;
+ }
+while( psegment != NULL ) {
+ putc('\n',out);
+ curr_segment = psegment; save_current = current;
+ for(i=0; i < totseqs; i++) {
+ if(tot_sel_seqs != 0 && ! sel_seqs[i]) continue;
+ psegment = curr_segment; current = save_current;
+ err = output_next_res_from_region(seq[i], eachlength[i],
+ &psegment, ¤t, out, widphylin, FALSE);
+ putc('\n', out);
+ if(err == -1) { retval = 2; goto fin; }
+ if(ferror(out)) goto fin;
+ }
+ }
+retval = 0;
+fin:
+fclose(out);
+return retval;
+}
+
+
+int output_next_res_from_region(char *seq, int lenseq,
+ list_segments **segment, int *current, FILE *out, int total,
+ int use_dots)
+/* ecrire dans le fichier out les total residus a partir de la position courante
+dans une liste de regions. lenseq est la longueur de la sequence seq.
+La position courante est determinee par le segment courant (*segment, qui peut
+etre modifie par la fonction) et par la position (from 0) dans celui-ci (*current
+qui est modifie par la fonction pour etre pret pour l'appel suivant)
+Rend le nombre de residus effectivement ecrits, ou -1 si depassement longueur de seq.
+Doit etre appelle la premiere fois avec *current = 0
+*/
+{
+int debut, fin, vfin, ecrit = 0, nombre;
+char *p;
+static char line[500];
+if( *segment == NULL)
+ return 0;
+do {
+ debut = (*segment)->debut; fin = (*segment)->fin;
+ vfin = fin; if(fin > lenseq) vfin = lenseq;
+ nombre = total;
+ if( nombre - 1 + *current + debut > vfin)
+ nombre = vfin + 1 - *current - debut;
+ if(nombre > 0) {
+ memcpy(line, seq + *current + debut - 1, nombre);
+ line[nombre] = 0;
+ if(use_dots) {
+ p = line;
+ while( (p = strchr(p, '-')) != NULL) *p = '.';
+ }
+ fwrite(line, 1, nombre, out);
+ ecrit += nombre; total -= nombre; (*current) += nombre;
+ }
+ if( fin > lenseq && total > 0 ) {
+ nombre = total;
+ if( nombre - 1 + *current + debut > fin)
+ nombre = fin + 1 - *current - debut;
+ ecrit += nombre; (*current) += nombre; total -= nombre;
+ while(nombre-- > 0) putc('-', out);
+ }
+ if( *current + debut > fin) {
+ *segment = (*segment)->next;
+ if(*segment == NULL) break;
+ *current = 0;
+ }
+ }
+while(total > 0);
+return ecrit;
+}
+
+
+void save_regions(list_regions *regions, FILE *out)
+{
+int total, l_line;
+list_segments *segment;
+char line[80];
+do {
+ total = 0;
+ segment = regions->element->list;
+ while(segment != NULL) {
+ total++;
+ segment = segment->next;
+ }
+ if(total == 0) continue;
+ fprintf(out,";;# of segments=%d %s\n",total,regions->element->name);
+ strcpy(line, ";;"); l_line=2;
+ segment = regions->element->list;
+ while(segment != NULL) {
+ if(l_line + 12 >= sizeof(line)-1) {
+ fputs(line,out); putc('\n',out);
+ strcpy(line,";;"); l_line=2;
+ }
+ sprintf(line+l_line," %d,%d", segment->debut, segment->fin);
+ l_line += strlen(line+l_line);
+ segment= segment->next;
+ }
+ fputs(line,out); putc('\n',out);
+ }
+while( regions = regions->next, regions != NULL );
+}
+
+
+int save_mase_file(const char *fname, char **seq, char **comments,
+ char *header, char **seqname, int totseqs, int *eachlength,
+ list_regions *regions, region *region_used, int numb_species_sets,
+ int **list_species_sets, char **name_species_sets,
+ int *sel_seqs, int tot_sel_seqs, int tot_comment_lines,
+ char **comment_name, char **comment_line)
+/* sauver un alignement au format mase
+regions: l'ensemble des regions a ecrire (si on sauve tout l'alignement)
+ NULL si on ne sauve que des regions
+region_used: pointeur vers la region a sauver
+ et on ne sauve que les seqs selectionnees s'il y en a,
+ ou NULL pour sauver tout l'alignement
+rend 0 si OK,
+ 1 si erreur ecriture du fichier
+ 2 si depassement de longueur d'une sequence (avec region seulement)
+*/
+{
+FILE *out;
+int num, retval = 1, current, ecrit, maxlength;
+time_t heure;
+list_segments *psegment, all_sequence;
+region maregion;
+
+if(totseqs == 0) return 0;
+out=fopen(fname,"w");
+if(out == NULL) return 1;
+
+maxlength = 0;
+
+time(&heure);
+fprintf(out,";; saved by seaview on %s",ctime(&heure));
+if(region_used == NULL) { /* on veut tout sauver */
+ all_sequence.debut = 1;
+ all_sequence.next = NULL;
+ maregion.list = &all_sequence;
+ maregion.name = NULL;
+ region_used = &maregion;
+ tot_sel_seqs = 0;
+ maxlength = eachlength[0];
+ for(num=1; num<totseqs; num++) {
+ if(maxlength < eachlength[num]) maxlength = eachlength[num];
+ }
+ }
+else
+ fprintf(out,";; region choice only: %s\n",region_used->name);
+if(ferror(out)) goto fin;
+if(header != NULL && *header != 0) {
+ fputs(header,out);
+ if(ferror(out)) goto fin;
+ }
+if(regions != NULL) {
+ save_regions(regions, out);
+ if(ferror(out)) goto fin;
+ }
+if(tot_comment_lines > 0) {
+ save_comment_lines(tot_comment_lines, comment_name, comment_line, out);
+ if(ferror(out)) goto fin;
+ }
+if(numb_species_sets != 0) { /* sauver les species sets */
+ save_species_sets(numb_species_sets, list_species_sets,
+ name_species_sets, totseqs, out);
+ if(ferror(out)) goto fin;
+ }
+for(num=0; num<totseqs; num++) {
+ if( tot_sel_seqs != 0 && ! sel_seqs[num] ) continue;
+ current = 0; psegment = region_used->list;
+ all_sequence.fin = eachlength[num];
+ if(comments[num] != NULL)
+ fputs(comments[num], out);
+ else fputs(";no comment\n", out);
+ if(ferror(out)) goto fin;
+ fprintf(out,"%s\n",seqname[num]);
+ if(ferror(out)) goto fin;
+ do {
+ ecrit = output_next_res_from_region(seq[num], eachlength[num],
+ &psegment, ¤t, out, 60, FALSE);
+ if(ferror(out)) goto fin;
+ if( ecrit > 0) putc('\n', out);
+ else if(ecrit == -1) {retval = 2; goto fin; }
+ }
+ while(ecrit != 0);
+ if( (ecrit = maxlength - eachlength[num]) > 0) {
+ int n;
+ for(n = 1; n <= ecrit; n++) {
+ putc('-', out); if(n % 60 == 0) putc('\n', out);
+ }
+ putc('\n', out);
+ }
+ if(ferror(out)) goto fin;
+ }
+retval = 0;
+fin:
+if( fclose(out) != 0 ) retval = 1;
+return retval;
+}
+
+
+int save_fasta_file(const char *fname, char **seq,
+ char **seqname, int totseqs, int *eachlength, region *region_used,
+ int *sel_seqs, int tot_sel_seqs)
+/* sauver des sequences ou des regions au format fasta
+region_used pointe vers la liste des regions a sauver
+si region_used == NULL, toutes les sequences sont sauvees
+rend 0 si ok, 1 si erreur d'ecriture dans le fichier
+ 2 si tentative de depasser la longueur d'une sequence
+*/
+{
+FILE *out;
+int num, retval = 1, current, ecrit;
+list_segments *psegment, all_sequence;
+region maregion;
+
+if(totseqs == 0) return 0;
+if( (out = fopen(fname,"w")) == NULL) return 1;
+if(region_used == NULL) { /* on veut tout sauver */
+ tot_sel_seqs = 0;
+ all_sequence.debut = 1;
+ all_sequence.fin = eachlength[0];
+ for(num = 1; num < totseqs; num++)
+ if( eachlength[num] < all_sequence.fin )
+ all_sequence.fin = eachlength[num];
+ all_sequence.next = NULL;
+ maregion.list = &all_sequence;
+ region_used = &maregion;
+ }
+for(num=0; num<totseqs; num++) {
+ if( tot_sel_seqs != 0 && ! sel_seqs[num] ) continue;
+ current = 0; psegment = region_used->list;
+ all_sequence.fin = eachlength[num];
+ fprintf(out,">%s\n",seqname[num]);
+ if(ferror(out)) goto fin;
+ do {
+ ecrit = output_next_res_from_region(seq[num], eachlength[num],
+ &psegment, ¤t, out, 60, FALSE);
+ if( ecrit > 0) putc('\n', out);
+ else if(ecrit == -1) {retval = 2; goto fin; }
+ }
+ while(ecrit != 0);
+ if(ferror(out)) goto fin;
+ }
+retval = 0;
+fin:
+if( fclose(out) != 0 ) return 1;
+return retval;
+}
+
+
+
+int save_clustal_file(const char *fname, char **seq,
+ char **seqname, int totseqs, int *eachlength, region *region_used,
+ int *sel_seqs, int tot_sel_seqs)
+/* sauver des sequences ou des regions au format clustal
+region_used pointe vers la liste des regions a sauver
+si region_used == NULL, toutes les sequences sont sauvees
+rend 0 si ok, 1 si erreur d'ecriture dans le fichier
+ 2 si tentative de depasser la longueur d'une sequence
+*/
+{
+const int widcluslin = 60;
+FILE *out;
+int i, j, retval = 1, current, save_current, err, l, lmax;
+list_segments *psegment, all_sequence, *curr_segment;
+region maregion;
+
+if(totseqs == 0) return 0;
+if( (out = fopen(fname,"w")) == NULL) return 1;
+if(region_used == NULL) { /* on veut tout sauver */
+ tot_sel_seqs = 0;
+ all_sequence.debut = 1;
+ all_sequence.fin = eachlength[0];
+ for(i = 1; i < totseqs; i++)
+ if( eachlength[i] > all_sequence.fin )
+ all_sequence.fin = eachlength[i];
+ all_sequence.next = NULL;
+ maregion.list = &all_sequence;
+ region_used = &maregion;
+ }
+lmax = 0;
+for(i=0; i < totseqs; i++) {
+ if( tot_sel_seqs != 0 && ! sel_seqs[i] ) continue;
+ l = strlen(seqname[i]);
+ if(l > lmax) lmax = l;
+ }
+lmax += 2;
+
+fprintf(out,"CLUSTAL W (1.7) multiple sequence alignment\n\n\n");
+current = 0; psegment = region_used->list;
+while( psegment != NULL ) {
+ curr_segment = psegment; save_current = current;
+ for(i=0; i < totseqs; i++) {
+ if( tot_sel_seqs != 0 && ! sel_seqs[i] ) continue;
+ psegment = curr_segment; current = save_current;
+/* remplacer espaces internes par _ */
+ for(j = 0; j < lmax; j++) {
+ if(seqname[i][j] == 0) break;
+ putc( (seqname[i][j] == ' ' ? '_' : seqname[i][j] ),
+ out);
+ }
+ while( j < lmax) {
+ putc(' ', out); j++;
+ }
+ err= output_next_res_from_region(seq[i], eachlength[i],
+ &psegment, ¤t, out, widcluslin, FALSE);
+ putc('\n', out);
+ if(err == -1) {retval = 2; goto fin; }
+ if(ferror(out)) goto fin;
+ }
+ fprintf(out, "\n\n");
+ }
+retval = 0;
+fin:
+if( fclose(out) != 0 ) return 1;
+return retval;
+}
+
+
+int calc_gcg_check(list_segments *psegment, char *seq)
+{
+int i, debut, fin, residue, pos = 0;
+long check = 0;
+while(psegment != NULL) {
+ debut = psegment->debut; fin = psegment->fin;
+ for( i=debut; i<= fin; i++) {
+ residue = toupper(seq[i - 1]);
+ if(residue == '-') residue = '.';
+ check += (( (pos++) % 57)+1) * residue;
+ }
+ psegment = psegment->next;
+ }
+return (check % 10000);
+}
+
+
+int save_msf_file(const char *fname, char **seq,
+ char **seqname, int totseqs, int *eachlength, region *region_used,
+ int protein, int *sel_seqs, int tot_sel_seqs)
+/* sauver des sequences ou des regions au format MSF
+region_used pointe vers la liste des regions a sauver
+si region_used == NULL, toutes les sequences sont sauvees
+rend 0 si ok, 1 si erreur d'ecriture dans le fichier
+ 2 si tentative de depasser la longueur d'une sequence
+*/
+{
+FILE *out;
+int i, j, k, retval = 1, current, save_current, err, lenseqs, gen_check,
+ *check_val, curr_len, toprint, save_complete, fromseq, new_current;
+list_segments *psegment, all_sequence, *curr_segment, *new_segment;
+region maregion;
+
+if(totseqs == 0) return 0;
+if( (out = fopen(fname,"w")) == NULL) return 1;
+save_complete = (region_used == NULL);
+if(save_complete) { /* on veut tout sauver */
+ tot_sel_seqs = 0;
+ all_sequence.debut = 1;
+ all_sequence.fin = 0;
+ for(i = 0; i < totseqs; i++) {
+ if( eachlength[i] > all_sequence.fin )
+ all_sequence.fin = eachlength[i];
+ }
+ lenseqs = all_sequence.fin;
+ all_sequence.next = NULL;
+ maregion.list = &all_sequence;
+ region_used = &maregion;
+ }
+else {
+ /* calcul longueur des regions */
+ lenseqs = 0;
+ psegment = region_used->list;
+ while(psegment != NULL) {
+ lenseqs += psegment->fin - psegment->debut + 1;
+ psegment = psegment->next;
+ }
+ }
+for(i = 0, k = 0; i < totseqs; i++) /* nbre de seqs editees */
+ if( tot_sel_seqs == 0 || sel_seqs[i] ) k++;
+check_val = (int *)malloc( k * sizeof(int) );
+if(check_val == NULL) {
+ fclose(out);
+ return 1; /* pas tres precis */
+ }
+gen_check = 0;
+for(i = 0, j = 0; i < totseqs; i++) {
+ if( tot_sel_seqs != 0 && ! sel_seqs[i] ) continue;
+ check_val[j] = calc_gcg_check(region_used->list, seq[i]);
+ gen_check += check_val[j++];
+ }
+gen_check = gen_check % 10000;
+fprintf(out,"PileUp\n\n\n\n MSF:%5d Type: %c Check:%6d .. \n\n",
+ lenseqs, (protein ? 'P' : 'N'), gen_check);
+for(i = 0 , j = 0; i < totseqs; i++) {
+ if( tot_sel_seqs != 0 && ! sel_seqs[i] ) continue;
+ fprintf(out, " Name: %-15.15s Len:%5d Check:%6d Weight: 1.00\n",
+ seqname[i], lenseqs, check_val[j++]);
+ }
+fprintf(out,"\n//\n\n\n");
+new_current = 0; new_segment = region_used->list; curr_len = 0;
+while( new_segment != NULL && curr_len < lenseqs) {
+ curr_segment = new_segment; save_current = new_current;
+ fprintf(out, "\n");
+ for(i=0; i < totseqs; i++) {
+ if( tot_sel_seqs != 0 && ! sel_seqs[i] ) continue;
+ psegment = curr_segment; current = save_current;
+ for(j = 0; j < MSF_WID_NAME; j++) {
+ if(seqname[i][j] == 0) break;
+ putc(seqname[i][j],out);
+ }
+ while( j < MSF_WID_NAME + 1) {
+ putc(' ', out); j++;
+ }
+ for(k = curr_len; k < curr_len + 50 && k < lenseqs; k += 10) {
+ toprint = 10;
+ if(k + toprint > lenseqs) toprint = lenseqs - k;
+ fromseq = toprint;
+ if(save_complete && k + fromseq > eachlength[i])
+ fromseq = eachlength[i] - k;
+ if(fromseq < 0) fromseq = 0;
+ if(fromseq > 0) {
+ err= output_next_res_from_region(
+ seq[i], eachlength[i], &psegment,
+ ¤t, out, fromseq, TRUE);
+ if(ferror(out)) goto fin;
+ if(err == -1) {retval = 2; goto fin; }
+ }
+ while(fromseq < toprint) {
+ putc('.', out); fromseq++;
+ }
+ putc(' ', out);
+ }
+ putc('\n', out);
+ if( (!save_complete) || eachlength[i] == lenseqs) {
+ new_current = current;
+ new_segment = psegment;
+ }
+ if(ferror(out)) goto fin;
+ }
+ curr_len += 50;
+ fprintf(out, "\n");
+ }
+retval = 0;
+fin:
+if( fclose(out) != 0 ) retval = 1;
+free(check_val);
+return retval;
+}
+
+
+char *save_alignment_or_region(const char *fname, char **seq, char **comments,
+ char *header, char **seqname, int totseqs, int *eachlength,
+ list_regions *regions, region *region_used, known_format format,
+ int numb_species_sets, int **list_species_sets,
+ char **name_species_sets, int *sel_seqs, int tot_sel_seqs, int protein,
+ int tot_comment_lines, char **comment_name, char **comment_line)
+/* sauver des sequences ou des regions au format de fichier format
+region_used pointe vers la liste des regions a sauver
+si region_used == NULL, toutes les sequences entieres sont sauvees
+rend NULL si ok
+ un message d'erreur sinon.
+*/
+{
+int err;
+static char err_message[200];
+
+if(format == MASE_FORMAT)
+ err = save_mase_file(fname, seq, comments,
+ header, seqname, totseqs, eachlength,
+ regions, region_used, numb_species_sets, list_species_sets,
+ name_species_sets, sel_seqs, tot_sel_seqs,
+ tot_comment_lines, comment_name, comment_line);
+else if(format == NEXUS_FORMAT)
+ err = save_nexus_file(fname, totseqs, protein,
+ seq, seqname, comments, header,
+ numb_species_sets, list_species_sets, name_species_sets,
+ regions, tot_comment_lines, comment_name, comment_line,
+ region_used, sel_seqs, tot_sel_seqs, eachlength);
+else if(format == PHYLIP_FORMAT)
+ err = save_phylip_file(fname, seq,
+ seqname, totseqs, eachlength, region_used,
+ sel_seqs, tot_sel_seqs);
+else if(format == CLUSTAL_FORMAT)
+ err = save_clustal_file(fname, seq,
+ seqname, totseqs, eachlength, region_used,
+ sel_seqs, tot_sel_seqs);
+else if(format == MSF_FORMAT)
+ err = save_msf_file(fname, seq,
+ seqname, totseqs, eachlength, region_used, protein,
+ sel_seqs, tot_sel_seqs);
+else if(format == FASTA_FORMAT)
+ err = save_fasta_file(fname, seq,
+ seqname, totseqs, eachlength, region_used,
+ sel_seqs, tot_sel_seqs);
+if(err == 0)
+ return NULL;
+else if(err == 1)
+ sprintf(err_message,"Error while writing to file %s",fname);
+else if(err == 2)
+ strcpy(err_message,
+ "Error: region goes beyond the end of one sequence");
+return err_message;
+}
+
+
+int prepare_printout(const char *filename, char **seq, int totseqs,
+ char **seqname,
+ int *eachlength, int char_per_line,
+ int block_size, int lines_per_page, int vary_only,
+ char *align_name, int ref0)
+{
+FILE *out;
+int num, i, j, k, current, max_seq_length, fin, curr_lines, widnames,
+ res_per_line, nl;
+int retval = TRUE;
+time_t heure;
+static char unnamed[] = "<unnamed>";
+static char num_line[200];
+int lettre;
+short *vary_need = NULL;
+int *vary_pos; /* rang ds alignement de la colonne imprimée */
+
+if(totseqs == 0) return 0;
+if( ( out=fopen(filename, "w") ) == NULL) {
+ return TRUE;
+ }
+if(ref0 < 0) vary_only = FALSE;
+time(&heure);
+if(align_name == NULL) align_name = unnamed;
+fprintf(out,"Alignment: %s\n", align_name);
+curr_lines = 1;
+if(vary_only) {
+ fprintf(out, "Displaying variable sites only.\n");
+ ++curr_lines;
+ }
+fprintf(out,"Printed by seaview [blocks=%d cpl=%d lpp=%d] on %s\n",
+ block_size, char_per_line, lines_per_page, ctime(&heure));
+curr_lines += 2;
+max_seq_length = 0; widnames = 0;
+for(i=0; i<totseqs; i++) {
+ if(eachlength[i] > max_seq_length) max_seq_length = eachlength[i];
+ if( ( fin=strlen(seqname[i]) ) > widnames) widnames = fin;
+ }
+widnames += 2;
+if(vary_only) {
+ vary_need = (short *)calloc(max_seq_length, sizeof(short));
+ if(vary_need == NULL) return TRUE;
+ vary_pos = (int *)calloc(char_per_line, sizeof(int));
+ if(vary_pos == NULL) return TRUE;
+ for(i = 0; i < max_seq_length; i++) {
+ for(num = 0; num < totseqs; num++) {
+ if( toupper(seq[num][i]) != toupper(seq[ref0][i]) ) {
+ vary_need[i] = TRUE;
+ break;
+ }
+ }
+ }
+ }
+/* nombre max de blocks qui tiennent sur une ligne de cpl chars */
+fin = (char_per_line - widnames + 1) / (block_size + 1);
+if(fin < 1) { /* garde fou */
+ fin = 1; block_size = char_per_line - widnames;
+ }
+res_per_line = fin * block_size;
+current = 0;
+if( totseqs + 1 > lines_per_page) lines_per_page = 1000000;
+while( current < max_seq_length ) {
+ nl = 1;
+ if(vary_only) {
+ memset(vary_pos, 0, res_per_line * sizeof(int) );
+ i = -1; j = 0; k = 0;
+ while( j < res_per_line) {
+ if(current + i >= max_seq_length) break;
+ if( !vary_need[current + ++i] ) continue;
+ j++;
+ vary_pos[k++] = current + i + 1;
+ if( j % block_size == 0) k++;
+ }
+ nl = calc_vary_lines(vary_pos, k);
+ }
+ if(curr_lines + totseqs + nl > lines_per_page) {
+ for(i = 0; i < lines_per_page - curr_lines; i++)
+ putc('\n', out);
+ curr_lines = 0;
+ }
+ if(vary_only) {
+ out_vary_pos(vary_pos, widnames, k, nl, out);
+ curr_lines += nl;
+ }
+ else {
+ sprintf(num_line, "%d", current + 1);
+ fin = strlen(num_line);
+ memmove(num_line + widnames - fin + 1, num_line, fin+1);
+ if(fin <= widnames) memset(num_line, ' ', widnames - fin + 1);
+ fputs(num_line, out); putc('\n', out); ++curr_lines;
+ }
+ for(num=0; num < totseqs; num++) {
+ for(j = 0; j < widnames; j++) {
+ if(seqname[num][j] == 0) break;
+ putc(seqname[num][j],out);
+ }
+ while( j < widnames) {
+ putc(' ', out); j++;
+ }
+ if(vary_only) {
+ i = -1; j = 0;
+ while( j < res_per_line) {
+ if(current + i >= max_seq_length) break;
+ if( !vary_need[current + ++i] ) continue;
+ j++;
+ if(current + i < eachlength[num]) {
+ if(num != ref0) lettre =
+( toupper(seq[num][current+i]) == toupper(seq[ref0][current+i]) ? '.' : seq[num][current+i] );
+ else lettre = seq[ref0][current+i];
+ putc(lettre, out);
+ }
+ if( j % block_size == 0) putc(' ', out);
+ }
+ if(num == totseqs - 1) current = current + i + 1;
+ }
+
+ else {
+ fin = res_per_line;
+ if(current+fin > eachlength[num])
+ fin = eachlength[num] - current;
+ if(ref0 != -1 && num != ref0) {
+ /* ecriture par reference a seq ref0 */
+ for(i=0; i<fin; i++) {
+ lettre =
+( toupper(seq[num][current+i]) == toupper(seq[ref0][current+i]) ? '.' : seq[num][current+i] );
+ putc(lettre, out);
+ if( i < fin-1 && (i+1)%block_size == 0)
+ putc(' ', out);
+ }
+ }
+ else { /* ecriture normale de seq */
+ for(i=0; i<fin; i++) {
+ putc(seq[num][current+i], out);
+ if( i < fin-1 && (i+1)%block_size == 0)
+ putc(' ', out);
+ }
+ }
+ }
+ putc('\n', out); ++curr_lines;
+ if(ferror(out)) goto fin;
+ }
+ if(curr_lines + 1 <= lines_per_page) {
+ fprintf(out, "\n"); ++curr_lines;
+ }
+ if( ! vary_only ) current += res_per_line;
+ }
+if(ferror(out)) goto fin;
+retval = FALSE;
+fin:
+fclose(out);
+return retval;
+}
+
+
+int calc_vary_lines(int *vary_pos, int widpos)
+{
+int maxi = 0, num, nl;
+
+for(num = 0; num < widpos; num++)
+ if(vary_pos[num] > maxi) maxi = vary_pos[num];
+if(maxi >= 100000)
+ nl = 6;
+else if(maxi >= 10000)
+ nl = 5;
+else if(maxi >= 1000)
+ nl = 4;
+else if(maxi >= 100)
+ nl = 3;
+else if(maxi >= 10)
+ nl = 2;
+else
+ nl = 1;
+return nl;
+}
+
+
+void out_vary_pos(int *vary_pos, int widnames, int widpos, int nl, FILE *out)
+{
+int num, l, echelle, digit, val;
+static char chiffre[] = "0123456789";
+
+echelle = 1;
+for(l = 2; l <= nl; l++) echelle *= 10;
+for(l = nl; l > 0; l--) {
+ for(num = 0; num < widnames; num++) putc(' ', out);
+ for(num = 0; num < widpos; num++) {
+ val = vary_pos[num];
+ if(val < echelle)
+ putc(' ', out);
+ else {
+ digit = (val / echelle) % 10 ;
+ putc(*(chiffre + digit), out);
+ }
+ }
+ putc('\n', out);
+ echelle /= 10;
+ }
+}
+
+
+#ifdef WIN32
+extern "C" {
+ char *get_prog_dir(void);
+ void add_to_path(char *dir);
+ }
+#endif
+
+
+FILE *open_path(char *fname) /* to open in read-only file fname searching for
+ it through all path directories */
+{
+#define Mxdir 200
+char dir[Mxdir+1], *path, *deb, *fin;
+FILE *fich;
+int lf, ltot;
+#ifdef WIN32
+/* try first dir where program was launched */
+char *p = get_prog_dir();
+strcpy(dir, ( p == NULL ? "" : p) );
+strcat(dir, fname);
+fich = fopen(dir, "r");
+if(fich != NULL) { /* ajouter cette dir au PATH */
+ add_to_path(p);
+ return fich;
+ }
+fich = fopen(fname, "r"); /* try next current directory */
+if(fich != NULL) return fich;
+#endif
+path = getenv("PATH"); // get the list of path directories, separated by : or ;
+if (path == NULL ) return fopen(fname,"r");
+lf = strlen(fname);
+deb = path;
+do {
+#ifdef WIN32
+ fin = strchr(deb,';');
+#else
+ fin = strchr(deb,':');
+#endif
+ if(fin != NULL)
+ { ltot = fin-deb; if(ltot > 0) strncpy(dir,deb,ltot); }
+ else
+ { strcpy(dir,deb); ltot=strlen(dir); }
+ /* now one directory is in string dir */
+ if( ltot > 0 && ltot + lf + 1 <= Mxdir)
+ {
+#ifdef WIN32
+ dir[ltot]='\\';
+#else
+ dir[ltot]='/';
+#endif
+ strcpy(dir+ltot+1,fname); /* now dir is appended with filename */
+ fich = fopen(dir,"r");
+ if( fich != NULL) break;
+ }
+ else fich = NULL;
+ deb = fin+1;
+ }
+while (fin != NULL);
+#ifndef WIN32
+if(fich == NULL) fich = fopen(fname,"r"); /* try also current directory */
+#endif
+return fich;
+#undef Mxdir
+}
+
+
+#ifdef WIN32
+
+int check_path(char *fname)
+{
+FILE *tmp = open_path(fname);
+if(tmp != NULL) {
+ fclose(tmp);
+ return 0;
+ }
+else return 1;
+}
+
+#else
+
+extern "C" { int stat(char *, void *); }
+
+int check_path(char *fname)
+/* to check for presence of file fname
+searching for it through all path directories
+returns 0 if found, != 0 if not found
+*/
+{
+#define Mxdir 200
+ char dir[Mxdir+1], *path, *deb, *fin;
+ int lf, ltot;
+ static char stat_struct[250]; /* bigger than necessary */
+ path=getenv("PATH"); /* get the list of path directories,
+ separated by :
+ */
+ if (path == NULL ) return -1;
+ lf=strlen(fname);
+ deb=path;
+ do
+ {
+ fin=strchr(deb,':');
+ if(fin!=NULL)
+ { strncpy(dir,deb,fin-deb); ltot=fin-deb; }
+ else
+ { strcpy(dir,deb); ltot=strlen(dir); }
+ /* now one directory is in string dir */
+ if( ltot + lf + 1 <= Mxdir)
+ {
+ dir[ltot]='/';
+ strcpy(dir+ltot+1,fname);
+ /* now dir is appended with filename */
+ if( stat(dir, stat_struct) == 0) return 0;
+ }
+ deb=fin+1;
+ }
+ while (fin != NULL);
+ return -1;
+#undef Mxdir
+}
+
+#endif
+
+
+static void save_species_sets(int numb_species_sets, int **list_species_sets,
+ char **name_species_sets, int totseqs, FILE *out)
+{
+int num, i, previous, total;
+for(num=0; num < numb_species_sets; num++) {
+ total = 0;
+ for(i=0; i< totseqs; i++)
+ if( list_species_sets[num][i] ) total++;
+ if( total == 0 ) continue;
+ fprintf(out,";;@ of species = %d %s\n;;", total,
+ name_species_sets[num]);
+ for(previous = 0; previous < totseqs; previous++)
+ if( list_species_sets[num][previous] ) break;
+ total = 0;
+ for(i = previous+1; i < totseqs; i++) {
+ if( list_species_sets[num][i] ) {
+ fprintf(out," %d,", previous+1);
+ previous = i;
+ total++;
+ if( total >= 15 ) {
+ fprintf(out, "\n;;");
+ total = 0;
+ }
+ }
+ }
+ fprintf(out," %d\n", previous+1);
+ }
+}
+
+
+void save_comment_lines(int tot_comment_lines, char **names, char **lines,
+ FILE *out)
+{
+int num, l, pos;
+
+for(num = 0; num < tot_comment_lines; num++) {
+ if( (l = strlen(lines[num]) ) == 0) continue;
+ fprintf(out, ";;|%s\n", names[num]);
+ for(pos = 0; pos < l; pos += 60)
+ fprintf(out, ";;%.60s\n", lines[num]+pos);
+ fprintf(out, ";;||\n");
+ }
+}
+
+
+known_format what_format(const char *filename)
+{
+FILE *in;
+char line[100], *p;
+int format = -1;
+int nseq, lseq;
+
+in = fopen(filename, "r");
+if(in == NULL) return (known_format)-1;
+p = fgets(line, sizeof(line), in);
+if( p == NULL) { fclose(in); return (known_format)-1; }
+while(*p) { *p = toupper(*p); p++; }
+if(*line == ';') format = MASE_FORMAT;
+else if(*line == '>') format = FASTA_FORMAT;
+else if(strncmp(line, "CLUSTAL", 7) == 0) format = CLUSTAL_FORMAT;
+else if(strncmp(line, "#NEXUS", 6) == 0) format = NEXUS_FORMAT;
+else {
+ nseq = lseq = -1;
+ sscanf(line, "%d%d", &nseq, &lseq);
+ if(nseq != -1 && lseq != -1) format = PHYLIP_FORMAT;
+ else {
+ /* try MSF format */
+ do p = fgets(line, sizeof(line), in);
+ while(p != NULL && *p == '\n');
+ if(p != NULL) {
+ while(*p == ' ') p++;
+ if(strncmp(p, "MSF:", 4) == 0) format = MSF_FORMAT;
+ }
+ }
+ }
+fclose(in);
+return (known_format)format;
+}
Added: trunk/packages/seaview/branches/upstream/current/xfmatpt.cxx
===================================================================
--- trunk/packages/seaview/branches/upstream/current/xfmatpt.cxx (rev 0)
+++ trunk/packages/seaview/branches/upstream/current/xfmatpt.cxx 2006-09-19 14:20:14 UTC (rev 111)
@@ -0,0 +1,1281 @@
+#include "matpt.h"
+#include <stdlib.h>
+#include <stdio.h>
+#include <math.h>
+#include <string.h>
+#include <ctype.h>
+
+#define MAXSEQLENGTH 10000 /* pas utilise pour interface avec seaview */
+#define MAXSEGMENTS 20000
+#define segment_x_ou_y(num, offset) \
+ (*(int *)(((char *)(segments + num)) + offset))
+/* globals */
+struct segment {
+ int x, y, longueur;
+ };
+static struct segment segments[MAXSEGMENTS+1];
+gap_site gap_sites[MAX_GAP_SITES];
+
+/* prototypes */
+void show_dot_plot(char *seq1, char *seq2, char *seqname1, char *seqname2,
+ int l1, int l2, int maxseqlength, void *seaview_data);
+FD_matpt *create_form_matpt(void);
+static void err_message(char *text);
+static char *check_alloc(int nbrelt, int sizelt);
+void log_to_phys(int lx, int ly, int *px, int *py, FD_matpt *matpt);
+void phys_to_log(int px, int py, int *lx, int *ly, FD_matpt *matpt);
+void reset_mat_data(FD_matpt *matpt);
+void reset_sliders_data(FD_matpt * matpt);
+void init_mat_data(FD_matpt * matpt, int seqlong1, int seqlong2,
+ char *seqname1, char *seqname2, char *seq1, char *seq2, char *name,
+ int maxseqlength);
+void set_size_data(FD_matpt *matpt);
+void compute_region_text(FD_matpt *matpt);
+void draw_rect(FD_matpt *matpt);
+int mat_handle_proc(Fl_Widget *ob, int event, float x, float y,
+ char key);
+void center_view_on_hit(FD_matpt *matpt);
+void magnify_reduce_proc(Fl_Widget *ob, void *extra);
+void change_comput_params(Fl_Widget *ob, void *data);
+void compute_proc(Fl_Widget *ob, void *data);
+void interrupt_callback(Fl_Widget *ob, void *data);
+void ps_draw_line(int x1, int y1, int x2, int y2, FD_matpt *matpt,
+ FILE *plotfile);
+void ps_set_mat_data(FD_matpt *matpt);
+void plot_button_proc(Fl_Widget *ob, void *data);
+int really_close(FD_matpt *matpt);
+void exit_button_proc(Fl_Widget *ob, void *data);
+void move_mat_proc(Fl_Widget *ob, void *data);
+void move_box_step(Fl_Widget *ob, void *extra);
+void region_size_proc(Fl_Widget *ob, void *data);
+char *readseq(FILE *infile, int *slong, char **seqname);
+char *readseqfile(char *fname, int *seqlong1, int *seqlong2,
+ char **name1, char **name2, char **seq1, char **seq2);
+int compute_diags(FD_matpt *matpt, int *erreur, char **errmess);
+void compute_title(FD_matpt *matpt);
+int find_next_gap_site(int pos, gap_site *gap_sites, int tot_gap_sites);
+void new_gap_site(int pos, int l, gap_site *gap_sites, int *p_tot_gap_sites,
+ int seqrank);
+int delete_gaps_bef_pos(char *seq, int pos, int number, int length,
+ int totsegments, int offset);
+int insert_gaps_bef_pos(char *seq, int pos, int number, int length,
+ int totsegments, int offset, int maxlen);
+int dispatch_gaps_bef(int pos, int number, char *seq, gap_site * gap_sites,
+ int *p_tot_gap_sites, int offset, int seqlen, int totsegments,
+ int seqrank, char *other_seq, int *other_seqlen, int other_offset,
+ int maxlen);
+void align_callback(Fl_Widget *ob, void *data);
+void record_alignment_callback(Fl_Widget *ob, void *data);
+extern int insert_gaps_at(SEA_VIEW *view, int seq, int site, int total);
+extern void update_current_seq_length(int newlength, SEA_VIEW *view);
+void update_col_lines(int num, SEA_VIEW *view);
+
+class matpt_panel : public Fl_Widget {
+ FL_EXPORT void draw(void);
+ FL_EXPORT int handle(int);
+public:
+ FL_EXPORT matpt_panel(int x,int y,int w,int h, void *data) :
+ Fl_Widget(x,y,w,h,NULL) {
+ this->user_data(data);
+ }
+};
+
+
+void my_watch_cursor(Fl_Window *win)
+{
+win->cursor(FL_CURSOR_WAIT);
+Fl::flush();
+}
+
+void fl_reset_cursor(Fl_Window *win)
+{
+Fl::flush();
+win->cursor(FL_CURSOR_DEFAULT);
+}
+
+
+void show_dot_plot(char *seq1, char *seq2, char *seqname1, char *seqname2,
+ int l1, int l2, int maxseqlength, void *seaview_data)
+{
+static int first = TRUE;
+static FD_matpt *matpt;
+char *new_seq1, *new_seq2;
+static char *old_seq1, *old_seq2;
+SEA_VIEW *view = (SEA_VIEW *)seaview_data;
+if(first) {
+ first = FALSE;
+ matpt = create_form_matpt();
+ matpt->form->callback(exit_button_proc, matpt);
+ matpt->seq1 = matpt->seq2 = NULL;
+ matpt->seaview_data = seaview_data;
+ old_seq1 = NULL; old_seq2 = NULL;
+ if(view->protein) {
+ ((Fl_Input *)matpt->win_size_type_box)->value("10");
+ ((Fl_Input *)matpt->ident_type_box)->value("5");
+ }
+ }
+if(matpt->seq1 == NULL || seq1 != old_seq1 || seq2 != old_seq2) {
+ if(matpt->seq1 != NULL) {
+ free(matpt->seq1+1);
+ free(matpt->seq2+1);
+ }
+ new_seq1 = (char *)malloc(maxseqlength+1);
+ memcpy(new_seq1, seq1, l1 + 1);
+ new_seq2 = (char *)malloc(maxseqlength+1);
+ memcpy(new_seq2, seq2, l2 + 1);
+ init_mat_data(matpt, l1, l2, seqname1, seqname2,
+ new_seq1 - 1, new_seq2 - 1, view->masename, maxseqlength);
+ set_size_data(matpt);
+ old_seq1 = seq1; old_seq2 = seq2;
+ }
+matpt->form->show();
+compute_title(matpt);
+}
+
+
+static Fl_Widget *cre_button(int x, int y, int *w, int h,
+ int si, char *label)
+{
+Fl_Widget *obj;
+fl_font(FL_HELVETICA, si);
+*w = (int)fl_width(label) + 4 * 2;
+obj = new Fl_Button(x, y, *w, h, label);
+obj->labelsize(si);
+return obj;
+}
+
+
+FD_matpt *create_form_matpt(void)
+{
+Fl_Widget *obj;
+FD_matpt *fdui = (FD_matpt *) check_alloc(1, sizeof(*fdui));
+static char def_title[] = "Dot Plot";
+Fl_Window *form;
+int curr_x, curr_y, fin, width, fontsize, but_height;
+user_data_plus *data;
+
+fdui->title = def_title;
+
+#if defined(WIN32) || defined(__APPLE__)
+fontsize = 10;
+fdui->form = form = new Fl_Window(540, 540);
+#else
+fontsize = 12;
+fdui->form = form = new Fl_Window(680, 815);
+#endif
+form->box(FL_FLAT_BOX);
+form->label("Dot Plot");
+
+curr_y = fin = 5;
+but_height = fontsize + 4 * 2;
+Fl_Group *top = new Fl_Group(fin, curr_y, form->w() - 2 * fin, but_height);
+obj = cre_button(fin, curr_y, &width, but_height, fontsize, "Fit to window");
+fin += width + 2;
+data = new user_data_plus;
+data->p = fdui;
+data->value = 1;
+obj->callback(magnify_reduce_proc, data);
+
+obj = cre_button(fin, curr_y, &width, but_height, fontsize, "Reduce");
+fin += width + 2;
+data = new user_data_plus;
+data->p = fdui;
+data->value = 2;
+obj->callback(magnify_reduce_proc, data);
+
+Fl_Widget *magnify = cre_button(fin, curr_y, &width, but_height, fontsize, "Magnify");
+fin += width + 2;
+data = new user_data_plus;
+data->p = fdui;
+data->value = 3;
+magnify->callback(magnify_reduce_proc, data);
+
+curr_x = fin;
+Fl_Widget *compute = cre_button(fin, curr_y, &width, but_height, fontsize, "Compute");
+fin += width + 2;
+compute->callback(compute_proc, fdui);
+fdui->compute_butt = compute;
+
+Fl_Widget *postscript = cre_button(fin, curr_y, &width, but_height, fontsize, "Write Postscript");
+fin += width;
+postscript->callback(plot_button_proc, fdui);
+
+#ifndef WIN32
+fin += 2;
+Fl_Widget *close = cre_button(fin, curr_y, &width, but_height, fontsize, "Close");
+fin += width;
+close->callback(exit_button_proc, fdui);
+#endif
+
+width = fin - curr_x;
+width = top->x() + top->w() - width;
+width = width - curr_x;
+compute->position(compute->x() + width, compute->y() );
+postscript->position(postscript->x() + width, postscript->y() );
+#ifndef WIN32
+close->position(close->x() + width, close->y() );
+#endif
+
+static char wsize_label[] = "Window size:";
+fl_font(FL_HELVETICA, fontsize);
+width = (int)fl_width(wsize_label) + 2;
+curr_x = magnify->x() + magnify->w() + 2;
+obj = new Fl_Input(curr_x + width, curr_y, 30, but_height, wsize_label);
+obj->type(FL_INT_INPUT);
+fin = obj->x() + obj->w() + 2;
+obj->labelsize(fontsize); ((Fl_Input *)obj)->textsize(fontsize);
+obj->callback(change_comput_params, fdui);
+((Fl_Input *)obj)->value("20");
+fdui->win_size_type_box = obj;
+
+static char wmatch_label[] = "matches/window:";
+fl_font(FL_HELVETICA, fontsize);
+width = (int)fl_width(wmatch_label) + 2;
+obj = new Fl_Input(fin + width, curr_y, 30, but_height, wmatch_label);
+obj->type(FL_INT_INPUT);
+fin = obj->x() + obj->w();
+obj->labelsize(fontsize); ((Fl_Input *)obj)->textsize(fontsize);
+obj->callback(change_comput_params, fdui);
+((Fl_Input *)obj)->value("13");
+fdui->ident_type_box = obj;
+
+curr_x = magnify->x() + magnify->w() + 1;
+width = compute->x() - curr_x - 1;
+top->add_resizable(*new Fl_Box(curr_x, curr_y, width, but_height) );
+top->end();
+
+curr_y += but_height + 2;
+Fl_Group *align_group = new Fl_Group(top->x(), curr_y, top->w(), but_height);
+fin = align_group->x();
+
+obj = cre_button(fin, curr_y, &width, but_height, fontsize, "Align");
+fin += width + 2;
+obj->callback(align_callback, fdui);
+fdui->align_button = obj;
+
+obj = cre_button(fin, curr_y, &width, but_height, fontsize, "Record alignment");
+fin += width + 5;
+obj->callback(record_alignment_callback, fdui);
+
+static char ref_choice_label[] = "Ref. sequence";
+fl_font(FL_HELVETICA, fontsize);
+width = (int)fl_width(ref_choice_label) + 4 * 2;
+obj = new Fl_Choice(fin + width, curr_y, 150, but_height, ref_choice_label);
+obj->type(0);
+obj->labelfont(FL_HELVETICA); obj->labelsize(fontsize);
+((Fl_Choice *)obj)->textfont(FL_HELVETICA); ((Fl_Choice *)obj)->textsize(fontsize);
+fdui->choice_ref_seq = obj;
+
+obj = cre_button(0, curr_y, &width, but_height, fontsize, "Interrupt");
+curr_x = align_group->x() + align_group->w() - width;
+obj->position(curr_x, obj->y());
+obj->callback(interrupt_callback, fdui);
+fdui->interrupt_butt = obj;
+
+curr_x = fdui->choice_ref_seq->x() + fdui->choice_ref_seq->w() + 1;
+width = fdui->interrupt_butt->x() - curr_x - 1;
+align_group->add_resizable(*new Fl_Box(curr_x, curr_y, width, but_height) );
+align_group->end();
+
+curr_y += but_height + 2;
+Fl_Group *region_group = new Fl_Group(top->x(), curr_y, top->w(), 80);
+
+#ifdef WIN32
+#define SQW 15
+#else
+#define SQW 20
+#endif
+fin = region_group->x();
+obj = new Fl_Repeat_Button(fin,curr_y,SQW,SQW,"@<-");
+obj->labeltype(FL_SYMBOL_LABEL);
+obj->box(FL_ENGRAVED_BOX);
+data = new user_data_plus;
+data->p = fdui;
+data->value = 1;
+obj->callback(move_box_step, data);
+obj = new Fl_Repeat_Button(fin + SQW,curr_y,SQW,SQW,"@->");
+obj->labeltype(FL_SYMBOL_LABEL);
+obj->box(FL_ENGRAVED_BOX);
+data = new user_data_plus;
+data->p = fdui;
+data->value = 2;
+obj->callback(move_box_step, data);
+curr_y += SQW;
+obj = new Fl_Repeat_Button(fin,curr_y,SQW,SQW,"@1->");
+obj->labeltype(FL_SYMBOL_LABEL);
+obj->box(FL_ENGRAVED_BOX);
+data = new user_data_plus;
+data->p = fdui;
+data->value = 3;
+obj->callback(move_box_step, data);
+obj = new Fl_Repeat_Button(fin + SQW,curr_y,SQW,SQW,"@9->");
+obj->labeltype(FL_SYMBOL_LABEL);
+obj->box(FL_ENGRAVED_BOX);
+data = new user_data_plus;
+data->p = fdui;
+data->value = 4;
+obj->callback(move_box_step, data);
+curr_y += SQW;
+obj = new Fl_Repeat_Button(fin,curr_y,SQW,SQW,"@2->");
+obj->labeltype(FL_SYMBOL_LABEL);
+obj->box(FL_ENGRAVED_BOX);
+data = new user_data_plus;
+data->p = fdui;
+data->value = 5;
+obj->callback(move_box_step, data);
+obj = new Fl_Repeat_Button(fin + SQW,curr_y,SQW,SQW,"@8->");
+obj->labeltype(FL_SYMBOL_LABEL);
+obj->box(FL_ENGRAVED_BOX);
+data = new user_data_plus;
+data->p = fdui;
+data->value = 6;
+obj->callback(move_box_step, data);
+
+curr_x = fin + 2*SQW + 3;
+curr_y -= 2 * SQW;
+width = form->w() - curr_x - 3;
+strcpy(fdui->regionboxtext, "");
+obj = new Fl_Box(FL_ENGRAVED_BOX,curr_x,curr_y,width,3*SQW,fdui->regionboxtext);
+obj->align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE);
+obj->labelsize(fontsize);
+obj->labelfont(FL_COURIER);
+fdui->region_box = obj;
+
+fl_font(fdui->region_box->labelfont(), fdui->region_box->labelsize() );
+int debut = 4 + 10 * (int)fl_width('A');
+int maxbound = (fdui->region_box->w() - 8) / (int)fl_width('A') - 6;
+obj = new Fl_Slider(FL_HOR_FILL_SLIDER, fdui->region_box->x() + debut,
+ fdui->region_box->y() + fdui->region_box->h(),
+ fdui->region_box->w() - debut, SQW, "");
+obj->callback(region_size_proc, fdui);
+((Fl_Slider *)obj)->when((Fl_When)(FL_WHEN_CHANGED | FL_WHEN_RELEASE));
+((Fl_Slider *)obj)->bounds(4, maxbound);
+((Fl_Slider *)obj)->value(10);
+fdui->region_slider = obj;
+
+region_group->resizable(fdui->region_slider);
+region_group->end();
+
+curr_y += fdui->region_box->h() + fdui->region_slider->h() + 5;
+Fl_Group *panel_group = new Fl_Group(top->x(), curr_y, top->w(), form->h() - curr_y - 5);
+
+obj = new Fl_Slider(FL_VERT_SLIDER, panel_group->x() + panel_group->w() - SQW,
+ panel_group->y(), SQW, panel_group->h() - SQW - 5, "");
+data = new user_data_plus;
+data->value = 1;
+data->p = fdui;
+obj->callback(move_mat_proc, data);
+((Fl_Slider*)obj)->when((Fl_When)(FL_WHEN_CHANGED | FL_WHEN_RELEASE));
+fdui->y_slider = obj;
+
+obj = new Fl_Slider(FL_HOR_SLIDER, panel_group->x(),
+ panel_group->y() + panel_group->h() - SQW, panel_group->w() - SQW -5, SQW, "");
+data = new user_data_plus;
+data->value = 2;
+data->p = fdui;
+obj->callback(move_mat_proc, data);
+((Fl_Slider*)obj)->when((Fl_When)(FL_WHEN_CHANGED | FL_WHEN_RELEASE));
+fdui->x_slider = obj;
+
+/* mat_panel */
+obj = new Fl_Box(FL_ENGRAVED_FRAME, panel_group->x()-3, panel_group->y()-3,
+ fdui->x_slider->w()+6, fdui->y_slider->h()+6, "");
+obj = new matpt_panel(panel_group->x(), panel_group->y(),
+ fdui->x_slider->w(), fdui->y_slider->h(), fdui);
+
+obj->color(FL_BLACK, FL_GRAY);
+fdui->mat_panel = obj;
+fdui->gap_sites = gap_sites;
+
+panel_group->resizable(fdui->mat_panel);
+panel_group->end();
+
+form->end();
+form->resizable(panel_group);
+return fdui;
+}
+
+
+static void err_message(char *text)
+{
+fl_alert(text);
+exit(1);
+}
+
+static char *check_alloc(int nbrelt, int sizelt)
+{
+char *retval;
+if( (retval = (char *)calloc(nbrelt,sizelt)) != NULL ) return retval;
+err_message("ERROR: I cannot obtain enough memory.");
+return NULL;
+}
+
+
+void log_to_phys(int lx, int ly, int *px, int *py, FD_matpt *matpt)
+{
+*px = (int)floor(lx * matpt->factor + matpt->kx + 0.5);
+*py = (int)floor( - ly * matpt->factor + matpt->ky + 0.5);
+}
+
+
+void phys_to_log(int px, int py, int *lx, int *ly, FD_matpt *matpt)
+{
+*lx = (int)floor( (px - matpt->kx) / matpt->factor + 0.5 );
+*ly = (int)floor( (matpt->ky - py) / matpt->factor + 0.5 );
+}
+
+
+void reset_mat_data(FD_matpt *matpt)
+{
+int a, b, c, d;
+matpt->factor = ((double) matpt->phys_width) / matpt->view_size;
+a = matpt->view_x; b = a + matpt->view_size;
+c = matpt->mat_panel->x() + matpt->margin; d = c + matpt->phys_width;
+matpt->kx = (b*c - a*d) / (double) matpt->view_size;
+a = matpt->view_y; b = a + matpt->view_size;
+c = matpt->mat_panel->y() + matpt->mat_panel->h() - matpt->margin;
+d = c - matpt->phys_width;
+matpt->ky = (b*c - a*d) / (double) matpt->view_size;
+}
+
+
+void reset_sliders_data(FD_matpt * matpt)
+{
+((Fl_Slider *)matpt->x_slider)->bounds(0, matpt->longmax - matpt->view_size);
+((Fl_Slider *)matpt->x_slider)->slider_size(matpt->view_size / (double)matpt->longmax);
+((Fl_Slider *)matpt->x_slider)->step(1);
+((Fl_Slider *)matpt->y_slider)->bounds( - (matpt->longmax - matpt->view_size), 0);
+((Fl_Slider *)matpt->y_slider)->slider_size(matpt->view_size / (double)matpt->longmax);
+((Fl_Slider *)matpt->y_slider)->step(1);
+((Fl_Slider *)matpt->x_slider)->value(matpt->view_x);
+((Fl_Slider *)matpt->y_slider)->value(- matpt->view_y);
+}
+
+
+void init_mat_data(FD_matpt * matpt, int seqlong1, int seqlong2,
+ char *seqname1, char *seqname2, char *seq1, char *seq2, char *name,
+ int maxseqlength)
+{
+const int margin = 5;
+int fenetre, identites;
+
+matpt->rect_only = FALSE;
+matpt->longmax = FL_max(seqlong1, seqlong2);
+matpt->margin = margin;
+matpt->seqlong1 = seqlong1;
+matpt->seqlong2 = seqlong2;
+matpt->seq1 = seq1;
+matpt->seq2 = seq2;
+matpt->seqname1 = seqname1;
+matpt->seqname2 = seqname2;
+matpt->view_x = matpt->view_y = 0;
+matpt->view_size = matpt->longmax;
+sscanf( ((Fl_Input *)matpt->win_size_type_box)->value(), "%d", &fenetre);
+matpt->fenetre = fenetre;
+sscanf( ((Fl_Input *)matpt->ident_type_box)->value(), "%d", &identites);
+matpt->identites = identites;
+matpt->region_size = fenetre;
+matpt->hitx = seqlong1/2;
+matpt->hity = seqlong2/2;
+matpt->totsegments = -1;
+matpt->need_compute = FALSE;
+matpt->modif_but_not_saved = FALSE;
+matpt->plotname = (char *)malloc(strlen(name) + 1);
+strcpy(matpt->plotname, name);
+if(matpt->align_button != NULL) {
+ char temp[200];
+ sprintf(temp, "align to %s|align to %s", seqname1, seqname2);
+ ((Fl_Choice*)matpt->choice_ref_seq)->clear();
+ ((Fl_Choice *)matpt->choice_ref_seq)->value(0);
+ ((Fl_Choice *)matpt->choice_ref_seq)->add(temp);
+ ((Fl_Choice *)matpt->choice_ref_seq)->mode(0, FL_MENU_RADIO);
+ ((Fl_Choice *)matpt->choice_ref_seq)->mode(1, FL_MENU_RADIO);
+ matpt->tot_gap_sites = 0;
+ matpt->maxseqlength = maxseqlength;
+ }
+}
+
+
+void set_size_data(FD_matpt *matpt)
+{
+matpt->phys_width = FL_min(matpt->mat_panel->w(), matpt->mat_panel->h()) -
+ 2 * matpt->margin;
+reset_mat_data(matpt);
+reset_sliders_data(matpt);
+}
+
+
+void compute_region_text(FD_matpt *matpt)
+{
+int i, matches=0, l;
+char *p;
+static char newtext[sizeof(matpt->regionboxtext)];
+
+if(matpt->longmax == 0) return;
+p = newtext;
+sprintf(p, "%5d ", matpt->hitx);
+l = FL_min(matpt->region_size, matpt->seqlong1 - matpt->hitx + 1);
+l = FL_min(l, matpt->seqlong2 - matpt->hity + 1);
+memcpy(p+6, (matpt->seq1 + matpt->hitx), l);
+*(p + l + 6) = '\n';
+p += l + 7;
+
+strcpy(p, " ");
+for(i=0; i < l; i++) {
+ if( toupper(*(matpt->seq1 + matpt->hitx + i)) ==
+ toupper(*(matpt->seq2 + matpt->hity + i)) &&
+ *(matpt->seq2 + matpt->hity + i) != '-' ) {
+ *(p + i + 6) = '|';
+ matches++;
+ }
+ else
+ *(p + i + 6)=' ';
+ }
+sprintf(p,"%d/%d", matches, matpt->region_size);
+*(p + strlen(p)) = ' ';
+*(p + 6 + l)='\n';
+p += l + 7;
+
+sprintf(p, "%5d ", matpt->hity);
+memcpy(p+6, (matpt->seq2 + matpt->hity), l);
+*(p + l + 6)='\0';
+if(strcmp(matpt->regionboxtext, newtext) != 0) {
+ strcpy(matpt->regionboxtext, newtext);
+ matpt->region_box->redraw();
+ }
+}
+
+
+void draw_rect(FD_matpt *matpt)
+{
+int px, py, pxf, pyf;
+rectangle old_rect;
+log_to_phys(matpt->hitx, matpt->hity, &px, &py, matpt);
+log_to_phys(matpt->hitx + matpt->region_size, matpt->hity + matpt->region_size,
+ &pxf, &pyf, matpt);
+// rectangle mis pour avoir h > 0
+old_rect.x = px; old_rect.y = pyf; old_rect.w = pxf - px; old_rect.h = py - pyf;
+fl_overlay_rect(old_rect.x, old_rect.y, old_rect.w, old_rect.h);
+fl_color(FL_BLACK);
+matpt->rect_only = FALSE;
+}
+
+
+void matpt_panel::draw(void)
+{
+FD_matpt *matpt = (FD_matpt *)this->user_data();
+static int erreur = FALSE;
+static char *errmess;
+int i, pxd, pyd, pxf, pyf;
+static int old_w = 0, old_h = 0;
+ this->clear_damage(); // tres important!
+ if( this->w() != old_w || this->h() != old_h ) { /* was resized */
+ old_w = this->w(); old_h = this->h();
+ set_size_data(matpt);
+ ((Fl_Slider *)matpt->region_slider)->value(matpt->region_size);
+ }
+ fl_clip(this->x(), this->y(), this->w(), this->h());
+ if(matpt->rect_only) goto label_draw_rect;
+ fl_overlay_clear();
+/* ecriture du fond */
+ fl_color(this->selection_color());
+ fl_rectf(this->x(), this->y(), this->w(), this->h());
+ fl_color(FL_BLACK);
+/* draw the diagonal line */
+ if( ( (SEA_VIEW *) matpt->seaview_data )->numb_gc > 1) {
+/* in red on color displays */
+ log_to_phys(0, 0, &pxd, &pyd, matpt);
+ i = FL_min(matpt->seqlong1, matpt->seqlong2);
+ log_to_phys(i, i, &pxf, &pyf, matpt);
+ fl_color(FL_RED);
+ fl_line(pxd, pyd, pxf, pyf);
+ fl_color(FL_BLACK);
+ }
+ else {
+/* as a dotted line on B&W displays */
+ int p, q;
+ log_to_phys(0, 0, &pxd, &pyd, matpt);
+ i = FL_min(matpt->seqlong1, matpt->seqlong2);
+ log_to_phys(i, i, &pxf, &pyf, matpt);
+ q = pyd;
+ for(p=pxd; p<=pxf; p += 2) {
+ fl_line(p, q, p, q);
+ q -= 2;
+ }
+ }
+ log_to_phys(0, 0, &pxd, &pyd, matpt);
+ log_to_phys(matpt->seqlong1, 0, &pxf, &pyf, matpt);
+ fl_line(pxd, pyd, pxf, pyf);
+ log_to_phys(0, matpt->seqlong2, &pxf, &pyf, matpt);
+ fl_line(pxd, pyd, pxf, pyf);
+ if(matpt->need_compute) {
+ matpt->totsegments = compute_diags(matpt, &erreur, &errmess);
+ }
+ else {
+ erreur = FALSE;
+ for (i = 0; i <= matpt->totsegments; i++) {
+ log_to_phys(segments[i].x,
+ segments[i].y,
+ &pxd, &pyd, matpt);
+ log_to_phys(segments[i].x+segments[i].longueur,
+ segments[i].y+segments[i].longueur,
+ &pxf, &pyf, matpt);
+ fl_line(pxd, pyd, pxf, pyf);
+ }
+ }
+label_draw_rect:
+ draw_rect(matpt);
+ fl_pop_clip();
+ compute_region_text(matpt);
+ fl_reset_cursor(this->window());
+ if(erreur) {
+ fl_message(errmess);
+ erreur = FALSE;
+ }
+}
+
+
+int matpt_panel::handle(int event)
+{
+FD_matpt *matpt = (FD_matpt *)this->user_data();
+
+if(event == FL_PUSH) {
+ int lx, ly;
+ phys_to_log( Fl::event_x(), Fl::event_y(), &lx, &ly, matpt);
+ if(lx <= 0 || ly <= 0 || lx > matpt->seqlong1 || ly > matpt->seqlong2)
+ return 1;
+ matpt->hitx = lx; matpt->hity = ly;
+ matpt->rect_only = TRUE;
+ matpt->mat_panel->redraw();
+ Fl::focus(this);
+ return 1;
+ }
+else if(event == FL_KEYBOARD) {
+ int key = Fl::event_key();
+ if(Fl::event_length() > 0 || (key != FL_Right && key != FL_Left &&
+ key != FL_Up && key != FL_Down) ) return 1;
+ if(key == FL_Left) {
+ matpt->hitx = FL_max(matpt->hitx - 5, 1);
+ matpt->hity = FL_max(matpt->hity - 5, 1);
+ }
+ else if(key == FL_Right) {
+ matpt->hitx = FL_min(matpt->hitx + 5, matpt->seqlong1);
+ matpt->hity = FL_min(matpt->hity + 5, matpt->seqlong2);
+ }
+ else if(key == FL_Up) {
+ matpt->hity = FL_min(matpt->hity + 5, matpt->seqlong2);
+ }
+ else { /* FL_Down */
+ matpt->hity = FL_max(matpt->hity - 5, 1);
+ }
+ matpt->rect_only = TRUE;
+ matpt->mat_panel->redraw();
+ return 1;
+ }
+else if(event == FL_FOCUS) {
+ return 1;
+ }
+return 0;
+}
+
+
+void center_view_on_hit(FD_matpt *matpt)
+{
+int newval;
+newval = matpt->hitx + (matpt->region_size - matpt->view_size) / 2;
+newval = FL_min( FL_max(newval, 0), matpt->longmax - matpt->view_size);
+matpt->view_x = newval;
+newval = matpt->hity + (matpt->region_size - matpt->view_size) / 2;
+newval = FL_min( FL_max(newval, 0), matpt->longmax - matpt->view_size);
+matpt->view_y = newval;
+reset_mat_data(matpt);
+reset_sliders_data(matpt);
+}
+
+
+void magnify_reduce_proc(Fl_Widget *ob, void *extra)
+{
+const int zoom = 2;
+FD_matpt *matpt = (FD_matpt *)((user_data_plus *)extra)->p;
+int data = ((user_data_plus *)extra)->value;
+
+if( data == 3 ) { /* magnify */
+ matpt->view_size /= zoom;
+ }
+else if ( data == 1 ) { /* fit to window */
+ matpt->view_size = matpt->longmax;
+ }
+else { /* reduce */
+ matpt->view_size = FL_min( matpt->view_size * zoom, matpt->longmax );
+ }
+center_view_on_hit(matpt);
+matpt->mat_panel->redraw();
+matpt->x_slider->redraw();
+matpt->y_slider->redraw();
+}
+
+
+void change_comput_params(Fl_Widget *ob, void *data)
+{
+const char *p;
+int value = -1;
+FD_matpt *fdui = (FD_matpt *)data;
+
+p= ((Fl_Input *)ob)->value();
+sscanf(p,"%d",&value);
+if(value<=0 || value>50) {
+ ((Fl_Input *)ob)->value("??");
+ value = -1;
+ }
+if(ob == fdui->win_size_type_box)
+ fdui->fenetre = value;
+else
+ fdui->identites = value;
+if(fdui->identites > fdui->fenetre && fdui->fenetre>0) {
+ char tmp[10];
+ fdui->identites = fdui->fenetre;
+ sprintf(tmp,"%d", fdui->identites);
+ ((Fl_Input *)fdui->ident_type_box)->value(tmp);
+ }
+}
+
+
+void compute_proc(Fl_Widget *ob, void *data)
+{
+FD_matpt *fdui = (FD_matpt *)data;
+change_comput_params(fdui->win_size_type_box, fdui);
+change_comput_params(fdui->ident_type_box, fdui);
+if(fdui->fenetre == -1 || fdui->identites == -1) return;
+my_watch_cursor(fdui->mat_panel->window());
+fdui->need_compute = TRUE;
+fdui->interrupted = FALSE;
+fdui->mat_panel->redraw();
+if(!fdui->form->visible()) return;
+if(fdui->fenetre > fdui->region_size) fdui->region_size = fdui->fenetre;
+((Fl_Slider *)fdui->region_slider)->value(fdui->region_size);
+fdui->region_slider->redraw();
+}
+
+
+void interrupt_callback(Fl_Widget *ob, void *data)
+{
+FD_matpt *fdui = (FD_matpt *)data;
+fdui->interrupted = TRUE;
+}
+
+
+void ps_draw_line(int x1, int y1, int x2, int y2, FD_matpt *matpt,
+ FILE *plotfile)
+{
+int px, py;
+px = (int)floor(x1 * matpt->factor + matpt->kx + 0.5);
+py = (int)floor(y1 * matpt->factor + matpt->ky + 0.5);
+fprintf(plotfile,"%d %d moveto ",px,py);
+px = (int)floor(x2 * matpt->factor + matpt->kx + 0.5);
+py = (int)floor(y2 * matpt->factor + matpt->ky + 0.5);
+fprintf(plotfile,"%d %d lineto stroke\n",px,py);
+}
+
+void ps_set_mat_data(FD_matpt *matpt)
+{
+int a, b, c, d;
+matpt->factor = ((double) matpt->phys_width) / matpt->view_size;
+a = matpt->view_x; b = a + matpt->view_size;
+c = matpt->margin; d = c + matpt->phys_width;
+matpt->kx = (b*c - a*d) / (double) matpt->view_size;
+a = matpt->view_y; b = a + matpt->view_size;
+c = matpt->margin;
+d = c + matpt->phys_width;
+matpt->ky = (b*c - a*d) / (double) matpt->view_size;
+}
+
+
+void plot_button_proc(Fl_Widget *ob, void *data)
+{
+FD_matpt *matpt = (FD_matpt *)data;
+int i;
+char plotfname[150], *sp;
+int old_phys;
+FILE *plotfile;
+
+strcpy(plotfname, matpt->plotname);
+sp = strchr(plotfname,'.');
+if( sp == NULL || strcmp(sp, ".ps") == 0 )
+ sp = plotfname+strlen(plotfname);
+strcpy(sp, ".ps");
+plotfile=fopen(plotfname,"w");
+if(plotfile == NULL) {
+ fl_alert("Cannot write to file\n%s", plotfname);
+ return;
+ }
+fprintf(plotfile,"%%!\n1 setlinecap 1 setlinejoin 1 setlinewidth 0 setgray\n");
+fprintf(plotfile,"/basefont /Helvetica findfont 12 scalefont def\n");
+fprintf(plotfile,"basefont setfont\n");
+fprintf(plotfile,"50 200 translate\n");
+fprintf(plotfile,"-10 -10 moveto 510 -10 lineto 510 510 lineto -10 510 lineto \
+-10 -10 lineto stroke\n");
+
+old_phys = matpt->phys_width; matpt->phys_width = 500;
+ps_set_mat_data(matpt);
+
+ps_draw_line(0, 0, matpt->seqlong1, 0, matpt, plotfile);
+ps_draw_line(0, 0, 0, matpt->seqlong2, matpt, plotfile);
+for (i = 0; i <= matpt->totsegments; i++) {
+ ps_draw_line(segments[i].x, segments[i].y,
+ segments[i].x+segments[i].longueur,
+ segments[i].y+segments[i].longueur, matpt, plotfile);
+
+ }
+matpt->phys_width = old_phys;
+reset_mat_data(matpt);
+
+fl_message("Dot plot is now in file\n%s\nin postscript format", plotfname);
+sprintf(plotfname,
+ "Horizontal: %s (%d) Vertical: %s (%d) Window: %d Matches: %d",
+ matpt->seqname1, matpt->seqlong1, matpt->seqname2, matpt->seqlong2,
+ matpt->fenetre, matpt->identites);
+fprintf(plotfile,"-10 -30 moveto (%s) show\n",plotfname);
+fprintf(plotfile,"showpage\n");
+fclose(plotfile);
+}
+
+
+int really_close(FD_matpt *matpt)
+{
+int rep;
+if(matpt->modif_but_not_saved) {
+ rep = fl_ask("Changes in dot plot were not saved in alignment\n"
+ "Do you really want to close the dot plot?");
+ if(!rep) return FALSE;
+ }
+free(matpt->seq1 + 1);
+free(matpt->seq2 + 1);
+matpt->seq1 = matpt->seq2 = NULL;
+return TRUE;
+}
+
+
+void exit_button_proc(Fl_Widget *ob, void *data)
+{
+if( really_close( (FD_matpt *)data ) ) ((FD_matpt *)data)->form->hide();
+}
+
+
+void move_mat_proc(Fl_Widget *ob, void *data)
+{
+int rank = ((user_data_plus *)data)->value;
+FD_matpt *matpt = (FD_matpt *)((user_data_plus *)data)->p;
+int val;
+val = (int)( ((Fl_Slider *)ob)->value() );
+if(rank == 1)
+ matpt->view_y = - val;
+else
+ matpt->view_x = val;
+reset_mat_data(matpt);
+matpt->mat_panel->redraw();
+}
+
+
+void move_box_step(Fl_Widget *ob, void *extra)
+{
+int data = ((user_data_plus *)extra)->value;
+FD_matpt *matpt = (FD_matpt *)((user_data_plus *)extra)->p;
+if(data == 1) {
+ matpt->hitx = FL_max(matpt->hitx - 1, 1);
+ }
+else if(data == 2) {
+ matpt->hitx = FL_min(matpt->hitx + 1, matpt->seqlong1);
+ }
+else if(data == 3) {
+ matpt->hitx = FL_max(matpt->hitx - 1, 1);
+ matpt->hity = FL_max(matpt->hity - 1, 1);
+ }
+else if(data == 4) {
+ matpt->hitx = FL_min(matpt->hitx + 1, matpt->seqlong1);
+ matpt->hity = FL_min(matpt->hity + 1, matpt->seqlong2);
+ }
+else if(data == 5) {
+ matpt->hity = FL_max(matpt->hity - 1, 1);
+ }
+else {
+ matpt->hity = FL_min(matpt->hity + 1, matpt->seqlong2);
+ }
+matpt->rect_only = TRUE;
+matpt->mat_panel->redraw();
+}
+
+
+void region_size_proc(Fl_Widget *ob, void *data)
+{
+FD_matpt *matpt = (FD_matpt *)data;
+matpt->region_size = (int)( ((Fl_Slider *)ob)->value() );
+matpt->rect_only = TRUE;
+matpt->mat_panel->redraw();
+}
+
+
+void compute_title(FD_matpt *matpt)
+{
+static char title[100];
+sprintf(title, "Horizontal: %s (%d) Vertical: %s (%d)",
+ matpt->seqname1, matpt->seqlong1, matpt->seqname2, matpt->seqlong2);
+matpt->title = title;
+matpt->mat_panel->window()->label(title);
+}
+
+
+int find_next_gap_site(int pos, gap_site *gap_sites, int tot_gap_sites)
+{
+int num;
+for(num = 0; num < tot_gap_sites; num++)
+ if(gap_sites[num].pos > pos) return num;
+return -1;
+}
+
+
+void new_gap_site(int pos, int l, gap_site *gap_sites, int *p_tot_gap_sites,
+ int seqrank)
+{
+int num, i;
+for(num = 0; num < *p_tot_gap_sites; num++)
+ if(gap_sites[num].pos >= pos) break;
+if(num < *p_tot_gap_sites && gap_sites[num].pos == pos)
+ gap_sites[num].l[seqrank-1] += l;
+else {
+ if(*p_tot_gap_sites >= MAX_GAP_SITES) return;
+ if(num < *p_tot_gap_sites) {
+ for(i = *p_tot_gap_sites; i > num; i--)
+ gap_sites[i] = gap_sites[i - 1];
+ }
+ (*p_tot_gap_sites)++;
+ gap_sites[num].pos = pos;
+ gap_sites[num].l[0] = 0;
+ gap_sites[num].l[1] = 0;
+ gap_sites[num].l[seqrank-1] = l;
+ }
+}
+
+
+int delete_gaps_bef_pos(char *seq, int pos, int number, int length,
+ int totsegments, int offset)
+{
+int i;
+if(number == 0) return length;
+memmove(seq + pos - number, seq + pos, length - pos + 2);
+for(i=0; i <= totsegments; i++)
+ if(segment_x_ou_y(i, offset) + segments[i].longueur - 1 >= pos )
+ segment_x_ou_y(i, offset) -= number;
+return length - number;
+}
+
+
+int insert_gaps_bef_pos(char *seq, int pos, int number, int length,
+ int totsegments, int offset, int maxlen)
+{
+int i;
+if(length + number > maxlen) return length;
+memmove(seq + pos + number, seq + pos, length - pos + 2);
+memset(seq + pos, '-', number);
+for(i=0; i <= totsegments; i++)
+ if(segment_x_ou_y(i, offset) + segments[i].longueur - 1 >= pos )
+ segment_x_ou_y(i, offset) += number;
+return length + number;
+}
+
+
+int dispatch_gaps_bef(int pos, int number, char *seq, gap_site * gap_sites,
+ int *p_tot_gap_sites, int offset, int seqlen, int totsegments,
+ int seqrank, char *other_seq, int *other_seqlen, int other_offset,
+ int maxlen)
+{
+int site, lnextgap, other_rank, i, seuil;
+site = find_next_gap_site(pos + number, gap_sites, *p_tot_gap_sites);
+if(site != -1) {
+ if(gap_sites[site].l[seqrank-1] >= number) {
+ seqlen = delete_gaps_bef_pos(seq, gap_sites[site].pos, number,
+ seqlen, totsegments, offset);
+ seqlen = insert_gaps_bef_pos(seq, pos, number, seqlen,
+ totsegments, offset, maxlen);
+ gap_sites[site].l[seqrank-1] -= number;
+ }
+ else {
+ lnextgap = gap_sites[site].l[seqrank-1];
+ other_rank = (seqrank == 1 ? 2 : 1);
+ seqlen = delete_gaps_bef_pos(seq, gap_sites[site].pos, lnextgap,
+ seqlen, totsegments, offset);
+ *other_seqlen = insert_gaps_bef_pos(other_seq,
+ gap_sites[site].pos,
+ number - lnextgap, *other_seqlen,
+ totsegments, other_offset, maxlen);
+ seqlen = insert_gaps_bef_pos(seq, pos, number, seqlen,
+ totsegments, offset, maxlen);
+ gap_sites[site].l[seqrank-1] = 0;
+ gap_sites[site].l[other_rank-1] += number - lnextgap;
+ seuil = gap_sites[site].pos;
+ for(i = 0; i < *p_tot_gap_sites; i++) {
+ if(gap_sites[i].pos < seuil) continue;
+ gap_sites[i].pos += number - lnextgap;
+ }
+ }
+ }
+else {
+ seqlen = insert_gaps_bef_pos(seq, pos, number, seqlen, totsegments,
+ offset, maxlen);
+ }
+new_gap_site(pos + number, number, gap_sites, p_tot_gap_sites, seqrank);
+return seqlen;
+}
+
+
+void align_callback(Fl_Widget *ob, void *data)
+{
+int number, offset_1, offset_2;
+FD_matpt *matpt = (FD_matpt *)data;
+if(matpt->hitx == matpt->hity) return;
+my_watch_cursor(ob->window());
+offset_1 = (char *)&(segments[0].x) - (char *)&(segments[0]);
+offset_2 = (char *)&(segments[0].y) - (char *)&(segments[0]);
+if(matpt->hitx > matpt->hity) {
+ number = matpt->hitx - matpt->hity;
+ matpt->seqlong2 = dispatch_gaps_bef(matpt->hity, number,
+ matpt->seq2, matpt->gap_sites,
+ &(matpt->tot_gap_sites), offset_2, matpt->seqlong2,
+ matpt->totsegments, 2, matpt->seq1, &matpt->seqlong1, offset_1,
+ matpt->maxseqlength);
+ matpt->hity = matpt->hitx;
+ }
+else {
+ number = matpt->hity - matpt->hitx;
+ matpt->seqlong1 = dispatch_gaps_bef(matpt->hitx, number,
+ matpt->seq1, matpt->gap_sites,
+ &(matpt->tot_gap_sites), offset_1, matpt->seqlong1,
+ matpt->totsegments, 1, matpt->seq2, &matpt->seqlong2, offset_2,
+ matpt->maxseqlength);
+ matpt->hitx = matpt->hity;
+ }
+matpt->longmax = FL_max(matpt->seqlong1, matpt->seqlong2);
+center_view_on_hit(matpt);
+matpt->mat_panel->redraw();
+matpt->x_slider->redraw();
+matpt->y_slider->redraw();
+compute_title(matpt);
+matpt->modif_but_not_saved = TRUE;
+}
+
+
+void update_col_lines(int num, SEA_VIEW *view)
+{
+int l, col, i, res;
+int (*calc_color_function)(int);
+
+if(view->numb_gc == 1) return;
+calc_color_function = ( view->protein ?
+ get_color_for_aa : get_color_for_base );
+l = view->each_length[num];
+for(col=0; col < view->numb_gc; col++) {
+ memset(view->col_seq[num][col], ' ', l);
+ view->col_seq[num][col][l]=0;
+ }
+for(i=0; i<l; i++) {
+ res = view->sequence[num][i];
+ col = calc_color_function( res );
+ view->col_seq[num][col][i] = ( view->allow_lower ? res : toupper(res) );
+ }
+}
+
+
+void record_alignment_callback(Fl_Widget *ob, void *data)
+{
+int num1, num2, site, need_big_gaps = FALSE, seqrank, num, ngaps,
+ newlength;
+FD_matpt *matpt = (FD_matpt *)data;
+SEA_VIEW *view = (SEA_VIEW *)matpt->seaview_data;
+Fl_Menu_ *menu = (Fl_Menu_ *)matpt->choice_ref_seq;
+if( ! menu->mvalue() ) {
+ fl_message("Please, select which is the reference sequence");
+ return;
+ }
+seqrank = menu->value();
+my_watch_cursor(ob->window());
+for(site = 0; site < matpt->tot_gap_sites; site++) {
+ if(matpt->gap_sites[site].l[seqrank] != 0) {
+ need_big_gaps = TRUE;
+ break;
+ }
+ }
+for(num1 = 0; num1 < view->tot_seqs; num1++)
+ if(view->sel_seqs[num1]) break;
+for(num2 = num1 + 1; num2 < view->tot_seqs; num2++)
+ if(view->sel_seqs[num2]) break;
+memcpy(view->sequence[num1], matpt->seq1 + 1, matpt->seqlong1 + 1);
+view->each_length[num1] = matpt->seqlong1;
+update_col_lines(num1, view);
+memcpy(view->sequence[num2], matpt->seq2 + 1, matpt->seqlong2 + 1);
+view->each_length[num2] = matpt->seqlong2;
+update_col_lines(num2, view);
+if( need_big_gaps ) {
+ newlength = FL_max(matpt->seqlong1, matpt->seqlong2);
+ for(site = 0; site < matpt->tot_gap_sites; site++) {
+ ngaps = matpt->gap_sites[site].l[seqrank];
+ if( ngaps == 0) continue;
+ for(num = 0; num < view->tot_seqs; num++) {
+ if( view->sel_seqs[num] ) continue;
+ insert_gaps_at(view, num+1,
+ matpt->gap_sites[site].pos - ngaps, ngaps);
+ newlength = FL_max(newlength, view->each_length[num]);
+ }
+ matpt->gap_sites[site].l[seqrank] = 0;
+ insert_region_part(view, matpt->gap_sites[site].pos - ngaps,
+ ngaps);
+ }
+ update_current_seq_length(newlength, view);
+ view->horsli->redraw();
+ }
+view->modif_but_not_saved = TRUE;
+matpt->modif_but_not_saved = FALSE;
+view->DNA_obj->redraw();
+fl_reset_cursor(ob->window());
+}
+
+
+/* dot plot pour sequences avec gaps:
+les segments sont calcules sans les gaps
+leurs coordonnees sont reportees sur les seqs avec gaps
+puis ils sont coupes en autant de morceaux sans gap
+*/
+int compute_diags(FD_matpt *matpt, int *erreur, char **errmess)
+{
+int lwin, match, seqlong1, seqlong2, longmax, diff;
+char *seq1, *seq2;
+int pxd, pyd, pxf, pyf;
+int dmin, dmax, k, deb, fin, *it, i, pp, nmatch, finw, d, totsegments, kk,
+ centre, flip;
+static char err_mem[]="Not enough memory";
+static char err_seg[]="Only part of the dot plot was computed";
+int *addgaps1, *addgaps2, deb1, deb2, fin1, fin2, lfrag;
+char *p;
+
+matpt->need_compute = FALSE;
+lwin = matpt->fenetre; match = matpt->identites;
+seqlong1 = matpt->seqlong1; seqlong2 = matpt->seqlong2;
+seq1 = matpt->seq1; seq2 = matpt->seq2;
+
+totsegments= -1;
+/* calcul corresp coord sans gap -> coord avec gap */
+addgaps1 = (int *)malloc( (seqlong1+2) * sizeof(int));
+addgaps2 = (int *)malloc( (seqlong2+2) * sizeof(int));
+if(addgaps1 == NULL || addgaps2 == NULL) {
+ *erreur = TRUE;
+ *errmess = err_mem;
+ return totsegments;
+ }
+p = seq1; seqlong1 = 0;
+while( *(++p) != 0) {
+ if( *p == '-') continue;
+ addgaps1[++seqlong1] = p - seq1;
+ }
+p = seq2; seqlong2 = 0;
+while( *(++p) != 0) {
+ if( *p == '-') continue;
+ addgaps2[++seqlong2] = p - seq2;
+ }
+
+dmin = lwin-seqlong2; dmax = seqlong1-lwin-1;
+longmax = FL_max(seqlong1, seqlong2);
+it = (int *)malloc( (longmax + 2) * sizeof(int));
+if(it == NULL) {
+ *erreur = TRUE;
+ *errmess = err_mem;
+ return totsegments;
+ }
+centre = (dmin + dmax)/2; flip = 1;
+for(kk = dmin + 1; kk <= dmax + 1; kk++) {
+ if( Fl::ready() ) {
+ Fl::check();
+ if(matpt->interrupted) break;
+ if( !matpt->form->visible() ) {
+ *erreur = TRUE;
+ goto fin;
+ }
+ }
+/* pour faire la boucle k = [dmin,dmax] en partant du centre et s'eloignant */
+ flip = - flip;
+ k = centre + ((kk - dmin)/2) * flip;
+ deb= ( k>=0 ? k+1 : 1);
+ fin= FL_min( seqlong2+k , seqlong1);
+/*on met it[1] ssi bases egales en majuscu dans les 2 seqs sur la diagonale k*/
+ for(i = deb; i <= fin; i++) {
+ diff = seq1[addgaps1[i]] - seq2[addgaps2[i-k]];
+ it[i] = (diff == 0 || diff == 32 || diff == -32 ? 1 : 0);
+ }
+ it[fin + 1] = 0;
+/* on met it[1] ssi au moins match bases egales dans fenetre de taille lwin
+sur la diagonale k
+*/
+ pp=it[deb];
+ nmatch=0;
+ for(i = deb; i < deb+lwin; i++) nmatch += it[i];
+ if(nmatch>=match)
+ it[deb]=1;
+ else
+ it[deb]=0;
+ finw = fin-lwin+1;
+ for(i = deb+1; i <= finw; i++) {
+ nmatch += (it[i+lwin-1]-pp);
+ pp=it[i];
+ if(nmatch>=match)
+ it[i]=1;
+ else
+ it[i]=0;
+ }
+ i=deb-1;
+/* calcul de d = debut des runs de 1, i = suivant de la fin du run de 1 */
+ while(i<finw) {
+ i++;
+ if(it[i]==0) continue;
+ d=i;
+ do {
+ i++;
+ if(i>finw) break;
+ }
+ while(it[i]==1);
+/* decoupage du segment sans gaps en autant de morceaux non coupes de gaps */
+ deb1 = addgaps1[d]; deb2 = addgaps2[d-k]; lfrag = 0;
+ do {
+ fin1 = deb1; fin2 = deb2;
+ while(lfrag < i - d && seq1[fin1] != '-' &&
+ seq2[fin2] != '-') {
+ fin1++; fin2++; lfrag++;
+ }
+ fin1--; fin2--;
+ if(totsegments>=MAXSEGMENTS) {
+ *erreur = TRUE;
+ *errmess = err_seg;
+ goto fin;
+ }
+ totsegments++;
+ segments[totsegments].x = deb1;
+ segments[totsegments].y = deb2;
+ segments[totsegments].longueur = fin1 - deb1 + 1;
+ log_to_phys(segments[totsegments].x,
+ segments[totsegments].y,
+ &pxd, &pyd, matpt);
+ log_to_phys(segments[totsegments].x +
+ segments[totsegments].longueur,
+ segments[totsegments].y +
+ segments[totsegments].longueur,
+ &pxf, &pyf, matpt);
+ fl_line(pxd, pyd, pxf, pyf);
+ deb1 = fin1+1; deb2 = fin2+1;
+ while(seq1[deb1] == '-') deb1++;
+ while(seq2[deb2] == '-') deb2++;
+ }
+ while(lfrag < i - d);
+ }
+ }
+*erreur = FALSE;
+fin:
+free(it);
+free(addgaps1); free(addgaps2);
+return totsegments;
+}
More information about the debian-med-commit
mailing list