int main(int argc, char **argv) { AjPSeq seq = NULL; AjPStr strand = NULL; AjPStr substr = NULL; AjPStr squares = NULL; AjPStr diamonds = NULL; AjPStr octags = NULL; AjBool amphipathic; AjPStr txt = NULL; AjPGraph graph = NULL; ajint begin; ajint end; ajint lc; ajint i; ajint j; ajint r; ajint count; ajint pstart; ajint pstop; float xmin = 0.0; float xmax = 150.0; float ymin = 0.0; float ymax = 112.5; float xstart; float ystart; float ch = (float)1.8; float xinc; float yinc; AjPStr fstr = NULL; float x; float y; embInit("pepnet", argc, argv); seq = ajAcdGetSeq("sequence"); graph = ajAcdGetGraph("graph"); octags = ajAcdGetString("octags"); squares = ajAcdGetString("squares"); diamonds = ajAcdGetString("diamonds"); amphipathic = ajAcdGetToggle("amphipathic"); ajStrFmtUpper(&octags); ajStrFmtUpper(&squares); ajStrFmtUpper(&diamonds); if(amphipathic) { ajStrAssignC(&squares,"ACFGILMVWY"); ajStrAssignC(&diamonds,""); ajStrAssignC(&octags,""); } substr = ajStrNew(); txt = ajStrNew(); fstr = ajStrNew(); begin = ajSeqGetBegin(seq); end = ajSeqGetEnd(seq); strand = ajSeqGetSeqCopyS(seq); ajStrFmtUpper(&strand); ajStrAssignSubC(&substr,ajStrGetPtr(strand),begin-1,end-1); ajGraphAppendTitleS(graph, ajSeqGetUsaS(seq)); ajGraphOpenWin(graph, xmin,xmax,ymin,ymax); for(count=begin-1,r=0;count<end;count+=231) { if (count > begin) ajGraphNewpage(graph, ajFalse); pstart=count; pstop = AJMIN(end-1, count+230); ajGraphicsSetCharscale(0.75); xstart = 145.0; ystart = 80.0; yinc = ch * (float)2.5; xinc = yinc / (float)2.5; x = xstart; for(i=pstart;i<=pstop;i+=7) { lc = i; if(x < 10.0*xinc) { x = xstart; ystart -= (float)7.5*yinc; } y=ystart; ajFmtPrintS(&txt,"%d",i+1); ajGraphicsSetFgcolour(RED); ajGraphicsDrawposTextJustify(x-xinc,y-yinc-1,ajStrGetPtr(txt),0.5); for(j=0;j<4;++j) { x -= xinc; y += yinc; if(lc <= pstop) pepnet_plotresidue(*(ajStrGetPtr(substr)+r),x,y, ajStrGetPtr(squares),ajStrGetPtr(octags), ajStrGetPtr(diamonds)); ++r; ++lc; } y=ystart+yinc/(float)2.0; for(j=4;j<7;++j) { x -= xinc; y += yinc; if(lc <= pstop) pepnet_plotresidue(*(ajStrGetPtr(substr)+r),x,y, ajStrGetPtr(squares),ajStrGetPtr(octags), ajStrGetPtr(diamonds)); ++r; ++lc; } } } ajGraphicsClose(); ajGraphxyDel(&graph); ajStrDel(&strand); ajStrDel(&fstr); ajSeqDel(&seq); ajStrDel(&substr); ajStrDel(&squares); ajStrDel(&diamonds); ajStrDel(&octags); ajStrDel(&txt); embExit(); return 0; }
static PSilent silent_checktrans(const AjPStr seq,const EmbPMatMatch match, const PRinfo rlp, ajint begin, ajint radj, AjBool rev, ajint end) { PSilent ret; const char *p = NULL; const char *q = NULL; const char *s = NULL; char *t; const char *u; ajint matchpos; ajint framep; ajint count; AjPTrn table = NULL; AjPStr s1 = NULL; AjPStr s2 = NULL; char c; char rc; ajint min = INT_MAX; /* Reverse sense intentional! */ ajint max = -INT_MAX; ajint fpos; ajint rpos; ajint x; AjPStr tstr = NULL; matchpos = match->start; fpos = matchpos; rpos=radj-fpos-match->len; tstr = ajStrNewS(seq); t = ajStrGetuniquePtr(&tstr); p = t+fpos-(begin+1); u = q = ajStrGetPtr(rlp->site); /* Test here for whether cut site is within sequence substring */ if(rlp->ncuts==4) { min = AJMIN(rlp->cut1,rlp->cut2); max = AJMAX(rlp->cut3,rlp->cut4); } else if(rlp->ncuts==2) { min = AJMIN(rlp->cut1,rlp->cut2); max = AJMAX(rlp->cut1,rlp->cut2); } else { ajWarn("Possibly corrupt RE file"); ajStrDel(&tstr); return NULL; } if(!rev) /* forward strand */ { if(matchpos+min<0||matchpos+max>end+1) { /*Cut site not in sequence range*/ ajStrDel(&tstr); return NULL; } } else /* reverse strand */ { if(radj-matchpos-1-min>end+1||radj-matchpos-1-max<begin) { /*Cut site not in sequence range*/ ajStrDel(&tstr); return NULL; } } count=0; while(ajBaseAlphaToBin(*q++) & ajBaseAlphaToBin(*p++)) ++count; /* Changed base postion */ x = fpos+count-(begin+1); /* Where the frame starts on the reverse strand */ framep = (end-begin+1)%3; c = t[x]; rc = u[count]; if(!rev) /* forward strand */ s = t+x-x%3; else /* reverse strand */ s = t+x-(x-framep)%3; table = ajTrnNewI(0); /* translates codon pointed to by s (original seq) */ s1 = ajStrNewK(ajTrnCodonC(table,s)); t[x] = rc; /* translates codon pointed to by s (mutated base from RS pattern */ s2 = ajStrNewK(ajTrnCodonC(table,s)); t[x] = c; /* changes mutated base in seq back to original base */ AJNEW(ret); ret->obase = c; ret->nbase = rc; ret->code = ajStrNewC(ajStrGetPtr(rlp->code)); ret->site = ajStrNewC(ajStrGetPtr(rlp->site)); ret->seqaa = ajStrNewC(ajStrGetPtr(s1)); ret->reaa = ajStrNewC(ajStrGetPtr(s2)); if(ajStrMatchS(s1,s2)) ret->issilent = ajTrue; else ret->issilent = ajFalse; if(!rev) { ret->match = matchpos; ret->base = matchpos+count; } else { ret->match = rpos; ret->base = rpos+match->len-1-count; } ajStrDel(&tstr); ajStrDel(&s1); ajStrDel(&s2); ajTrnDel(&table); return ret; }
int main(int argc, char **argv) { AjPSeq seq = NULL; AjPStr strand = NULL; AjPStr substr = NULL; AjPStr squares = NULL; AjPStr diamonds = NULL; AjPStr octags = NULL; AjBool wheel; AjBool amphipathic; AjPGraph graph=0; AjBool first; AjBool startloop; ajint begin; ajint end; ajint len; ajint steps; ajint turns; ajint lc; ajint i; ajint j; ajint k; float xmin = (float) -1.0; float xmax = (float) 1.0; float ymin = (float) -0.75; float ymax = (float) 0.75; float minresplot = (float) 36.0; float resgap = (float) 0.0533; float wheelgap = (float) 0.00; float nresgap = (float) 0.08; float angle; float oldangle; float ang; float radius; float wradius; float xx1; float xx2; float yy1; float yy2; embInit("pepwheel", argc, argv); seq = ajAcdGetSeq("sequence"); steps = ajAcdGetInt("steps"); turns = ajAcdGetInt("turns"); graph = ajAcdGetGraph("graph"); octags = ajAcdGetString("octags"); squares = ajAcdGetString("squares"); diamonds = ajAcdGetString("diamonds"); wheel = ajAcdGetBoolean("wheel"); amphipathic = ajAcdGetToggle("amphipathic"); ajStrFmtUpper(&octags); ajStrFmtUpper(&squares); ajStrFmtUpper(&diamonds); if(amphipathic) { ajStrAssignC(&squares,"ACFGILMVWY"); ajStrAssignC(&diamonds,""); ajStrAssignC(&octags,""); } substr = ajStrNew(); begin = ajSeqGetBegin(seq); end = ajSeqGetEnd(seq); ajDebug("begin: %d end: %d\n", begin, end); strand = ajSeqGetSeqCopyS(seq); ajStrFmtUpper(&strand); ajStrAssignSubC(&substr,ajStrGetPtr(strand),begin-1,end-1); len = ajStrGetLen(substr); ajGraphAppendTitleS(graph, ajSeqGetUsaS(seq)); ajGraphOpenWin(graph,xmin,xmax,ymin,ymax); ajGraphicsSetFgcolour(AJB_BLACK); ang = ((float)360.0 / (float)steps) * (float)turns; first = ajTrue; angle = (float) 90.0 + ang; if(end-begin > (ajint)minresplot) wradius = (float) 0.2; else wradius = (float) 0.40; for(i=0,lc=0,radius=wradius+wheelgap;i<len;i+=steps) { wradius += wheelgap; startloop = ajTrue; k = AJMIN(i+steps, end); for(j=i;j<k;++j) { oldangle = angle; angle = oldangle-ang; if(first) startloop = first = ajFalse; else { if(startloop) { if(wheel) { ajCvtPolToRec(wradius-wheelgap,oldangle,&xx1,&yy1); ajCvtPolToRec(wradius,angle,&xx2,&yy2); ajGraphicsDrawposLine(xx1,yy1,xx2,yy2); } startloop=ajFalse; } else if(wheel) { ajCvtPolToRec(wradius,oldangle,&xx1,&yy1); ajCvtPolToRec(wradius,angle,&xx2,&yy2); ajGraphicsDrawposLine(xx1,yy1,xx2,yy2); } } pepwheel_plotresidue(*(ajStrGetPtr(substr)+lc),radius+resgap,angle, ajStrGetPtr(squares),ajStrGetPtr(octags), ajStrGetPtr(diamonds), xmin,xmax,ymin,ymax); ++lc; if(lc==len) break; } radius += nresgap; } ajGraphicsClose(); ajGraphxyDel(&graph); ajStrDel(&strand); ajStrDel(&substr); ajSeqDel(&seq); ajStrDel(&squares); ajStrDel(&diamonds); ajStrDel(&octags); embExit(); return 0; }