static void prophet_scan_profile(const AjPStr substr, const AjPStr name, const AjPStr pname, ajint mlen, float * const *fmatrix, AjPAlign align, const AjPStr cons, float opencoeff, float extendcoeff, float *path, ajint *compass, AjPStr *m, AjPStr *n, ajint slen) { /* JISON AjPAlign align replaces AjPOutfile outf */ float score; ajint start1; ajint start2; AjPSeq seqm=NULL; AjPSeq seqn=NULL; score=embAlignProfilePathCalc(ajStrGetPtr(substr),mlen,slen, opencoeff,extendcoeff, path,fmatrix,compass,0); /*score=embAlignScoreProfileMatrix(path,compass,opencoeff,extendcoeff, substr,mlen,slen,fmatrix,&start1, &start2);*/ embAlignWalkProfileMatrix(path,compass,opencoeff,extendcoeff,cons, substr,m,n,mlen,slen,fmatrix,&start1, &start2); /* JISON ... used to be embAlignPrintProfile(outf,ajStrGetPtr(cons),ajStrGetPtr(substr),*m,*n, start1,start2,score,1,fmatrix,"Consensus", ajStrGetPtr(pname),1,begin); */ /* JISON new block */ embAlignReportProfile(align, *m, *n, start1, start2, score, ajStrGetPtr(pname), ajStrGetPtr(name)); /* seqm=ajSeqNewNameS((const AjPStr)*m, (const AjPStr)pname); seqn=ajSeqNewNameS((const AjPStr)*n, (const AjPStr)name); ajAlignDefineSS(align, seqm, seqn); ajAlignSetScoreR(align, score); ajAlignSetRange(align, start1, start1+mlen-1, mlen, 1, start2, start2+slen-1, slen, 1); */ ajAlignWrite(align); ajSeqDel(&seqm); ajSeqDel(&seqn); return; }
static void splitter_ProcessChunk (AjPSeqout seqout, const AjPSeq seq, ajuint start, ajuint end, const AjPStr name, AjBool feature) { AjPStr str; AjPFeattable new_feattable = NULL; AjPSeq subseq; ajDebug("splitter_ProcessChunk %d..%d '%S' %B\n", start, end, name, feature); str = ajStrNew(); subseq = ajSeqNew(); new_feattable = ajFeattableNew(name); subseq->Fttable = new_feattable; ajFeattableSetNuc(new_feattable); ajStrAssignSubC(&str,ajSeqGetSeqC(seq),start,end); ajSeqAssignSeqS(subseq,str); if(feature) splitter_AddSubSeqFeat(subseq->Fttable,start,end,seq); ajSeqAssignNameS(subseq, name); splitter_write(seqout,subseq,seq); ajStrDel(&str); ajSeqDel(&subseq); return; }
int main(int argc, char **argv) { AjPSeqout seqout; AjPSeqall seqall; AjPSeq seq = NULL; embInit("seqretallfeat", argc, argv); seqout = ajAcdGetSeqoutall("outseq"); seqall = ajAcdGetSeqall("sequence"); while (ajSeqallNext(seqall, &seq)) { ajSeqoutWriteSeq(seqout, seq); ajSeqTrace(seq); } ajSeqoutClose(seqout); ajFeatTest(); ajSeqallDel(&seqall); ajSeqDel(&seq); ajSeqoutDel(&seqout); embExit(); return 0; }
int main(int argc, char **argv) { AjPSeqall seqall; AjPSeqout seqout; AjPSeq seq = NULL; AjBool firstonly; embInit("seqret", argc, argv); seqout = ajAcdGetSeqoutall("outseq"); seqall = ajAcdGetSeqall("sequence"); firstonly = ajAcdGetBoolean("firstonly"); while(ajSeqallNext(seqall, &seq)) { ajSeqoutWriteSeq(seqout, seq); if(firstonly) break; } ajSeqoutClose(seqout); ajSeqallDel(&seqall); ajSeqDel(&seq); ajSeqoutDel(&seqout); embExit(); return 0; }
int main(int argc, char **argv) { AjPSeqall seqall; AjPSeq seq = NULL; AjPFile primerFile; /* read the primer pairs from a file */ AjPFile outf; AjPList primerList; ajint mmp = 0; embInit("primersearch", argc, argv); seqall = ajAcdGetSeqall("seqall"); outf = ajAcdGetOutfile("outfile"); primerFile = ajAcdGetInfile("infile"); mmp = ajAcdGetInt("mismatchpercent"); /* build list of forward/reverse primer pairs as read from primerfile */ primerList = ajListNew(); /* read in primers from primerfile, classify and compile them */ primersearch_read_primers(&primerList,primerFile, mmp); /* check there are primers to be searched */ if(!ajListGetLength(primerList)) { ajErr("No suitable primers found - exiting"); embExitBad(); return 0; } /* query sequences one by one */ while(ajSeqallNext(seqall,&seq)) primersearch_primer_search(primerList, seq); /* output the results */ primersearch_print_hits(primerList, outf); /* delete all nodes of list, then the list itself */ ajListMap(primerList, primersearch_free_primer, NULL); ajListFree(&primerList); ajListFree(&primerList); ajFileClose(&outf); ajSeqallDel(&seqall); ajSeqDel(&seq); ajFileClose(&primerFile); embExit(); return 0; }
int main(int argc, char **argv) { AjPSeqall seqall; AjPSeqout seqout; AjPSeqout junkout; AjPSeq seq = NULL; AjPStr exclude = NULL; AjPStr pattern = NULL; AjPStr name = NULL; AjPStr acc = NULL; embInit("notseq", argc, argv); seqout = ajAcdGetSeqoutall("outseq"); junkout = ajAcdGetSeqoutall("junkoutseq"); seqall = ajAcdGetSeqall("sequence"); exclude = ajAcdGetString("exclude"); notseq_readfile(exclude, &pattern); while(ajSeqallNext(seqall, &seq)) { ajStrAssignS(&name, ajSeqGetNameS(seq)); ajStrAssignS(&acc, ajSeqGetAccS(seq)); if(embMiscMatchPatternDelimC(name, pattern, ",;") || embMiscMatchPatternDelimC(acc, pattern, ",;")) ajSeqoutWriteSeq(junkout, seq); else /* no match, so not excluded */ ajSeqoutWriteSeq(seqout, seq); ajStrSetClear(&name); ajStrSetClear(&acc); } ajSeqoutClose(seqout); ajSeqoutClose(junkout); ajSeqallDel(&seqall); ajSeqDel(&seq); ajSeqoutDel(&seqout); ajSeqoutDel(&junkout); ajStrDel(&exclude); ajStrDel(&pattern); ajStrDel(&name); ajStrDel(&acc); embExit(); return 0; }
int main(int argc, char **argv) { AjPSeqall seqall; AjPSeq a; AjPSeqout outf; AjPStr substr; AjPStr back; AjPStr gctable; AjPCod codon = NULL; ajint gctablenum; ajint beg; ajint end; embInit("backtranambig", argc, argv); seqall = ajAcdGetSeqall("sequence"); outf = ajAcdGetSeqoutall("outfile"); gctable = ajAcdGetListSingle("table"); ajStrToInt(gctable, &gctablenum); codon = ajCodNewCodenum(gctablenum); while(ajSeqallNext(seqall, &a)) { substr = ajStrNew(); beg = ajSeqGetBegin(a); end = ajSeqGetEnd(a); ajStrAssignSubC(&substr,ajSeqGetSeqC(a),beg-1,end-1); back = ajStrNew(); ajCodBacktranslateAmbig(&back,substr,codon); ajSeqAssignSeqS (a, back); ajSeqSetNuc(a); ajSeqoutWriteSeq(outf,a); } ajSeqoutClose(outf); ajStrDel(&back); ajStrDel(&substr); ajSeqoutDel(&outf); ajCodDel(&codon); ajStrDel(&gctable); ajSeqallDel(&seqall); ajSeqDel(&a); embExit(); return 0; }
int main(int argc, char **argv) { AjPSeqset seqset; AjPSeqall seqall; AjPSeq seq; ajint i = 0; AjPStr kimout = NULL; AjPStr dir = NULL; AjPFile obofile = NULL; AjPFile resfile = NULL; AjPDir taxdir = NULL; embInit("ajtest", argc, argv); seqall = ajAcdGetSeqall ("sequence"); seqset = ajAcdGetSeqset ("bsequence"); dir = ajAcdGetOutdirName("outdir"); obofile = ajAcdGetInfile ("obofile"); taxdir = ajAcdGetDirectory ("taxdir"); resfile = ajAcdGetInfile ("dbxreffile"); ajUser("Directory '%S'", dir); ajUser("Set of %d", ajSeqsetGetSize(seqset)); while(ajSeqallNext (seqall, &seq)) { ajUser ("%3d <%S>", i++, ajSeqGetUsaS(seq)); ajFmtPrintS(&kimout, "kim%d.out", i); ajtest_kim (kimout, seq); } ajSeqDel(&seq); ajSeqallDel(&seqall); ajSeqsetDel(&seqset); ajStrDel(&kimout); ajStrDel(&dir); if(taxdir) ajTaxLoad(taxdir); ajDirDel(&taxdir); if(obofile) ajOboParseObofile(obofile, ""); ajFileClose(&obofile); if(resfile) ajResourceParse(resfile, ""); ajFileClose(&resfile); embExit(); return 0; }
int main(int argc, char **argv) { AjPSeqall seqall; AjPSeq seq; AjPFile outf; AjPCod codon; AjPStr substr; ajint beg; ajint end; ajint ccnt; embInit("cusp", argc, argv); seqall = ajAcdGetSeqall("sequence"); outf = ajAcdGetOutfile("outfile"); ccnt = 0; substr = ajStrNew(); codon = ajCodNewCodenum(0); ajCodSetNameS(codon, ajFileGetPrintnameS(outf)); while(ajSeqallNext(seqall, &seq)) { beg = ajSeqallGetseqBegin(seqall); end = ajSeqallGetseqEnd(seqall); ajStrAssignSubS(&substr,ajSeqGetSeqS(seq),beg-1,end-1); ajCodSetTripletsS(codon,substr,&ccnt); } ajCodCalcUsage(codon,ccnt); ajCodSetDescC(codon, "CUSP codon usage file"); ajCodWrite(codon, outf); ajFileClose(&outf); ajStrDel(&substr); ajCodDel(&codon); ajSeqallDel(&seqall); ajSeqDel(&seq); embExit(); return 0; }
int main(int argc, char **argv) { AjPSeqall seqall; AjPSeq seq; AjPTable table = 0; AjPFile outf; ajint wordsize; ajint mincount; embInit("wordcount", argc, argv); seqall = ajAcdGetSeqall("sequence1"); wordsize = ajAcdGetInt("wordsize"); outf = ajAcdGetOutfile("outfile"); mincount = ajAcdGetInt("mincount"); embWordLength(wordsize); while (ajSeqallNext(seqall, &seq)) { embWordGetTable(&table, seq); /* get table of words */ } embWordPrintTableFI(table, mincount, outf); /* print table of words */ /* ** test if table can be added to ** if(getWordTable(&table, seq, wordcount)) ?? get table of words ?? ** { ** printWordTable(table); ?? print table of words ?? ** } */ embWordFreeTable(&table); /* free table of words */ ajSeqallDel(&seqall); ajSeqDel(&seq); ajFileClose(&outf); embExit(); return 0; }
int main(int argc, char **argv) { AjPSeqall seqall; AjPFile outf; AjPSeq seq = NULL; AjPList xrefs = NULL; ajuint nrefs; AjPSeqXref xref = NULL; embInit("seqxref", argc, argv); outf = ajAcdGetOutfile("outfile"); seqall = ajAcdGetSeqall("sequence"); xrefs = ajListNew(); while(ajSeqallNext(seqall, &seq)) { nrefs = ajSeqGetXrefs(seq, xrefs); ajSeqxreflistSort(xrefs); ajFmtPrintF(outf, "#%S: %u\n", ajSeqGetUsaS(seq), nrefs); while(ajListPop(xrefs, (void**)&xref)) { ajFmtPrintF(outf, "%S:%S\n", xref->Db, xref->Id); ajSeqxrefDel(&xref); } } ajListFree(&xrefs); ajSeqDel(&seq); ajFileClose(&outf); ajSeqallDel(&seqall); embExit(); return 0; }
int main(int argc, char **argv) { AjPSeq seq; AjPGraph graph = 0; AjPFile outf = NULL; AjPFile file = NULL; AjPStr buffer = NULL; float twist[4][4][4]; float roll[4][4][4]; float tilt[4][4][4]; float rbend; float rcurve; float bendscale; float curvescale; float twistsum = (float) 0.0; float pi = (float) 3.14159; float pifac = (pi/(float) 180.0); float pi2 = pi/(float) 2.0; ajint *iseq = NULL; float *x; float *y; float *xave; float *yave; float *curve; float *bend; const char *ptr; ajint i; ajint ii; ajint k; ajint j; char residue[2]; float maxbend; float minbend; float bendfactor; float maxcurve; float mincurve; float curvefactor; float fxp; float fyp; float yincr; float yy1; ajint ixlen; ajint iylen; ajint ixoff; ajint iyoff; float ystart; float defheight; float currentheight; ajint count; ajint portrait = 0; ajint title = 0; ajint numres; ajint ibeg; ajint iend; ajint ilen; AjPStr sstr = NULL; ajint ipos; float dx; float dy; float rxsum; float rysum; float yp1; float yp2; double td; embInit("banana", argc, argv); seq = ajAcdGetSeq("sequence"); file = ajAcdGetDatafile("anglesfile"); outf = ajAcdGetOutfile("outfile"); graph = ajAcdGetGraph("graph"); numres = ajAcdGetInt("residuesperline"); ibeg = ajSeqGetBegin(seq); iend = ajSeqGetEnd(seq); ajStrAssignSubS(&sstr, ajSeqGetSeqS(seq), ibeg-1, iend-1); ilen = ajStrGetLen(sstr); AJCNEW0(iseq,ilen+1); AJCNEW0(x,ilen+1); AJCNEW0(y,ilen+1); AJCNEW0(xave,ilen+1); AJCNEW0(yave,ilen+1); AJCNEW0(curve,ilen+1); AJCNEW0(bend,ilen+1); ptr= ajStrGetPtr(sstr); for(ii=0;ii<ilen;ii++) { if(*ptr=='A' || *ptr=='a') iseq[ii+1] = 0; else if(*ptr=='T' || *ptr=='t') iseq[ii+1] = 1; else if(*ptr=='G' || *ptr=='g') iseq[ii+1] = 2; else if(*ptr=='C' || *ptr=='c') iseq[ii+1] = 3; else ajErr("%c is not an ATCG hence not valid",*ptr); ptr++; } if(!file) ajErr("Banana failed to open angle file"); ajReadline(file,&buffer); /* 3 junk lines */ ajReadline(file,&buffer); ajReadline(file,&buffer); for(k=0;k<4;k++) for(ii=0;ii<4;ii++) { if(ajReadline(file,&buffer)) { sscanf(ajStrGetPtr(buffer),"%f,%f,%f,%f", &twist[ii][0][k],&twist[ii][1][k],&twist[ii][2][k], &twist[ii][3][k]); } else ajErr("Error reading angle file"); for(j=0;j<4;j++) twist[ii][j][k] *= pifac; } for(k=0;k<4;k++) for(ii=0;ii<4;ii++) if(ajReadline(file,&buffer)) { sscanf(ajStrGetPtr(buffer),"%f,%f,%f,%f",&roll[ii][0][k], &roll[ii][1][k],&roll[ii][2][k],&roll[ii][3][k]); } else ajErr("Error reading angle file"); for(k=0;k<4;k++) for(ii=0;ii<4;ii++) if(ajReadline(file,&buffer)) sscanf(ajStrGetPtr(buffer),"%f,%f,%f,%f",&tilt[ii][0][k], &tilt[ii][1][k],&tilt[ii][2][k],&tilt[ii][3][k]); else ajErr("Error reading angle file"); if(ajReadline(file,&buffer)) sscanf(ajStrGetPtr(buffer),"%f,%f,%f,%f",&rbend,&rcurve, &bendscale,&curvescale); else ajErr("Error reading angle file"); ajFileClose(&file); ajStrDel(&buffer); for(ii=1;ii<ilen-1;ii++) { twistsum += twist[iseq[ii]][iseq[ii+1]][iseq[ii+2]]; dx = (roll[iseq[ii]][iseq[ii+1]][iseq[ii+2]]*sinfban(twistsum)) + (tilt[iseq[ii]][iseq[ii+1]][iseq[ii+2]]*sinfban(twistsum-pi2)); dy = roll[iseq[ii]][iseq[ii+1]][iseq[ii+2]]*cosfban(twistsum) + tilt[iseq[ii]][iseq[ii+1]][iseq[ii+2]]*cosfban(twistsum-pi2); x[ii+1] = x[ii]+dx; y[ii+1] = y[ii]+dy; } for(ii=6;ii<ilen-6;ii++) { rxsum = 0.0; rysum = 0.0; for(k=-4;k<=4;k++) { rxsum+=x[ii+k]; rysum+=y[ii+k]; } rxsum+=(x[ii+5]*(float)0.5); rysum+=(y[ii+5]*(float)0.5); rxsum+=(x[ii-5]*(float)0.5); rysum+=(y[ii-5]*(float)0.5); xave[ii] = rxsum*(float)0.1; yave[ii] = rysum*(float)0.1; } for(i=(ajint)rbend+1;i<=ilen-(ajint)rbend-1;i++) { td = sqrt(((x[i+(ajint)rbend]-x[i-(ajint)rbend])* (x[i+(ajint)rbend]-x[i-(ajint)rbend])) + ((y[i+(ajint)rbend]-y[i-(ajint)rbend])* (y[i+(ajint)rbend]-y[i-(ajint)rbend]))); bend[i] = (float) td; bend[i]*=bendscale; } for(i=(ajint)rcurve+6;i<=ilen-(ajint)rcurve-6;i++) { td = sqrt(((xave[i+(ajint)rcurve]- xave[i-(ajint)rcurve])*(xave[i+(ajint)rcurve]- xave[i-(ajint)rcurve]))+ ((yave[i+(ajint)rcurve]-yave[i-(ajint)rcurve])* (yave[i+(ajint)rcurve]-yave[i-(ajint)rcurve]))); curve[i] = (float) td; } if(outf) { ajFmtPrintF(outf,"Base Bend Curve\n"); ptr = ajStrGetPtr(sstr); for(ii=1;ii<=ilen;ii++) { ajFmtPrintF(outf,"%c %6.1f %6.1f\n", *ptr, bend[ii], curve[ii]); ptr++; } ajFileClose(&outf); } if(graph) { maxbend = minbend = 0.0; maxcurve = mincurve = 0.0; for(ii=1;ii<=ilen;ii++) { if(bend[ii] > maxbend) maxbend = bend[ii]; if(bend[ii] < minbend) minbend = bend[ii]; if(curve[ii] > maxcurve) maxcurve = curve[ii]; if(curve[ii] < mincurve) mincurve = curve[ii]; } ystart = 75.0; ajGraphAppendTitleS(graph, ajSeqGetUsaS(seq)); ajGraphicsSetPagesize(960, 768); ajGraphOpenWin(graph,(float)-1.0, (float)numres+(float)10.0, (float)0.0, ystart+(float)5.0); ajGraphicsGetParamsPage(&fxp,&fyp,&ixlen,&iylen,&ixoff,&iyoff); if(portrait) { ixlen = 768; iylen = 960; } else { ixlen = 960; iylen = 768; } ajGraphicsGetCharsize(&defheight,¤theight); if(!currentheight) { defheight = currentheight = (float) 4.440072; currentheight = defheight * ((float)ixlen/ ((float)(numres)*(currentheight+(float)1.0))) /currentheight; } ajGraphicsSetCharscale(((float)ixlen/((float)(numres)* (currentheight+(float)1.0)))/ currentheight); ajGraphicsGetCharsize(&defheight,¤theight); yincr = (currentheight + (float)3.0)*(float)0.3; if(!title) yy1 = ystart; else yy1 = ystart-(float)5.0; count = 1; residue[1]='\0'; bendfactor = (3*yincr)/maxbend; curvefactor = (3*yincr)/maxcurve; ptr = ajStrGetPtr(sstr); yy1 = yy1-(yincr*((float)5.0)); for(ii=1;ii<=ilen;ii++) { if(count > numres) { yy1 = yy1-(yincr*((float)5.0)); if(yy1<1.0) { if(!title) yy1=ystart; else yy1 = ystart-(float)5.0; yy1 = yy1-(yincr*((float)5.0)); ajGraphNewpage(graph,AJFALSE); } count = 1; } residue[0] = *ptr; ajGraphicsDrawposTextAtend((float)(count)+(float)2.0,yy1,residue); if(ii>1 && ii < ilen) { yp1 = yy1+yincr + (bend[ii]*bendfactor); yp2 = yy1+yincr + (bend[ii+1]*bendfactor); ajGraphicsDrawposLine((float)count+(float)1.5,yp1, (float)(count)+(float)2.5,yp2); } ipos = ilen-(ajint)rcurve-7; if(ipos < 0) ipos = 0; if(ii>rcurve+5 && ii<ipos) { yp1 = yy1+yincr + (curve[ii]*curvefactor); yp2 = yy1+yincr + (curve[ii+1]*curvefactor); ajGraphicsDrawposLine((float)count+(float)1.7,yp1, (float)(count)+(float)2.3,yp2); } ajGraphicsDrawposLine((float)count+(float)1.5,yy1+yincr, (float)(count)+(float)2.5,yy1+yincr); count++; ptr++; } ajGraphicsClose(); } AJFREE(iseq); AJFREE(x); AJFREE(y); AJFREE(xave); AJFREE(yave); AJFREE(curve); AJFREE(bend); ajStrDel(&sstr); ajSeqDel(&seq); ajFileClose(&file); ajFileClose(&outf); ajGraphxyDel(&graph); embExit(); return 0; }
int main(int argc, char **argv) { AjPList list = NULL; AjPSeq seq; AjPSeq seq2; AjPStr aa0str = 0; AjPStr aa1str = 0; const char *s1; const char *s2; char *strret = NULL; ajuint i; ajuint j; ajuint k; ajint l; ajint abovethresh; ajint total; ajint starti = 0; ajint startj = 0; ajint windowsize; float thresh; AjPGraph graph = NULL; AjPGraph xygraph = NULL; float flen1; float flen2; ajuint len1; ajuint len2; AjPTime ajtime = NULL; time_t tim; AjBool boxit=AJTRUE; /* Different ticks as they need to be different for x and y due to length of string being important on x */ ajuint acceptableticksx[]= { 1,10,50,100,500,1000,1500,10000, 500000,1000000,5000000 }; ajuint acceptableticks[]= { 1,10,50,100,200,500,1000,2000,5000,10000,15000, 500000,1000000,5000000 }; ajint numbofticks = 10; float xmargin; float ymargin; float ticklen; float tickgap; float onefifth; float k2; float max; char ptr[10]; AjPMatrix matrix = NULL; ajint** sub; AjPSeqCvt cvt; AjPStr subt = NULL; ajint b1; ajint b2; ajint e1; ajint e2; AjPStr se1; AjPStr se2; ajint ithresh; AjBool stretch; PPoint ppt = NULL; float xa[1]; float ya[1]; AjPGraphdata gdata=NULL; AjPStr tit = NULL; AjIList iter = NULL; float x1 = 0.; float x2 = 0.; float y1 = 0.; float y2 = 0.; ajuint tui; se1 = ajStrNew(); se2 = ajStrNew(); embInit("dotmatcher", argc, argv); seq = ajAcdGetSeq("asequence"); seq2 = ajAcdGetSeq("bsequence"); stretch = ajAcdGetToggle("stretch"); graph = ajAcdGetGraph("graph"); xygraph = ajAcdGetGraphxy("xygraph"); windowsize = ajAcdGetInt("windowsize"); ithresh = ajAcdGetInt("threshold"); matrix = ajAcdGetMatrix("matrixfile"); sub = ajMatrixGetMatrix(matrix); cvt = ajMatrixGetCvt(matrix); thresh = (float)ithresh; ajtime = ajTimeNew(); tim = time(0); ajTimeSetLocal(ajtime, tim); b1 = ajSeqGetBegin(seq); b2 = ajSeqGetBegin(seq2); e1 = ajSeqGetEnd(seq); e2 = ajSeqGetEnd(seq2); len1 = ajSeqGetLen(seq); len2 = ajSeqGetLen(seq2); tui = ajSeqGetLen(seq); flen1 = (float) tui; tui = ajSeqGetLen(seq2); flen2 = (float) tui; ajStrAssignSubC(&se1,ajSeqGetSeqC(seq),b1-1,e1-1); ajStrAssignSubC(&se2,ajSeqGetSeqC(seq2),b2-1,e2-1); ajSeqAssignSeqS(seq,se1); ajSeqAssignSeqS(seq2,se2); s1 = ajStrGetPtr(ajSeqGetSeqS(seq)); s2 = ajStrGetPtr(ajSeqGetSeqS(seq2)); aa0str = ajStrNewRes(1+len1); /* length plus trailing blank */ aa1str = ajStrNewRes(1+len2); list = ajListNew(); for(i=0;i<len1;i++) ajStrAppendK(&aa0str,(char)ajSeqcvtGetCodeK(cvt, *s1++)); for(i=0;i<len2;i++) ajStrAppendK(&aa1str,(char)ajSeqcvtGetCodeK(cvt, *s2++)); max = (float)len1; if(len2 > max) max = (float) len2; xmargin = ymargin = max *(float)0.15; ticklen = xmargin*(float)0.1; onefifth = xmargin*(float)0.2; subt = ajStrNewC((strret= ajFmtString("(windowsize = %d, threshold = %3.2f %D)", windowsize,thresh,ajtime))); if(!stretch) { if( ajStrGetLen(ajGraphGetSubtitleS(graph)) <=1) ajGraphSetSubtitleS(graph,subt); ajGraphOpenWin(graph, (float)0.0-ymargin,(max*(float)1.35)+ymargin, (float)0.0-xmargin,(float)max+xmargin); ajGraphicsDrawposTextAtmid(flen1*(float)0.5, (float)0.0-(xmargin/(float)2.0), ajGraphGetXlabelC(graph)); ajGraphicsDrawposTextAtlineJustify((float)0.0-(xmargin*(float)0.75), flen2*(float)0.5, (float)0.0-(xmargin*(float)0.75),flen1, ajGraphGetYlabelC(graph),0.5); ajGraphicsSetCharscale(0.5); } s1= ajStrGetPtr(aa0str); s2 = ajStrGetPtr(aa1str); for(j=0; (ajint)j < (ajint)len2-windowsize;j++) { i =0; total = 0; abovethresh =0; k = j; for(l=0;l<windowsize;l++) total = total + sub[(ajint)s1[i++]][(ajint)s2[k++]]; if(total >= thresh) { abovethresh=1; starti = i-windowsize; startj = k-windowsize; } while(i < len1 && k < len2) { total = total - sub[(ajint)s1[i-windowsize]] [(ajint)s2[k-windowsize]]; total = total + sub[(ajint)s1[i]][(ajint)s2[k]]; if(abovethresh) { if(total < thresh) { abovethresh = 0; /* draw the line */ dotmatcher_pushpoint(&list,(float)starti,(float)startj, (float)i-1,(float)k-1,stretch); } } else if(total >= thresh) { starti = i-windowsize; startj = k-windowsize; abovethresh= 1; } i++; k++; } if(abovethresh) /* draw the line */ dotmatcher_pushpoint(&list,(float)starti,(float)startj, (float)i-1,(float)k-1, stretch); } for(i=0; (ajint)i < (ajint)len1-windowsize;i++) { j = 0; total = 0; abovethresh =0; k = i; for(l=0;l<windowsize;l++) total = total + sub[(ajint)s1[k++]][(ajint)s2[j++]]; if(total >= thresh) { abovethresh=1; starti = k-windowsize; startj = j-windowsize; } while(k < len1 && j < len2) { total = total - sub[(ajint)s1[k-windowsize]] [(ajint)s2[j-windowsize]]; total = total + sub[(ajint)s1[k]][(ajint)s2[j]]; if(abovethresh) { if(total < thresh) { abovethresh = 0; /* draw the line */ dotmatcher_pushpoint(&list,(float)starti,(float)startj, (float)k-1,(float)j-1,stretch); } } else if(total >= thresh) { starti = k-windowsize; startj = j-windowsize; abovethresh= 1; } j++; k++; } if(abovethresh) /* draw the line */ dotmatcher_pushpoint(&list,(float)starti,(float)startj, (float)k-1,(float)j-1, stretch); } if(boxit && !stretch) { ajGraphicsDrawposRect(0.0,0.0,flen1, flen2); i=0; while(acceptableticksx[i]*numbofticks < len1) i++; if(i<=13) tickgap = (float)acceptableticksx[i]; else tickgap = (float)acceptableticksx[10]; ticklen = xmargin*(float)0.1; onefifth = xmargin*(float)0.2; if(len2/len1 > 10 ) { /* if a lot smaller then just label start and end */ ajGraphicsDrawposLine((float)0.0,(float)0.0,(float)0.0,(float)0.0-ticklen); sprintf(ptr,"%d",b1-1); ajGraphicsDrawposTextAtmid((float)0.0,(float)0.0-(onefifth),ptr); ajGraphicsDrawposLine(flen1,(float)0.0, flen1,(float)0.0-ticklen); sprintf(ptr,"%d",len1+b1-1); ajGraphicsDrawposTextAtmid(flen1,(float)0.0-(onefifth),ptr); } else for(k2=0.0;k2<len1;k2+=tickgap) { ajGraphicsDrawposLine(k2,(float)0.0,k2,(float)0.0-ticklen); sprintf(ptr,"%d",(ajint)k2+b1-1); ajGraphicsDrawposTextAtmid(k2,(float)0.0-(onefifth),ptr); } i = 0; while(acceptableticks[i]*numbofticks < len2) i++; tickgap = (float)acceptableticks[i]; ticklen = ymargin*(float)0.01; onefifth = ymargin*(float)0.02; if(len1/len2 > 10 ) { /* if a lot smaller then just label start and end */ ajGraphicsDrawposLine((float)0.0,(float)0.0,(float)0.0-ticklen,(float)0.0); sprintf(ptr,"%d",b2-1); ajGraphicsDrawposTextAtend((float)0.0-(onefifth),(float)0.0,ptr); ajGraphicsDrawposLine((float)0.0,flen2,(float)0.0-ticklen, flen2); sprintf(ptr,"%d",len2+b2-1); ajGraphicsDrawposTextAtend((float)0.0-(onefifth),flen2,ptr); } else for(k2=0.0;k2<len2;k2+=tickgap) { ajGraphicsDrawposLine((float)0.0,k2,(float)0.0-ticklen,k2); sprintf(ptr,"%d",(ajint)k2+b2-1); ajGraphicsDrawposTextAtend((float)0.0-(onefifth),k2,ptr); } } if(!stretch) ajGraphicsClose(); else /* the xy graph for -stretch */ { tit = ajStrNew(); ajFmtPrintS(&tit,"%S",ajGraphGetTitleS(xygraph)); gdata = ajGraphdataNewI(1); xa[0] = (float)b1; ya[0] = (float)b2; ajGraphSetTitleC(xygraph,ajStrGetPtr(tit)); ajGraphSetXlabelC(xygraph,ajSeqGetNameC(seq)); ajGraphSetYlabelC(xygraph,ajSeqGetNameC(seq2)); ajGraphdataSetTypeC(gdata,"2D Plot Float"); ajGraphdataSetTitleS(gdata,subt); ajGraphdataSetMinmax(gdata,(float)b1,(float)e1,(float)b2, (float)e2); ajGraphdataSetTruescale(gdata,(float)b1,(float)e1,(float)b2, (float)e2); ajGraphxySetXstartF(xygraph,(float)b1); ajGraphxySetXendF(xygraph,(float)e1); ajGraphxySetYstartF(xygraph,(float)b2); ajGraphxySetYendF(xygraph,(float)e2); ajGraphxySetXrangeII(xygraph,b1,e1); ajGraphxySetYrangeII(xygraph,b2,e2); if(list) { iter = ajListIterNewread(list); while((ppt = ajListIterGet(iter))) { x1 = ppt->x1+b1-1; y1 = ppt->y1+b2-1; x2 = ppt->x2+b1-1; y2 = ppt->y2+b2-1; ajGraphAddLine(xygraph,x1,y1,x2,y2,0); AJFREE(ppt); } ajListIterDel(&iter); } ajGraphdataAddXY(gdata,xa,ya); ajGraphDataReplace(xygraph,gdata); ajGraphxyDisplay(xygraph,ajFalse); ajGraphicsClose(); ajStrDel(&tit); } ajListFree(&list); ajSeqDel(&seq); ajSeqDel(&seq2); ajGraphxyDel(&graph); ajGraphxyDel(&xygraph); ajMatrixDel(&matrix); ajTimeDel(&ajtime); /* deallocate memory */ ajStrDel(&aa0str); ajStrDel(&aa1str); ajStrDel(&se1); ajStrDel(&se2); ajStrDel(&subt); AJFREE(strret); /* created withing ajFmtString */ embExit(); return 0; }
int main(int argc, char **argv) { ajint begin, end; AjPSeqall seqall; AjPSeq seq; EmbPShow ss; AjPFile outfile; AjPStr tablename; ajint table; AjPRange uppercase; AjPRange highlight; AjBool threeletter; AjBool numberseq; AjBool nameseq; ajint width; ajint length; ajint margin; AjBool description; ajint offset; AjBool html; AjPStr descriptionline; ajint orfminsize; AjPTrn trnTable; AjBool translation; AjBool reverse; AjBool cutlist; AjBool flat; EmbPMatMatch mm = NULL; AjPStr *framelist; AjBool frames[6]; /* frames to be translated 1 to 3, -1 to -3 */ /* stuff for tables and lists of enzymes and hits */ ajint default_mincuts = 1; ajint default_maxcuts = 2000000000; AjPTable hittable; /* enzyme hits */ /* stuff lifted from Alan's 'restrict.c' */ AjPStr enzymes = NULL; ajint mincuts; ajint maxcuts; ajint sitelen; AjBool single; AjBool blunt; AjBool sticky; AjBool ambiguity; AjBool plasmid; AjBool commercial; AjBool limit; AjBool methyl; AjPFile enzfile = NULL; AjPFile equfile = NULL; AjPFile methfile = NULL; AjPTable retable = NULL; ajint hits; AjPList restrictlist = NULL; embInit("remap", argc, argv); seqall = ajAcdGetSeqall("sequence"); outfile = ajAcdGetOutfile("outfile"); tablename = ajAcdGetListSingle("table"); uppercase = ajAcdGetRange("uppercase"); highlight = ajAcdGetRange("highlight"); threeletter = ajAcdGetBoolean("threeletter"); numberseq = ajAcdGetBoolean("number"); width = ajAcdGetInt("width"); length = ajAcdGetInt("length"); margin = ajAcdGetInt("margin"); nameseq = ajAcdGetBoolean("name"); description = ajAcdGetBoolean("description"); offset = ajAcdGetInt("offset"); html = ajAcdGetBoolean("html"); orfminsize = ajAcdGetInt("orfminsize"); translation = ajAcdGetBoolean("translation"); reverse = ajAcdGetBoolean("reverse"); cutlist = ajAcdGetBoolean("cutlist"); flat = ajAcdGetBoolean("flatreformat"); framelist = ajAcdGetList("frame"); /* restriction enzyme stuff */ mincuts = ajAcdGetInt("mincuts"); maxcuts = ajAcdGetInt("maxcuts"); sitelen = ajAcdGetInt("sitelen"); single = ajAcdGetBoolean("single"); blunt = ajAcdGetBoolean("blunt"); sticky = ajAcdGetBoolean("sticky"); ambiguity = ajAcdGetBoolean("ambiguity"); plasmid = ajAcdGetBoolean("plasmid"); commercial = ajAcdGetBoolean("commercial"); limit = ajAcdGetBoolean("limit"); enzymes = ajAcdGetString("enzymes"); methfile = ajAcdGetDatafile("mfile"); methyl = ajAcdGetBoolean("methylation"); if(!blunt && !sticky) ajFatal("Blunt/Sticky end cutters shouldn't both be disabled."); /* get the number of the genetic code used */ ajStrToInt(tablename, &table); trnTable = ajTrnNewI(table); /* read the local file of enzymes names */ remap_read_file_of_enzyme_names(&enzymes); /* get the frames to be translated */ remap_GetFrames(framelist, frames); while(ajSeqallNext(seqall, &seq)) { /* get begin and end positions */ begin = ajSeqGetBegin(seq)-1; end = ajSeqGetEnd(seq)-1; /* do the name and description */ if(nameseq) { if(html) ajFmtPrintF(outfile, "<H2>%S</H2>\n", ajSeqGetNameS(seq)); else ajFmtPrintF(outfile, "%S\n", ajSeqGetNameS(seq)); } if(description) { /* ** wrap the description line at the width of the sequence ** plus margin */ if(html) ajFmtPrintF(outfile, "<H3>%S</H3>\n", ajSeqGetDescS(seq)); else { descriptionline = ajStrNew(); ajStrAssignS(&descriptionline, ajSeqGetDescS(seq)); ajStrFmtWrap(&descriptionline, width+margin); ajFmtPrintF(outfile, "%S\n", descriptionline); ajStrDel(&descriptionline); } } /* get the restriction cut sites */ /* ** most of this is lifted from the program 'restrict.c' by Alan ** Bleasby */ if(single) maxcuts=mincuts=1; retable = ajTablestrNew(EQUGUESS); enzfile = ajDatafileNewInNameC(ENZDATA); if(!enzfile) ajFatal("Cannot locate enzyme file. Run REBASEEXTRACT"); if(limit) { equfile = ajDatafileNewInNameC(EQUDATA); if(!equfile) limit = ajFalse; else remap_read_equiv(&equfile, &retable, commercial); } ajFileSeek(enzfile, 0L, 0); restrictlist = ajListNew(); /* search for hits, but don't use mincuts and maxcuts criteria yet */ hits = embPatRestrictMatch(seq, begin+1, end+1, enzfile, methfile, enzymes, sitelen,plasmid, ambiguity, default_mincuts, default_maxcuts, blunt, sticky, commercial, methyl, restrictlist); ajDebug("Remap found %d hits\n", hits); if(hits) { /* this bit is lifted from printHits */ embPatRestrictRestrict(restrictlist, hits, !limit, ajFalse); if(limit) remap_RestrictPreferred(restrictlist,retable); } ajFileClose(&enzfile); ajFileClose(&methfile); /* ** Remove those violating the mincuts and maxcuts ** criteria, but save them in hittable for printing out later. ** Keep a count of how many hits each enzyme gets in hittable. */ hittable = ajTablestrNewCase(TABLEGUESS); remap_RemoveMinMax(restrictlist, hittable, mincuts, maxcuts); /* make the Show Object */ ss = embShowNew(seq, begin, end, width, length, margin, html, offset); if(html) ajFmtPrintF(outfile, "<PRE>"); /* create the format to display */ embShowAddBlank(ss); embShowAddRE(ss, 1, restrictlist, plasmid, flat); embShowAddSeq(ss, numberseq, threeletter, uppercase, highlight); if(!numberseq) embShowAddTicknum(ss); embShowAddTicks(ss); if(reverse) { embShowAddComp(ss, numberseq); embShowAddRE(ss, -1, restrictlist, plasmid, flat); } if(translation) { if(reverse) embShowAddBlank(ss); if(frames[0]) embShowAddTran(ss, trnTable, 1, threeletter, numberseq, NULL, orfminsize, AJFALSE, AJFALSE, AJFALSE, AJFALSE); if(frames[1]) embShowAddTran(ss, trnTable, 2, threeletter, numberseq, NULL, orfminsize, AJFALSE, AJFALSE, AJFALSE, AJFALSE); if(frames[2]) embShowAddTran(ss, trnTable, 3, threeletter, numberseq, NULL, orfminsize, AJFALSE, AJFALSE, AJFALSE, AJFALSE); if(reverse) { embShowAddTicks(ss); if(frames[5]) embShowAddTran(ss, trnTable, -3, threeletter, numberseq, NULL, orfminsize, AJFALSE, AJFALSE, AJFALSE, AJFALSE); if(frames[4]) embShowAddTran(ss, trnTable, -2, threeletter, numberseq, NULL, orfminsize, AJFALSE, AJFALSE, AJFALSE, AJFALSE); if(frames[3]) embShowAddTran(ss, trnTable, -1, threeletter, numberseq, NULL, orfminsize, AJFALSE, AJFALSE, AJFALSE, AJFALSE); } } embShowPrint(outfile, ss); /* display a list of the Enzymes that cut and don't cut */ if(cutlist) { remap_CutList(outfile, hittable, limit, html, mincuts, maxcuts); remap_NoCutList(outfile, hittable, html, enzymes, blunt, sticky, sitelen, commercial, ambiguity, limit, retable); } /* add a gratuitous newline at the end of the sequence */ ajFmtPrintF(outfile, "\n"); /* tidy up */ embShowDel(&ss); while(ajListPop(restrictlist,(void **)&mm)) embMatMatchDel(&mm); ajListFree(&restrictlist); remap_DelTable(&hittable); ajTablestrFree(&retable); } ajTrnDel(&trnTable); ajSeqallDel(&seqall); ajSeqDel(&seq); ajFileClose(&outfile); ajStrDel(&tablename); ajStrDel(&enzymes); ajStrDelarray(&framelist); ajRangeDel(&uppercase); ajRangeDel(&highlight); embExit(); return 0; }
int main(int argc, char *argv[]) { embInitPV("gp2", argc, argv, "GEMBASSY", "1.0.1"); AjPSeqall seqall; AjPSeq seq; AjPStr inseq = NULL; AjBool accid = ajFalse; AjPStr restid = NULL; AjPStr seqid = NULL; AjPStr base = NULL; AjPStr url = NULL; AjPFile tmpfile = NULL; AjPStr tmpname = NULL; AjPFile outf = NULL; seqall = ajAcdGetSeqall("sequence"); accid = ajAcdGetBoolean("accid"); outf = ajAcdGetOutfile("outfile"); base = ajStrNewC("rest.g-language.org"); gAssignUniqueName(&tmpname); while(ajSeqallNext(seqall, &seq)) { inseq = NULL; if(!accid) { if(gFormatGenbank(seq, &inseq)) { tmpfile = ajFileNewOutNameS(tmpname); if(!tmpfile) { ajDie("Output file (%S) open error\n", tmpname); } ajFmtPrintF(tmpfile, "%S", inseq); ajFileClose(&tmpfile); ajFmtPrintS(&url, "http://%S/upload/upl.pl", base); gFilePostSS(url, tmpname, &restid); ajStrDel(&url); ajSysFileUnlinkS(tmpname); } else { ajDie("Sequence does not have features\n" "Proceeding with sequence accession ID\n"); accid = ajTrue; } } if(accid) { ajStrAssignS(&restid, ajSeqGetAccS(seq)); if(!ajStrGetLen(restid)) { ajStrAssignS(&restid, ajSeqGetNameS(seq)); } if(!ajStrGetLen(restid)) { ajDie("No valid header information\n"); } } ajStrAssignS(&seqid, ajSeqGetAccS(seq)); url = ajStrNew(); ajFmtPrintS(&url, "http://%S/%S/P2/output=f/tag=gene", base, restid); ajFmtPrintF(outf, "Sequence: %S\n", seqid); if(!gFileOutURLS(url, &outf)) { ajDie("Failed to download result from:\n%S\n", url); } ajStrDel(&url); ajStrDel(&inseq); } ajFileClose(&outf); ajSeqallDel(&seqall); ajSeqDel(&seq); ajStrDel(&seqid); embExit(); return 0; }
int main(int argc, char **argv) { embInitPV("kdnapenny", argc, argv, "KBWS", "1.0.8"); struct soap soap; char* jobid; char* result; AjPSeqall seqall; AjPSeq seq; AjPFile outf; AjPStr substr; AjPStr inseq = NULL; seqall = ajAcdGetSeqall("seqall"); outf = ajAcdGetOutfile("outfile"); AjPStr tmp = NULL; AjPStr tmpFileName = NULL; AjPSeqout fil_file; AjPStr line = NULL; AjPStr sizestr = NULL; ajint thissize = 0; ajint nb = 0; AjBool are_prot = ajFalse; ajint size = 0; AjPFile infile; tmp = ajStrNewC("fasta"); fil_file = ajSeqoutNew(); tmpFileName = getUniqueFileName(); if( !ajSeqoutOpenFilename(fil_file, tmpFileName) ) { embExitBad(); } ajSeqoutSetFormatS(fil_file, tmp); while (ajSeqallNext(seqall, &seq)) { if (!nb) { are_prot = ajSeqIsProt(seq); } ajSeqoutWriteSeq(fil_file, seq); ++nb; } ajSeqoutClose(fil_file); ajSeqoutDel(&fil_file); if (nb < 2) { ajFatal("Multiple alignments need at least two sequences"); } infile = ajFileNewInNameS(tmpFileName); while (ajReadline(infile, &line)) { ajStrAppendS(&inseq,line); ajStrAppendC(&inseq,"\n"); } soap_init(&soap); char* in0; in0 = ajCharNewS(inseq); if ( soap_call_ns1__runDnapenny( &soap, NULL, NULL, in0, &jobid ) == SOAP_OK ) { fprintf(stderr,"Jobid: %s\n",jobid); } else { soap_print_fault(&soap, stderr); } int check = 0; while ( check == 0 ) { if ( soap_call_ns1__checkStatus( &soap, NULL, NULL, jobid, &check ) == SOAP_OK ) { fprintf(stderr,"*"); } else { soap_print_fault(&soap, stderr); } sleep(3); } fprintf(stderr, "\n"); if ( soap_call_ns1__getResult( &soap, NULL, NULL, jobid, &result ) == SOAP_OK ) { substr = ajStrNewC(result); ajFmtPrintF(outf,"%S\n",substr); } else { soap_print_fault(&soap, stderr); } ajSysFileUnlinkS(tmpFileName); soap_destroy(&soap); soap_end(&soap); soap_done(&soap); ajFileClose(&outf); ajSeqallDel(&seqall); ajSeqDel(&seq); ajStrDel(&substr); embExit(); return 0; }
int main(int argc, char **argv) { AjPSeqall seqall; AjPSeqout seqout; AjPSeq seq; ajint size; ajint overlap; ajint len; ajint pos; AjBool addover; AjBool feature; AjPStr outseq_name = ajStrNew(); ajint start; ajint end; embInit("splitter", argc, argv); seqout = ajAcdGetSeqoutall("outseq"); seqall = ajAcdGetSeqall("sequence"); size = ajAcdGetInt("size"); overlap = ajAcdGetInt("overlap"); addover = ajAcdGetBoolean("addoverlap"); feature = ajAcdGetBoolean("feature"); while(ajSeqallNext(seqall, &seq)) { ajSeqTrim(seq); len = ajSeqGetLen(seq); pos = 0; ajStrAssignC(&outseq_name, ""); if (!addover) { while(pos+size <= len-1) { start = pos; end = pos+size-1; splitter_MakeSubSeqName (&outseq_name, seq, start, end); splitter_ProcessChunk (seqout, seq, start, end, outseq_name, feature); pos += size-overlap; } } else { while(pos+size+overlap < len-1) { start = pos; end = pos+size+overlap-1; splitter_MakeSubSeqName (&outseq_name, seq, start, end); splitter_ProcessChunk (seqout, seq, start, end, outseq_name, feature); pos += size; } } splitter_MakeSubSeqName(&outseq_name, seq, pos, len-1); splitter_ProcessChunk (seqout, seq, pos, len-1, outseq_name, feature); } ajSeqoutClose(seqout); ajSeqallDel(&seqall); ajSeqoutDel(&seqout); ajSeqDel(&seq); ajStrDel(&outseq_name); embExit(); return 0; }
int main(int argc, char **argv) { AjPSeqall seqall; AjPSeq seq = NULL; AjPFile outf = NULL; AjPStr strand = NULL; AjPStr substr = NULL; AjPStr bases = NULL; ajint begin; ajint end; ajint len; ajint minlen; float minobsexp; float minpc; ajint window; ajint shift; ajint plotstart; ajint plotend; float *xypc = NULL; float *obsexp = NULL; AjBool *thresh = NULL; float obsexpmax; ajint i; ajint maxarr; embInit("newcpgreport",argc,argv); seqall = ajAcdGetSeqall("sequence"); window = ajAcdGetInt("window"); shift = ajAcdGetInt("shift"); outf = ajAcdGetOutfile("outfile"); minobsexp = ajAcdGetFloat("minoe"); minlen = ajAcdGetInt("minlen"); minpc = ajAcdGetFloat("minpc"); substr = ajStrNew(); bases = ajStrNewC("CG"); maxarr = 0; while(ajSeqallNext(seqall, &seq)) { begin = ajSeqallGetseqBegin(seqall); end = ajSeqallGetseqEnd(seqall); strand = ajSeqGetSeqCopyS(seq); ajStrFmtUpper(&strand); ajStrAssignSubC(&substr,ajStrGetPtr(strand),--begin,--end); len=ajStrGetLen(substr); if(len > maxarr) { AJCRESIZE(obsexp, len); AJCRESIZE(thresh, len); AJCRESIZE(xypc, len); maxarr = len; } for(i=0;i<len;++i) obsexp[i]=xypc[i]=0.0; newcpgreport_findbases(substr, len, window, shift, obsexp, xypc, bases, &obsexpmax, &plotstart, &plotend); newcpgreport_identify(outf, obsexp, xypc, thresh, 0, len, shift, ajStrGetPtr(bases), ajSeqGetNameC(seq), minlen, minobsexp, minpc, ajStrGetPtr(strand)); ajStrDel(&strand); } ajStrDel(&bases); ajSeqDel(&seq); ajStrDel(&substr); ajFileClose(&outf); AJFREE(obsexp); AJFREE(thresh); AJFREE(xypc); ajSeqallDel(&seqall); embExit(); return 0; }
int main(int argc, char **argv) { AjPSeqall seqall; AjPSeqout seqout; AjPSeq seq; ajint before; ajint after; AjBool join; AjPFeattable featab; AjBool featinname; AjPStr describe; /* feature filter criteria */ AjPStr source = NULL; AjPStr feattype = NULL; ajint sense; float minscore; float maxscore; AjPStr tag = NULL; AjPStr value = NULL; AjBool testscore = AJFALSE; embInit("extractfeat", argc, argv); seqall = ajAcdGetSeqall("sequence"); seqout = ajAcdGetSeqout("outseq"); before = ajAcdGetInt("before"); after = ajAcdGetInt("after"); join = ajAcdGetBoolean("join"); featinname = ajAcdGetBoolean("featinname"); describe = ajAcdGetString("describe"); /* feature filter criteria */ source = ajAcdGetString("source"); feattype = ajAcdGetString("type"); sense = ajAcdGetInt("sense"); minscore = ajAcdGetFloat("minscore"); maxscore = ajAcdGetFloat("maxscore"); tag = ajAcdGetString("tag"); value = ajAcdGetString("value"); testscore = (minscore || maxscore); if(minscore && !maxscore) if(minscore > maxscore) maxscore = minscore; if(!minscore && maxscore) if(minscore > maxscore) minscore = maxscore; while(ajSeqallNext(seqall, &seq)) { /* get the feature table of the sequence */ featab = ajSeqGetFeatCopy(seq); /* delete features in the table that don't match our criteria */ extractfeat_FeatureFilter(featab, source, feattype, sense, testscore, minscore, maxscore, tag, value); /* extract the features */ extractfeat_FeatSeqExtract(seq, seqout, featab, before, after, join, featinname, describe); ajFeattableDel(&featab); } ajSeqoutClose(seqout); ajSeqoutDel(&seqout); ajSeqallDel(&seqall); ajSeqDel(&seq); ajStrDel(&describe); ajStrDel(&source); ajStrDel(&feattype); ajStrDel(&tag); ajStrDel(&value); embExit(); return 0; }
int main(int argc, char **argv) { embInitPV("kmafft", argc, argv, "KBWS", "1.0.8"); struct soap soap; struct ns1__mafftInputParams params; char* jobid; char* result; AjPSeqall seqall; AjPSeq seq; AjPFile outf; AjPStr substr; AjPStr inseq = NULL; AjPStr strategy; AjPStr outorder; float op; float ep; AjPStr scorematrix; AjBool homologs; AjBool showhomologs; float threshold; AjPStr referenceseq; AjPStr harrplot; strategy = ajAcdGetString("strategy"); outorder = ajAcdGetString("outorder"); op = ajAcdGetFloat("op"); ep = ajAcdGetFloat("ep"); scorematrix = ajAcdGetString("scorematrix"); homologs = ajAcdGetBoolean("homologs"); showhomologs = ajAcdGetBoolean("showhomologs"); threshold = ajAcdGetFloat("threshold"); referenceseq = ajAcdGetString("referenceseq"); harrplot = ajAcdGetString("harrplot"); seqall = ajAcdGetSeqall("seqall"); outf = ajAcdGetOutfile("outfile"); params.strategy = ajCharNewS(strategy); params.outorder = ajCharNewS(outorder); params.op = op; params.ep = ep; params.scorematrix = ajCharNewS(scorematrix); if (homologs) { params.homologs = xsd__boolean__true_; } else { params.homologs = xsd__boolean__false_; } if (showhomologs) { params.showhomologs = xsd__boolean__true_; } else { params.showhomologs = xsd__boolean__false_; } params.threshold = threshold; params.referenceseq = ajCharNewS(referenceseq); params.harrplot = ajCharNewS(harrplot); AjPStr tmp = NULL; AjPStr tmpFileName = NULL; AjPSeqout fil_file; AjPStr line = NULL; /* if "AjPStr line; -> ajReadline is not success!" */ AjPStr sizestr = NULL; ajint thissize; ajint nb = 0; AjBool are_prot = ajFalse; ajint size = 0; AjPFile infile; tmp = ajStrNewC("fasta"); fil_file = ajSeqoutNew(); tmpFileName = getUniqueFileName(); if( !ajSeqoutOpenFilename(fil_file, tmpFileName) ) { embExitBad(); } ajSeqoutSetFormatS(fil_file, tmp); while (ajSeqallNext(seqall, &seq)) { if (!nb) { are_prot = ajSeqIsProt(seq); } ajSeqoutWriteSeq(fil_file, seq); ++nb; } ajSeqoutClose(fil_file); ajSeqoutDel(&fil_file); if (nb < 2) { ajFatal("Multiple alignments need at least two sequences"); } infile = ajFileNewInNameS(tmpFileName); while (ajReadline(infile, &line)) { ajStrAppendS(&inseq,line); ajStrAppendC(&inseq,"\n"); } soap_init(&soap); char* in0; in0 = ajCharNewS(inseq); if ( soap_call_ns1__runMafft( &soap, NULL, NULL, in0, ¶ms, &jobid ) == SOAP_OK ) { fprintf(stderr,"Jobid: %s\n",jobid); } else { soap_print_fault(&soap, stderr); } int check = 0; while ( check == 0 ) { if ( soap_call_ns1__checkStatus( &soap, NULL, NULL, jobid, &check ) == SOAP_OK ) { fprintf(stderr,"*"); } else { soap_print_fault(&soap, stderr); } sleep(3); } fprintf(stderr,"\n"); if ( soap_call_ns1__getResult( &soap, NULL, NULL, jobid, &result ) == SOAP_OK ) { substr = ajStrNewC(result); ajFmtPrintF(outf,"%S\n",substr); } else { soap_print_fault(&soap, stderr); } ajSysFileUnlinkS(tmpFileName); soap_destroy(&soap); soap_end(&soap); soap_done(&soap); ajFileClose(&outf); ajSeqallDel(&seqall); ajSeqDel(&seq); ajStrDel(&substr); embExit(); return 0; }
int main(int argc, char *argv[]) { embInitPV("gdeltagcskew", argc, argv, "GEMBASSY", "1.0.3"); AjPSeqall seqall; AjPSeq seq; AjPStr inseq = NULL; AjBool at = 0; AjBool purine = 0; AjBool keto = 0; AjPStr method = 0; AjBool accid = ajFalse; AjPStr restid = NULL; AjPStr seqid = NULL; AjPStr base = NULL; AjPStr url = NULL; AjPFile tmpfile = NULL; AjPStr tmpname = NULL; AjPFilebuff tmp = NULL; AjPStr line = NULL; AjPFile outf = NULL; seqall = ajAcdGetSeqall("sequence"); at = ajAcdGetBoolean("at"); purine = ajAcdGetBoolean("purine"); keto = ajAcdGetBoolean("keto"); method = ajAcdGetSelectSingle("method"); accid = ajAcdGetBoolean("accid"); outf = ajAcdGetOutfile("outfile"); base = ajStrNewC("rest.g-language.org"); gAssignUniqueName(&tmpname); while(ajSeqallNext(seqall, &seq)) { inseq = NULL; if(!accid) { if(gFormatGenbank(seq, &inseq)) { tmpfile = ajFileNewOutNameS(tmpname); if(!tmpfile) { ajDie("Output file (%S) open error\n", tmpname); } ajFmtPrintF(tmpfile, "%S", inseq); ajFileClose(&tmpfile); ajFmtPrintS(&url, "http://%S/upload/upl.pl", base); gFilePostSS(url, tmpname, &restid); ajStrDel(&url); ajSysFileUnlinkS(tmpname); } else { ajWarn("Sequence does not have features\n" "Proceeding with sequence accession ID\n"); accid = ajTrue; } } ajStrAssignS(&seqid, ajSeqGetAccS(seq)); if(ajStrGetLen(seqid) == 0) { ajStrAssignS(&seqid, ajSeqGetNameS(seq)); } if(ajStrGetLen(seqid) == 0) { ajWarn("No valid header information\n"); } if(accid) { ajStrAssignS(&restid, seqid); if(ajStrGetLen(seqid) == 0) { ajDie("Cannot proceed without header with -accid\n"); } if(!gValID(seqid)) { ajDie("Invalid accession ID:%S, exiting\n", seqid); } } url = ajStrNew(); ajFmtPrintS(&url, "http://%S/%S/delta_gcskew/", base, restid); if(!gFilebuffURLS(url, &tmp)) { ajDie("Failed to download result from:\n%S\n", url); } ajBuffreadLine(tmp, &line); ajStrRemoveSetC(&line, "\n"); ajFmtPrintF(outf, "Sequence: %S DELTA-GCskew %S\n", seqid, line); ajStrDel(&url); ajStrDel(&restid); ajStrDel(&seqid); ajStrDel(&inseq); } ajFileClose(&outf); ajSeqallDel(&seqall); ajSeqDel(&seq); ajStrDel(&base); embExit(); return 0; }
int main(int argc, char **argv) { AjPSeqall seq1; AjPSeqset seq2; AjPSeq a; const AjPSeq b; AjPStr m = 0; AjPStr n = 0; AjPFile errorf; AjBool show = ajFalse; ajint lena = 0; ajint lenb = 0; const char *p; const char *q; AjPMatrixf matrix; AjPSeqCvt cvt = 0; float **sub; ajint *compass = NULL; float *path = NULL; float gapopen; float gapextend; float score; ajint begina; ajint i; ajuint k; ajint beginb; ajint start1 = 0; ajint start2 = 0; ajint end1 = 0; ajint end2 = 0; ajint width = 0; AjPTable seq1MatchTable = 0; ajint wordlen = 6; ajint oldmax = 0; AjPAlign align = NULL; embInit("supermatcher", argc, argv); matrix = ajAcdGetMatrixf("datafile"); seq1 = ajAcdGetSeqall("asequence"); seq2 = ajAcdGetSeqset("bsequence"); gapopen = ajAcdGetFloat("gapopen"); gapextend = ajAcdGetFloat("gapextend"); wordlen = ajAcdGetInt("wordlen"); align = ajAcdGetAlign("outfile"); errorf = ajAcdGetOutfile("errorfile"); width = ajAcdGetInt("width"); /* not the same as awidth */ gapopen = ajRoundFloat(gapopen, 8); gapextend = ajRoundFloat(gapextend, 8); sub = ajMatrixfGetMatrix(matrix); cvt = ajMatrixfGetCvt(matrix); embWordLength(wordlen); ajSeqsetTrim(seq2); while(ajSeqallNext(seq1,&a)) { ajSeqTrim(a); begina = 1 + ajSeqGetOffset(a); m = ajStrNewRes(1+ajSeqGetLen(a)); lena = ajSeqGetLen(a); ajDebug("Read '%S'\n", ajSeqGetNameS(a)); if(!embWordGetTable(&seq1MatchTable, a)) /* get table of words */ ajErr("Could not generate table for %s\n", ajSeqGetNameC(a)); for(k=0;k<ajSeqsetGetSize(seq2);k++) { b = ajSeqsetGetseqSeq(seq2, k); lenb = ajSeqGetLen(b); beginb = 1 + ajSeqGetOffset(b); ajDebug("Processing '%S'\n", ajSeqGetNameS(b)); p = ajSeqGetSeqC(a); q = ajSeqGetSeqC(b); if(!supermatcher_findstartpoints(seq1MatchTable,b,a, &start1, &start2, &end1, &end2)) { ajFmtPrintF(errorf, "No wordmatch start points for " "%s vs %s. No alignment\n", ajSeqGetNameC(a),ajSeqGetNameC(b)); continue; } n=ajStrNewRes(1+ajSeqGetLen(b)); ajStrAssignC(&m,""); ajStrAssignC(&n,""); ajDebug("++ %S v %S start:%d %d end:%d %d\n", ajSeqGetNameS(a), ajSeqGetNameS(b), start1, start2, end1, end2); if(end1-start1+1 > oldmax) { oldmax = ((end1-start1)+1); AJRESIZE(path,oldmax*width*sizeof(float)); AJRESIZE(compass,oldmax*width*sizeof(ajint)); ajDebug("++ resize to oldmax: %d\n", oldmax); } for(i=0;i<((end1-start1)+1)*width;i++) path[i] = 0.0; ajDebug("Calling embAlignPathCalcFast " "%d..%d [%d/%d] %d..%d [%d/%d]\n", start1, end1, (end1 - start1 + 1), lena, start2, end2, (end2 - start2 + 1), lenb); score = embAlignPathCalcSWFast(&p[start1],&q[start2], end1-start1+1,end2-start2+1, 0,width, gapopen,gapextend, path,sub,cvt, compass,show); embAlignWalkSWMatrixFast(path,compass,gapopen,gapextend,a,b, &m,&n,end1-start1+1,end2-start2+1, 0,width, &start1,&start2); if(!ajAlignFormatShowsSequences(align)) { ajAlignDefineCC(align, ajStrGetPtr(m), ajStrGetPtr(n), ajSeqGetNameC(a), ajSeqGetNameC(b)); ajAlignSetScoreR(align, score); } else { embAlignReportLocal(align, a, b, m,n,start1,start2, gapopen, gapextend, score,matrix, begina, beginb); } ajAlignWrite(align); ajAlignReset(align); ajStrDel(&n); } embWordFreeTable(&seq1MatchTable); /* free table of words */ seq1MatchTable=0; ajStrDel(&m); } if(!ajAlignFormatShowsSequences(align)) { ajMatrixfDel(&matrix); } AJFREE(path); AJFREE(compass); ajAlignClose(align); ajAlignDel(&align); ajSeqallDel(&seq1); ajSeqDel(&a); ajSeqsetDel(&seq2); ajFileClose(&errorf); embExit(); return 0; }
int main(int argc, char *argv[]) { embInitPV("ggcskew", argc, argv, "GEMBASSY", "1.0.3"); AjPSeqall seqall; AjPSeq seq; AjPStr inseq = NULL; AjBool accid = ajFalse; AjPStr restid = NULL; AjPStr seqid = NULL; AjPStr base = NULL; AjPStr url = NULL; AjPStr tmpname = NULL; AjPSeqout tmpout = NULL; ajint window = 0; ajint slide = 0; AjBool cumulative = 0; AjBool at = 0; AjBool purine = 0; AjBool keto = 0; AjBool plot = 0; AjPFile outf = NULL; AjPFilebuff buff = NULL; AjPGraph mult = NULL; gPlotParams gpp; AjPStr title = NULL; seqall = ajAcdGetSeqall("sequence"); window = ajAcdGetInt("window"); slide = ajAcdGetInt("slide"); cumulative = ajAcdGetBoolean("cumulative"); at = ajAcdGetBoolean("at"); purine = ajAcdGetBoolean("purine"); keto = ajAcdGetBoolean("keto"); plot = ajAcdGetToggle("plot"); outf = ajAcdGetOutfile("outfile"); mult = ajAcdGetGraphxy("graph"); base = ajStrNewC("rest.g-language.org"); gAssignUniqueName(&tmpname); ajStrAppendC(&tmpname, ".fasta"); while(ajSeqallNext(seqall, &seq)) { tmpout = ajSeqoutNew(); if(!ajSeqoutOpenFilename(tmpout, tmpname)) { embExitBad(); } ajSeqoutSetFormatS(tmpout,ajStrNewC("fasta")); ajSeqoutWriteSeq(tmpout, seq); ajSeqoutClose(tmpout); ajSeqoutDel(&tmpout); ajFmtPrintS(&url, "http://%S/upload/upl.pl", base); gFilePostSS(url, tmpname, &restid); ajStrDel(&url); ajSysFileUnlinkS(tmpname); ajStrAssignS(&seqid, ajSeqGetAccS(seq)); if(ajStrGetLen(seqid) == 0) { ajStrAssignS(&seqid, ajSeqGetNameS(seq)); } if(ajStrGetLen(seqid) == 0) { ajWarn("No valid header information\n"); } url = ajStrNew(); ajFmtPrintS(&url, "http://%S/%S/gcskew/window=%d/slide=%d/cumulative=%d/" "at=%d/purine=%d/keto=%d/output=f/", base, restid, window, slide, cumulative, at, purine, keto); if(plot) { title = ajStrNew(); ajStrAppendC(&title, argv[0]); ajStrAppendC(&title, " of "); ajStrAppendS(&title, seqid); gpp.title = ajStrNewS(title); gpp.xlab = ajStrNewC("location"); gpp.ylab = ajStrNewC("GC skew"); if(!gFilebuffURLS(url, &buff)) { ajDie("File downloading error from:\n%S\n", url); } if(!gPlotFilebuff(buff, mult, &gpp)) { ajDie("Error in plotting\n"); } AJFREE(gpp.title); AJFREE(gpp.xlab); AJFREE(gpp.ylab); ajStrDel(&title); ajFilebuffDel(&buff); } else { ajFmtPrintF(outf, "Sequence: %S\n", seqid); if(!gFileOutURLS(url, &outf)) { ajDie("File downloading error from:\n%S\n", url); } } ajStrDel(&url); ajStrDel(&restid); ajStrDel(&seqid); } ajFileClose(&outf); ajSeqallDel(&seqall); ajSeqDel(&seq); ajStrDel(&base); embExit(); return 0; }
int main(int argc, char **argv) { // initialize EMBASSY info embInitPV("kweblogo", argc, argv, "KBWS", "1.0.9"); // soap driver and parameter object struct soap soap; struct ns1__weblogoInputParams params; char* jobid; AjPSeqall seqall; AjPSeq seq; AjPStr substr; AjPStr inseq = NULL; // get input sequence seqall= ajAcdGetSeqall("seqall"); // get/set parameters params.format = ajCharNewS(ajAcdGetString("format")); AjPStr tmp= NULL; AjPStr tmpFileName= NULL; AjPSeqout fil_file; AjPStr line= NULL; /* if "AjPStr line; -> ajReadline is not success!" */ AjPStr sizestr= NULL; ajint thissize; ajint nb= 0; AjBool are_prot= ajFalse; ajint size= 0; AjPFile infile; AjPFile goutf; AjPStr goutfile; goutfile= ajAcdGetString("goutfile"); tmp= ajStrNewC("fasta"); fil_file= ajSeqoutNew(); tmpFileName= getUniqueFileName(); if(!ajSeqoutOpenFilename(fil_file, tmpFileName)) { embExitBad(); } ajSeqoutSetFormatS(fil_file, tmp); while (ajSeqallNext(seqall, &seq)) { if (!nb) { are_prot = ajSeqIsProt(seq); } ajSeqoutWriteSeq(fil_file, seq); ++nb; } ajSeqoutClose(fil_file); ajSeqoutDel(&fil_file); if (nb < 2) { ajFatal("Multiple alignments need at least two sequences"); } infile = ajFileNewInNameS(tmpFileName); while (ajReadline(infile, &line)) { ajStrAppendS(&inseq,line); ajStrAppendC(&inseq,"\n"); } soap_init(&soap); char* in0; in0= ajCharNewS(inseq); if (soap_call_ns1__runWeblogo( &soap, NULL, NULL, in0, ¶ms, &jobid) == SOAP_OK) { } else { soap_print_fault(&soap, stderr); } int check= 0; while (check == 0 ) { if (soap_call_ns1__checkStatus(&soap, NULL, NULL, jobid, &check) == SOAP_OK) { } else { soap_print_fault(&soap, stderr); } sleep(3); } char* image_url; if (soap_call_ns1__getResult(&soap, NULL, NULL, jobid, &image_url) == SOAP_OK) { goutf= ajFileNewOutNameS(goutfile); if (!goutf) { // can not open image output file ajFmtError("Problem writing out image file"); embExitBad(); } if (!gHttpGetBinC(image_url, &goutf)) { // can not download image file ajFmtError("Problem downloading image file"); embExitBad(); } } else { soap_print_fault(&soap, stderr); } // delete temporary multi-fasta sequence file ajSysFileUnlinkS(tmpFileName); // destruct SOAP driver soap_destroy(&soap); soap_end(&soap); soap_done(&soap); // destruct EMBOSS object ajSeqallDel(&seqall); ajSeqDel(&seq); ajStrDel(&substr); // exit embExit(); return 0; }
int main(int argc, char *argv[]) { embInitPV("gbaseinformationcontent", argc, argv, "GEMBASSY", "1.0.1"); AjPSeqall seqall; AjPSeq seq; AjPStr inseq = NULL; AjPStr position = 0; ajint PatLen = 0; ajint upstream = 0; ajint downstream = 0; AjBool accid = ajFalse; AjPStr restid = NULL; AjPStr seqid = NULL; AjPStr base = NULL; AjPStr url = NULL; AjPFile tmpfile = NULL; AjPStr tmpname = NULL; AjBool plot = 0; AjPFile outf = NULL; AjPFilebuff buff = NULL; AjPGraph mult = NULL; gPlotParams gpp; AjPStr title = NULL; seqall = ajAcdGetSeqall("sequence"); position = ajAcdGetSelectSingle("position"); PatLen = ajAcdGetInt("patlen"); upstream = ajAcdGetInt("upstream"); downstream = ajAcdGetInt("downstream"); accid = ajAcdGetBoolean("accid"); plot = ajAcdGetToggle("plot"); outf = ajAcdGetOutfile("outfile"); mult = ajAcdGetGraphxy("graph"); base = ajStrNewC("rest.g-language.org"); gAssignUniqueName(&tmpname); while(ajSeqallNext(seqall, &seq)) { inseq = NULL; if(!accid) { if(gFormatGenbank(seq, &inseq)) { gAssignUniqueName(&tmpname); tmpfile = ajFileNewOutNameS(tmpname); if(!tmpfile) { ajFmtError("Output file (%S) open error\n", tmpname); embExitBad(); } ajFmtPrintF(tmpfile, "%S", inseq); ajFileClose(&tmpfile); ajFmtPrintS(&url, "http://%S/upload/upl.pl", base); gFilePostSS(url, tmpname, &restid); ajStrDel(&url); ajSysFileUnlinkS(tmpname); } else { ajFmtError("Sequence does not have features\n" "Proceeding with sequence accession ID\n"); accid = ajTrue; } } if(accid) { ajStrAssignS(&seqid, ajSeqGetAccS(seq)); if(!ajStrGetLen(seqid)) { ajStrAssignS(&seqid, ajSeqGetNameS(seq)); } if(!ajStrGetLen(seqid)) { ajFmtError("No valid header information\n"); embExitBad(); } ajStrAssignS(&restid, seqid); } ajStrAssignS(&seqid, ajSeqGetAccS(seq)); url = ajStrNew(); ajFmtPrintS(&url, "http://%S/%S/base_information_content/position=%S/" "PatLen=%d/upstream=%d/downstream=%d/output=f/tag=gene", base, restid, position, PatLen, upstream, downstream); if(plot) { title = ajStrNew(); ajStrAppendC(&title, argv[0]); ajStrAppendC(&title, " of "); ajStrAppendS(&title, seqid); gpp.title = ajStrNewS(title); gpp.xlab = ajStrNewC("position"); gpp.ylab = ajStrNewC("information content"); if(!gFilebuffURLS(url, &buff)) { ajDie("File downloading error from:\n%S\n", url); } if(!gPlotFilebuff(buff, mult, &gpp)) { ajDie("Error in plotting\n"); } AJFREE(gpp.title); AJFREE(gpp.xlab); AJFREE(gpp.ylab); ajStrDel(&title); ajFilebuffDel(&buff); } else { ajFmtPrintF(outf, "Sequence: %S\n", seqid); if(!gFileOutURLS(url, &outf)) { ajDie("File downloading error from:\n%S\n", url); } } } ajFileClose(&outf); ajSeqallDel(&seqall); ajSeqDel(&seq); ajStrDel(&seqid); ajStrDel(&position); embExit(); return 0; }
int main(int argc, char **argv) { AjPSeqall seqall; AjPSeq seq = NULL; AjPReport outf = NULL; AjPFile inf = NULL; ajint begin; ajint end; AjPList l = NULL; AjPStr strand = NULL; AjPStr substr = NULL; AjPStr line = NULL; AjPStr name = NULL; AjPStr acc = NULL; AjPStr bf = NULL; AjPStr menu; AjPStr pattern = NULL; AjPStr opattern = NULL; AjPStr pname = NULL; AjPStr key = NULL; AjPStr value = NULL; AjPTable atable = NULL; AjPTable btable = NULL; ajint mismatch; ajint minlength; ajint sum; ajint v; char cp; const char *p; embInit("tfscan", argc, argv); seqall = ajAcdGetSeqall("sequence"); outf = ajAcdGetReport("outfile"); mismatch = ajAcdGetInt("mismatch"); minlength = ajAcdGetInt("minlength"); menu = ajAcdGetListSingle("menu"); pname = ajStrNew(); cp=ajStrGetCharFirst(menu); if(cp=='F') ajStrAssignC(&pname,"tffungi"); else if(cp=='I') ajStrAssignC(&pname,"tfinsect"); else if(cp=='O') ajStrAssignC(&pname,"tfother"); else if(cp=='P') ajStrAssignC(&pname,"tfplant"); else if(cp=='V') ajStrAssignC(&pname,"tfvertebrate"); else if(cp=='C') inf = ajAcdGetDatafile("custom"); if(cp!='C') { inf = ajDatafileNewInNameS(pname); if(!inf) ajFatal("Either EMBOSS_DATA undefined or TFEXTRACT needs running"); } name = ajStrNew(); acc = ajStrNew(); bf = ajStrNewC(""); substr = ajStrNew(); line = ajStrNew(); pattern = ajStrNewC("AA"); opattern = ajStrNew(); while(ajSeqallNext(seqall, &seq)) { begin=ajSeqallGetseqBegin(seqall); end=ajSeqallGetseqEnd(seqall); ajStrAssignC(&name,ajSeqGetNameC(seq)); strand=ajSeqGetSeqCopyS(seq); ajStrAssignSubC(&substr,ajStrGetPtr(strand),begin-1,end-1); ajStrFmtUpper(&substr); l=ajListNew(); atable = ajTablestrNew(1000); btable = ajTablestrNew(1000); sum=0; while(ajReadlineTrim(inf,&line)) { p = ajStrGetPtr(line); if(!*p || *p=='#' || *p=='\n' || *p=='!') continue; ajFmtScanS(line,"%S%S%S",&pname,&pattern,&acc); p += ajStrGetLen(pname); while(*p && *p==' ') ++p; p += ajStrGetLen(pattern); while(*p && *p==' ') ++p; p += ajStrGetLen(acc); while(*p && *p==' ') ++p; ajStrAssignS(&opattern,pattern); ajStrAssignC(&bf,p); /* rest of line */ v = embPatVariablePattern(pattern,substr,pname,l,0, mismatch,begin); if(v) { key = ajStrNewS(pname); value = ajStrNewS(acc); ajTablePut(atable,(void *)key,(void *)value); key = ajStrNewS(pname); value = ajStrNewS(bf); ajTablePut(btable,(void *)key,(void *)value); } sum += v; } if(sum) tfscan_print_hits(&l,sum,outf,atable,seq,minlength, btable); ajFileSeek(inf,0L,0); ajListFree(&l); ajTablestrFree(&atable); ajTablestrFree(&btable); ajStrDel(&strand); } ajStrDel(&line); ajStrDel(&name); ajStrDel(&acc); ajStrDel(&pname); ajStrDel(&opattern); ajStrDel(&bf); ajStrDel(&pattern); ajStrDel(&substr); ajSeqDel(&seq); ajFileClose(&inf); ajReportClose(outf); ajReportDel(&outf); ajSeqallDel(&seqall); ajSeqDel(&seq); ajStrDel(&menu); embExit(); return 0; }
int main(int argc, char *argv[]) { embInitPV("gseqinfo", argc, argv, "GEMBASSY", "1.0.1"); struct soap soap; AjPSeqall seqall; AjPSeq seq; AjPStr inseq = NULL; AjPStr seqid = NULL; AjPStr tmp = NULL; AjPStr parse = NULL; AjPStr numA = NULL; AjPStr numT = NULL; AjPStr numG = NULL; AjPStr numC = NULL; AjPStrTok handle = NULL; ajint n; char *in0; char *result; AjBool show = 0; AjPFile outf = NULL; seqall = ajAcdGetSeqall("sequence"); outf = ajAcdGetOutfile("outfile"); while(ajSeqallNext(seqall, &seq)) { soap_init(&soap); inseq = NULL; ajStrAppendC(&inseq, ">"); ajStrAppendS(&inseq, ajSeqGetNameS(seq)); ajStrAppendC(&inseq, "\n"); ajStrAppendS(&inseq, ajSeqGetSeqS(seq)); ajStrAssignS(&seqid, ajSeqGetAccS(seq)); in0 = ajCharNewS(inseq); if(soap_call_ns1__seqinfo( &soap, NULL, NULL, in0, &result ) == SOAP_OK) { tmp = ajStrNewC(result); ajStrExchangeCC(&tmp, "<", "\n"); ajStrExchangeCC(&tmp, ">", "\n"); handle = ajStrTokenNewC(tmp, "\n"); while(ajStrTokenNextParse(handle, &parse)) { if(ajStrIsInt(parse)) if(!numA) numA = ajStrNewS(parse); else if(!numT) numT = ajStrNewS(parse); else if(!numG) numG = ajStrNewS(parse); else if(!numC) numC = ajStrNewS(parse); } if(show) ajFmtPrint("Sequence: %S A: %S T: %S G: %S C: %S\n", seqid, numA, numT, numG, numC); else ajFmtPrintF(outf, "Sequence: %S A: %S T: %S G: %S C: %S\n", seqid, numA, numT, numG, numC); } else { soap_print_fault(&soap, stderr); } soap_destroy(&soap); soap_end(&soap); soap_done(&soap); AJFREE(in0); ajStrDel(&inseq); } ajSeqallDel(&seqall); ajSeqDel(&seq); ajStrDel(&seqid); embExit(); return 0; }
int main(int argc, char **argv) { AjPFile inf = NULL; AjPFile inf2 = NULL; AjPFeattable tab = NULL; AjPReport report = NULL; AjPSeq sequence = NULL; AjPStr redatanew = NULL; AjPStr str = NULL; AjPStr regexp = NULL; AjPStr temp = NULL; AjPStr text = NULL; AjPStr docdata = NULL; AjPStr data = NULL; AjPStr accession = NULL; AjPStr name = NULL; EmbPPatMatch match = NULL; AjPStr savereg = NULL; AjPStr fthit = NULL; AjBool full; AjBool prune; ajint i; ajint number; ajint start; ajint end; ajint length; ajint zstart; ajint zend; const char *p; ajint seqlength; AjPStr tmpstr = NULL; AjPStr tailstr = NULL; AjPFeature gf; embInit("patmatmotifs", argc, argv); ajStrAssignC(&fthit, "SO:0001067"); savereg = ajStrNew(); str = ajStrNew(); regexp = ajStrNew(); temp = ajStrNew(); data = ajStrNew(); accession = ajStrNew(); text = ajStrNew(); name = ajStrNew(); sequence = ajAcdGetSeq("sequence"); report = ajAcdGetReport("outfile"); full = ajAcdGetBoolean("full"); prune = ajAcdGetBoolean("prune"); ajSeqFmtUpper(sequence); /* prosite regexs are all upper case */ tab = ajFeattableNewSeq(sequence); ajStrAssignC(&tailstr, ""); seqlength = ajStrGetLen(str); str = ajSeqGetSeqCopyS(sequence); redatanew = ajStrNewC("PROSITE/prosite.lines"); docdata = ajStrNewC("PROSITE/"); inf = ajDatafileNewInNameS(redatanew); if(!inf) ajFatal("Either EMBOSS_DATA undefined or PROSEXTRACT needs running"); ajFmtPrintAppS(&tmpstr, "Full: %B\n", full); ajFmtPrintAppS(&tmpstr, "Prune: %B\n", prune); ajFmtPrintAppS(&tmpstr, "Data_file: %F\n", inf); ajReportSetHeaderS(report, tmpstr); while(ajReadlineTrim(inf, ®exp)) { p=ajStrGetPtr(regexp); if(*p && *p!=' ' && *p!='^') { p=ajSysFuncStrtok(p," "); ajStrAssignC(&name,p); if(prune) if(ajStrMatchCaseC(name,"myristyl") || ajStrMatchCaseC(name,"asn_glycosylation") || ajStrMatchCaseC(name,"camp_phospho_site") || ajStrMatchCaseC(name,"pkc_phospho_site") || ajStrMatchCaseC(name,"ck2_phospho_site") || ajStrMatchCaseC(name,"tyr_phospho_site")) { for(i=0;i<4;++i) ajReadlineTrim(inf, ®exp); continue; } p=ajSysFuncStrtok(NULL," "); ajStrAssignC(&accession,p); } if(ajStrPrefixC(regexp, "^")) { p = ajStrGetPtr(regexp); ajStrAssignC(&temp,p+1); ajStrAssignC(&savereg,p+1); match = embPatMatchFind(temp, str, ajFalse, ajFalse); number = embPatMatchGetNumber(match); for(i=0; i<number; i++) { seqlength = ajStrGetLen(str); start = 1+embPatMatchGetStart(match, i); end = 1+embPatMatchGetEnd(match, i); length = embPatMatchGetLen(match, i); gf = ajFeatNew(tab, NULL, fthit, start, end, (float) length, ' ', 0); ajFmtPrintS(&tmpstr, "*motif %S", name); ajFeatTagAddSS(gf, NULL, tmpstr); if(start-5<0) zstart = 0; else zstart = start-5; if(end+5> seqlength) zend = end; else zend = end+5; ajStrAssignSubS(&temp, str, zstart, zend); } if(full && number) { ajStrAssignC(&redatanew,ajStrGetPtr(docdata)); ajStrAppendC(&redatanew,ajStrGetPtr(accession)); inf2 = ajDatafileNewInNameS(redatanew); if(!inf2) continue; /* ** Insert Prosite documentation from files made by ** prosextract.c */ ajFmtPrintAppS(&tailstr, "Motif: %S\n", name); ajFmtPrintAppS(&tailstr, "Count: %d\n\n", number); while(ajReadlineTrim(inf2, &text)) ajFmtPrintAppS(&tailstr, "%S\n", text); ajFmtPrintAppS(&tailstr, "\n***************\n\n"); ajFileClose(&inf2); } embPatMatchDel(&match); } } ajReportSetTailS(report,tailstr); ajReportWrite(report, tab, sequence); ajReportDel(&report); ajFeattableDel(&tab); ajStrDel(&temp); ajStrDel(®exp); ajStrDel(&savereg); ajStrDel(&str); ajStrDel(&data); ajStrDel(&docdata); ajStrDel(&text); ajStrDel(&redatanew); ajStrDel(&accession); ajSeqDel(&sequence); ajStrDel(&tailstr); ajStrDel(&fthit); ajStrDel(&name); ajStrDel(&tmpstr); ajFeattableDel(&tab); ajFileClose(&inf); embExit(); return 0; }
int main(int argc, char **argv) { AjPSeqall seqall; AjPSeq seq = NULL; AjPReport report = NULL; AjPStr jaspdir = NULL; AjPStr menu = NULL; AjPStr substr = NULL; AjPStr mats = NULL; AjPStr excl = NULL; float thresh = 0.; ajuint recurs = 0; AjPStr dir = NULL; AjPStr mfname = NULL; AjPList flist = NULL; AjPList hits = NULL; AjPStr head = NULL; ajint begin; ajint end; ajuint mno; char cp; ajuint i; AjPTable mattab = NULL; AjPFeattable TabRpt = NULL; AjBool both = ajFalse; embInit("jaspscan", argc, argv); seqall = ajAcdGetSeqall("sequence"); menu = ajAcdGetListSingle("menu"); mats = ajAcdGetString("matrices"); excl = ajAcdGetString("exclude"); thresh = ajAcdGetFloat("threshold"); report = ajAcdGetReport("outfile"); both = ajAcdGetBoolean("both"); jaspdir = ajStrNew(); substr = ajStrNew(); flist = ajListNew(); hits = ajListNew(); dir = ajStrNew(); head = ajStrNew(); cp = ajStrGetCharFirst(menu); if(cp=='C') ajStrAssignC(&jaspdir,J_COR); else if(cp=='F') ajStrAssignC(&jaspdir,J_FAM); else if(cp=='P') ajStrAssignC(&jaspdir,J_PHY); else if(cp=='N') ajStrAssignC(&jaspdir,J_CNE); else if(cp=='O') ajStrAssignC(&jaspdir,J_POL); else if(cp=='S') ajStrAssignC(&jaspdir,J_SPL); else ajFatal("Invalid JASPAR database selection"); ajStrAssignS(&dir, ajDatafileValuePath()); if(!ajStrGetLen(dir)) ajFatal("EMBOSS DATA directory couldn't be determined"); jaspscan_ParseInput(dir, jaspdir, mats, excl, &recurs, flist); mno = ajListGetLength(flist); if(cp == 'C') mattab = jaspscan_ReadCoreList(jaspdir); if(cp == 'F') mattab = jaspscan_ReadFamList(jaspdir); if(cp == 'P') mattab = jaspscan_ReadCoreList(jaspdir); if(cp == 'N') mattab = jaspscan_ReadCoreList(jaspdir); if(cp == 'O') mattab = jaspscan_ReadCoreList(jaspdir); if(cp == 'S') mattab = jaspscan_ReadCoreList(jaspdir); ajFmtPrintS(&head,"Database scanned: %S Threshold: %.3f",jaspdir,thresh); ajReportSetHeaderS(report,head); while(ajSeqallNext(seqall, &seq)) { begin = ajSeqallGetseqBegin(seqall); end = ajSeqallGetseqEnd(seqall); ajStrAssignSubC(&substr,ajSeqGetSeqC(seq),begin-1,end-1); ajStrFmtUpper(&substr); TabRpt = ajFeattableNewSeq(seq); for(i=0; i < mno; ++i) { ajListPop(flist,(void **)&mfname); jaspscan_scan(substr,begin,mfname, cp, thresh, both, hits); ajListPushAppend(flist, (void **)mfname); } jaspscan_ReportHits(TabRpt,mattab,hits); ajReportWrite(report, TabRpt, seq); ajFeattableDel(&TabRpt); } while(ajListPop(flist,(void **)&mfname)) ajStrDel(&mfname); ajStrDel(&dir); ajStrDel(&menu); ajStrDel(&excl); ajStrDel(&substr); ajStrDel(&mats); ajStrDel(&head); ajStrDel(&jaspdir); ajSeqDel(&seq); ajTableMapDel(mattab,jaspscan_ClearTable,NULL); ajTableFree(&mattab); ajListFree(&flist); ajListFree(&hits); ajSeqallDel(&seqall); ajReportDel(&report); embExit(); return 0; }
int main(int argc, char **argv) { AjPDasServer server = NULL; AjPDasSource source = NULL; AjPDasSegment segment = NULL; AjPStr host = NULL; AjPStr path = NULL; AjPFile outf = NULL; ajint port = 80; AjBool sequencesourcesonly; AjBool entrypoints; AjBool showtestqueries; AjBool runtestqueries = ajTrue; AjBool quickexit = ajFalse; ajint itest=0; ajint j=0; ajint maxtests=0; ajint maxfeatures=0; ajint maxsegments=0; AjIList iter = NULL; AjIList coordsi = NULL; AjIList itereps = NULL; AjPFilebuff buff = NULL; AjPUrlref uo = NULL; AjPList segments = NULL; AjPStr ffname = NULL; AjPStr url = NULL; AjPStr dbhttpver = ajStrNew(); AjPStr dbname = ajStrNew(); AjPStr dbproxy = ajStrNew(); AjPStr servername = NULL; AjPTable titlecount = NULL; const ajuint* count; int k=0; embInit("dastest", argc, argv); host = ajAcdGetString("host"); path = ajAcdGetString("path"); port = ajAcdGetInt("port"); sequencesourcesonly = ajAcdGetBoolean("sequencesourcesonly"); entrypoints = ajAcdGetBoolean("entrypoints"); showtestqueries = ajAcdGetBoolean("showtestqueries"); runtestqueries = ajAcdGetBoolean("runtestqueries"); servername = ajAcdGetString("servername"); outf = ajAcdGetOutfile("outfile"); maxtests = ajAcdGetInt("maxtests"); maxfeatures = ajAcdGetInt("maxfeatures"); maxsegments = ajAcdGetInt("maxsegments"); server = ajDasServerNew(); if(runtestqueries) { url = ajStrNew(); if(!ajNamServer(servername)) { ajWarn("following das server is required to be defined " "for test queries..."); ajWarn("\nSERVER %S [\n" " type: \"sequence\"\n" " method: \"das\"\n" " url: \"http://%S%S\"\n" "]\n",servername, host,path); ajWarn("ignoring -runtestqueries option..."); runtestqueries = ajFalse; } else { ajNamSvrGetUrl(servername, &url); ajHttpUrlDeconstruct(url, &port, &host, &path); ajStrDel(&url); } } ajDasServerSethostS(server,host); ajDasServerSetport(server,port); if(ajStrGetCharLast(path)!='/') ajStrAppendK(&path,'/'); ajStrAppendC(&path,"sources"); ajDasServerSetpathS(server,path); ajFmtPrintF(outf,"host = %S\npath = %S\nport = %d\n", server->host, server->path, server->port); /* * TODO: stop using http-read but instead use * ajNamSvrListListDatabases(svrname, dbnames); */ buff = ajHttpRead(dbhttpver, dbname, dbproxy, host, port, path); if(!buff) ajExitAbort(); ajFilebuffHtmlNoheader(buff); ajDasParseRegistry(buff, server->sources); ajFmtPrintF(outf,"DAS sources and descriptions\n\n"); titlecount = dastestGetTitleCount(server); iter = ajListIterNew(server->sources); while(!ajListIterDone(iter) && !quickexit) { source = ajListIterGet(iter); if ((sequencesourcesonly && !source->sequence) || ajStrMatchC(source->title,"cath") || k++ <50) continue; ajFmtPrintF(outf,"%-30S %-50S\n%S\n",source->uri,source->title, source->description); if(entrypoints && source->entry_points) { uo = ajHttpUrlrefNew(); ajHttpUrlrefParseC(&uo, ajStrGetPtr(source->entry_points_uri)); if(ajStrGetLen(uo->Port)) ajStrToInt(uo->Port, &port); else port = 80; ajFilebuffDel(&buff); buff = ajHttpRead(dbhttpver, dbname, dbproxy, uo->Host, port, uo->Absolute); ajHttpUrlrefDel(&uo); if(!buff) continue; ajFilebuffHtmlNoheader(buff); segments = ajListNew(); ajDasParseEntrypoints(buff, segments); itereps = ajListIterNew(segments); ajFmtPrintF(outf, "Number of entry points %d\n", ajListGetLength(segments)); j=0; while(!ajListIterDone(itereps)) { segment = ajListIterGet(itereps); if (j++ < maxsegments) ajFmtPrintF(outf, "segment id:%S orientation:%S start:%d stop:%d\n", segment->id, segment->orientation, segment->start, segment->stop); ajDasSegmentDel(&segment); } ajListIterDel(&itereps); ajListFree(&segments); } if(showtestqueries || runtestqueries) { AjPDasCoordinate coord; coordsi = ajListIterNew(source->coordinates); while(!ajListIterDone(coordsi) && !quickexit) { coord = ajListIterGet(coordsi); ajDebug("coordinate uri:%S taxid:%S source:%S test_range:%S\n", coord->uri, coord->taxid, coord->source, coord->test_range); if(showtestqueries) { if(source->sequence) ajFmtPrintF(outf, "example/test entry = '%S?segment=%S'\n", source->sequence_query_uri,coord->test_range); if(source->features) ajFmtPrintF(outf, "example/test entry = '%S?segment=%S'\n", source->features_query_uri,coord->test_range); } if(runtestqueries) { AjPStr idqry = ajStrNew(); AjPStr entry = NULL; AjPSeq seq = NULL; ajint ibegin = 0; ajint iend = 0; AjPStr example = NULL; example = ajDasTestrangeParse(coord->test_range, &entry, &ibegin, &iend); if(ajStrGetLen(entry)) { count = ajTableFetchS(titlecount, source->title); dbname = ajDasSourceGetDBname(source, *count>1); if (source->features) { AjPStr qpath=NULL; uo = ajHttpUrlrefNew(); ajFmtPrintS(&idqry,"dasgff::%S:%S:%S", servername, dbname, entry); ajFmtPrintF(outf, "feature query: %S start:%d end:%d\n", idqry, ibegin, iend); ajHttpUrlrefParseC(&uo, ajStrGetPtr(source->features_query_uri)); ajHttpUrlrefSplitPort(uo); ajFmtPrintS(&qpath,"%S?segment=%S", uo->Absolute,entry); if(iend>0) ajFmtPrintAppS(&qpath,":%d,%d",ibegin, iend); if(ajStrGetLen(uo->Port)) ajStrToInt(uo->Port, &port); else port = 80; ajDebug("calling ajHttpRead to get the raw" " output; host:%S port:%d path:%S\n", uo->Host, port, qpath); ajFilebuffDel(&buff); buff = ajHttpRead(dbhttpver, dbname, dbproxy, uo->Host, port, qpath); if(buff) { AjPFeattable ft; ajFmtPrintS(&ffname, "%S.%S", source->uri, entry); ajFilebuffHtmlNoheader(buff); dastestSaveRawFeatures(buff, ffname); ajDebug("now using EMBOSS feature queries\n"); ft = dastestFeatureQuery(idqry, ibegin, iend); dastestSaveMappedFeatures(ft, ffname, outf, maxfeatures); ajStrDel(&ffname); ajFeattableDel(&ft); } ajHttpUrlrefDel(&uo); ajStrDel(&qpath); if(++itest>=maxtests) quickexit = ajTrue; } else if(source->sequence) { seq = ajSeqNewRes(iend-ibegin+1); ajFmtPrintS(&idqry,"%S:%S:%S", servername, dbname, entry); ajFmtPrintF(outf, "sequence query: %S start:%d end:%d\n", idqry, ibegin, iend); ajSeqGetFromUsaRange(idqry, ajFalse, ibegin, iend, seq); ajFmtPrintF(outf, "length of sequence returned: %d\n", ajSeqGetLen(seq)); if(ajSeqGetLen(seq)>0) ajFmtPrintF(outf, "sequence returned (first 100 bases):" " %-100.100s\n", ajSeqGetSeqC(seq)); ajSeqDel(&seq); } ajStrDel(&dbname); } ajStrDel(&entry); ajStrDel(&idqry); ajStrDel(&example); } } ajListIterDel(&coordsi); } } ajListIterDel(&iter); ajDasServerDel(&server); ajFilebuffDel(&buff); ajStrDel(&host); ajStrDel(&path); ajStrDel(&servername); ajStrDel(&dbhttpver); ajStrDel(&dbname); ajStrDel(&dbproxy); ajFileClose(&outf); ajTableDelValdel(&titlecount, ajMemFree); embExit(); return 0; }