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) { AjPSeq seq = NULL; AjPFile outf = NULL; embInitPV("myseq", argc, argv, "myemboss",VERSION); seq = ajAcdGetSeq("sequence"); outf = ajAcdGetOutfile("outfile"); ajFmtPrintF(outf, "Sequence properties\n"); ajFmtPrintF(outf, "===================\n"); ajFmtPrintF(outf, "Name: %S\n", ajSeqGetNameS(seq)); ajFmtPrintF(outf, "Usa: %S\n", ajSeqGetUsaS(seq)); ajFmtPrintF(outf, "Length: %d\n", ajSeqGetLen(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; }
static void listor_Write(AjPFile list, const AjPSeqset seqset, ajint i) { ajFmtPrintF(list, "%S\n", ajSeqGetUsaS(ajSeqsetGetseqSeq(seqset, i))); return; }
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) { AjPSeqset seqset = NULL; AjPStr refseq; /* input name/number of reference sequence */ ajint nrefseq; /* numeric reference sequence */ AjPMatrix matrix; /* scoring matrix structure */ ajint **sub; /* integer scoring matrix */ AjPSeqCvt cvt = 0; /* conversion table for scoring matrix */ float identity; ajint ident; float fplural; AjPStr cons; AjPSeq consensus; const AjPSeq ref; const AjPSeq seq; ajuint i; AjBool html; AjBool doheader; AjBool dousa; AjBool doname; AjBool doseqlength; AjBool doalignlength; AjBool dogaps; AjBool dogapcount; AjBool doidcount; AjBool dosimcount; AjBool dodifcount; AjBool dochange; AjBool dodesc; AjBool dowt; ajint seqlength; ajint alignlength; ajint gaps; ajint gapcount; ajint idcount; ajint simcount; ajint difcount; float change; AjPFile outfile; const AjPStr usa; const AjPStr name; AjPStr altusa; /* default name when the real name is not known */ AjPStr altname; AjPStr xxx = NULL; embInit("infoalign", argc, argv); seqset = ajAcdGetSeqset("sequence"); refseq = ajAcdGetString("refseq"); matrix = ajAcdGetMatrix("matrix"); ajSeqsetFill(seqset); outfile = ajAcdGetOutfile("outfile"); html = ajAcdGetBoolean("html"); doheader = ajAcdGetBoolean("heading"); dousa = ajAcdGetBoolean("usa"); doname = ajAcdGetBoolean("name"); doseqlength = ajAcdGetBoolean("seqlength"); doalignlength = ajAcdGetBoolean("alignlength"); dogaps = ajAcdGetBoolean("gaps"); dogapcount = ajAcdGetBoolean("gapcount"); doidcount = ajAcdGetBoolean("idcount"); dosimcount = ajAcdGetBoolean("simcount"); dodifcount = ajAcdGetBoolean("diffcount"); dochange = ajAcdGetBoolean("change"); dodesc = ajAcdGetBoolean("description"); dowt = ajAcdGetBoolean("weight"); /* consensus parameters */ fplural = ajAcdGetFloat("plurality"); identity = ajAcdGetFloat("identity"); cons = ajStrNew(); consensus = ajSeqNew(); altusa = ajStrNewC("-"); altname = ajStrNewC("-"); /* get conversion table and scoring matrix */ cvt = ajMatrixGetCvt(matrix); sub = ajMatrixGetMatrix(matrix); /* get the number of the reference sequence */ nrefseq = infoalign_Getrefseq(refseq, seqset); /* change the % plurality to the fraction of absolute total weight */ fplural = ajSeqsetGetTotweight(seqset) * fplural / 100; /* ** change the % identity to the number of identical sequences at a ** position required for consensus */ ident = ajSeqsetGetSize(seqset) * (ajint)identity / 100; /* get the consensus sequence */ embConsCalc(seqset, matrix, ajSeqsetGetSize(seqset), ajSeqsetGetLen(seqset), fplural, 0.0, ident, ajFalse, &cons); ajSeqAssignSeqS(consensus, cons); ajSeqAssignNameS(consensus,(xxx=ajStrNewC("Consensus"))); /* get the reference sequence */ if(nrefseq == -1) ref = consensus; else ref = ajSeqsetGetseqSeq(seqset, nrefseq); /* start the HTML table */ if(html) ajFmtPrintF(outfile,"<table border cellpadding=4 bgcolor=" "\"#FFFFF0\">\n"); /* print the header information */ if(doheader) { /* start the HTML table title line and output the Name header */ if(html) ajFmtPrintF(outfile, "<tr>"); else ajFmtPrintF(outfile, "%s", "# "); if(dousa) { if(html) ajFmtPrintF(outfile, "<th>USA</th>"); else ajFmtPrintF(outfile, "%-16s", "USA"); } if(doname) { if(html) ajFmtPrintF(outfile, "<th>Name</th>"); else ajFmtPrintF(outfile, "%-12s", "Name"); } if(doseqlength) { if(html) ajFmtPrintF(outfile, "<th>Sequence Length</th>"); else ajFmtPrintF(outfile, "SeqLen\t"); } if(doalignlength) { if(html) ajFmtPrintF(outfile, "<th>Aligned Length</th>"); else ajFmtPrintF(outfile, "AlignLen\t"); } if(dogaps) { if(html) ajFmtPrintF(outfile, "<th>Gaps</th>"); else ajFmtPrintF(outfile, "Gaps\t"); } if(dogapcount) { if(html) ajFmtPrintF(outfile, "<th>Gap Length</th>"); else ajFmtPrintF(outfile, "GapLen\t"); } if(doidcount) { if(html) ajFmtPrintF(outfile, "<th>Identity</th>"); else ajFmtPrintF(outfile, "Ident\t"); } if(dosimcount) { if(html) ajFmtPrintF(outfile, "<th>Similarity</th>"); else ajFmtPrintF(outfile, "Similar\t"); } if(dodifcount) { if(html) ajFmtPrintF(outfile, "<th>Difference</th>"); else ajFmtPrintF(outfile, "Differ\t"); } if(dochange) { if(html) ajFmtPrintF(outfile, "<th>%% Change</th>"); else ajFmtPrintF(outfile, "%% Change\t"); } if(dowt) { if(html) ajFmtPrintF(outfile, "<th>Weight</th>"); else ajFmtPrintF(outfile, "Weight\t"); } if(dodesc) { if(html) ajFmtPrintF(outfile, "<th>Description</th>"); else ajFmtPrintF(outfile, "Description"); } /* end the HTML table title line */ if(html) ajFmtPrintF(outfile, "</tr>\n"); else ajFmtPrintF(outfile, "\n"); } for(i=0; i<ajSeqsetGetSize(seqset); i++) { seq = ajSeqsetGetseqSeq(seqset, i); /* get the usa ('-' if unknown) */ usa = ajSeqGetUsaS(seq); if(ajStrGetLen(usa) == 0) usa = altusa; /* get the name ('-' if unknown) */ name = ajSeqGetNameS(seq); if(ajStrGetLen(name) == 0) name = altname; /* get the stats from the comparison to the reference sequence */ infoalign_Compare(ref, seq, sub, cvt, &seqlength, &alignlength, &gaps, &gapcount, &idcount, &simcount, &difcount, &change); /* start table line */ if(html) ajFmtPrintF(outfile, "<tr>"); if(dousa) infoalign_OutputStr(outfile, usa, html, (dodesc || dowt || dochange || dodifcount || dosimcount || doidcount || dogapcount || dogaps || doseqlength || doalignlength || doname), 18); if(doname) infoalign_OutputStr(outfile, name, html, (dodesc || dowt || dochange || dodifcount || dosimcount || doidcount || dogapcount || dogaps || doseqlength || doalignlength), 14); if(doseqlength) infoalign_OutputInt(outfile, seqlength, html, (dodesc || dowt || dochange || dodifcount || dosimcount || doidcount || dogapcount || dogaps || doalignlength)); if(doalignlength) infoalign_OutputInt(outfile, alignlength, html, (dodesc || dowt || dochange || dodifcount || dosimcount || doidcount || dogapcount || dogaps)); if(dogaps) infoalign_OutputInt(outfile, gaps, html, (dodesc || dowt || dochange || dodifcount || dosimcount || doidcount || dogapcount)); if(dogapcount) infoalign_OutputInt(outfile, gapcount, html, (dodesc || dowt || dochange || dodifcount || dosimcount || doidcount)); if(doidcount) infoalign_OutputInt(outfile, idcount, html, (dodesc || dowt || dochange || dodifcount || dosimcount)); if(dosimcount) infoalign_OutputInt(outfile, simcount, html, (dodesc || dowt || dochange || dodifcount)); if(dodifcount) infoalign_OutputInt(outfile, difcount, html, (dodesc || dowt || dochange)); if(dochange) infoalign_OutputFloat(outfile, change, html, (dodesc || dowt) ); if(dowt) infoalign_OutputFloat(outfile, ajSeqsetGetseqWeight(seqset,i), html, dodesc); if(dodesc) infoalign_OutputStr(outfile, ajSeqGetDescS(seq), html, ajFalse, NOLIMIT); /* end table line */ if(html) ajFmtPrintF(outfile, "</tr>\n"); else ajFmtPrintF(outfile, "\n"); } /* end the HTML table */ if(html) ajFmtPrintF(outfile, "</table>\n"); ajFileClose(&outfile); /* tidy up */ ajStrDel(&altusa); ajStrDel(&altname); ajStrDel(&xxx); ajSeqDel(&consensus); ajSeqsetDel(&seqset); ajStrDel(&refseq); ajMatrixDel(&matrix); ajStrDel(&cons); embExit(); return 0; }
int main(int argc, char **argv) { /* Global details */ AjBool explain_flag; AjBool file_flag; AjPStr* task; AjBool do_primer; AjBool do_hybrid; ajint num_return; ajint first_base_index; /* "Sequence" Input Tags */ AjPSeqall sequence; AjPRange included_region; AjPRange target; AjPRange excluded_region; AjPStr left_input; AjPStr right_input; /* Primer details */ AjBool pick_anyway; AjPFile mispriming_library; float max_mispriming; float pair_max_mispriming; ajint gc_clamp; ajint opt_size; ajint min_size; ajint max_size; float opt_tm; float min_tm; float max_tm; float max_diff_tm; float opt_gc_percent; float min_gc; float max_gc; float salt_conc; float dna_conc; ajint num_ns_accepted; float self_any; float self_end; ajint max_poly_x; /* Sequence Quality. These are not (yet) implemented */ /* AjPFile sequence_quality; ajint min_quality; ajint min_end_quality; ajint quality_range_min; ajint quality_range_max; */ /* Product details */ ajint product_opt_size; AjPRange product_size_range; float product_opt_tm; float product_min_tm; float product_max_tm; /* Objective Function Penalty Weights for Primers */ float max_end_stability; /* these are not (yet) implemented */ /* float inside_penalty; float outside_penalty; */ /* Primer penalties */ /* these are not (yet) implemented */ /* Internal Oligo "Sequence" Input Tags */ AjPRange internal_oligo_excluded_region; /* Internal Oligo "Global" Input Tags */ AjPStr internal_oligo_input; ajint internal_oligo_opt_size; ajint internal_oligo_min_size; ajint internal_oligo_max_size; float internal_oligo_opt_tm; float internal_oligo_min_tm; float internal_oligo_max_tm; float internal_oligo_opt_gc_percent; float internal_oligo_min_gc; float internal_oligo_max_gc; float internal_oligo_salt_conc; float internal_oligo_dna_conc; float internal_oligo_self_any; float internal_oligo_self_end; ajint internal_oligo_max_poly_x; AjPFile internal_oligo_mishyb_library; float internal_oligo_max_mishyb; /* ajint internal_oligo_min_quality; */ /* Internal Oligo penalties */ /* these are not (yet) implemented */ /* EMBOSS-wrapper-specific stuff */ AjPFile outfile; /* other variables */ AjPStr result = NULL; AjPStr strand = NULL; AjPStr substr = NULL; AjPSeq seq = NULL; ajint begin = 0; ajint end; FILE* stream; AjPStr taskstr = NULL; const AjPStr program = NULL; /* pipe variables */ int *pipeto; /* pipe to feed the exec'ed program input */ int *pipefrom; /* pipe to get the exec'ed program output */ embInit("eprimer3", argc, argv); /* Global details */ explain_flag = ajAcdGetBoolean("explainflag"); file_flag = ajAcdGetBoolean("fileflag"); task = ajAcdGetList("task"); do_primer = ajAcdGetToggle("primer"); do_hybrid = ajAcdGetToggle("hybridprobe"); num_return = ajAcdGetInt("numreturn"); first_base_index = ajAcdGetInt("firstbaseindex"); /* "Sequence" Input Tags */ sequence = ajAcdGetSeqall("sequence"); included_region = ajAcdGetRange("includedregion"); target = ajAcdGetRange("targetregion"); excluded_region = ajAcdGetRange("excludedregion"); left_input = ajAcdGetString("forwardinput"); right_input = ajAcdGetString("reverseinput"); /* Primer details */ pick_anyway = ajAcdGetBoolean("pickanyway"); mispriming_library = ajAcdGetInfile("mispriminglibraryfile"); max_mispriming = ajAcdGetFloat("maxmispriming"); pair_max_mispriming = ajAcdGetFloat("pairmaxmispriming"); gc_clamp = ajAcdGetInt("gcclamp"); opt_size = ajAcdGetInt("osize"); min_size = ajAcdGetInt("minsize"); max_size = ajAcdGetInt("maxsize"); opt_tm = ajAcdGetFloat("otm"); min_tm = ajAcdGetFloat("mintm"); max_tm = ajAcdGetFloat("maxtm"); max_diff_tm = ajAcdGetFloat("maxdifftm"); opt_gc_percent = ajAcdGetFloat("ogcpercent"); min_gc = ajAcdGetFloat("mingc"); max_gc = ajAcdGetFloat("maxgc"); salt_conc = ajAcdGetFloat("saltconc"); dna_conc = ajAcdGetFloat("dnaconc"); num_ns_accepted = ajAcdGetInt("numnsaccepted"); self_any = ajAcdGetFloat("selfany"); self_end = ajAcdGetFloat("selfend"); max_poly_x = ajAcdGetInt("maxpolyx"); AJCNEW0(pipeto,2); AJCNEW0(pipefrom,2); /* Sequence Quality */ /* these are not (yet) implemented */ /* sequence_quality = ajAcdGetInfile("sequencequality"); min_quality = ajAcdGetInt("minquality"); min_end_quality = ajAcdGetInt("minendquality"); quality_range_min = ajAcdGetInt("qualityrangemin"); quality_range_max = ajAcdGetInt("qualityrangemax"); */ /* Product details */ product_opt_size = ajAcdGetInt("psizeopt"); product_size_range = ajAcdGetRange("prange"); product_opt_tm = ajAcdGetFloat("ptmopt"); product_min_tm = ajAcdGetFloat("ptmmin"); product_max_tm = ajAcdGetFloat("ptmmax"); /* Objective Function Penalty Weights for Primers */ max_end_stability = ajAcdGetFloat("maxendstability"); /* these are not (yet) implemented */ /* inside_penalty = ajAcdGetFloat("insidepenalty"); outside_penalty = ajAcdGetFloat("outsidepenalty"); */ /* Primer penalties */ /* these are not (yet) implemented */ /* Internal Oligo "Sequence" Input Tags */ internal_oligo_excluded_region = ajAcdGetRange("oexcludedregion"); internal_oligo_input = ajAcdGetString("oligoinput"); /* Internal Oligo "Global" Input Tags */ internal_oligo_opt_size = ajAcdGetInt("osizeopt"); internal_oligo_min_size = ajAcdGetInt("ominsize"); internal_oligo_max_size = ajAcdGetInt("omaxsize"); internal_oligo_opt_tm = ajAcdGetFloat("otmopt"); internal_oligo_min_tm = ajAcdGetFloat("otmmin"); internal_oligo_max_tm = ajAcdGetFloat("otmmax"); internal_oligo_opt_gc_percent = ajAcdGetFloat("ogcopt"); internal_oligo_min_gc = ajAcdGetFloat("ogcmin"); internal_oligo_max_gc = ajAcdGetFloat("ogcmax"); internal_oligo_salt_conc = ajAcdGetFloat("osaltconc"); internal_oligo_dna_conc = ajAcdGetFloat("odnaconc"); internal_oligo_self_any = ajAcdGetFloat("oanyself"); internal_oligo_self_end = ajAcdGetFloat("oendself"); internal_oligo_max_poly_x = ajAcdGetInt("opolyxmax"); internal_oligo_mishyb_library = ajAcdGetInfile("mishyblibraryfile"); internal_oligo_max_mishyb = ajAcdGetFloat("omishybmax"); /* internal_oligo_min_quality = ajAcdGetInt("oligominquality"); */ /* Internal Oligo penalties */ /* these are not (yet) implemented */ /* EMBOSS-wrapper-specific stuff */ outfile = ajAcdGetOutfile("outfile"); ajStrRemoveWhite(&left_input); ajStrRemoveWhite(&right_input); /* ** OK - we will now try to do a separate fork-exec for each sequence. */ result = ajStrNew(); while(ajSeqallNext(sequence, &seq)) { program = ajAcdGetpathC("primer3_core"); if(!ajSysExecRedirectC(ajStrGetPtr(program),&pipeto,&pipefrom)) ajFatal("eprimer3: Could not exec primer3_core"); stream = eprimer3_start_write(pipeto[1]); /* send primer3 Primer "Global" parameters */ eprimer3_send_bool(stream, "PRIMER_EXPLAIN_FLAG", explain_flag); eprimer3_send_bool(stream, "PRIMER_FILE_FLAG", file_flag); if(do_hybrid) { if(!ajStrCmpC(task[0], "1")) ajStrAssignC(&taskstr, "pick_pcr_primers_and_hyb_probe"); else if(!ajStrCmpC(task[0], "2")) ajStrAssignC(&taskstr, "pick_left_only"); else if(!ajStrCmpC(task[0], "3")) ajStrAssignC(&taskstr, "pick_right_only"); else if(!ajStrCmpC(task[0], "4")) ajStrAssignC(&taskstr, "pick_hyb_probe_only"); if (!do_primer) ajStrAssignC(&taskstr, "pick_hyb_probe_only"); } else { if(!ajStrCmpC(task[0], "1")) ajStrAssignC(&taskstr, "pick_pcr_primers"); else if(!ajStrCmpC(task[0], "2")) ajStrAssignC(&taskstr, "pick_left_only"); else if(!ajStrCmpC(task[0], "3")) ajStrAssignC(&taskstr, "pick_right_only"); else if(!ajStrCmpC(task[0], "4")) ajStrAssignC(&taskstr, "pick_hyb_probe_only"); } eprimer3_send_string(stream, "PRIMER_TASK", taskstr); eprimer3_send_int(stream, "PRIMER_NUM_RETURN", num_return); eprimer3_send_int(stream, "PRIMER_FIRST_BASE_INDEX", first_base_index); eprimer3_send_bool(stream, "PRIMER_PICK_ANYWAY", pick_anyway); /* mispriming library may not have been specified */ if(mispriming_library) eprimer3_send_stringC(stream, "PRIMER_MISPRIMING_LIBRARY", ajFileGetPrintnameC(mispriming_library)); eprimer3_send_float(stream, "PRIMER_MAX_MISPRIMING", max_mispriming); eprimer3_send_float(stream, "PRIMER_PAIR_MAX_MISPRIMING", pair_max_mispriming); eprimer3_send_int(stream, "PRIMER_GC_CLAMP", gc_clamp); eprimer3_send_int(stream, "PRIMER_OPT_SIZE", opt_size); eprimer3_send_int(stream, "PRIMER_MIN_SIZE", min_size); eprimer3_send_int(stream, "PRIMER_MAX_SIZE", max_size); eprimer3_send_float(stream, "PRIMER_OPT_TM", opt_tm); eprimer3_send_float(stream, "PRIMER_MIN_TM", min_tm); eprimer3_send_float(stream, "PRIMER_MAX_TM", max_tm); eprimer3_send_float(stream, "PRIMER_MAX_DIFF_TM", max_diff_tm); eprimer3_send_float(stream, "PRIMER_OPT_GC_PERCENT", opt_gc_percent); eprimer3_send_float(stream, "PRIMER_MIN_GC", min_gc); eprimer3_send_float(stream, "PRIMER_MAX_GC", max_gc); eprimer3_send_float(stream, "PRIMER_SALT_CONC", salt_conc); eprimer3_send_float(stream, "PRIMER_DNA_CONC", dna_conc); eprimer3_send_int(stream, "PRIMER_NUM_NS_ACCEPTED", num_ns_accepted); eprimer3_send_float(stream, "PRIMER_SELF_ANY", self_any); eprimer3_send_float(stream, "PRIMER_SELF_END", self_end); eprimer3_send_int(stream, "PRIMER_MAX_POLY_X", max_poly_x); eprimer3_send_int(stream, "PRIMER_PRODUCT_OPT_SIZE", product_opt_size); eprimer3_send_range2(stream, "PRIMER_PRODUCT_SIZE_RANGE", product_size_range); eprimer3_send_float(stream, "PRIMER_PRODUCT_OPT_TM", product_opt_tm); eprimer3_send_float(stream, "PRIMER_PRODUCT_MIN_TM", product_min_tm); eprimer3_send_float(stream, "PRIMER_PRODUCT_MAX_TM", product_max_tm); eprimer3_send_float(stream, "PRIMER_MAX_END_STABILITY", max_end_stability); /* send primer3 Internal Oligo "Global" parameters */ eprimer3_send_int(stream, "PRIMER_INTERNAL_OLIGO_OPT_SIZE", internal_oligo_opt_size); eprimer3_send_int(stream, "PRIMER_INTERNAL_OLIGO_MIN_SIZE", internal_oligo_min_size); eprimer3_send_int(stream, "PRIMER_INTERNAL_OLIGO_MAX_SIZE", internal_oligo_max_size); eprimer3_send_float(stream, "PRIMER_INTERNAL_OLIGO_OPT_TM", internal_oligo_opt_tm); eprimer3_send_float(stream, "PRIMER_INTERNAL_OLIGO_MIN_TM", internal_oligo_min_tm); eprimer3_send_float(stream, "PRIMER_INTERNAL_OLIGO_MAX_TM", internal_oligo_max_tm); eprimer3_send_float(stream, "PRIMER_INTERNAL_OLIGO_OPT_GC_PERCENT", internal_oligo_opt_gc_percent); eprimer3_send_float(stream, "PRIMER_INTERNAL_OLIGO_MIN_GC", internal_oligo_min_gc); eprimer3_send_float(stream, "PRIMER_INTERNAL_OLIGO_MAX_GC", internal_oligo_max_gc); eprimer3_send_float(stream, "PRIMER_INTERNAL_OLIGO_SALT_CONC", internal_oligo_salt_conc); eprimer3_send_float(stream, "PRIMER_INTERNAL_OLIGO_DNA_CONC", internal_oligo_dna_conc); eprimer3_send_float(stream, "PRIMER_INTERNAL_OLIGO_SELF_ANY", internal_oligo_self_any); eprimer3_send_float(stream, "PRIMER_INTERNAL_OLIGO_SELF_END", internal_oligo_self_end); eprimer3_send_int(stream, "PRIMER_INTERNAL_OLIGO_MAX_POLY_X", internal_oligo_max_poly_x); /* ** internal oligo mishybridising library may not have been ** specified */ if(internal_oligo_mishyb_library) eprimer3_send_stringC(stream, "PRIMER_INTERNAL_OLIGO_MISHYB_LIBRARY", ajFileGetPrintnameC(internal_oligo_mishyb_library)); eprimer3_send_float(stream, "PRIMER_INTERNAL_OLIGO_MAX_MISHYB", internal_oligo_max_mishyb); /* ** Start sequence-specific stuff */ begin = ajSeqallGetseqBegin(sequence) - 1; end = ajSeqallGetseqEnd(sequence) - 1; strand = ajSeqGetSeqCopyS(seq); ajStrFmtUpper(&strand); ajStrAssignSubC(&substr,ajStrGetPtr(strand), begin, end); /* send flags to turn on using optimal product size */ eprimer3_send_float(stream, "PRIMER_PAIR_WT_PRODUCT_SIZE_GT", (float)0.05); eprimer3_send_float(stream, "PRIMER_PAIR_WT_PRODUCT_SIZE_LT", (float)0.05); /* send primer3 Primer "Sequence" parameters */ eprimer3_send_string(stream, "SEQUENCE", substr); /* if no ID name, use the USA */ if(ajStrMatchC(ajSeqGetNameS(seq),"")) eprimer3_send_string(stream, "PRIMER_SEQUENCE_ID", ajSeqGetUsaS(seq)); else eprimer3_send_string(stream, "PRIMER_SEQUENCE_ID", ajSeqGetNameS(seq)); eprimer3_send_range(stream, "INCLUDED_REGION", included_region, begin); eprimer3_send_range(stream, "TARGET", target, begin); eprimer3_send_range(stream, "EXCLUDED_REGION", excluded_region, begin); eprimer3_send_string(stream, "PRIMER_LEFT_INPUT", left_input); eprimer3_send_string(stream, "PRIMER_RIGHT_INPUT", right_input); /* send primer3 Internal Oligo "Sequence" parameters */ eprimer3_send_range(stream, "PRIMER_INTERNAL_OLIGO_EXCLUDED_REGION", internal_oligo_excluded_region, begin); eprimer3_send_string(stream, "PRIMER_INTERNAL_OLIGO_INPUT", internal_oligo_input); /* end the primer3 input sequence record with a '=' */ eprimer3_send_end(stream); /* and close the ouput pipe stream */ eprimer3_end_write(stream); /* read the primer3 output */ eprimer3_read(pipefrom[0], &result); eprimer3_report(outfile, result, num_return, begin); ajStrSetClear(&result); #ifndef WIN32 close(pipeto[1]); close(pipefrom[0]); #endif } /* end of sequence loop */ ajStrDel(&result); ajSeqDel(&seq); ajStrDel(&strand); ajStrDel(&substr); ajFileClose(&outfile); ajStrDel(&taskstr); ajStrDelarray(&task); ajSeqallDel(&sequence); ajSeqDel(&seq); ajRangeDel(&included_region); ajRangeDel(&target); ajRangeDel(&excluded_region); ajRangeDel(&product_size_range); ajRangeDel(&internal_oligo_excluded_region); ajStrDel(&left_input); ajStrDel(&right_input); ajStrDel(&internal_oligo_input); AJFREE(pipeto); AJFREE(pipefrom); ajFileClose(&mispriming_library); embExit(); return 0; }
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; }
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; }