#include #include #include #include #include "clustalw.h" #include "xmenu.h" static void RemoveWin(WindoW w); static void QuitWinW(WindoW w); static void QuitWinI(IteM i); static void QuitHelpW(WindoW w); static void QuitHelpB(ButtoN b); static void SearchStrWin (IteM item); static void SavePSSeqWin (IteM item); static void SavePSPrf1Win (IteM item); static void SavePSPrf2Win (IteM item); static void SaveSeqFileWin (IteM item); static void SavePrf1FileWin (IteM item); static void SavePrf2FileWin (IteM item); static void OpenColorParWin (IteM item); static void SearchStr(ButtoN but); static void SavePSSeqFile(ButtoN but); static void SavePSPrf1File(ButtoN but); static void SavePSPrf2File(ButtoN but); static void SaveSeqFile(ButtoN but); static void SavePrf1File(ButtoN but); static void SavePrf2File(ButtoN but); static void SaveScoresWin (IteM item); static void SaveScores(ButtoN but); static void OpenColorPar(ButtoN but); static void CancelWin(ButtoN but); static void SaveTreeWin (IteM item); static void CAlignWin (IteM item); static void RealignSeqsWin (IteM item); static void RealignSeqRangeWin (IteM item); static void DrawTreeWin (IteM item); static void AlignFromTreeWin(IteM item); static void PrfPrfAlignWin(IteM item); static void PrfPrfTreeAlignWin(IteM item); static void SeqPrfAlignWin(IteM item); static void SeqPrfTreeAlignWin(IteM item); static void BootstrapTreeWin (IteM item); static void CreateAlignTree(ButtoN but); static void CompleteAlign(ButtoN but); static void RealignSeqs(ButtoN but); static void RealignSeqRange(ButtoN but); static void DrawTree(ButtoN but); static void AlignFromTree(ButtoN but); static void PrfPrfAlign(ButtoN but); static void PrfPrfTreeAlign(ButtoN but); static void SeqPrfAlign(ButtoN but); static void SeqPrfTreeAlign(ButtoN but); static void BootstrapTree(ButtoN but); static void OpenSeqFile (IteM item); static void AppendSeqFile (IteM item); static void OpenPrf1File (IteM item); static void OpenPrf2File (IteM item); static void ScoreWin(IteM item); static void SegmentWin(IteM item); static void ScoreSegments(ButtoN but); static void PWParameters(IteM item); static void MultiParameters(IteM item); static void GapParameters(IteM item); static void SSParameters(IteM item); static void OutputParameters(IteM item); static void OutputTreeParameters(IteM item); static void HelpProc(IteM item); static void DefColorPar(IteM item); static void BlackandWhite(IteM item); static void set_reset_new_gaps(IteM i); static void set_reset_all_gaps(IteM i); static void SearchStringAgain(ButtoN but); static PopuP make_toggle(GrouP g,CharPtr title,CharPtr true_text, CharPtr false_text, Boolean *value,PupActnProc SetProc); static PrompT make_scale(GrouP g,CharPtr title,int length,int value,int max,BarScrlProc SetProc); static PrompT make_prompt(GrouP g,CharPtr title); static void CutSequences(IteM item); static void PasteSequences(IteM item); static void RemoveGaps(IteM item); static void RemoveGapPos(IteM item); static void SelectSeqs(IteM item); static void SelectPrf1(IteM item); static void SelectPrf2(IteM item); static void MergeProfiles(IteM item); static void ClearSeqs(IteM item); static void cut_multiplem(void); static void cut_profile1(void); static void cut_profile2(void); static void ssave(int j); static void sscpy(int i,int j); static void sload(int i); static void clear_seqrange(spanel p); static void select_seqs(spanel p,Boolean flag); static void clear_seg_exceptions(spanel p); static void make_menu_headers(WindoW w); static void make_help_menu(void); static void make_score_menu(void); static void make_file_menu(void); static void make_edit_menu(void); static void make_align_menu(void); static void make_tree_menu(void); static void make_color_menu(void); static void save_aln_window(int prf_no,char *title,char *prompt,void save_proc(ButtoN but)); static void save_ps_window(int prf_no,char *prompt,void save_proc(ButtoN but)); static void read_file_window(char *title,char *prompt,char *filename,void read_proc(ButtoN but)); static void do_align_window(WindoW *alignw,TexT *treetext,Boolean treestatus,char *title,void align_proc(ButtoN but)); static void do_palign_window(WindoW *alignw,TexT *tree1text,TexT *tree2test,Boolean treestatus,char *title,void align_proc(ButtoN but)); static Boolean open_aln_files(void); static void write_file(int fseq,int lseq,int fres,int lres); Boolean x_menus=FALSE; int mheader = 2; /* maximum header lines */ int mfooter = 1; /* maximum footer lines */ int max_mlines = 20; /* multiple align display length */ int min_mlines = 10; /* multiple align display length */ int max_plines = 8; /* profile align display length */ int min_plines1 = 5; /* profile align display length */ int min_plines2 = 3; /* profile align display length */ Boolean aln_mode = MULTIPLEM; Boolean window_displayed = FALSE; int save_format = CLUSTAL; Boolean fixed_prf_scroll = FALSE; int loffset,boffset,toffset; int roffset; int poffset; int score_cutoff=5; /* cutoff for residue exceptions */ int score_hwin=5; /* half window for summing alignment column scores */ int score_scale=5; int segment_dnascale=5; int length_cutoff=1; /* length cutoff for segment exceptions */ Boolean residue_exceptions=FALSE; Boolean segment_exceptions=FALSE; int score_matnum=4; char score_mtrxname[FILENAMELEN]; int segment_matnum=3; char segment_mtrxname[FILENAMELEN]; int score_dnamatnum=1; char score_dnamtrxname[FILENAMELEN]; int segment_dnamatnum=1; char segment_dnamtrxname[FILENAMELEN]; Boolean output_ss; Boolean output_gp; extern char revision_level[]; extern Boolean interactive; extern char seqname[]; extern char outfile_name[]; extern char profile1_name[]; extern char profile2_name[]; extern char usermtrxname[], pw_usermtrxname[]; extern char dnausermtrxname[], pw_dnausermtrxname[]; extern Boolean usemenu; extern Boolean use_tree_file; extern Boolean use_tree1_file,use_tree2_file; extern Boolean dnaflag; extern sint nseqs; extern sint profile1_nseqs; extern sint profile_no; extern sint max_aa; extern sint *seqlen_array; extern char **seq_array; extern char **names, **titles; extern Boolean empty; extern Boolean profile1_empty, profile2_empty; extern sint gap_pos1, gap_pos2; extern Boolean use_ambiguities; extern float gap_open, gap_extend; extern float dna_gap_open, dna_gap_extend; extern float prot_gap_open, prot_gap_extend; extern float pw_go_penalty, pw_ge_penalty; extern float dna_pw_go_penalty, dna_pw_ge_penalty; extern float prot_pw_go_penalty, prot_pw_ge_penalty; extern sint wind_gap,ktup,window,signif; extern sint dna_wind_gap, dna_ktup, dna_window, dna_signif; extern sint prot_wind_gap,prot_ktup,prot_window,prot_signif; extern sint helix_penalty; extern sint strand_penalty; extern sint loop_penalty; extern sint helix_end_minus; extern sint helix_end_plus; extern sint strand_end_minus; extern sint strand_end_plus; extern sint helix_end_penalty; extern sint strand_end_penalty; extern sint divergence_cutoff; extern sint gap_dist; extern sint boot_ntrials; /* number of bootstrap trials */ extern unsigned sint boot_ran_seed; /* random number generator seed */ extern sint matnum,pw_matnum; extern char mtrxname[], pw_mtrxname[]; extern sint dnamatnum,pw_dnamatnum; extern char dnamtrxname[], pw_dnamtrxname[]; extern MatMenu matrix_menu; extern MatMenu pw_matrix_menu; extern MatMenu dnamatrix_menu; extern Boolean quick_pairalign; extern sint matnum,pw_matnum; extern Boolean neg_matrix; extern float transition_weight; extern char hyd_residues[]; extern Boolean no_var_penalties, no_hyd_penalties, no_pref_penalties; extern Boolean use_endgaps; extern Boolean endgappenalties; extern Boolean output_clustal, output_nbrf, output_phylip, output_gcg, output_gde, output_nexus; extern Boolean save_parameters; extern Boolean output_tree_clustal, output_tree_phylip, output_tree_distances, output_tree_nexus; extern Boolean lowercase; /* Flag for GDE output - set on comm. line*/ extern Boolean cl_seq_numbers; extern sint output_order; extern sint *output_index; extern Boolean reset_alignments_new; /* DES */ extern Boolean reset_alignments_all; /* DES */ extern FILE *clustal_outfile, *gcg_outfile, *nbrf_outfile, *phylip_outfile; extern FILE *gde_outfile, *nexus_outfile; extern sint max_aln_length; extern Boolean tossgaps; /* Ignore places in align. where ANY seq. has a gap*/ extern Boolean kimura; /* Use correction for multiple substitutions */ extern sint bootstrap_format; /* bootstrap file format */ extern sint output_struct_penalties; extern Boolean use_ss1, use_ss2; extern char *res_cat1[]; extern char *res_cat2[]; extern char *amino_acid_codes; PrompT message; /* used in temporary message window */ static Char filename[FILENAMELEN]; /* used in temporary file selection window */ Boolean mess_output=TRUE; Boolean save_log=FALSE; FILE *save_log_fd=NULL; static char save_log_filename[FILENAMELEN]; static IteM save_item1,save_item2,exc_item; spanel seq_panel; /* data for multiple alignment area */ spanel prf_panel[2]; /* data for profile alignment areas */ spanel active_panel; /* 'in-use' panel -scrolling,clicking etc. */ static range selected_seqs; /* sequences selected by clicking on names */ static range selected_res; /* residues selected by clicking on seqs */ int firstres, lastres; /* range of alignment for saving as ... */ /* data for Search function */ char find_string[MAXFINDSTR]=""; aln_pos find_pos; /* arrays for storing clustalw data for cut-and-paste sequences */ static sint *saveseqlen_array=NULL; static char **saveseq_array=NULL; static char **savenames=NULL, **savetitles=NULL; sint ncutseqs=0; FonT datafont,helpfont; WindoW mainw=NULL; WindoW messagew=NULL; WindoW readfilew=NULL; WindoW savealnw=NULL; WindoW savescoresw=NULL; WindoW savepsw=NULL; WindoW findw=NULL; WindoW calignw=NULL; WindoW ralignw=NULL; WindoW rralignw=NULL; WindoW talignw=NULL; WindoW palignw=NULL; WindoW salignw=NULL; WindoW scorew=NULL; WindoW exceptionw=NULL; TexT savealntext; TexT savescorestext; TexT savepstext; TexT findtext; TexT pspartext; TexT ctreetext; TexT rtreetext; TexT rrtreetext; TexT ttreetext; TexT ptree1text,ptree2text; TexT streetext; TexT readfiletext; WindoW savetreew=NULL; TexT savetreetext; WindoW drawtreew=NULL; TexT drawnjtreetext; TexT drawphtreetext; TexT drawdsttreetext; TexT drawnxstreetext; WindoW boottreew=NULL; TexT bootnjtreetext; TexT bootphtreetext; TexT bootnxstreetext; TexT blocklentext; PrompT mattext,pwmattext,dnamattext,pwdnamattext,scoremattext,segmentmattext; PrompT scorednamattext,segmentdnamattext; GrouP seg_matrix_list,score_matrix_list; GrouP seg_dnamatrix_list,score_dnamatrix_list; GrouP matrix_list,pw_matrix_list,dnamatrix_list,pw_dnamatrix_list; TexT cl_outtext,pir_outtext,msf_outtext,phylip_outtext,gde_outtext,nexus_outtext; GrouP slow_para,fast_para; GrouP seq_display,prf1_display,prf2_display; MenU filem,alignm,editm,treem,colorm; menu_item file_item,align_item,edit_item,tree_item,color_item; MenU scorem,helpmenu; menu_item score_item,help_item; IteM segment_item; IteM bw_item,defcol_item,usercol_item; IteM new_gaps_item,all_gaps_item; WindoW helpw[MAXHELPW]; int numhelp=0; PopuP modetext,flisttext; ButtoN pscrolltext; PopuP show_seg_toggle; PrompT residue_cutofftext; PrompT length_cutofftext; PrompT scorescaletext; PrompT segmentdnascaletext; #define MAXFONTS 6 int nfonts=5; int av_font[MAXFONTS]={8,10,12,14,18}; int font_size=1; int ncolors=0; int ncolor_pars=0; color color_lut[MAXCOLORS+1]; char def_protpar_file[]="colprot.par"; char def_dnapar_file[]="coldna.par"; char *explicit_par_file = NULL; char *par_file = NULL; int inverted = TRUE; int usebw=FALSE,usedefcolors=TRUE,useusercolors=FALSE; char ps_par_file[FILENAMELEN]="colprint.par"; int pagesize=A4; int orientation=LANDSCAPE; Boolean ps_header=TRUE; Boolean ps_ruler=TRUE; Boolean resize=TRUE; int first_printres=0,last_printres=0,blocklen; Boolean ps_curve=TRUE; Boolean ps_resno=TRUE; PoinT display_pos; int namewidth,seqwidth; /* fixed widths of sequence display areas */ Boolean realign_endgappenalties=TRUE; Boolean align_endgappenalties=FALSE; char helptext[MAXHELPLENGTH]; /* main subroutine called from clustalx.c, initialises windows and enters a forever loop monitoring user input */ void x_menu(void) { int i,n; char font[30]; char tstr[30]; int height; PrompT fsize; RecT wr,r,r1; /* make the pulldown menu bar */ #ifdef WIN_MAC MenU m; m=AppleMenu (NULL); DeskAccGroup (m); make_menu_headers(NULL); #endif #ifndef UNIX ProcessUpdatesFirst(FALSE); #endif sprintf(tstr,"Clustal%s",revision_level); /*#ifdef WIN_MSWIN mainw = FixedWindow (-50,-33,-10,-10,tstr,QuitWinW); #else*/ mainw = DocumentWindow (-50,-33,-10,-10,tstr,QuitWinW,ResizeWindowProc); /*#endif*/ SetGroupSpacing(mainw,0,10); SetGroupSpacing(mainw,0,10); x_menus=TRUE; #ifndef WIN_MAC make_menu_headers(mainw); #endif /* decide if we're starting in profile or sequence mode */ if (!profile1_empty) aln_mode=PROFILEM; else aln_mode=MULTIPLEM; make_file_menu(); make_edit_menu(); make_align_menu(); make_tree_menu(); make_color_menu(); make_score_menu(); make_help_menu(); /* add a button to switch between multiple and profile alignment modes */ modetext=PopupList(mainw,TRUE,set_aln_mode); PopupItem(modetext,"Multiple Alignment Mode"); PopupItem(modetext,"Profile Alignment Mode"); if(aln_mode==MULTIPLEM) SetValue(modetext,1); else SetValue(modetext,2); sprintf(font, "%s,%d,%c", "courier", av_font[font_size], 'm'); datafont=ParseFont(font); sprintf(font, "%s,%d,%c", "courier", 10, 'm'); helpfont=ParseFont(font); Advance(mainw); shift(mainw,20,0); /* add a button to select font size */ fsize=StaticPrompt(mainw,"Font Size:",0,dialogTextHeight,systemFont,'r'); Advance(mainw); flisttext=PopupList(mainw,TRUE,set_font_size); for(i=0;in) seqwidth=n-namewidth; height=(max_mlines+mfooter+MARGIN)*stdLineHeight+2+SCOREHEIGHT; n=screenRect.bottom-screenRect.top; if(height>n) height=n; seq_display=make_scroll_area(mainw,0,namewidth,seqwidth,height,1,nseqs,&seq_panel); position_scrollbars(seq_panel); /* initialise the profile alignment display area */ SetNextPosition(mainw,display_pos); height=(max_plines+MARGIN)*stdLineHeight+2+SCOREHEIGHT; if(height>n) height=n; prf1_display=make_scroll_area(mainw,1,namewidth,seqwidth,height,1,profile1_nseqs,&prf_panel[0]); position_scrollbars(prf_panel[0]); prf2_display=make_scroll_area(mainw,2,namewidth,seqwidth,height,profile1_nseqs+1,nseqs-profile1_nseqs,&prf_panel[1]); position_scrollbars(prf_panel[1]); /* add the message line */ Break(mainw); Advance(mainw); SelectFont(systemFont); stdCharWidth=CharWidth('A'); stdLineHeight=LineHeight(); message = StaticPrompt(mainw, "",500, 0,systemFont,'l'); /* save some pixel sizes for future resizing events */ if(aln_mode==PROFILEM) { Hide(seq_display); profile_no=1; Show(prf1_display); Show(prf2_display); Show(pscrolltext); active_panel=prf_panel[0]; Select(prf1_display); load_aln(prf_panel[0],0,profile1_nseqs-1,TRUE); load_aln(prf_panel[1],profile1_nseqs,nseqs-1,TRUE); Show(mainw); ObjectRect(mainw,&wr); ObjectRect(prf_panel[0].names,&r); ObjectRect(prf_panel[1].names,&r1); boffset=wr.bottom-wr.top-r1.bottom; loffset=r.left; toffset=r.top; ObjectRect(prf_panel[0].seqs,&r); roffset=wr.right-wr.left-r.right; } else { Hide(prf1_display); Hide(prf2_display); Hide(pscrolltext); profile_no=0; Show(seq_display); active_panel=seq_panel; Select(seq_display); load_aln(seq_panel,0,nseqs-1,TRUE); Show(mainw); ObjectRect(mainw,&wr); ObjectRect(seq_panel.names,&r); boffset=wr.bottom-wr.top-r.bottom; loffset=r.left; toffset=r.top; ObjectRect(seq_panel.seqs,&r); roffset=wr.right-wr.left-r.right; } ObjectRect(prf_panel[0].names,&r); ObjectRect(prf_panel[1].names,&r1); poffset=r1.top-r.bottom; /* initialise some variables before we display the window */ if(orientation==LANDSCAPE) { if(pagesize==A4) blocklen=150; else if (pagesize==A3) blocklen=250; else blocklen=150; } else { if(pagesize==A4) blocklen=80; else if (pagesize==A3) blocklen=150; else blocklen=150; } /* ok - Go! */ window_displayed=TRUE; ProcessEvents(); } static void RemoveWin(WindoW w) { Remove(w); } static void QuitWinW(WindoW w) { if(aln_mode == MULTIPLEM) { if(seq_panel.modified) if (Message(MSG_YN,"Alignment has not been saved.\n" "Quit program anyway?")==ANS_NO) return; } else if(aln_mode == PROFILEM) { if(prf_panel[0].modified) if (Message(MSG_YN,"Profile 1 has not been saved.\n" "Quit program anyway?")==ANS_NO) return; if(prf_panel[1].modified) if (Message(MSG_YN,"Profile 2 has not been saved.\n" "Quit program anyway?")==ANS_NO) return; } QuitProgram (); } static void SearchStrWin (IteM item) { int i; Boolean sel=FALSE; GrouP findgr; ButtoN find_can,find_ok; PopuP ps,or; char path[FILENAMELEN]; char str[FILENAMELEN]; panel_data data; GetPanelExtra(active_panel.names,&data); if (data.nseqs==0) { Message(MSG_OK,"No file loaded."); return; } for (i=0;iseqlen_array[i] || (val == gap_pos1) || (val == gap_pos2)) c = '-'; else { c = amino_acid_codes[val]; } fprintf(outfile,"%c ",c); } } fprintf(outfile,"\t%3d\n",seq_data.colscore[j-1]); } } fclose(outfile); if (Visible(savescoresw)) { Remove(savescoresw); savescoresw=NULL; } info("File %s saved",filename); } static void SaveSeqFileWin (IteM item) { if (empty) { error("No file loaded"); return; } save_aln_window(0,"SAVE SEQUENCES","SAVE SEQUENCES AS:",SaveSeqFile); } static void SavePrf1FileWin (IteM item) { if (profile1_empty) { error("No file loaded"); return; } save_aln_window(1,"SAVE PROFILE","SAVE PROFILE 1 AS:",SavePrf1File); } static void SavePrf2FileWin (IteM item) { if (profile2_empty) { error("No file loaded"); return; } save_aln_window(2,"SAVE PROFILE","SAVE PROFILE 2 AS:",SavePrf2File); } static void save_aln_window(int prf_no,char *title,char *prompt,void save_proc(ButtoN but)) { GrouP savegr; ButtoN save_ok, save_can; GrouP maing; GrouP format_list; ButtoN formatb[6]; PopuP case_toggle,snos_toggle; char path[FILENAMELEN]; char str[FILENAMELEN]; SelectFont(systemFont); stdCharWidth=CharWidth('A'); stdLineHeight=LineHeight(); savealnw=FixedWindow(-50, -33, -10, -10, title,RemoveWin); format_list=NormalGroup(savealnw,3,0,"Format",systemFont,set_format); formatb[0]=RadioButton(format_list,"CLUSTAL"); formatb[1]=RadioButton(format_list,"NBRF/PIR"); formatb[2]=RadioButton(format_list,"GCG/MSF"); formatb[3]=RadioButton(format_list,"PHYLIP"); formatb[4]=RadioButton(format_list,"GDE"); formatb[5]=RadioButton(format_list,"NEXUS"); if(prf_no==0) get_path(seqname,path); else if(prf_no==1) get_path(profile1_name,path); else if(prf_no==2) get_path(profile2_name,path); if (save_format==CLUSTAL) { SetValue(format_list,1); strcat(path,"aln"); } else if (save_format==PIR) { SetValue(format_list,2); strcat(path,"pir"); } else if (save_format==MSF) { SetValue(format_list,3); strcat(path,"msf"); } else if (save_format==PHYLIP) { SetValue(format_list,4); strcat(path,"phy"); } else if (save_format==GDE) { SetValue(format_list,5); strcat(path,"gde"); } else if (save_format==NEXUS) { SetValue(format_list,6); strcat(path,"nxs"); } maing=HiddenGroup(savealnw,0,0,NULL); SetGroupSpacing(maing,0,10); case_toggle=make_toggle(maing,"GDE output case :","Lower","Upper",&lowercase,set_case); Break(maing); snos_toggle=make_toggle(maing,"CLUSTALW sequence numbers :","ON","OFF",&cl_seq_numbers,set_snos); Break(maing); make_prompt(maing, "Save from residue :"); Advance(maing); sprintf(str,"%5d",firstres); DialogText(maing, str, 5,set_fres); Advance(maing); make_prompt(maing, "to :"); Advance(maing); sprintf(str,"%5d",lastres); DialogText(maing, str, 5,set_lres); Break(maing); shift(savealnw, 0, 20); make_prompt(savealnw, prompt); stdLineHeight=18; SelectFont(programFont); Break(savealnw); savealntext=DialogText(savealnw, "", 35, NULL); Break(savealnw); savegr=HiddenGroup(savealnw, 2, 0, NULL); shift(savegr, 60, 20); save_ok=PushButton(savegr, " OK ", save_proc); shift(savegr, 20,0); save_can=PushButton(savegr, "CANCEL", CancelWin); SetTitle(savealntext, path); Show(savealnw); } static void read_file_window(char *title,char *prompt,char *filename,void read_proc(ButtoN but)) { GrouP readgr; ButtoN read_ok, read_can; GrouP maing; SelectFont(systemFont); stdCharWidth=CharWidth('A'); stdLineHeight=LineHeight(); readfilew=FixedWindow(-50, -33, -10, -10, title,RemoveWin); maing=HiddenGroup(readfilew,2,0,NULL); SetGroupSpacing(maing,0,10); shift(readfilew, 0, 20); make_prompt(readfilew, prompt); stdLineHeight=18; SelectFont(programFont); Break(readfilew); readfiletext=DialogText(readfilew, "", 35, NULL); if (filename != NULL) SetTitle(readfiletext, filename); Break(readfilew); readgr=HiddenGroup(readfilew, 2, 0, NULL); shift(readgr, 60, 20); read_ok=PushButton(readgr, " OK ", read_proc); shift(readgr, 20,0); read_can=PushButton(readgr, "CANCEL", CancelWin); Show(readfilew); } static void CancelWin (ButtoN but) { Remove(ParentWindow(but)); } static void SearchStr(ButtoN but) { /* reset the current position */ find_pos.seq=0; find_pos.res=-1; /* find the next occurrence of the string */ SearchStringAgain(but); } static void SearchStringAgain(ButtoN but) { int i,j,ix,length; int seq,res,start_res; Boolean in_string,found; panel_data ndata,sdata; GetTitle(findtext, filename, FILENAMELEN); stripspace(filename); strncpy(find_string,filename,MAXFINDSTR); length=strlen(find_string); if(length==0) return; for(i=0;i0) { if (Message(MSG_YN,"Replace existing sequences ?")==ANS_NO) return; } if (!GetInputFileName (filename,FILENAMELEN,"","")) return; strcpy(seqname,filename); GetPanelExtra(seq_panel.names,&data); data.nseqs=0; data.vseqs=0; SetPanelExtra(seq_panel.names,&data); GetPanelExtra(seq_panel.seqs,&data); data.nseqs=0; data.vseqs=0; SetPanelExtra(seq_panel.seqs,&data); n=seq_input(FALSE); if (n<=0) { info("File %s not loaded.",seqname); return; } load_aln(seq_panel,0,nseqs-1,TRUE); ncutseqs=0; info("File %s loaded.",seqname); } static void AppendSeqFile (IteM item) { int n; panel_data data; if (!GetInputFileName (filename,FILENAMELEN,"","")) return; strcpy(seqname,filename); GetPanelExtra(seq_panel.names,&data); data.nseqs=0; SetPanelExtra(seq_panel.names,&data); n=seq_input(TRUE); if (n<=0) { info("File %s not loaded.",seqname); return; } load_aln(seq_panel,0,nseqs-1,FALSE); info("File %s appended.",seqname); } static void OpenPrf1File (IteM item) { int i,j,n,tmpn=0,tmpfs; sint *tmplen_array; sint *tmpindex; char **tmp_array; char **tmpnames; char **tmptitles; panel_data data; if (profile1_nseqs>0) { if (Message(MSG_YN,"Replace existing sequences ?")==ANS_NO) return; } if (!GetInputFileName (filename,FILENAMELEN,"","")) return; if(!profile2_empty) { tmpn=nseqs-profile1_nseqs; tmpfs=profile1_nseqs; tmpnames=(char **)ckalloc((tmpn+1)*sizeof(char *)); tmptitles=(char **)ckalloc((tmpn+1)*sizeof(char *)); tmplen_array=(sint *)ckalloc((tmpn+1)*sizeof(sint)); tmpindex=(sint *)ckalloc((tmpn+1)*sizeof(sint)); tmp_array=(char **)ckalloc((tmpn+1)*sizeof(char *)); for(i=profile1_nseqs+1;i<=nseqs;i++) { tmpnames[i-profile1_nseqs-1]=(char *)ckalloc((MAXNAMES+2)*sizeof(char)); tmptitles[i-profile1_nseqs-1]=(char *)ckalloc((MAXTITLES+2)*sizeof(char)); strcpy(tmpnames[i-profile1_nseqs-1],names[i]); strcpy(tmptitles[i-profile1_nseqs-1],titles[i]); tmplen_array[i-profile1_nseqs-1]=seqlen_array[i]; tmpindex[i-profile1_nseqs-1]=output_index[i]-tmpfs+profile1_nseqs; tmp_array[i-profile1_nseqs-1]=(char *)ckalloc((seqlen_array[i]+2)*sizeof(char)); for(j=1;j<=seqlen_array[i];j++) tmp_array[i-profile1_nseqs-1][j]=seq_array[i][j]; } } strcpy(seqname,filename); GetPanelExtra(prf_panel[0].names,&data); data.nseqs=0; data.vseqs=0; SetPanelExtra(prf_panel[0].names,&data); GetPanelExtra(prf_panel[0].seqs,&data); data.nseqs=0; data.vseqs=0; SetPanelExtra(prf_panel[0].seqs,&data); profile_no = 1; n=profile_input(); if (n<=0) { info("File %s not loaded.",seqname); return; } strcpy(profile1_name,seqname); load_aln(prf_panel[0],0,profile1_nseqs-1,TRUE); if(tmpn!=0) { nseqs=tmpn+profile1_nseqs; realloc_aln(profile1_nseqs+1,nseqs); for(i=profile1_nseqs+1;i<=nseqs;i++) { names[i]=(char *)ckalloc((MAXNAMES+2)*sizeof(char)); titles[i]=(char *)ckalloc((MAXTITLES+2)*sizeof(char)); strcpy(names[i],tmpnames[i-profile1_nseqs-1]); ckfree(tmpnames[i-profile1_nseqs-1]); strcpy(titles[i],tmptitles[i-profile1_nseqs-1]); ckfree(tmptitles[i-profile1_nseqs-1]); seqlen_array[i]=tmplen_array[i-profile1_nseqs-1]; output_index[i]=tmpindex[i-profile1_nseqs-1]-tmpfs+profile1_nseqs; seq_array[i]=(char *)ckalloc((seqlen_array[i]+2)*sizeof(char)); for(j=1;j<=seqlen_array[i];j++) seq_array[i][j]=tmp_array[i-profile1_nseqs-1][j]; ckfree(tmp_array[i-profile1_nseqs-1]); } ckfree(tmpnames); ckfree(tmptitles); ckfree(tmplen_array); ckfree(tmpindex); ckfree(tmp_array); profile2_empty=FALSE; } load_aln(prf_panel[1],profile1_nseqs,nseqs-1,TRUE); ncutseqs=0; info("File %s loaded.",profile1_name); } static void OpenPrf2File (IteM item) { int n; panel_data data; if(profile1_empty) { error("You must load profile 1 first."); return; } if (nseqs>profile1_nseqs) { if (Message(MSG_YN,"Replace existing sequences ?")==ANS_NO) return; } if (!GetInputFileName (filename,FILENAMELEN,"","")) return; strcpy(seqname,filename); GetPanelExtra(prf_panel[1].names,&data); data.nseqs=0; data.vseqs=0; SetPanelExtra(prf_panel[1].names,&data); GetPanelExtra(prf_panel[1].seqs,&data); data.nseqs=0; data.vseqs=0; SetPanelExtra(prf_panel[1].seqs,&data); profile_no = 2; n=profile_input(); if (n<=0) { info("File %s not loaded.",seqname); return; } strcpy(profile2_name,seqname); ncutseqs=0; load_aln(prf_panel[1],profile1_nseqs,nseqs-1,TRUE); info("File %s loaded.",profile2_name); } static void BlackandWhite(IteM item) { ncolors=1; if (aln_mode == MULTIPLEM) color_seqs(); else { color_prf1(); color_prf2(); } usebw=TRUE; usedefcolors=FALSE; useusercolors=FALSE; SetStatus(bw_item,usebw); SetStatus(defcol_item,usedefcolors); SetStatus(usercol_item,useusercolors); info("Done."); } static void DefColorPar(IteM item) { if (explicit_par_file != NULL) ckfree(explicit_par_file); explicit_par_file=NULL; if(dnaflag) par_file=find_file(def_dnapar_file); else par_file=find_file(def_protpar_file); init_color_parameters(par_file); if (aln_mode == MULTIPLEM) color_seqs(); else { color_prf1(); color_prf2(); } usebw=FALSE; usedefcolors=TRUE; useusercolors=FALSE; SetStatus(bw_item,usebw); SetStatus(defcol_item,usedefcolors); SetStatus(usercol_item,useusercolors); info("Done."); } void set_reset_new_gaps(IteM i) { reset_alignments_new=GetStatus(i); if(reset_alignments_new==TRUE) { reset_alignments_all=FALSE; SetStatus(all_gaps_item,reset_alignments_all); } } void set_reset_all_gaps(IteM i) { reset_alignments_all=GetStatus(i); if(reset_alignments_all==TRUE) { reset_alignments_new=FALSE; SetStatus(new_gaps_item,reset_alignments_new); } } static void OpenColorParWin(IteM item) { read_file_window("Input Color File","COLOR PARAMETER FILE NAME:",explicit_par_file,OpenColorPar); } static void OpenColorPar(ButtoN but) { GetTitle(readfiletext, filename, FILENAMELEN); stripspace(filename); if (explicit_par_file != NULL) ckfree(explicit_par_file); explicit_par_file=(char *)ckalloc(FILENAMELEN*sizeof(char)); if (par_file != NULL) ckfree(par_file); par_file=(char *)ckalloc(FILENAMELEN*sizeof(char)); strcpy(explicit_par_file,filename); strcpy(par_file,filename); info("Loading color file: %s\n",par_file); init_color_parameters(par_file); if (Visible(readfilew)) { Remove(readfilew); readfilew=NULL; } if (aln_mode == MULTIPLEM) color_seqs(); else { color_prf1(); color_prf2(); } usebw=FALSE; usedefcolors=FALSE; useusercolors=TRUE; SetStatus(bw_item,usebw); SetStatus(defcol_item,usedefcolors); SetStatus(usercol_item,useusercolors); info("Done."); } static void RemoveGapPos(IteM item) { int i,j,sl; Boolean sel=FALSE; if (nseqs==0) { Message(MSG_OK,"No file loaded."); return; } if (Message(MSG_YN,"Remove positions that contain gaps in all sequences ?")==ANS_NO) return; if(aln_mode==MULTIPLEM) { remove_gap_pos(1,nseqs,0); load_aln(seq_panel,0,nseqs-1,FALSE); } else { remove_gap_pos(1,profile1_nseqs,1); load_aln(prf_panel[0],0,profile1_nseqs-1,FALSE); remove_gap_pos(profile1_nseqs+1,nseqs,2); load_aln(prf_panel[1],profile1_nseqs,nseqs-1,FALSE); } info("Gap positions removed."); } static void RemoveGaps(IteM item) { int i,j,sl; panel_data data; Boolean sel=FALSE; if (nseqs==0) { Message(MSG_OK,"No file loaded."); return; } GetPanelExtra(active_panel.names,&data); for (i=0;i0) { if (Message(MSG_YN,"The previously cut sequences will be lost.\nDo you want to continue?")==ANS_NO) return; } if (saveseqlen_array!=NULL) ckfree(saveseqlen_array); if (saveseq_array!=NULL) { for(i=0;i=data.nseqs) pos=data.nseqs-1; if(data.nseqs>0) data.selected[pos]=TRUE; SetPanelExtra(active_panel.names,&data); DrawPanel(active_panel.names); active_panel.modified=TRUE; info("Cut %d sequences.",ncutseqs); } static void cut_multiplem(void) { int i,j; panel_data data; GetPanelExtra(active_panel.names,&data); for (i=data.nseqs;i>0;i--) { if(data.selected[i-1]==TRUE) { ssave(i); for(j=i;j0) if(nseqs<=data.vseqs) load_aln(active_panel,0,nseqs-1,TRUE); else load_aln(active_panel,0,nseqs-1,FALSE); } static void cut_profile1(void) { int i,j; panel_data data; GetPanelExtra(active_panel.names,&data); for (i=data.nseqs;i>0;i--) { if(data.selected[i-1]==TRUE) { ssave(i); for(j=i;j0) { if(profile1_nseqs<=data.vseqs) load_aln(active_panel,0,profile1_nseqs-1,TRUE); else load_aln(active_panel,0,profile1_nseqs-1,FALSE); if (!profile2_empty) load_aln(prf_panel[1],profile1_nseqs,nseqs-1,FALSE); } } static void cut_profile2(void) { int i,j; panel_data data; GetPanelExtra(active_panel.names,&data); for (i=data.nseqs;i>0;i--) { if(data.selected[i-1]==TRUE) { ssave(i+profile1_nseqs); for(j=i+profile1_nseqs;j0) if(nseqs-profile1_nseqs<=data.vseqs) load_aln(active_panel,profile1_nseqs,nseqs-1,FALSE); else load_aln(active_panel,profile1_nseqs,nseqs-1,TRUE); } static void PasteSequences(IteM item) { int insert; int i,n; panel_data data; if (ncutseqs<=0) { Message(MSG_OK,"No sequences available for pasting.\n" " Cut selected sequences first."); return; } GetPanelExtra(active_panel.names,&data); n=ncutseqs; insert=-1; if (data.nseqs>0) { for(i=data.nseqs-1;i>=0;i--) if(data.selected[i]==TRUE) { insert=i; break; } if (insert==-1) { Message(MSG_OK,"Select a sequence by clicking on the name.\n" " Cut sequences will be pasted after this one."); return; } } if (data.prf_no == 2) { insert += profile1_nseqs; for(i=profile1_nseqs+data.nseqs;i>insert+1;i--) sscpy(i+ncutseqs,i); for(i=1;ncutseqs>0;i++) sload(insert+i+1); } else { for(i=nseqs;i>insert+1;i--) sscpy(i+ncutseqs,i); for(i=1;ncutseqs>0;i++) sload(insert+i+1); } if(data.prf_no==0) { nseqs=data.nseqs+n; if (nseqs>0) empty=FALSE; load_aln(seq_panel,0,nseqs-1,FALSE); } else if(data.prf_no==1) { profile1_nseqs=data.nseqs+n; nseqs+=n; if (profile1_nseqs>0) profile1_empty=FALSE; load_aln(active_panel,0,profile1_nseqs-1,FALSE); if (!profile2_empty) load_aln(prf_panel[1],profile1_nseqs,nseqs-1,FALSE); } else if(data.prf_no==2) { nseqs=profile1_nseqs+data.nseqs+n; if (profile1_nseqs0;i--) { if(data.selected[i-1]==TRUE) { ssave(i); for(j=i;jinsert+1;i--) sscpy(i+ncutseqs,i); for(i=1;ncutseqs>0;i++) sload(insert+i+1); nseqs=profile1_nseqs+n; /* align profile 2 sequences to profile 1 */ WatchCursor(); if (Visible(ralignw)) { Remove(ralignw); ralignw=NULL; } new_sequence_align(phylip_name); if(save_log && save_log_fd!=NULL) { fclose(save_log_fd); save_log_fd=NULL; } /* reload the sequences from the output file (so that the sequence order is correct - either INPUT or ALIGNED */ reload_alignment(); load_aln(seq_panel,0,nseqs-1,FALSE); GetPanelExtra(seq_panel.names,&data); for (i=0;imax_aln_length) max_aln_length=length1; length2=newlen_array[i]; seqlen_array[i]=length1; realloc_seq(i,length1); for(j=1;j<=data.firstsel;j++) seq_array[i][j]=tmp_array[i][j]; for(j=data.firstsel+1;j<=data.firstsel+length2;j++) seq_array[i][j]=new_array[i][j-data.firstsel]; for(j=data.firstsel+length2+1;j<=length1;j++) seq_array[i][j]=tmp_array[i][data.lastsel+j-data.firstsel-length2+1]; } max_aln_length*=2; ckfree(tmplen_array); for(i=1;i<=data.nseqs;i++) ckfree(tmp_array[i]); ckfree(tmp_array); ckfree(newlen_array); for(i=1;i<=data.nseqs;i++) ckfree(new_array[i]); ckfree(new_array); if (open_aln_files()) create_alignment_output(1,data.nseqs); load_aln(seq_panel,0,nseqs-1,FALSE); GetPanelExtra(seq_panel.seqs,&data); data.firstsel=fs; data.lastsel=data.firstsel+length2-1; SetPanelExtra(seq_panel.seqs,&data); highlight_seqrange(seq_panel.seqs,data.firstsel,data.lastsel,HIGHLIGHT); ArrowCursor(); info("Selected sequence range realigned."); } void AlignFromTreeWin(IteM item) { if (empty) { error("No sequences loaded"); return; } if (nseqs < 2) { error("Alignment has only %d sequences",nseqs); return; } do_align_window(&talignw,&ttreetext,OLD,"Alignment from Guide Tree",AlignFromTree); } static void do_align_window(WindoW *ralignw,TexT *rtreetext,Boolean treestatus,char *title,void align_proc(ButtoN but)) { WindoW alignw; TexT treetext; GrouP aligngr; GrouP output_list; ButtoN align_ok, align_can; GrouP maing; char name[FILENAMELEN+1]; char path[FILENAMELEN+1]; get_path(seqname,path); SelectFont(systemFont); stdCharWidth=CharWidth('A'); stdLineHeight=LineHeight(); alignw=FixedWindow(-50, -33, -10, -10,title,RemoveWin); maing=HiddenGroup(alignw,2,0,NULL); SetGroupSpacing(maing,0,10); if(treestatus==NEW) make_prompt(alignw, "Output Guide Tree File:"); else make_prompt(alignw, "Input Guide Tree File:"); stdLineHeight=18; SelectFont(programFont); Break(alignw); treetext=DialogText(alignw, "", 35, NULL); strcpy(name,path); strcat(name,"dnd"); SetTitle(treetext, name); Break(alignw); make_prompt(alignw, "Output Alignment Files:"); output_list=HiddenGroup(alignw, 2, 0, NULL); if(output_clustal) { make_prompt(output_list,"Clustal: "); cl_outtext=DialogText(output_list, "", 35, NULL); strcpy(name,path); strcat(name,"aln"); SetTitle(cl_outtext, name); Break(output_list); } if(output_nbrf) { make_prompt(output_list,"NBRF/PIR: "); pir_outtext=DialogText(output_list, "", 35, NULL); strcpy(name,path); strcat(name,"pir"); SetTitle(pir_outtext, name); Break(output_list); } if(output_gcg) { make_prompt(output_list,"GCG/MSF: "); msf_outtext=DialogText(output_list, "", 35, NULL); strcpy(name,path); strcat(name,"msf"); SetTitle(msf_outtext, name); Break(output_list); } if(output_phylip) { make_prompt(output_list,"Phylip: "); phylip_outtext=DialogText(output_list, "", 35, NULL); strcpy(name,path); strcat(name,"phy"); SetTitle(phylip_outtext, name); Break(output_list); } if(output_gde) { make_prompt(output_list,"GDE: "); gde_outtext=DialogText(output_list, "", 35, NULL); strcpy(name,path); strcat(name,"gde"); SetTitle(gde_outtext, name); Break(output_list); } if(output_nexus) { make_prompt(output_list,"Nexus: "); nexus_outtext=DialogText(output_list, "", 35, NULL); strcpy(name,path); strcat(name,"nxs"); SetTitle(nexus_outtext, name); Break(output_list); } Break(alignw); aligngr=HiddenGroup(alignw, 2, 0, NULL); shift(aligngr, 60, 20); align_ok=PushButton(aligngr, " ALIGN ", align_proc); shift(aligngr, 20,0); align_can=PushButton(aligngr, "CANCEL", CancelWin); *ralignw=alignw; *rtreetext=treetext; Show(alignw); } static void do_palign_window(WindoW *ralignw,TexT *rtree1text,TexT *rtree2text,Boolean treestatus,char *title,void align_proc(ButtoN but)) { Boolean istree=FALSE; WindoW alignw; TexT tree1text,tree2text; GrouP aligngr; GrouP output_list; ButtoN align_ok, align_can; GrouP maing; char name[FILENAMELEN+1]; char path[FILENAMELEN+1]; SelectFont(systemFont); stdCharWidth=CharWidth('A'); stdLineHeight=LineHeight(); alignw=FixedWindow(-50, -33, -10, -10,title,RemoveWin); maing=HiddenGroup(alignw,2,0,NULL); SetGroupSpacing(maing,0,10); if(treestatus==NEW) make_prompt(alignw, "Output Guide Tree Files:"); else make_prompt(alignw, "Input Guide Tree Files:"); stdLineHeight=18; SelectFont(programFont); Break(alignw); tree1text=DialogText(alignw, "", 35, NULL); get_path(profile1_name,path); strcpy(name,path); strcat(name,"dnd"); SetTitle(tree1text, name); Break(alignw); tree2text=DialogText(alignw, "", 35, NULL); get_path(profile2_name,path); strcpy(name,path); strcat(name,"dnd"); SetTitle(tree2text, name); Break(alignw); make_prompt(alignw, "Output Alignment Files:"); output_list=HiddenGroup(alignw, 2, 0, NULL); if(output_clustal) { make_prompt(output_list,"Clustal: "); cl_outtext=DialogText(output_list, "", 35, NULL); strcpy(name,path); strcat(name,"aln"); SetTitle(cl_outtext, name); Break(output_list); } if(output_nbrf) { make_prompt(output_list,"NBRF/PIR: "); pir_outtext=DialogText(output_list, "", 35, NULL); strcpy(name,path); strcat(name,"pir"); SetTitle(pir_outtext, name); Break(output_list); } if(output_gcg) { make_prompt(output_list,"GCG/MSF: "); msf_outtext=DialogText(output_list, "", 35, NULL); strcpy(name,path); strcat(name,"msf"); SetTitle(msf_outtext, name); Break(output_list); } if(output_phylip) { make_prompt(output_list,"Phylip: "); phylip_outtext=DialogText(output_list, "", 35, NULL); strcpy(name,path); strcat(name,"phy"); SetTitle(phylip_outtext, name); Break(output_list); } if(output_gde) { make_prompt(output_list,"GDE: "); gde_outtext=DialogText(output_list, "", 35, NULL); strcpy(name,path); strcat(name,"gde"); SetTitle(gde_outtext, name); Break(output_list); } if(output_nexus) { make_prompt(output_list,"Nexus: "); nexus_outtext=DialogText(output_list, "", 35, NULL); strcpy(name,path); strcat(name,"nxs"); SetTitle(nexus_outtext, name); Break(output_list); } Break(alignw); aligngr=HiddenGroup(alignw, 2, 0, NULL); shift(aligngr, 60, 20); align_ok=PushButton(aligngr, " ALIGN ", align_proc); shift(aligngr, 20,0); align_can=PushButton(aligngr, "CANCEL", CancelWin); *ralignw=alignw; *rtree1text=tree1text; *rtree2text=tree2text; Show(alignw); } void AlignFromTree(ButtoN but) { FILE *tree; char phylip_name[FILENAMELEN]; GetTitle(ttreetext, filename, FILENAMELEN); stripspace(filename); strcpy(phylip_name,filename); #ifdef VMS if((tree=fopen(phylip_name,"r","rat=cr","rfm=var"))==NULL) { #else if((tree=fopen(phylip_name,"r"))==NULL) { #endif error("Cannot open tree file [%s]",phylip_name); return; } if (!open_aln_files()) return; WatchCursor(); info("Doing alignments from guide tree..."); if (Visible(talignw)) { Remove(talignw); talignw=NULL; } get_tree(phylip_name); if(save_log && save_log_fd!=NULL) { fclose(save_log_fd); save_log_fd=NULL; } /* reload the sequences from the output file (so that the sequence order is correct - either INPUT or ALIGNED */ reload_alignment(); load_aln(seq_panel,0,nseqs-1,FALSE); ArrowCursor(); info("Done."); } static void PrfPrfAlignWin (IteM item) { if (profile1_empty) { error("Profile 1 not loaded"); return; } if (profile2_empty) { error("Profile 2 not loaded"); return; } do_palign_window(&palignw,&ptree1text,&ptree2text,NEW,"Profile to Profile Alignment",PrfPrfAlign); } static void PrfPrfTreeAlignWin (IteM item) { if (profile1_empty) { error("Profile 1 not loaded"); return; } if (profile2_empty) { error("Profile 2 not loaded"); return; } do_palign_window(&palignw,&ptree1text,&ptree2text,OLD,"Profile Alignment from Tree",PrfPrfTreeAlign); } static void SeqPrfAlignWin (IteM item) { if (profile1_empty) { error("Profile 1 not loaded"); return; } if (profile2_empty) { error("Profile 2 not loaded"); return; } do_align_window(&salignw,&streetext,NEW,"Sequence to Profile Alignment",SeqPrfAlign); } static void SeqPrfTreeAlignWin (IteM item) { if (profile1_empty) { error("Profile 1 not loaded"); return; } if (profile2_empty) { error("Profile 2 not loaded"); return; } do_align_window(&salignw,&streetext,OLD,"Sequence to Profile Alignment from Tree",SeqPrfTreeAlign); } static void PrfPrfAlign(ButtoN but) { char p1_tree_name[FILENAMELEN]; char p2_tree_name[FILENAMELEN]; GetTitle(ptree1text, filename, FILENAMELEN); stripspace(filename); use_tree1_file=FALSE; strcpy(p1_tree_name,filename); GetTitle(ptree2text, filename, FILENAMELEN); stripspace(filename); use_tree2_file=FALSE; strcpy(p2_tree_name,filename); if (!open_aln_files()) return; WatchCursor(); if (Visible(palignw)) { Remove(palignw); palignw=NULL; } profile_align(p1_tree_name,p2_tree_name); if(save_log && save_log_fd!=NULL) { fclose(save_log_fd); save_log_fd=NULL; } load_aln(prf_panel[0],0,profile1_nseqs-1,FALSE); load_aln(prf_panel[1],profile1_nseqs,nseqs-1,FALSE); ArrowCursor(); } static void PrfPrfTreeAlign(ButtoN but) { char p1_tree_name[FILENAMELEN]; char p2_tree_name[FILENAMELEN]; GetTitle(ptree1text, filename, FILENAMELEN); stripspace(filename); if(filename[0]!=EOS) use_tree1_file=TRUE; strcpy(p1_tree_name,filename); GetTitle(ptree2text, filename, FILENAMELEN); stripspace(filename); if(filename[0]!=EOS) use_tree2_file=TRUE; strcpy(p2_tree_name,filename); if (!open_aln_files()) return; WatchCursor(); if (Visible(palignw)) { Remove(palignw); palignw=NULL; } profile_align(p1_tree_name,p2_tree_name); if(save_log && save_log_fd!=NULL) { fclose(save_log_fd); save_log_fd=NULL; } load_aln(prf_panel[0],0,profile1_nseqs-1,FALSE); load_aln(prf_panel[1],profile1_nseqs,nseqs-1,FALSE); ArrowCursor(); } static void SeqPrfAlign(ButtoN but) { char phylip_name[FILENAMELEN]; GetTitle(streetext, filename, FILENAMELEN); stripspace(filename); strcpy(phylip_name,filename); use_tree_file=FALSE; if (!open_aln_files()) return; WatchCursor(); if (Visible(salignw)) { Remove(salignw); salignw=NULL; } new_sequence_align(phylip_name); if(save_log && save_log_fd!=NULL) { fclose(save_log_fd); save_log_fd=NULL; } /* reload the sequences from the output file (so that the sequence order is correct - either INPUT or ALIGNED */ reload_alignment(); load_aln(prf_panel[0],0,profile1_nseqs-1,FALSE); load_aln(prf_panel[1],profile1_nseqs,nseqs-1,FALSE); ArrowCursor(); } static void SeqPrfTreeAlign(ButtoN but) { char phylip_name[FILENAMELEN]; GetTitle(streetext, filename, FILENAMELEN); stripspace(filename); strcpy(phylip_name,filename); use_tree_file=TRUE; if (!open_aln_files()) return; WatchCursor(); if (Visible(salignw)) { Remove(salignw); salignw=NULL; } new_sequence_align(phylip_name); if(save_log && save_log_fd!=NULL) { fclose(save_log_fd); save_log_fd=NULL; } /* reload the sequences from the output file (so that the sequence order is correct - either INPUT or ALIGNED */ reload_alignment(); load_aln(prf_panel[0],0,profile1_nseqs-1,FALSE); load_aln(prf_panel[1],profile1_nseqs,nseqs-1,FALSE); ArrowCursor(); } void reload_alignment(void) { int i,k; sint *sseqlen_array; char **sseq_array; char **snames, **stitles; if (nseqs==0) return; if (output_order == INPUT) return; snames=(char **)ckalloc((nseqs+2) * sizeof(char *)); stitles=(char **)ckalloc((nseqs+2) * sizeof(char *)); sseq_array=(char **)ckalloc((nseqs+2) * sizeof(char *)); sseqlen_array=(sint *)ckalloc((nseqs+2) * sizeof(sint)); for (i=1;i<=nseqs;i++) { snames[i]=(char *)ckalloc((MAXNAMES+2)*sizeof(char)); stitles[i]=(char *)ckalloc((MAXTITLES+2)*sizeof(char)); sseq_array[i]=(char *)ckalloc((seqlen_array[output_index[i]]+2)*sizeof(char)); strcpy(snames[i],names[output_index[i]]); strcpy(stitles[i],titles[output_index[i]]); sseqlen_array[i]=seqlen_array[output_index[i]]; for(k=1;k<=seqlen_array[output_index[i]];k++) sseq_array[i][k]=seq_array[output_index[i]][k]; } for (i=1;i<=nseqs;i++) { strcpy(names[i],snames[i]); strcpy(titles[i],stitles[i]); seqlen_array[i]=sseqlen_array[i]; realloc_seq(i,seqlen_array[i]); for(k=1;k<=seqlen_array[i];k++) seq_array[i][k]=sseq_array[i][k]; output_index[i]=i; } ckfree(sseqlen_array); for(i=1;i<=nseqs;i++) ckfree(sseq_array[i]); ckfree(sseq_array); for(i=1;i<=nseqs;i++) ckfree(stitles[i]); ckfree(stitles); for(i=1;i<=nseqs;i++) ckfree(snames[i]); ckfree(snames); ncutseqs=0; } static void SegmentWin(IteM item) { WindoW w; GrouP maing; ButtoN closeb; GrouP mat_list; ButtoN matrixb[5]; SelectFont(systemFont); stdCharWidth=CharWidth('A'); stdLineHeight=LineHeight(); w=FixedWindow(-50, -33, -10, -10, "Low-Scoring Segment Parameters",RemoveWin); maing=HiddenGroup(w,0,0,NULL); SetGroupSpacing(maing,20,10); closeb=PushButton(maing, "CLOSE", CancelWin); Break(maing); /*PushButton(maing, "Calculate Low-Scoring Segments", calc_segment_exceptions); Break(maing);*/ length_cutofftext=make_scale(maing,"Minimum Length of Segments:",9,length_cutoff,19,set_lengthcutoff); Break(maing); segmentdnascaletext=make_scale(maing,"DNA Marking Scale:",9,segment_dnascale,9,set_segment_dnascale); if(!dnaflag) Disable(segmentdnascaletext); Break(maing); mat_list=NormalGroup(maing,4,0,"Protein Weight Matrix",systemFont,set_segment_matrix); matrixb[0]=RadioButton(mat_list,"Gonnet PAM 80"); matrixb[1]=RadioButton(mat_list,"Gonnet PAM 120"); matrixb[2]=RadioButton(mat_list,"Gonnet PAM 250"); matrixb[3]=RadioButton(mat_list,"Gonnet PAM 350"); matrixb[4]=RadioButton(mat_list,"User defined"); SetValue(mat_list,segment_matnum); seg_matrix_list=mat_list; Break(maing); PushButton(maing, "Load protein matrix: ", set_segment_user_matrix); Advance(maing); segmentmattext=StaticPrompt(maing,"", MAXPROMPTLEN, dialogTextHeight, systemFont, 'l'); SetTitle(segmentmattext,segment_mtrxname); Break(maing); mat_list=NormalGroup(maing,4,0,"DNA Weight Matrix",systemFont,set_segment_dnamatrix); matrixb[0]=RadioButton(mat_list,"IUB"); matrixb[1]=RadioButton(mat_list,"CLUSTALW(1.6)"); matrixb[2]=RadioButton(mat_list,"User defined"); SetValue(mat_list,segment_dnamatnum); seg_dnamatrix_list=matrix_list; Break(maing); PushButton(maing, "Load DNA matrix: ", set_segment_user_dnamatrix); Advance(maing); segmentdnamattext=StaticPrompt(maing,"", MAXPROMPTLEN, dialogTextHeight, systemFont, 'l'); SetTitle(segmentdnamattext,segment_dnamtrxname); Break(maing); Show(w); } static void ScoreWin(IteM item) { WindoW w; GrouP maing; ButtoN closeb; GrouP mat_list; PopuP show_exceptions; ButtoN matrixb[5]; SelectFont(systemFont); stdCharWidth=CharWidth('A'); stdLineHeight=LineHeight(); w=FixedWindow(-50, -33, -10, -10, "Score Parameters",RemoveWin); maing=HiddenGroup(w,0,0,NULL); SetGroupSpacing(maing,20,10); closeb=PushButton(maing, "CLOSE", CancelWin); Break(maing); /* add a scale to set the scaling value for the alignment scoring function */ scorescaletext=make_scale(maing,"Score Plot Scale:",9,score_scale,9,set_scorescale); Break(maing); residue_cutofftext=make_scale(maing,"Residue Exception Cutoff:",9,score_cutoff,9,set_scorecutoff); Break(maing); mat_list=NormalGroup(maing,4,0,"Protein Weight Matrix",systemFont,set_score_matrix); matrixb[0]=RadioButton(mat_list,"Identity"); matrixb[1]=RadioButton(mat_list,"Gonnet PAM 80"); matrixb[2]=RadioButton(mat_list,"Gonnet PAM 120"); matrixb[3]=RadioButton(mat_list,"Gonnet PAM 250"); matrixb[4]=RadioButton(mat_list,"Gonnet PAM 350"); matrixb[5]=RadioButton(mat_list,"User defined"); SetValue(mat_list,score_matnum); score_matrix_list=mat_list; Break(maing); PushButton(maing, "Load protein matrix: ", set_score_user_matrix); Advance(maing); scoremattext=StaticPrompt(maing,"", MAXPROMPTLEN, dialogTextHeight, systemFont, 'l'); SetTitle(scoremattext,score_mtrxname); Break(maing); mat_list=NormalGroup(maing,4,0,"DNA Weight Matrix",systemFont,set_score_dnamatrix); matrixb[0]=RadioButton(mat_list,"IUB"); matrixb[1]=RadioButton(mat_list,"CLUSTALW(1.6)"); matrixb[2]=RadioButton(mat_list,"User defined"); SetValue(mat_list,score_dnamatnum); score_dnamatrix_list=mat_list; Break(maing); PushButton(maing, "Load DNA matrix: ", set_score_user_dnamatrix); Advance(maing); scorednamattext=StaticPrompt(maing,"", MAXPROMPTLEN, dialogTextHeight, systemFont, 'l'); SetTitle(scorednamattext,score_dnamtrxname); Break(maing); Show (w); } static void PWParameters(IteM item) { int i; WindoW w; PoinT pt; GrouP maing; ButtoN closeb; TexT go_scale,ge_scale; TexT gp_scale,ktuple_scale,topdiags_scale,window_scale; PopuP fs_toggle; GrouP mat_list; ButtoN matrixb[5]; char str[FILENAMELEN]; if(dnaflag) { gap_open = dna_gap_open; gap_extend = dna_gap_extend; pw_go_penalty = dna_pw_go_penalty; pw_ge_penalty = dna_pw_ge_penalty; ktup = dna_ktup; window = dna_window; signif = dna_signif; wind_gap = dna_wind_gap; } else { gap_open = prot_gap_open; gap_extend = prot_gap_extend; pw_go_penalty = prot_pw_go_penalty; pw_ge_penalty = prot_pw_ge_penalty; ktup = prot_ktup; window = prot_window; signif = prot_signif; wind_gap = prot_wind_gap; } SelectFont(systemFont); stdCharWidth=CharWidth('A'); stdLineHeight=LineHeight(); w=FixedWindow(-50, -33, -10, -10, "Pairwise Parameters",RemoveWin); maing=HiddenGroup(w,0,0,NULL); SetGroupSpacing(maing,0,10); closeb=PushButton(maing, "CLOSE", CancelWin); Break(maing); fs_toggle=make_toggle(maing,"Pairwise Alignments :","Fast-Approximate","Slow-Accurate",&quick_pairalign,set_fs_toggle); Break(maing); GetNextPosition(maing,&pt); slow_para=NormalGroup(maing,0,0,"Pairwise Parameters",systemFont,NULL); SetGroupSpacing(slow_para,0,10); make_prompt(slow_para, "Gap Opening [0-100] :"); Advance(slow_para); sprintf(str,"%.2f",pw_go_penalty); go_scale=DialogText(slow_para, str, 5, set_pw_go_penalty); Break(slow_para); make_prompt(slow_para, "Gap Extension [0-100] :"); Advance(slow_para); sprintf(str,"%.2f",pw_ge_penalty); ge_scale=DialogText(slow_para, str, 5, set_pw_ge_penalty); Break(slow_para); mat_list=NormalGroup(slow_para,4,0,"Protein Weight Matrix",systemFont,set_pw_matrix); for(i=0;i 0) profile1_empty = FALSE; profile2_empty = TRUE; check_menus(file_item,MULTIPLEM); check_menus(align_item,MULTIPLEM); check_menus(edit_item,MULTIPLEM); check_menus(tree_item,MULTIPLEM); check_menus(color_item,MULTIPLEM); active_panel=prf_panel[0]; get_path(seqname,path); strcpy(profile1_name,path); strcat(profile1_name,"1."); strcpy(profile2_name,path); strcat(profile2_name,"2."); fix_gaps(); load_aln_data(prf_panel[0],0,profile1_nseqs-1,TRUE); load_aln_data(prf_panel[1],profile1_nseqs,nseqs-1,TRUE); Show(prf1_display); Show(prf2_display); Show(pscrolltext); } } static void make_menu_headers(WindoW w) { filem = PulldownMenu (w,"File"); editm = PulldownMenu (w,"Edit"); alignm = PulldownMenu (w,"Alignment"); treem = PulldownMenu(w,"Trees"); colorm = PulldownMenu(w,"Colors"); scorem = PulldownMenu(w,"Quality"); helpmenu = PulldownMenu(w,"Help"); } static void make_file_menu(void) { int n=0; file_item.mode[n] = MULTIPLEM; file_item.i[n] = CommandItem (filem,"Load Sequences", OpenSeqFile); n++; file_item.mode[n] = MULTIPLEM; file_item.i[n] = CommandItem (filem,"Append Sequences", AppendSeqFile); n++; file_item.mode[n] = MULTIPLEM; file_item.i[n] = CommandItem (filem,"Save Sequences as...", SaveSeqFileWin); n++; file_item.mode[n] = PROFILEM; file_item.i[n] = CommandItem (filem,"Load Profile 1", OpenPrf1File); n++; file_item.mode[n] = PROFILEM; file_item.i[n] = CommandItem (filem,"Load Profile 2", OpenPrf2File); n++; file_item.mode[n] = PROFILEM; file_item.i[n] = CommandItem (filem,"Save Profile 1 as...", SavePrf1FileWin); n++; file_item.mode[n] = PROFILEM; file_item.i[n] = CommandItem (filem,"Save Profile 2 as...", SavePrf2FileWin); n++; file_item.mode[n] = MULTIPLEM; file_item.i[n] = CommandItem (filem,"Write Alignment as PostScript", SavePSSeqWin); n++; file_item.mode[n] = PROFILEM; file_item.i[n] = CommandItem (filem,"Write Profile 1 as PostScript", SavePSPrf1Win); n++; file_item.mode[n] = PROFILEM; file_item.i[n] = CommandItem (filem,"Write Profile 2 as PostScript", SavePSPrf2Win); n++; file_item.i[n] = CommandItem (filem,"Quit", QuitWinI); n++; file_item.num = n; if(aln_mode==MULTIPLEM) check_menus(file_item,PROFILEM); else check_menus(file_item,MULTIPLEM); } static void QuitWinI (IteM i) { if(aln_mode == MULTIPLEM) { if(seq_panel.modified) if (Message(MSG_YN,"Alignment has not been saved.\n" "Quit program anyway?")==ANS_NO) return; } else if(aln_mode == PROFILEM) { if(prf_panel[0].modified) if (Message(MSG_YN,"Profile 1 has not been saved.\n" "Quit program anyway?")==ANS_NO) return; if(prf_panel[1].modified) if (Message(MSG_YN,"Profile 2 has not been saved.\n" "Quit program anyway?")==ANS_NO) return; } QuitProgram (); } static void make_score_menu(void) { int n=0; score_item.i[n] = CommandItem (scorem,"Calculate Low-Scoring Segments", calc_segment_exceptions); n++; segment_item=score_item.i[n]=StatusItem(scorem, "Show Low-Scoring Segments", set_show_segments); SetStatus(score_item.i[n],segment_exceptions); n++; score_item.i[n]=StatusItem(scorem, "Show Exceptional Residues", set_residue_exceptions); SetStatus(score_item.i[n],residue_exceptions); n++; score_item.i[n] = CommandItem (scorem,"Low-Scoring Segment Parameters",SegmentWin); n++; score_item.i[n] = CommandItem (scorem,"Column Score Parameters",ScoreWin); n++; score_item.mode[n] = MULTIPLEM; score_item.i[n]=CommandItem(scorem, "Save Column Scores to File", SaveScoresWin); n++; score_item.num = n; } static void make_help_menu(void) { int n=0; help_item.ptr[n] = 'G'; help_item.i[n] = CommandItem (helpmenu,"General",HelpProc); n++; help_item.ptr[n] = 'F'; help_item.i[n] = CommandItem (helpmenu,"Input & Output Files",HelpProc); n++; help_item.ptr[n] = 'E'; help_item.i[n] = CommandItem (helpmenu,"Editing Alignments",HelpProc); n++; help_item.ptr[n] = 'M'; help_item.i[n] = CommandItem (helpmenu,"Multiple Alignments",HelpProc); n++; help_item.ptr[n] = 'P'; help_item.i[n] = CommandItem (helpmenu,"Profile Alignments",HelpProc); n++; help_item.ptr[n] = 'B'; help_item.i[n] = CommandItem (helpmenu,"Secondary Structures",HelpProc); n++; help_item.ptr[n] = 'T'; help_item.i[n] = CommandItem (helpmenu,"Trees",HelpProc); n++; help_item.ptr[n] = 'C'; help_item.i[n] = CommandItem (helpmenu,"Colors",HelpProc); n++; help_item.ptr[n] = 'Q'; help_item.i[n] = CommandItem (helpmenu,"Alignment Quality",HelpProc); n++; help_item.ptr[n] = '9'; help_item.i[n] = CommandItem (helpmenu,"Command Line Parameters",HelpProc); n++; help_item.ptr[n] = 'R'; help_item.i[n] = CommandItem (helpmenu,"References",HelpProc); n++; help_item.num = n; } static void HelpProc(IteM item) { int n,index=-1; FILE *fd; int i, number, nlines; Boolean found_help; char temp[MAXLINE+1]; char token; char *digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; char *help_marker = ">>HELP"; TexT htext; char *help_file = NULL; extern char *help_file_name; helptext[0]='\0'; for(n=0;nMAXHELPLENGTH) break; for(i=strlen(temp)-1;i>=0;i--) if(iscntrl(temp[i])||isspace(temp[i])) temp[i]='\0'; else break; /* ignore lines starting with < - these are for html output processing */ if(temp[0]!='<') { strcat(helptext,temp); #ifdef WIN_MAC strcat(helptext,"\r"); #else #ifdef WIN32 strcat(helptext,"\r\n"); #else strcat(helptext,"\n"); #endif #endif ++nlines; } } fclose(fd); #ifdef WIN_MAC if(numhelp>=1) #else if(numhelp>=MAXHELPW) #endif { error("Too many help windows"); return; } numhelp++; helpw[numhelp]=FixedWindow(-50, -33, -10, -10, "", QuitHelpW); SelectFont(helpfont); #ifdef WIN_MAC htext=ScrollText(helpw[numhelp], 60, 20, helpfont, TRUE, NULL); #else htext=ScrollText(helpw[numhelp], 80, 30, helpfont, TRUE, NULL); #endif Break(helpw[numhelp]); PushButton(helpw[numhelp], "OK", QuitHelpB); SetTitle(htext, helptext); Show(helpw[numhelp]); return; } } } } void QuitHelpB(ButtoN b) { Remove(ParentWindow(b)); numhelp--; } void QuitHelpW(WindoW w) { Remove(w); numhelp--; } static void make_edit_menu(void) { int n=0; edit_item.i[n] = CommandItem (editm,"Cut Sequences", CutSequences); n++; edit_item.i[n] = CommandItem (editm,"Paste Sequences", PasteSequences); n++; edit_item.mode[n] = MULTIPLEM; edit_item.i[n] = CommandItem (editm,"Select All Sequences", SelectSeqs); n++; edit_item.mode[n] = PROFILEM; edit_item.i[n] = CommandItem (editm,"Select Profile 1", SelectPrf1); n++; edit_item.mode[n] = PROFILEM; edit_item.i[n] = CommandItem (editm,"Select Profile 2", SelectPrf2); n++; edit_item.mode[n] = PROFILEM; edit_item.i[n] = CommandItem (editm,"Add Profile 2 to Profile 1", MergeProfiles); n++; edit_item.i[n] = CommandItem (editm,"Clear Sequence Selection",ClearSeqs); n++; edit_item.i[n] = CommandItem (editm,"Clear Range Selection",ClearSeqRange); n++; SeparatorItem(editm); edit_item.i[n] = CommandItem (editm,"Search for String", SearchStrWin); n++; SeparatorItem(editm); edit_item.i[n] = CommandItem (editm,"Remove All Gaps", RemoveGaps); n++; edit_item.i[n] = CommandItem (editm,"Remove Gap-Only Columns", RemoveGapPos); n++; edit_item.num = n; if(aln_mode==MULTIPLEM) check_menus(edit_item,PROFILEM); else check_menus(edit_item,MULTIPLEM); } static void make_align_menu(void) { MenU parasm; int n=0; align_item.mode[n] = MULTIPLEM; align_item.i[n] = CommandItem (alignm,"Do Complete Alignment",CAlignWin); n++; align_item.mode[n] = MULTIPLEM; align_item.i[n] = CommandItem (alignm,"Produce Guide Tree Only",SaveTreeWin); n++; align_item.mode[n] = MULTIPLEM; align_item.i[n] = CommandItem (alignm,"Do Alignment from Guide Tree",AlignFromTreeWin); n++; SeparatorItem(alignm); align_item.mode[n] = MULTIPLEM; align_item.i[n] = CommandItem (alignm,"Realign Selected Sequences",RealignSeqsWin); n++; align_item.mode[n] = MULTIPLEM; align_item.i[n] = CommandItem (alignm,"Realign Selected Residue Range",RealignSeqRangeWin); n++; align_item.mode[n] = PROFILEM; align_item.i[n] = CommandItem (alignm,"Align Profile 2 to Profile 1",PrfPrfAlignWin); n++; align_item.mode[n] = PROFILEM; align_item.i[n] = CommandItem (alignm,"Align Profiles from Guide Trees",PrfPrfTreeAlignWin); n++; align_item.mode[n] = PROFILEM; align_item.i[n] = CommandItem (alignm,"Align Sequences to Profile 1",SeqPrfAlignWin); n++; align_item.mode[n] = PROFILEM; align_item.i[n] = CommandItem (alignm,"Align Sequences to Profile 1 from Tree",SeqPrfTreeAlignWin); n++; SeparatorItem(alignm); parasm=SubMenu(alignm,"Alignment Parameters"); new_gaps_item=align_item.i[n]=StatusItem(parasm, "Reset New Gaps before Alignment", set_reset_new_gaps); SetStatus(align_item.i[n],reset_alignments_new); n++; all_gaps_item=align_item.i[n]=StatusItem(parasm, "Reset All Gaps before Alignment", set_reset_all_gaps); SetStatus(align_item.i[n],reset_alignments_all); n++; align_item.i[n] = CommandItem (parasm,"Pairwise Alignment Parameters",PWParameters); n++; align_item.i[n] = CommandItem (parasm,"Multiple Alignment Parameters",MultiParameters); n++; align_item.i[n] = CommandItem (parasm,"Protein Gap Parameters",GapParameters); n++; align_item.mode[n] = PROFILEM; align_item.i[n] = CommandItem (parasm,"Secondary Structure Parameters",SSParameters); n++; align_item.i[n]=StatusItem(alignm, "Save Log File", set_save_log); save_item1=align_item.i[n]; SetStatus(save_item1,save_log); n++; align_item.i[n] = CommandItem (alignm,"Output Format Options",OutputParameters); n++; align_item.num = n; if(aln_mode==MULTIPLEM) check_menus(align_item,PROFILEM); else check_menus(align_item,MULTIPLEM); } void set_save_log(IteM i) { save_log=GetStatus(i); SetStatus(save_item1,save_log); SetStatus(save_item2,save_log); } static void make_tree_menu(void) { int n=0; tree_item.mode[n] = MULTIPLEM; tree_item.i[n] = CommandItem (treem,"Draw N-J Tree",DrawTreeWin); n++; tree_item.mode[n] = MULTIPLEM; tree_item.i[n] = CommandItem (treem,"Bootstrap N-J Tree",BootstrapTreeWin); n++; SeparatorItem(treem); tree_item.mode[n] = MULTIPLEM; tree_item.i[n]=StatusItem(treem, "Exclude Positions with Gaps", set_tossgaps); SetStatus(tree_item.i[n],tossgaps); n++; tree_item.mode[n] = MULTIPLEM; tree_item.i[n]=StatusItem(treem, "Correct for Multiple Substitutions", set_kimura); SetStatus(tree_item.i[n],kimura); n++; SeparatorItem(treem); tree_item.mode[n] = MULTIPLEM; tree_item.i[n]=StatusItem(treem, "Save Log File", set_save_log); save_item2=tree_item.i[n]; SetStatus(save_item2,save_log); n++; tree_item.mode[n] = MULTIPLEM; tree_item.i[n] = CommandItem (treem,"Output Format Options",OutputTreeParameters); n++; tree_item.mode[n] = MULTIPLEM; tree_item.num = n; if(aln_mode==MULTIPLEM) check_menus(tree_item,PROFILEM); else check_menus(tree_item,MULTIPLEM); } static void make_color_menu(void) { int n=0; color_item.i[n]=StatusItem(colorm, "Background Coloring", set_inverted); SetStatus(color_item.i[n],inverted); n++; SeparatorItem(colorm); bw_item=color_item.i[n] = StatusItem (colorm,"Black and White",BlackandWhite); SetStatus(color_item.i[n],usebw); n++; defcol_item=color_item.i[n] = StatusItem (colorm,"Default Colors",DefColorPar); SetStatus(color_item.i[n],usedefcolors); n++; usercol_item=color_item.i[n] = StatusItem (colorm,"Load Color Parameter File",OpenColorParWin); SetStatus(color_item.i[n],useusercolors); n++; color_item.num = n; } void check_menus(menu_item m,int mode) { int i; for (i=0;i