/* dispn.c associated subroutines for matching sequences */ /* $Name: fa_34_26_5 $ - $Id: c_dispn.c,v 1.21 2005/10/25 20:22:52 wrp Exp $ */ #include #include #include #include #include "defs.h" #include "structs.h" #include "param.h" #define XTERNAL #define YES 1 #define NO 0 #define MAXOUT 201 /* the seqca[] array has the following codes: 0 - no alignment symbol 1 - align; pam < 0 2 - align; pam == 0 3 - align; pam > 0 4 - align; ident 5 - align; del the map_sym arrays determine the value to be displayed with each type of aligned residue */ static char *map_sym_0 =" ..: "; static char *map_sym_1 =" Xxx "; static char *map_sym_2 =" . "; #ifdef M10_CONS_L static char *map_sym_10=" mzp=-"; #else static char *map_sym_10=" ..:-"; #endif void discons(FILE *fd, struct mngmsg m_msg, struct pstruct pst, char *seqc0, char *seqc0a, char *seqc1, char *seqca, int nc, int n0, int n1, char *name0, char *name1, int nml, struct a_struct *aln, long loffset) { char line[3][MAXOUT], cline[2][MAXOUT+10], *clinep[2]; int il, i, lend, loff, id; int del0, del1, ic, ll0, ll1, ll01, cl0, cl1, rl0, rl1; int ic_save; char *map_sym_p; int l_llen; int ioff0, ioff00, ioff1, ioff10; long qqoff, lloff, qoffset; int llsgn, llfact, qlsgn, qlfact, qfx0, qfxn, lfx0, lfxn; int have_res; char *name01, *sq; char blank[MAX_UID], afmt[32]; memset(blank,' ',sizeof(blank)-1); blank[sizeof(blank)-1]='\0'; if (nml > 6) { blank[nml-6]='\0'; sprintf(afmt,"%%-%ds %%s\n",nml); } else { blank[0]='\0'; strncpy(afmt,"%-6s %s\n",sizeof(afmt)); } if (pst.ext_sq_set) sq = pst.sqx; else sq = pst.sq; clinep[0]=cline[0]+1; clinep[1]=cline[1]+1; if (aln->qlfact == 0) {qlfact = 1;} else qlfact = aln->qlfact; if (aln->qlrev == 1) { qoffset = n0; qlsgn = -1; qfx0 = 0; qfxn = 1; } else { qoffset = 0; qlsgn = 1; qfx0 = 1; qfxn = 0; } if (aln->llfact == 0) {llfact = 1;} else llfact = aln->llfact; if (aln->llrev == 1) { loffset += n1; llsgn = -1; lfx0 = 0; lfxn = 1; } else { llsgn = 1; lfx0 = 1; lfxn = 0; } l_llen = aln->llen; if ((m_msg.markx & MX_M9SUMM) && m_msg.show_code != 1) { l_llen += 40; } if ((m_msg.markx & MX_ATYPE)==2) name01=name1; else name01 = "\0"; ioff0=aln->smin0; ioff00 = ioff0; ioff1=aln->smin1; ioff10 = ioff1; if (m_msg.markx& MX_AMAP && (m_msg.markx & MX_ATYPE)==7) return; /* set *map_sym_p to correct match symbol */ if ((m_msg.markx&MX_ATYPE)==1) {map_sym_p = map_sym_1;} else if ((m_msg.markx&MX_ATYPE)==2) {map_sym_p = map_sym_2;} else if (m_msg.markx&MX_M10FORM) {map_sym_p = map_sym_10;} else {map_sym_p = map_sym_0;} if (m_msg.markx & MX_ASEP) { fprintf(fd,">%s ..\n",name0); for (i=0; i%s ..\n",name1); for (i=0; i%s ..\n",name0); fprintf(fd,"; sq_len: %d\n",n0); fprintf(fd,"; sq_offset: %ld\n",m_msg.sq0off); fprintf(fd,"; sq_type: %c\n",m_msg.sqtype[0]); fprintf(fd,"; al_start: %ld\n",aln->d_start0); fprintf(fd,"; al_stop: %ld\n",aln->d_stop0); fprintf(fd,"; al_display_start: %ld\n", qoffset+qlsgn*ioff0*aln->llmult+qfx0); have_res = 0; for (i=0; i%s ..\n",name1); fprintf(fd,"; sq_len: %d\n",n1); fprintf(fd,"; sq_type: %c\n",m_msg.sqtype[0]); fprintf(fd,"; al_start: %ld\n",aln->d_start1); fprintf(fd,"; al_stop: %ld\n",aln->d_stop1); fprintf(fd,"; al_display_start: %ld\n",loffset+llsgn*ioff1+lfx0); have_res = 0; for (i=0; iamax0 && i < nc; i++,id++) { if (seqc0[i] == '\0' || seqc1[i] == '\0') break; if (seqc0[i]=='-' || seqc0[i]==' ' || seqc0[i]=='\\') del0++; else if (seqc0[i]=='/') del0++; if (id-del0amin0) fputc(' ',fd); else if (seqc0[i]=='-'||seqc1[i]=='-') fputc('-',fd); else fputc(map_sym_10[seqca[i]],fd); if (i%50 == 49) fputc('\n',fd); } if ((i-1)%50!=49 || seqc1[i-1]==' ') fputc('\n',fd); #endif return; } memset(line[0],' ',MAXOUT); memset(line[1],' ',MAXOUT); memset(line[2],' ',MAXOUT); /* cl0 indicates whether a coordinate should be printed over the first sequence; cl1 indicates a coordinate for the second; */ ic = 0; del0=del1=0; for (il=0; il<(nc+l_llen-1)/l_llen; il++) { loff=il*l_llen; lend=min(l_llen,nc-loff); ll0 = NO; ll1 = NO; memset(cline[0],' ',MAXOUT+1); memset(cline[1],' ',MAXOUT+1); ic_save = ic; for (i=0; iframe + (long)llsgn*aln->llmult*ioff10 + (long)llsgn*llfact*(ioff1-del1-ioff10); if (cl1 && lloff%10 == 9) { sprintf(&clinep[1][i-lfxn],"%8ld",lloff+1l); clinep[1][i+8-lfxn]=' '; rl1 = NO; } else if (cl1 && lloff== -1) { sprintf(&clinep[1][i],"%8ld",0l); clinep[1][i+8-lfxn]=' '; rl1 = NO; } else if (rl1 && (lloff+1)%10 == 0) { sprintf(&clinep[1][i-lfxn],"%8ld",lloff+1); clinep[1][i+8-lfxn]=' '; } line[1][i] = ' '; if (ioff0-del0 >= aln->amin0 && ioff0-del0 <= aln->amax0) { if (seqca[ic]==4) {line[1][i]=map_sym_p[4];} else if ((m_msg.markx&MX_ATYPE)==2) line[1][i]=line[2][i]; else line[1][i] = map_sym_p[seqca[ic]]; } else if ((m_msg.markx&MX_ATYPE)==2) line[1][i]=line[2][i]; } if (m_msg.ann_flg) { for (ic=ic_save,i=0; ishowall || ll0)) ll1=0; fprintf(fd,"\n"); if (ll0) fprintf(fd,"%s%s\n",blank,clinep[0]); if (ll0) fprintf(fd,afmt,name0,line[0]); if (ll01) fprintf(fd,afmt,name01,line[1]); if (ll1) fprintf(fd,afmt,name1,line[2]); if (ll1) fprintf(fd,"%s%s\n",blank,clinep[1]); } } static float gscale= -1.0; void disgraph(FILE *fd, int n0,int n1, float percent, int score, int min0, int min1, int max0, int max1, long sq0off, char *name0, char *name1, int nml, int mlen, int markx) { int i, gstart, gstop, gend; int llen; char line[MAXOUT+1]; char afmt[16], afmtf[64]; if (nml > 6) { sprintf(afmt,"%%-%ds",nml); } else { strncpy(afmt,"%-6s",sizeof(afmt)); } strncpy(afmtf,afmt,sizeof(afmtf)); strncat(afmtf," %4ld-%4ld: %5.1f%%:%s:\n",sizeof(afmtf)); llen = mlen - 10; memset(line,' ',llen); line[llen-1]='\0'; if (gscale < 0.0) { gscale = (float)llen/(float)n0; if ((markx&MX_ATYPE) == 7 ) fprintf(fd,afmtf,name0,sq0off,sq0off+n0-1,100.0,line); } gstart = (int)(gscale*(float)min0+0.5); gstop = (int)(gscale*(float)max0+0.5); gend = gstop+(int)(gscale*(float)(n1-max1)); if (gstop >= llen) gstop = llen-1; if (gend >= llen) gend = llen-1; for (i=0; iqlrev == 1) { qoffset = sq0off -1 + n0; qlsgn = -1; qfx0 = 0; qfxn = 1; } else { qoffset = sq0off - 1; qlsgn = 1; qfx0 = 1; qfxn = 0; } if (aln->llrev == 1) { loffset += n1; llsgn = -1; lfx0 = 0; lfxn = 1; } else { llsgn = 1; lfx0 = 1; lfxn = 0; } aln->d_start0 = qoffset+qlsgn*aln->amin0+qfx0; aln->d_stop0 = qoffset+qlsgn*aln->amax0+qfxn; aln->d_start1 = loffset+llsgn*aln->amin1*aln->llmult+lfx0+aln->frame; aln->d_stop1 = loffset+llsgn*aln->amax1*aln->llmult+lfxn+aln->frame; }