#include #include #include #include #include #include #include "clustalw.h" #include "xmenu.h" #define SIMPLE 1 #define COMPOUND 2 #define LEFTMARGIN 20 #define SEPARATION 2 #define CHARHEIGHT 10 #define CHARWIDTH 6 #define A4X 564 #define A4Y 800 #define A3X 832 #define A3Y 1159 #define USLETTERX 564 #define USLETTERY 750 #define SCOREY 3 #define HEADER 7 #define NOHEADER 0 #define MAXRESNO 6 #define MAXPARLEN 10 #define MAXPAR 100 static void print_ps_info(FILE *fd,int pagesize); static void print_page_header(FILE *fd,int ps_rotation,int maxx,int maxy, int page,int numpages,Boolean header,char *str_time, char *ps_file,int ps_xtrans,int ps_ytrans,float ps_scale); static void print_header_line(FILE *fd,panel_data name_data, panel_data seq_data, int ix,int fr,int lr); static void print_footer_line(FILE *fd,panel_data name_data, panel_data seq_data, int ix,int fr,int lr); static void print_quality_curve(FILE *fd,panel_data seq_data ,int fr,int lr,int score_height); static void print_seq_line(FILE *fd,panel_data name_data, panel_data seq_data, int row,int seq,int fr,int lr,int res_number); typedef struct consensus_parameters { char consensus; int cutoff; int length; char cutoff_list[20]; } consensus_para; typedef struct color_parameters { int type; char residue; int color; int length; char cons_list[20]; } color_para; static void init_color_lut(FILE *fd); static int init_printer_lut(char *filename); static char *init_consensus(panel_data data); static int SaveColPara(char word[MAXPAR][MAXPARLEN],int num_words,int count); static int SaveConPara(char word[MAXPAR][MAXPARLEN],int num_words,int count); static int get_line(char *sinline,char word[MAXPAR][MAXPARLEN]); static int residue_color(char res,char consensus); static Boolean commentline(char *line); #define DEF_NCOLORS 4 #define MAX_NCOLORS 8 #define DEFAULT_COLOR 0 typedef struct rgb_color { char name[20]; float r,g,b; } rgb_color; rgb_color def_color_lut[MAX_NCOLORS]={ "RED" ,0.9, 0.1, 0.1, "BLUE" ,0.1, 0.1, 0.7, "GREEN" ,0.1, 0.9, 0.1, "ORANGE" ,0.9, 0.6, 0.3, "CYAN" ,0.1, 0.9, 0.9, "PINK" ,0.9, 0.5, 0.5, "MAGENTA" ,0.9, 0.1, 0.9, "YELLOW" ,0.9, 0.9, 0.0, }; char def_aacolor[MAX_NCOLORS][26]={"krh", "fwy", "ilmv", "gpst"}; char def_dnacolor[MAX_NCOLORS][26]={"a", "c", "tu", "g"}; extern char revision_level[]; extern int max_names; extern int ncolors; extern int ncolor_pars; extern color color_lut[]; extern int inverted; extern Boolean residue_exceptions; extern Boolean segment_exceptions; extern Boolean dnaflag; int NumColParas; int NumConParas; color_para Col_Par[100]; consensus_para Con_Par[100]; void make_colormask(panel_data data) { int i,j; for(i=0;i 1) { data.consensus=init_consensus(data); for(i=0;i=MAXCOLORS) { warning("Only using first %d colors in rgb index.",MAXCOLORS); break; } } } } /* if we can't find a table, use the hard-coded colors */ if (ncolors==1) { ncolors=MAX_NCOLORS+1; for(i=1;imaxparas) || (NumConParas>maxparas)) error("Too many parameters in color file"); } } if (color_found == FALSE) { error("@color not found in parameter file - using defaults\n"); ncolor_pars=0; } fclose(par_fd); } ncolor_pars=NumColParas; /* if no color parameters found, use the default aa groupings */ if(ncolor_pars==0) { if (dnaflag) { for(i=0;i= Con_Par[par].cutoff) cons_data[res] = Con_Par[par].consensus; } } return(cons_data); } static int SaveColPara(char word[MAXPAR][MAXPARLEN],int num_words,int count) { int i; if (num_words < 3) { error("Wrong format in color list"); return(1); } if (word[1][0] != '=') { error("Wrong format in color list"); return(2); } if (num_words == 3) { Col_Par[count].type = SIMPLE; Col_Par[count].residue = word[0][0]; Col_Par[count].color = -1; for (i=0;i0) warning("No PS Colors file: using default colors\n"); /* get the page size parameters */ if (pagesize==A4) { if (orientation==PORTRAIT) { maxx=A4X; maxy=A4Y; ps_rotation=0; } else { maxx=A4Y; maxy=A4X; ps_rotation=-90; } } else if (pagesize==A3) { if (orientation==PORTRAIT) { maxx=A3X; maxy=A3Y; ps_rotation=0; } else { maxx=A3Y; maxy=A3X; ps_rotation=-90; } } else if (pagesize==USLETTER) { if (orientation==PORTRAIT) { maxx=USLETTERX; maxy=USLETTERY; ps_rotation=0; } else { maxx=USLETTERY; maxy=USLETTERX; ps_rotation=-90; } } if(show_curve) score_height=SCOREY; if(header) main_header=HEADER; else main_header=NOHEADER; ppix_width=maxx-LEFTMARGIN*2; ppix_height=maxy-main_header*CHARHEIGHT; /* get the name data */ GetPanelExtra(p.names,&name_data); /* get the sequence data */ GetPanelExtra(p.seqs,&seq_data); numseqs=seq_data.nseqs; nhead=seq_data.nhead; if(ruler) nfoot=seq_data.nfoot; else nfoot=seq_data.nfoot-1; numelines=nhead+nfoot+score_height+SEPARATION; /* check the block length, residue range parameters */ if(first_printres<=0) first_printres=1; if((last_printres<=0) || (last_printres>seq_data.ncols)) last_printres=seq_data.ncols; if(first_printres>last_printres) { error("Bad residue range - cannot write postscript"); return; } if (blength==0 || last_printres-first_printres+1=numseqs) { row++; break; } } footer_top = seq_top-row*CHARHEIGHT; /* show the footer lines */ for (i=0;i=last_printres) lr=last_printres-1; /* show the header lines */ for (i=0;i 0) { fprintf(fd,"%d %d %1.1f %1.1f %1.1f %d %d %1.1f %1.1f %1.1f white_inv\n", ps_x,ps_y,1.0,1.0,1.0,ps_x,ps_y,0.1,0.1,0.1); } else if(residue_exceptions && seq_data.residue_exception[seq][i] == TRUE) { fprintf(fd,"%d %d %1.1f %1.1f %1.1f %d %d %1.1f %1.1f %1.1f white_inv\n", ps_x,ps_y,1.0,1.0,1.0,ps_x,ps_y,0.4,0.4,0.4); } else { if(inverted) fprintf(fd,"%d %d %d %d %1.1f %1.1f %1.1f color_inv\n", ps_x,ps_y,ps_x,ps_y,red,green,blue); else fprintf(fd,"%d %d %1.1f %1.1f %1.1f color_char\n", ps_x,ps_y,red,green,blue); } } if(res_number>0) { ps_x = block_left + (lr-fr+1) * CHARWIDTH; ps_y = seq_top - (row * CHARHEIGHT); fprintf(fd,"%d %d moveto\n",ps_x,ps_y); fprintf(fd,"(%*d) show\n",MAXRESNO,res_number); } fprintf(fd,"\n"); }