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 = 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) { 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; 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) { AjPSeqall seqall; AjPSeq seq; AjPFile outf; AjPCod codon; AjPStr substr; AjBool sum; ajint ccnt; ajint beg; ajint end; float Nc; double td; embInit("chips", argc, argv); seqall = ajAcdGetSeqall("seqall"); outf = ajAcdGetOutfile("outfile"); sum = ajAcdGetBoolean("sum"); codon = ajCodNewCodenum(0); ccnt = 0; substr = ajStrNew(); while(ajSeqallNext(seqall, &seq)) { beg = ajSeqallGetseqBegin(seqall); end = ajSeqallGetseqEnd(seqall); ajStrAssignSubS(&substr,ajSeqGetSeqS(seq),beg-1,end-1); ajStrFmtUpper(&substr); ajCodSetTripletsS(codon,substr,&ccnt); if(!sum) { ajCodCalcUsage(codon,ccnt); td = ajCodCalcNc(codon); Nc = (float) td; ajFmtPrintF(outf,"%-20s Nc = %.3f\n",ajSeqGetNameC(seq),Nc); ajCodClearData(codon); } } if(sum) { ajCodCalcUsage(codon,ccnt); td = ajCodCalcNc(codon); Nc = (float) td; ajFmtPrintF(outf,"# CHIPS codon usage statistics\n\n"); ajFmtPrintF(outf,"Nc = %.3f\n",Nc); } ajFileClose(&outf); ajCodDel(&codon); ajSeqallDel(&seqall); ajSeqDel(&seq); ajStrDel(&substr); 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) { AjPSeqall seqall; AjPSeq seq = NULL; AjPFile outf = NULL; ajint begin; ajint end; ajuint emin; ajuint emax; AjPFile mfile = NULL; EmbPMatPrints s = NULL; AjPList l = NULL; AjPStr strand = NULL; AjPStr substr = NULL; AjPStr name = NULL; AjBool all; AjBool ordered; ajint hits; ajint nmotifs; embInit("pscan", argc, argv); seqall = ajAcdGetSeqall("sequence"); outf = ajAcdGetOutfile("outfile"); emin = ajAcdGetInt("emin"); emax = ajAcdGetInt("emax"); substr = ajStrNew(); name = ajStrNew(); all = ordered = ajTrue; 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); nmotifs = 0; ajDebug("pscan sequence '%S'\n", ajSeqGetNameS(seq)); embMatPrintsInit(&mfile); ajDebug("pscan prints file '%F'\n", mfile); l = ajListNew(); while((s = embMatProtReadInt(mfile))) { ajDebug("pscan file '%F' read\n", mfile); if(s->n >= emin && s->n <= emax) { hits=embMatProtScanInt(substr,name,s,&l,&all,&ordered, 1); if(hits) ++nmotifs; } embMatProtDelInt(&s); } pscan_print_hits(outf, l, nmotifs, begin); ajListFree(&l); ajStrDel(&strand); ajFileClose(&mfile); } ajStrDel(&substr); ajStrDel(&name); ajSeqallDel(&seqall); ajSeqDel(&seq); ajFileClose(&outf); embExit(); return 0; }
int main(int argc, char **argv) { AjPSeqall seqall; AjPSeq seq = NULL; AjPStr seqcmp = NULL; AjPStr enzymes = NULL; AjPFile outf = NULL; ajint begin; ajint end; ajint min; ajint max; ajint sitelen; AjBool alpha; AjBool single; AjBool blunt; AjBool ambiguity; AjBool sticky; AjBool plasmid; AjBool threeprime; AjBool commercial; AjBool html; AjBool limit; AjBool frags; AjBool methyl; AjPFile dfile; AjPFile enzfile = NULL; AjPFile equfile = NULL; AjPFile methfile = NULL; AjPStr name = NULL; AjPTable table = NULL; ajint hits; AjPList l = NULL; embInit("restover", argc, argv); seqall = ajAcdGetSeqall("sequence"); seqcmp = ajAcdGetString("seqcomp"); ajStrFmtUpper(&seqcmp); outf = ajAcdGetOutfile("outfile"); /* ** Some of these are not needed but I left them in case someone wants to ** use them some time ... */ enzymes = ajStrNewC("all"); min = ajAcdGetInt("min"); max = ajAcdGetInt("max"); sitelen = 2; threeprime = ajAcdGetBoolean("threeprime"); blunt = ajAcdGetBoolean("blunt"); sticky = ajAcdGetBoolean("sticky"); single = ajAcdGetBoolean("single"); html = ajAcdGetBoolean("html"); alpha = ajAcdGetBoolean("alphabetic"); ambiguity = ajAcdGetBoolean("ambiguity"); plasmid = ajAcdGetBoolean("plasmid"); commercial = ajAcdGetBoolean("commercial"); limit = ajAcdGetBoolean("limit"); frags = ajAcdGetBoolean("fragments"); methyl = ajAcdGetBoolean("methylation"); dfile = ajAcdGetDatafile("datafile"); methfile = ajAcdGetDatafile("mfile"); if(single) max = min = 1; table = ajTablestrNew(EQUGUESS); l = ajListNew(); if(threeprime) ajStrReverse(&seqcmp); /* read the local file of enzymes names */ restover_read_file_of_enzyme_names(&enzymes); if(!dfile) { enzfile = ajDatafileNewInNameC(ENZDATA); if(!enzfile) ajFatal("Cannot locate enzyme file. Run REBASEEXTRACT"); } else { enzfile = dfile; } if(limit) { equfile = ajDatafileNewInNameC(EQUDATA); if(!equfile) limit=ajFalse; else { restover_read_equiv(equfile,table); ajFileClose(&equfile); } } while(ajSeqallNext(seqall, &seq)) { begin = ajSeqallGetseqBegin(seqall); end = ajSeqallGetseqEnd(seqall); ajFileSeek(enzfile,0L,0); ajSeqFmtUpper(seq); hits = embPatRestrictMatch(seq,begin,end,enzfile,methfile,enzymes, sitelen,plasmid,ambiguity,min,max,blunt, sticky,commercial,methyl,l); ajDebug("hits:%d listlen:%u\n", hits, ajListGetLength(l)); if(hits) { name = ajStrNewC(ajSeqGetNameC(seq)); restover_printHits(seq, seqcmp, outf,l,name,hits,begin,end, min,max,plasmid, sitelen,limit,table,alpha,frags, html); ajStrDel(&name); } ajListFree(&l); } ajListFree(&l); ajSeqDel(&seq); ajFileClose(&outf); ajFileClose(&dfile); ajFileClose(&enzfile); ajFileClose(&equfile); ajFileClose(&methfile); ajSeqallDel(&seqall); ajStrDel(&seqcmp); ajStrDel(&enzymes); ajStrDel(&name); ajTablestrFree(&table); embExit(); return 0; }
int main(int argc, char **argv) { AjPSeqall seqall; AjPSeq sequence; AjPFile outfile; ajint minLen; ajint maxLen; ajint maxGap; ajint beginPos; ajint endPos; ajint maxmismatches; AjPStr seqstr; ajint current; ajint rev; ajint count; ajint gap; ajint begin; ajint end; ajint mismatches; ajint mismatchAtEnd; ajint istart; ajint iend; ajint ic; ajint ir; AjBool alln; /* TRUE if all of palindrome is N's */ Palindrome pfirstpal; Palindrome plastpal = NULL; Palindrome ppal = NULL; Palindrome pnext = NULL; AjBool found = AJFALSE; embInit("palindrome", argc, argv); seqall = ajAcdGetSeqall("sequence"); minLen = ajAcdGetInt("minpallen"); maxLen = ajAcdGetInt("maxpallen"); maxGap = ajAcdGetInt("gaplimit"); outfile = ajAcdGetOutfile("outfile"); maxmismatches = ajAcdGetInt("nummismatches"); overlap = ajAcdGetBoolean("overlap"); while(ajSeqallNext(seqall, &sequence)) { beginPos = ajSeqallGetseqBegin(seqall); endPos = ajSeqallGetseqEnd(seqall); /* set to NULL to indicate that we have no first palindrome find yet */ pfirstpal = NULL; /* write header to file */ ajFmtPrintF(outfile, "Palindromes of: %s \n", ajSeqGetNameC(sequence)); ajFmtPrintF(outfile, "Sequence length is: %d \n", ajSeqGetLen(sequence)); ajFmtPrintF(outfile, "Start at position: %d\nEnd at position: %d\n", beginPos, endPos); ajFmtPrintF(outfile,"Minimum length of Palindromes is: %d \n", minLen); ajFmtPrintF(outfile,"Maximum length of Palindromes is: %d \n", maxLen); ajFmtPrintF(outfile,"Maximum gap between elements is: %d \n", maxGap); ajFmtPrintF(outfile,"Number of mismatches allowed in Palindrome: %d\n", maxmismatches); ajFmtPrintF(outfile, "\n\n\n"); ajFmtPrintF(outfile, "Palindromes:\n"); /* set vars in readiness to enter loop */ seqstr = ajStrNewC(ajSeqGetSeqC(sequence)); begin = beginPos - 1; end = endPos - 1; ajStrFmtLower(&seqstr); /* make comparisons case independent */ /* loop to look for inverted repeats */ for(current = begin; current < end; current++) { iend = current + 2*(maxLen) + maxGap; if(iend > end) iend = end; istart = current + minLen; for(rev = iend; rev > istart; rev--) { count = 0; mismatches = 0; mismatchAtEnd = 0; alln = ajTrue; ic = current; ir = rev; if(ajStrGetCharPos(seqstr, ic) == ajBaseAlphacharComp(ajStrGetCharPos(seqstr, ir))) while(mismatches <= maxmismatches && ic < ir) { if(ajStrGetCharPos(seqstr, ic++) == ajBaseAlphacharComp(ajStrGetCharPos(seqstr, ir--))) { mismatchAtEnd = 0; if(ajStrGetCharPos(seqstr, ic-1) != 'n') alln = ajFalse; } else { mismatches++; mismatchAtEnd++; } count++; } count -= mismatchAtEnd; gap = rev - current - count - count + 1; /* Find out if there's a reverse repeat long enough */ if(count >= minLen && gap <= maxGap && !alln) { /* create new struct to hold palindrome data */ ppal = palindrome_New(current,(current+count),rev, (rev-count)); /* ** if it is the first palindrome find then save it as start ** of palindrome list */ if(pfirstpal == NULL) { pfirstpal = ppal; plastpal = ppal; } else { /* Is it a subset of a palindrome already met */ pnext = pfirstpal; found = AJFALSE; while(pnext != NULL) { if(overlap && palindrome_AInB(ppal, pnext)) { found = AJTRUE; break; } if(!overlap && palindrome_AOverB(ppal, pnext)) { if(palindrome_Longer(ppal, pnext)) { palindrome_Swap(ppal, pnext); } found = AJTRUE; break; } pnext = pnext->next; } /* if new palindrome add to end of list */ if(!found) { plastpal->next = ppal; plastpal = ppal; } else AJFREE(ppal); } } } } /* Print out palindromes */ ppal = pfirstpal; while(ppal != NULL) { palindrome_Print(outfile, seqstr, ppal, maxLen); ppal = ppal->next; } /* make a gap beween outputs of different sequences */ ajFmtPrintF(outfile, "\n\n\n"); /* free memory used for palindrome list */ ppal = pfirstpal; while(ppal != NULL) { pnext = ppal->next; AJFREE(ppal); ppal = pnext; } ajStrDel(&seqstr); } ajFileClose(&outfile); ajSeqallDel(&seqall); ajSeqDel(&sequence); ajStrDel(&seqstr); embExit(); return 0; }
int main(int argc, char **argv) { AjPSeqall seqall; AjPSeq seq = NULL; AjPFile inf = NULL; AjPStr strand = NULL; AjPStr substr = NULL; AjPStr name = NULL; AjPStr mname = NULL; AjPStr tname = NULL; AjPStr pname = NULL; AjPStr line = NULL; AjPStr cons = NULL; AjPStr m = NULL; AjPStr n = NULL; AjPAlign align= NULL; /* JISON, replaces AjPOutfile outf */ ajint type; ajint begin; ajint end; ajulong len; ajint i; ajint j; float **fmatrix=NULL; ajint mlen; float maxfs; ajint thresh; float gapopen; float gapextend; float opencoeff; float extendcoeff; const char *p; ajulong maxarr = 1000; ajulong alen; float *path; ajint *compass; size_t stlen; embInit("prophet", argc, argv); seqall = ajAcdGetSeqall("sequence"); inf = ajAcdGetInfile("infile"); opencoeff = ajAcdGetFloat("gapopen"); extendcoeff = ajAcdGetFloat("gapextend"); align = ajAcdGetAlign("outfile"); /*JISON replacing outfile */ opencoeff = ajRoundFloat(opencoeff, 8); extendcoeff = ajRoundFloat(extendcoeff, 8); substr = ajStrNew(); name = ajStrNew(); mname = ajStrNew(); tname = ajStrNew(); line = ajStrNew(); m = ajStrNewC(""); n = ajStrNewC(""); type = prophet_getType(inf,&tname); if(!type) ajFatal("Unrecognised profile/matrix file format"); prophet_read_profile(inf,&pname,&mname,&mlen,&gapopen,&gapextend,&thresh, &maxfs, &cons); ajAlignSetMatrixName(align, mname); AJCNEW(fmatrix, mlen); for(i=0;i<mlen;++i) { AJCNEW(fmatrix[i], AZ); if(!ajReadlineTrim(inf,&line)) ajFatal("Missing matrix line"); p = ajStrGetPtr(line); p = ajSysFuncStrtok(p," \t"); for(j=0;j<AZ;++j) { sscanf(p,"%f",&fmatrix[i][j]); p = ajSysFuncStrtok(NULL," \t"); } } AJCNEW(path, maxarr); AJCNEW(compass, maxarr); 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); len = ajStrGetLen(substr); if(len > (ULONG_MAX/(ajulong)(mlen+1))) ajFatal("Sequences too big. Try 'supermatcher'"); alen = len*mlen; if(alen>maxarr) { stlen = (size_t) alen; AJCRESIZE(path,stlen); AJCRESIZE(compass,stlen); maxarr=alen; } ajStrAssignC(&m,""); ajStrAssignC(&n,""); /* JISON used to be prophet_scan_profile(substr,pname,name,mlen,fmatrix, outf,cons,opencoeff, extendcoeff,path,compass,&m,&n,len); */ /* JISON new call and reset align */ prophet_scan_profile(substr,name,pname,mlen,fmatrix, align,cons,opencoeff, extendcoeff,path,compass,&m,&n,(ajint)len); ajAlignReset(align); ajStrDel(&strand); } for(i=0;i<mlen;++i) AJFREE (fmatrix[i]); AJFREE (fmatrix); AJFREE(path); AJFREE(compass); ajStrDel(&line); ajStrDel(&cons); ajStrDel(&name); ajStrDel(&pname); ajStrDel(&mname); ajStrDel(&tname); ajStrDel(&substr); ajStrDel(&m); ajStrDel(&n); ajSeqDel(&seq); ajFileClose(&inf); ajAlignClose(align); ajAlignDel(&align); ajSeqallDel(&seqall); embExit(); return 0; }
int main(int argc, char **argv) { AjPSeqall seqall; AjPSeq seq = NULL; AjPFile outf = NULL; AjPStr strand = NULL; AjPStr substr = NULL; AjPFeattabOut featout; AjPFeattable feattable=NULL; ajint begin; ajint end; ajint len; ajint score; embInit("cpgreport",argc,argv); seqall = ajAcdGetSeqall("sequence"); score = ajAcdGetInt("score"); outf = ajAcdGetOutfile("outfile"); featout = ajAcdGetFeatout("outfeat"); substr = ajStrNew(); while(ajSeqallNext(seqall, &seq)) { if (!feattable) feattable = ajFeattableNewDna(ajSeqGetNameS(seq)); begin = ajSeqallGetseqBegin(seqall); end = ajSeqallGetseqEnd(seqall); strand = ajSeqGetSeqCopyS(seq); ajStrFmtUpper(&strand); ajStrAssignSubC(&substr,ajStrGetPtr(strand),begin-1,end-1); len=ajStrGetLen(substr); ajFmtPrintF(outf,"\n\nCPGREPORT of %s from %d to %d\n\n", ajSeqGetNameC(seq),begin,begin+len-1); ajFmtPrintF(outf,"Sequence Begin End Score"); ajFmtPrintF(outf," CpG %%CG CG/GC\n"); cpgreport_cpgsearch(outf,0,len,ajStrGetPtr(substr),ajSeqGetNameC(seq), begin,score,feattable); ajStrDel(&strand); } ajSeqDel(&seq); ajStrDel(&substr); ajFileClose(&outf); ajFeatSortByStart(feattable); ajFeattableWrite(featout, feattable); ajFeattableDel(&feattable); ajFeattabOutDel(&featout); ajSeqallDel(&seqall); ajStrDel(&cpgreportSource); ajStrDel(&cpgreportType); embExit(); return 0; }