📄 xmenu.c
字号:
} SetValue(flisttext,font_size+1); Advance(mainw); shift(mainw,20,0); /* ramu ......... selFonts = PushButton(mainw,"Select Fonts",VSeqMgrFontProc); Advance(mainw); shift(mainw,20,0); end ramu ........... *//* add a button to switch profile scrolling modes */ pscrolltext=CheckBox(mainw,"Lock Scroll",set_pscroll_mode); if(fixed_prf_scroll) SetStatus(pscrolltext,TRUE); Break(mainw); selected_seqs.first=selected_seqs.last=-1; selected_res.first=selected_res.last=-1;/* initialise the multiple alignment display area */ SelectFont(datafont); stdCharWidth=CharWidth('A'); stdLineHeight=LineHeight(); GetNextPosition(mainw,&display_pos);/* calculate initial pixel width and height of displays */ namewidth=(DNAMES+DNUMBER+1)*stdCharWidth; seqwidth=(DCOLS+2*MARGIN)*stdCharWidth+2; n=screenRect.right-screenRect.left; if(seqwidth+namewidth>n) 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+20,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;i<data.nseqs;i++) if(data.selected[i]==TRUE) { sel=TRUE; break; } if(sel==FALSE) { Message(MSG_OK,"Select sequences by clicking on the names."); return; } SelectFont(systemFont); stdCharWidth=CharWidth('A'); stdLineHeight=LineHeight(); findw=FixedWindow(-50, -33, -10, -10, "SEARCH IN SELECTED SEQUENCES",RemoveWin); stdLineHeight=18; SelectFont(programFont); findtext=DialogText(findw, "", 35, NULL); Break(findw); find_ok=PushButton(findw, "SEARCH FROM START", SearchStr); Break(findw); find_ok=PushButton(findw, "SEARCH AGAIN", SearchStringAgain); Break(findw); find_can=PushButton(findw, "CLOSE", CancelWin); Show(findw);}static void SavePSSeqWin (IteM item){ if (empty) { error("No file loaded"); return; } save_ps_window(0,"WRITE SEQUENCES TO:",SavePSSeqFile);}static void SavePSPrf1Win (IteM item){ if (profile1_empty) { error("No file loaded"); return; } save_ps_window(1,"WRITE PROFILE 1 TO:",SavePSPrf1File);}static void SavePSPrf2Win (IteM item){ if (profile2_empty) { error("No file loaded"); return; } save_ps_window(2,"WRITE PROFILE 2 TO:",SavePSPrf2File);}static void save_ps_window(int prf_no,char *prompt,void save_proc(ButtoN but)){ GrouP savegr; ButtoN save_can,save_ok; PopuP ps,or; char path[FILENAMELEN]; char str[FILENAMELEN]; panel_data data; SelectFont(systemFont); stdCharWidth=CharWidth('A'); stdLineHeight=LineHeight(); savepsw=FixedWindow(-50, -33, -10, -10, "WRITE POSTSCRIPT FILE",RemoveWin); make_prompt(savepsw, prompt); stdLineHeight=18; SelectFont(programFont); savepstext=DialogText(savepsw, "", 35, NULL); Break(savepsw); make_prompt(savepsw, "PS Colors File :"); pspartext=DialogText(savepsw, ps_par_file, 35, NULL); Break(savepsw); make_prompt(savepsw, "Page Size"); Advance(savepsw); ps=PopupList(savepsw,TRUE,set_pagesize); PopupItem(ps,"A4"); PopupItem(ps,"A3"); PopupItem(ps,"US Letter"); if (pagesize == A4) SetValue(ps,1); else if (pagesize == A3) SetValue(ps,2); else if (pagesize == USLETTER) SetValue(ps,3); Break(savepsw); make_prompt(savepsw, "Orientation"); Advance(savepsw); or=PopupList(savepsw,TRUE,set_orientation); PopupItem(or,"LANDSCAPE"); PopupItem(or,"PORTRAIT"); if (orientation == LANDSCAPE) SetValue(or,1); else if (orientation == PORTRAIT) SetValue(or,2); Break(savepsw); make_toggle(savepsw,"Print Header :","YES","NO",&ps_header,set_header); Advance(savepsw); make_toggle(savepsw,"Print Quality Curve :","YES","NO",&ps_curve,set_curve); Break(savepsw); make_toggle(savepsw,"Print Ruler :","YES","NO",&ps_ruler,set_ruler); Advance(savepsw); make_toggle(savepsw,"Print Residue Numbers :","YES","NO",&ps_resno,set_resno); Break(savepsw); make_toggle(savepsw,"Resize to fit page:","YES","NO",&resize,set_resize); Break(savepsw); first_printres=1; if (prf_no==0) GetPanelExtra(seq_panel.seqs,&data); else if (prf_no==1) GetPanelExtra(prf_panel[0].seqs,&data); else GetPanelExtra(prf_panel[1].seqs,&data); last_printres=data.ncols; make_prompt(savepsw, "Print from position :"); Advance(savepsw); sprintf(str,"%5d",first_printres); DialogText(savepsw, str, 5,set_fpres); Advance(savepsw); make_prompt(savepsw, "to :"); Advance(savepsw); sprintf(str,"%5d",last_printres); DialogText(savepsw, str, 5,set_lpres); Break(savepsw); make_prompt(savepsw, "Use block length :"); Advance(savepsw); sprintf(str,"%5d",blocklen); blocklentext=DialogText(savepsw, str, 5,set_blocklen); Break(savepsw); savegr=HiddenGroup(savepsw, 2, 0, NULL); shift(savegr, 60, 20); save_ok=PushButton(savegr, " OK ", save_proc); shift(savegr, 20,0); save_can=PushButton(savegr, "CLOSE", CancelWin); 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); strcat(path,"ps"); SetTitle(savepstext, path); Show(savepsw);}static void SaveScoresWin (IteM item){ int i; Boolean sel=FALSE; GrouP scoregr; ButtoN score_can,score_ok; PopuP ps,or; char path[FILENAMELEN]; char str[FILENAMELEN]; panel_data data; if (empty) { error("No file loaded"); return; } GetPanelExtra(active_panel.names,&data); for (i=0;i<data.nseqs;i++) if(data.selected[i]==TRUE) { sel=TRUE; break; } if(sel==FALSE) { Message(MSG_OK,"Select sequences to be written by clicking on the names."); return; } get_path(seqname,path); strcat(path,"qscores"); SelectFont(systemFont); stdCharWidth=CharWidth('A'); stdLineHeight=LineHeight(); savescoresw=FixedWindow(-50, -33, -10, -10, "SAVE QUALITY SCORES",RemoveWin); stdLineHeight=18; SelectFont(programFont); make_prompt(savescoresw, "SAVE QUALITY SCORES TO:"); stdLineHeight=18; SelectFont(programFont); Break(savescoresw); savescorestext=DialogText(savescoresw, "", 35, NULL); Break(savescoresw); scoregr=HiddenGroup(savescoresw, 2, 0, NULL); shift(scoregr, 60, 20); score_ok=PushButton(scoregr, " OK ", SaveScores); shift(scoregr, 20,0); score_can=PushButton(scoregr, "CANCEL", CancelWin); SetTitle(savescorestext, path); Show(savescoresw); Advance(savescoresw); Show(savescoresw);}static void SaveScores(ButtoN but){ char c; int i,j,val; int length=0; FILE *outfile; panel_data name_data,seq_data; Boolean gap; GetPanelExtra(active_panel.names,&name_data); GetPanelExtra(active_panel.seqs,&seq_data); GetTitle(savescorestext, filename, FILENAMELEN); stripspace(filename); outfile=open_explicit_file(filename); /* get the maximum length of the selected sequences */ for (i=1;i<=nseqs;i++) if (name_data.selected[i-1]==TRUE && length < seqlen_array[i]) length = seqlen_array[i]; for(j=1;j<=length;j++) {/* first check for a column of gaps */ gap=TRUE; for (i=1;i<=nseqs;i++) if (name_data.selected[i-1]==TRUE) { val = seq_array[i][j]; if(j<=seqlen_array[i] && (val != gap_pos1) && (val != gap_pos2)) { gap=FALSE; break; } } if(gap==FALSE) { for (i=1;i<=nseqs;i++) { if (name_data.selected[i-1]==TRUE) { val = seq_array[i][j]; if(j>seqlen_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+1]; /* + 1 for fasta */ PopuP case_toggle,snos_toggle; PopuP seqRange_toggle; /* Ramu */ char path[FILENAMELEN+1]; char str[FILENAMELEN+1]; 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"); formatb[6]=RadioButton(format_list,"FASTA"); 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) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -