int main(int argc, char **argv) { AjPStr directory = NULL; AjPTable mtable = NULL; AjPList jdirlist = NULL; AjPStr jdirloc = NULL; embInit("jaspextract",argc,argv); directory = ajAcdGetDirectoryName("directory"); mtable = ajTablestrNewLen(PFMNUMGUESS); jdirlist = ajListNew(); jaspextract_openoutdirs(); jaspextract_copyfiles(directory); jaspextract_readmatrixlist(mtable, directory); jaspextract_getjaspdirs(jdirlist); while(ajListPop(jdirlist,(void **)&jdirloc)) { jaspextract_writematrixfile(mtable, jdirloc); ajStrDel(&jdirloc); } ajTablestrFree(&mtable); ajStrDel(&directory); ajListFree(&jdirlist); 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) { 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) { AjPSeq seq = NULL; AjPFile angles = NULL; AjPFile energies = NULL; AjPFile result = NULL; AjPTable angletable = NULL; AjPTable energytable = NULL; AjPStr nucs = NULL; const AjPStr valstr = NULL; const char * dinuc = NULL; ajint len; ajint begin; ajint end; ajint i; float val; float anglesum = 0.0; float energysum = 0.0; float twists = 0.0; float basesperturn = 0.0; float energyperbase = 0.0; embInit ("btwisted", argc, argv); seq = ajAcdGetSeq ("sequence"); angles = ajAcdGetDatafile("angledata"); energies = ajAcdGetDatafile("energydata"); result = ajAcdGetOutfile ("outfile"); nucs = ajStrNew(); angletable = btwisted_getdinucdata(angles); energytable = btwisted_getdinucdata(energies); ajFileClose(&angles); ajFileClose(&energies); begin = ajSeqGetBegin(seq); end = ajSeqGetEnd(seq); len = end-begin+1; dinuc = ajSeqGetSeqC(seq); for(i=begin-1; i<end-1; ++i) { ajStrAssignSubC(&nucs,dinuc,i,i+1); if(!(valstr = ajTableFetchS(angletable, nucs))) ajFatal("Incomplete table"); ajStrToFloat(valstr,&val); anglesum += val; if(!(valstr = ajTableFetchS(energytable, nucs))) ajFatal("Incomplete table"); ajStrToFloat(valstr,&val); energysum += val; } twists = anglesum / (float)360.0 ; basesperturn = (float) len * (float)360.0 /anglesum; energyperbase = energysum/(float) (len-1); ajFmtPrintF(result, "# Output from BTWISTED\n"); ajFmtPrintF(result, "# Twisting calculated from %d to %d of %s\n", begin, end, ajSeqGetNameC(seq)); ajFmtPrintF(result,"Total twist (degrees): %.1f\n", anglesum); ajFmtPrintF(result,"Total turns : %.2f\n", twists); ajFmtPrintF(result,"Average bases per turn: %.2f\n", basesperturn); ajFmtPrintF(result,"Total stacking energy : %.2f\n", energysum); ajFmtPrintF(result,"Average stacking energy per dinucleotide: %.2f\n", energyperbase); ajTablestrFree(&angletable); ajTablestrFree(&energytable); ajStrDel(&nucs); ajFileClose(&result); ajSeqDel(&seq); embExit (); return 0; }
static void eprimer3_report(AjPFile outfile, const AjPStr output, ajint numreturn, ajint begin) { AjPStr line = NULL; AjPStrTok linetokenhandle; char eol[] = "\n\r"; AjPStrTok keytokenhandle; char equals[] = "="; AjPStr key = NULL; AjPStr value = NULL; AjBool gotsequenceid = AJFALSE; AjPTable table; linetokenhandle = ajStrTokenNewC(output, eol); /* get next line of relevant results */ while(ajStrTokenNextParseC(&linetokenhandle, eol, &line)) { if(!gotsequenceid) { /* ** Att the start of another sequence's results? ** Start storing the results in the table. */ if(ajStrCmpLenC(line, "PRIMER_SEQUENCE_ID=", 19) == 0) { gotsequenceid = AJTRUE; table = ajTablestrNew(TABLEGUESS); } else continue; } else { /* ** At the end of this sequence? - marked by a '=' in the primer3 ** output - then output the results. */ if(ajStrCmpC(line, "=") == 0) { gotsequenceid = AJFALSE; eprimer3_output_report(outfile, table, numreturn, begin); ajTablestrFree(&table); continue; } } /* ** store key and value in table and parse values ** when have all of the sequence ** results in the table because the LEFT, RIGHT ** and INTERNAL results for each ** resulting primer are interleaved */ keytokenhandle = ajStrTokenNewC(line, equals); key = ajStrNew(); ajStrTokenNextParse(&keytokenhandle, &key); value = ajStrNew(); ajStrTokenNextParse(&keytokenhandle, &value); ajDebug("key=%S\tvalue=%S\n", key, value); ajTablePut(table,(void *)key, (void *)value); ajStrTokenDel(&keytokenhandle); } ajStrDel(&line); ajStrTokenDel(&linetokenhandle); ajTablestrFree(&table); return; }
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) { AjPStr cl = NULL; AjPStr stmp = NULL; AjPStr squal = NULL; /* AjBool bqual = ajFalse; */ AjPTable preftab = NULL; embInitPV("emira", argc, argv, "MIRA",VERSION); cl = ajStrNewS(ajAcdGetpathC("mira")); stmp = ajStrNew(); preftab = emira_makepreftab(); if(ajAcdIsUserdefinedC("genome")) { squal = ajAcdGetListSingle("genome"); ajFmtPrintAppS(&cl," -genome%S",squal); ajStrDel(&squal); } if(ajAcdIsUserdefinedC("mapping")) { squal = ajAcdGetListSingle("mapping"); ajFmtPrintAppS(&cl," -mapping%S",squal); ajStrDel(&squal); } if(ajAcdIsUserdefinedC("clipping")) { squal = ajAcdGetListSingle("clipping"); ajFmtPrintAppS(&cl," -clipping%S",squal); ajStrDel(&squal); } if(ajAcdIsUserdefinedC("setparam")) { squal = ajAcdGetListSingle("setparam"); if(!ajStrMatchC(squal,"unspecified")) ajFmtPrintAppS(&cl," -%S",squal); ajStrDel(&squal); } emira_dostrings(&cl, preftab); emira_doinfiles(&cl, preftab); emira_dodirectories(&cl, preftab); emira_dobools(&cl, preftab); emira_dointegers(&cl, preftab); emira_dolistsingles(&cl, preftab); ajDebug("Constructed command line: %S\n",cl); #if 0 ajFmtPrint("%S\n",cl); #endif #if 1 system(ajStrGetPtr(cl)); #endif ajStrDel(&stmp); ajStrDel(&cl); ajTablestrFree(&preftab); embExit(); return 0; }