/* @prog scopparse ************************************************************ ** ** Converts raw scop classification files to a file in embl-like format. ** ******************************************************************************/ int main(int argc, char **argv) { AjPFile inf1 = NULL; AjPFile inf2 = NULL; AjPFile outf = NULL; AjPList list = NULL; AjPScop tmp = NULL; AjBool nosegments = ajFalse; AjBool nomultichain = ajFalse; AjBool nominor = ajFalse; /* Read data from acd. */ embInitPV("scopparse", argc, argv, "DOMAINATRIX",VERSION); inf1 = ajAcdGetInfile("classfile"); inf2 = ajAcdGetInfile("desinfile"); outf = ajAcdGetOutfile("dcffile"); nosegments = ajAcdGetBoolean("nosegments"); nomultichain = ajAcdGetBoolean("nomultichain"); nominor = ajAcdGetBoolean("nominor"); /* ajFmtPrint("nosegments: %B\n", nosegments); ajFmtPrint("nomultichain: %B\n", nomultichain); ajFmtPrint("nominor: %B\n", nominor); */ /* Main body of code. */ list = ajScopReadAllRawNew(inf1, inf2, nomultichain); while(ajListPop(list, (void **) &tmp)) { if(((!nosegments) || (tmp->N == 1)) && ((!nominor) || ((tmp->Sunid_Class == 46456) || /* All alpha*/ (tmp->Sunid_Class == 48724) || /* All beta */ (tmp->Sunid_Class == 51349) || /* a/b */ (tmp->Sunid_Class == 53931)))) /* a+b */ ajScopWrite(outf, tmp); ajScopDel(&tmp); } /* Memory management. */ ajFileClose(&outf); ajFileClose(&inf1); ajFileClose(&inf2); ajListFree(&list); ajExit(); 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 getorf_acd(int argc, char **argv) { AjPSeqout seqout; AjPSeqall seqall; AjPStr tablestr; ajuint minsize; ajuint maxsize; AjPStr findstr; AjBool methionine; AjBool circular; AjBool reverse; ajint around; embInit("getorf", argc, argv); seqout = ajAcdGetSeqoutall("outseq"); seqall = ajAcdGetSeqall("sequence"); tablestr = ajAcdGetListSingle("table"); minsize = ajAcdGetInt("minsize"); maxsize = ajAcdGetInt("maxsize"); findstr = ajAcdGetListSingle("find"); methionine = ajAcdGetBoolean("methionine"); circular = ajAcdGetBoolean("circular"); reverse = ajAcdGetBoolean("reverse"); around = ajAcdGetInt("flanking"); getorf(seqout, seqall, tablestr, minsize, maxsize, findstr, methionine, circular, reverse, around); ajSeqoutClose(seqout); ajSeqallDel(&seqall); ajSeqoutDel(&seqout); ajStrDel(&tablestr); ajStrDel(&findstr); embExit(); return 0; }
int main(int argc, char **argv) { /* Variable Declarations */ AjPSeqset seqset = NULL; AjPAlign align = NULL; AjPStr name = NULL; AjPStr comment = NULL; AjBool append = ajFalse; AjPStr header = NULL; /* ACD File Processing */ embInit("aligncopy", argc, argv); seqset = ajAcdGetSeqset("sequences"); align = ajAcdGetAlign("outfile"); name = ajAcdGetString("name"); comment = ajAcdGetString("comment"); append = ajAcdGetBoolean("append"); /* Application logic */ ajAlignDefine(align, seqset); if(ajStrGetLen(name)) ajFmtPrintS(&header, "Alignment: %S\n\n", name); ajStrAppendS(&header, comment); if(append) ajAlignSetHeaderApp(align, header); else ajAlignSetHeader(align, header); ajAlignWrite(align); ajAlignClose(align); /* Memory management and exit */ ajSeqsetDel(&seqset); ajAlignDel(&align); ajStrDel(&name); ajStrDel(&comment); ajStrDel(&header); embExit(); return 0; }
static void emira_dobools(AjPStr *cl, AjPTable table) { ajuint i; AjBool bqual = ajFalse; AjBool def = ajFalse; AjPStr prefix = NULL; AjPStr key = NULL; AjPStr value = NULL; prefix = ajStrNew(); key = ajStrNew(); i = 0; while(mirabools[i].qname) { bqual = ajAcdGetBoolean(mirabools[i].qname); ajStrAssignC(&key,mirabools[i].qname); ajStrAssignC(&prefix,""); value = ajTableFetch(table, key); if(value) ajStrAssignS(&prefix,value); def = ajCharMatchC(mirabools[i].def,"N") ? ajFalse : ajTrue; if(bqual != def) { ajFmtPrintAppS(cl," -%S%s=",prefix,mirabools[i].mname); if(bqual) ajFmtPrintAppS(cl,"yes"); else ajFmtPrintAppS(cl,"no"); } ++i; } ajStrDel(&key); ajStrDel(&prefix); return; }
int main(int argc, char **argv) { /* Variable Declarations */ AjPSeqset seqset = NULL; AjPSeqout seqout = NULL; AjBool bigfirst; ajuint nseqs; ajuint i; /* ACD File Processing */ embInit("sizeseq", argc, argv); seqset = ajAcdGetSeqset("sequences"); bigfirst = ajAcdGetBoolean("descending"); seqout = ajAcdGetSeqoutall("outseq"); /* Application logic */ ajSeqsetSortLen(seqset); nseqs = ajSeqsetGetSize(seqset); if(bigfirst) { for(i=nseqs; i>0; i--) ajSeqoutWriteSeq(seqout, ajSeqsetGetseqSeq(seqset,i-1)); } else { for(i=0; i<nseqs; i++) ajSeqoutWriteSeq(seqout, ajSeqsetGetseqSeq(seqset,i)); } /* Memory management and exit */ ajSeqsetDel(&seqset); ajSeqoutClose(seqout); ajSeqoutDel(&seqout); embExit(); return 0; }
void emboss_getoptions(char *pgm, int argc, char *argv[]) { AjPStr test = NULL; AjPStr outputformat = NULL; AjPStr typeofseq = NULL; AjPStr justweights = NULL; AjBool rewrite = false; long inseed, inseed0; data = genefreqs; seq = dna; bootstrap = false; jackknife = false; permute = false; ild = false; lockhart = false; blocksize = 1; regular = true; fracsample = 1.0; all = true; reps = 100; weights = false; mixture = false; ancvar = false; categories = false; justwts = false; printdata = false; dotdiff = true; progress = true; interleaved = true; xml = false; nexus = false; factors = false; enzymes = false; embInitPV(pgm, argc, argv, "PHYLIPNEW",VERSION); phylofreqs = ajAcdGetFrequencies("infile"); test = ajAcdGetListSingle("test"); if(ajStrMatchC(test, "b")) { bootstrap = true; regular = ajAcdGetToggle("regular"); if(regular) fracsample = 1.0; else { fracsample = ajAcdGetFloat("fracsample"); fracsample = fracsample/100.0; } blocksize = ajAcdGetInt("blocksize"); } else if(ajStrMatchC(test, "j")) { jackknife = true; regular = ajAcdGetToggle("regular"); if(regular) fracsample = 0.5; else { fracsample = ajAcdGetFloat("fracsample"); fracsample = fracsample/100.0; } } else if(ajStrMatchC(test, "c")) permute = true; else if(ajStrMatchC(test, "o")) ild = true; else if(ajStrMatchC(test, "s")) lockhart = true; else if(ajStrMatchC(test, "r")) rewrite = true; if(rewrite) { if (data == seqs) { outputformat = ajAcdGetListSingle("rewriteformat"); if(ajStrMatchC(outputformat, "n")) nexus = true; else if(ajStrMatchC(outputformat, "x")) xml = true; if( (nexus) || (xml) ) { typeofseq = ajAcdGetListSingle("seqtype"); if(ajStrMatchC(typeofseq, "d")) seq = dna; else if(ajStrMatchC(typeofseq, "r")) seq = rna; else if(ajStrMatchC(typeofseq, "p")) seq = protein; } } } else{ reps = ajAcdGetInt("reps"); inseed = ajAcdGetInt("seed"); emboss_initseed(inseed, &inseed0, seed); if(jackknife || bootstrap || permute) { phyloweights = ajAcdGetProperties("weights"); if(phyloweights) weights = true; } if(!permute) { justweights = ajAcdGetListSingle("justweights"); if(ajStrMatchC(justweights, "j")) justwts = true; } } printdata = ajAcdGetBoolean("printdata"); if(printdata) dotdiff = ajAcdGetBoolean("dotdiff"); progress = ajAcdGetBoolean("progress"); embossoutfile = ajAcdGetOutfile("outfile"); emboss_openfile(embossoutfile, &outfile, &outfilename); printf("\n bootstrap: %s",(bootstrap ? "true" : "false")); printf("\njackknife: %s",(jackknife ? "true" : "false")); printf("\n permute: %s",(permute ? "true" : "false")); printf("\n lockhart: %s",(lockhart ? "true" : "false")); printf("\n ild: %s",(ild ? "true" : "false")); printf("\n justwts: %s \n",(justwts ? "true" : "false")); } /* emboss_getoptions */
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("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[]) { 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[]) { 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 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[]) { embInitPV("ggeneskew", argc, argv, "GEMBASSY", "1.0.3"); AjPSeqall seqall; AjPSeq seq; AjPStr inseq = NULL; ajint window = 0; ajint slide = 0; AjBool cumulative = ajFalse; AjBool gc3 = ajFalse; AjPStr basetype = NULL; 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"); window = ajAcdGetInt("window"); slide = ajAcdGetInt("slide"); cumulative = ajAcdGetBoolean("cumulative"); gc3 = ajAcdGetBoolean("gctri"); basetype = ajAcdGetSelectSingle("base"); accid = ajAcdGetBoolean("accid"); plot = ajAcdGetToggle("plot"); outf = ajAcdGetOutfile("outfile"); mult = ajAcdGetGraphxy("graph"); if(ajStrMatchC(base, "none")) basetype = ajStrNewC(""); 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; } } 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/geneskew/window=%d/slide=%d/" "cumulative=%d/gc3=%d/base=%S/output=f/tag=gene", base, restid, window, slide, cumulative, gc3, basetype); if(plot) { title = ajStrNew(); ajStrAppendC(&title, argv[0]); ajStrAppendC(&title, " of "); ajStrAppendS(&title, seqid); gpp.title = ajStrNewS(title); gpp.xlab = ajStrNewC("gene skew"); gpp.ylab = ajStrNewC("bp"); 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); ajStrDel(&inseq); } ajFileClose(&outf); ajSeqallDel(&seqall); ajSeqDel(&seq); ajStrDel(&base); embExit(); return 0; }
int main(int argc, char *argv[]) { embInitPV("gcircularmap", argc, argv, "GEMBASSY", "1.0.1"); struct soap soap; struct ns1__circular_USCOREmapInputParams params; AjPSeqall seqall; AjPSeq seq; AjPStr inseq = NULL; AjPStr seqid = NULL; AjBool accid = ajFalse; AjPFile outf = NULL; AjPStr filename = NULL; AjPStr outfname = NULL; AjPStr format = NULL; ajint i; char *in0; char *result; seqall = ajAcdGetSeqall("sequence"); filename = ajAcdGetString("goutfile"); accid = ajAcdGetBoolean("accid"); format = ajAcdGetString("format"); params.gmap = 0; i = 0; while(ajSeqallNext(seqall, &seq)) { soap_init(&soap); soap.send_timeout = 0; soap.recv_timeout = 0; inseq = NULL; ajStrAssignS(&seqid, ajSeqGetAccS(seq)); if(!ajStrGetLen(seqid)) ajStrAssignS(&seqid, ajSeqGetNameS(seq)); if(!ajStrGetLen(seqid)) { ajWarn("No valid header information\n"); } if(accid || !gFormatGenbank(seq, &inseq)) { if(!accid) ajWarn("Sequence does not have features\n" "Proceeding with sequence accession ID:%S\n", seqid); if(!gValID(seqid)) { ajDie("Invalid accession ID:%S, exiting\n", seqid); } ajStrAssignS(&inseq, seqid); } in0 = ajCharNewS(inseq); if(soap_call_ns1__circular_USCOREmap( &soap, NULL, NULL, in0, ¶ms, &result ) == SOAP_OK) { ++i; outfname = ajStrNewS(ajFmtStr("%S.%d.%S", filename, i, format)); outf = ajFileNewOutNameS(outfname); if(!outf) { ajDie("File open error\n"); } if(!ajStrMatchC(format, "svg")) { if(!gHttpConvertC(result, &outf, ajStrNewC("svg"), format)) { ajDie("File downloading error from:\n%s\n", result); } else { ajFmtPrint("Created %S\n", outfname); } } else { if(!gHttpGetBinC(result, &outf)) { ajDie("File downloading error from:\n%s\n", result); } else { ajFmtPrint("Created %S\n", outfname); } } ajStrDel(&outfname); } 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); ajStrDel(&filename); embExit(); return 0; }
int main(int argc, char **argv) { const char *hmmfile; /* file to read HMMs from */ FILE *fp; /* output file handle */ HMMFILE *hmmfp; /* opened hmmfile for reading */ struct plan7_s *hmm; /* HMM to generate from */ int L; /* length of a sequence */ int i; /* counter over sequences */ char *ofile; /* output sequence file */ int nseq; /* number of seqs to sample */ int seed; /* random number generator seed */ int be_quiet; /* TRUE to silence header/footer */ int do_alignment; /* TRUE to output in aligned format */ int do_consensus; /* TRUE to do a single consensus seq */ AjBool ajselex; AjBool ajcons; AjPFile inf=NULL; AjPFile outf=NULL; AjPStr instr=NULL; AjPStr outstr=NULL; #ifdef MEMDEBUG unsigned long histid1, histid2, orig_size, current_size; orig_size = malloc_inuse(&histid1); fprintf(stderr, "[... memory debugging is ON ...]\n"); #endif /*********************************************** * Parse command line ***********************************************/ nseq = 10; be_quiet = FALSE; do_alignment = FALSE; do_consensus = FALSE; ofile = NULL; embInitPV("ohmmemit",argc,argv,"HMMER",VERSION); ajselex = ajAcdGetBoolean("selex"); ajcons = ajAcdGetBoolean("consensus"); nseq = ajAcdGetInt("number"); seed = ajAcdGetInt("seed"); inf = ajAcdGetInfile("infile"); outf = ajAcdGetOutfile("outfile"); if(!seed) seed = time ((time_t *) NULL); if(ajselex) do_alignment=TRUE; else do_alignment=FALSE; if(ajcons) do_consensus=TRUE; else do_consensus=FALSE; instr = ajStrNewC((char *)ajFileGetNameC(inf)); outstr = ajStrNewC((char *)ajFileGetNameC(outf)); hmmfile = ajStrGetPtr(instr); sre_srandom(seed); if (do_alignment && do_consensus) ajFatal("Sorry, -selex and -consensus are incompatible.\n"); if (nseq != 10 && do_consensus) ajWarn("-consensus overrides -number (# of sampled seqs)"); /*********************************************** * Open HMM file (might be in HMMERDB or current directory). * Read a single HMM from it. ***********************************************/ if ((hmmfp = HMMFileOpen(hmmfile, "HMMERDB")) == NULL) ajFatal("Failed to open HMM file %s\n", hmmfile); if (!HMMFileRead(hmmfp, &hmm)) ajFatal("Failed to read any HMMs from %s\n", hmmfile); HMMFileClose(hmmfp); if (hmm == NULL) ajFatal("HMM file %s corrupt or in incorrect format? Parse failed", hmmfile); /* Configure the HMM to shut off N,J,C emission: so we * do a simple single pass through the model. */ Plan7NakedConfig(hmm); Plan7Renormalize(hmm); /*********************************************** * Open the output file, or stdout ***********************************************/ fp = ajFileGetFileptr(outf); /*********************************************** * Show the options banner ***********************************************/ be_quiet=TRUE; if (! be_quiet) { printf("HMM file: %s\n", hmmfile); if (! do_consensus) { printf("Number of seqs: %d\n", nseq); printf("Random seed: %d\n", seed); } printf("- - - - - - - - - - - - - - - - - - - - - - - - - " "- - - - - - -\n\n"); } /*********************************************** * Do the work. * If we're generating an alignment, we have to collect * all our traces, then output. If we're generating unaligned * sequences, we can emit one at a time. ***********************************************/ if (do_consensus) { char *seq; SQINFO sqinfo; /* info about sequence (name/desc) */ EmitConsensusSequence(hmm, &seq, NULL, &L, NULL); strcpy(sqinfo.name, "consensus"); sqinfo.len = L; sqinfo.flags = SQINFO_NAME | SQINFO_LEN; WriteSeq(fp, kPearson, seq, &sqinfo); free(seq); } else if (do_alignment) { struct p7trace_s **tr; char **dsq; SQINFO *sqinfo; char **aseq; AINFO ainfo; float *wgt; dsq = MallocOrDie(sizeof(char *) * nseq); tr = MallocOrDie(sizeof(struct p7trace_s *) * nseq); sqinfo = MallocOrDie(sizeof(SQINFO) * nseq); wgt = MallocOrDie(sizeof(float) * nseq); FSet(wgt, nseq, 1.0); for (i = 0; i < nseq; i++) { EmitSequence(hmm, &(dsq[i]), &L, &(tr[i])); sprintf(sqinfo[i].name, "seq%d", i+1); sqinfo[i].len = L; sqinfo[i].flags = SQINFO_NAME | SQINFO_LEN; } P7Traces2Alignment(dsq, sqinfo, wgt, nseq, hmm->M, tr, FALSE, &aseq, &ainfo); /* Output the alignment */ WriteSELEX(fp, aseq, &ainfo, 50); if (ofile != NULL && !be_quiet) printf("Alignment saved in file %s\n", ofile); /* Free memory */ for (i = 0; i < nseq; i++) { P7FreeTrace(tr[i]); free(dsq[i]); } FreeAlignment(aseq, &ainfo); free(sqinfo); free(dsq); free(wgt); free(tr); } else /* unaligned sequence output */ { struct p7trace_s *tr; char *dsq; char *seq; SQINFO sqinfo; for (i = 0; i < nseq; i++) { EmitSequence(hmm, &dsq, &L, &tr); sprintf(sqinfo.name, "seq%d", i+1); sqinfo.len = L; sqinfo.flags = SQINFO_NAME | SQINFO_LEN; seq = DedigitizeSequence(dsq, L); WriteSeq(fp, kPearson, seq, &sqinfo); P7FreeTrace(tr); free(dsq); free(seq); } } ajFileClose(&outf); FreePlan7(hmm); SqdClean(); #ifdef MEMDEBUG current_size = malloc_inuse(&histid2); if (current_size != orig_size) malloc_list(2, histid1, histid2); else fprintf(stderr, "[No memory leaks.]\n"); #endif ajStrDel(&instr); ajStrDel(&outstr); ajFileClose(&inf); ajFileClose(&outf); 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; }
int main(int argc, char **argv) { AjPFile infile = NULL; AjPFile outfile = NULL; AjPStr line; AjPGraph graphLB = NULL; AjPGraphdata xygraph = NULL; AjPGraphdata xygraph2 = NULL; AjBool doplot; ajint N=0; float *xdata = NULL; float *ydata = NULL; float *V = NULL; float *S = NULL; float a; float b; float upperXlimit; float upperYlimit; float A; float B; float C; float D; float xmin; float xmax; float ymin; float ymax; float xmin2; float xmax2; float ymin2; float ymax2; float Vmax; float Km; float cutx; float cuty; float amin = 0.; float amax = 0.; float bmin = 0.; float bmax = 0.; embInit("findkm", argc, argv); infile = ajAcdGetInfile("infile"); outfile = ajAcdGetOutfile ("outfile"); doplot = ajAcdGetBoolean("plot"); graphLB = ajAcdGetGraphxy("graphLB"); line = ajStrNew(); /* Determine N by reading infile */ while(ajReadlineTrim(infile, &line)) if(ajStrGetLen(line) >0) N++; /* only allocate memory to the arrays */ AJCNEW(xdata, N); AJCNEW(ydata, N); AJCNEW(S, N); AJCNEW(V, N); ajFileSeek(infile, 0L, 0); N=0; while(ajReadlineTrim(infile, &line)) { if(ajStrGetLen(line) > 0) { sscanf(ajStrGetPtr(line),"%f %f",&S[N],&V[N]); if(S[N] > 0.0 && V[N] > 0.0) { xdata[N] = S[N]; ydata[N] = S[N]/V[N]; N++; } } } /* find the max and min values for the graph parameters*/ xmin = (float)0.5*findkm_findmin(xdata, N); xmax = (float)1.5*findkm_findmax(xdata, N); ymin = (float)0.5*findkm_findmin(ydata, N); ymax = (float)1.5*findkm_findmax(ydata, N); xmin2 = (float)0.5*findkm_findmin(S, N); xmax2 = (float)1.5*findkm_findmax(S, N); ymin2 = (float)0.5*findkm_findmin(V, N); ymax2 = (float)1.5*findkm_findmax(V, N); /* ** In case the casted ints turn out to be same number on the axis, ** make the max number larger than the min so graph can be seen. */ if((ajint)xmax == (ajint)xmin) ++xmax; if((ajint)ymax == (ajint)ymin) ++ymax; if((ajint)xmax2 == (ajint)xmin2) ++xmax2; if((ajint)ymax2 == (ajint)ymin2) ++ymax2; /* ** Gaussian Elimination for Best-fit curve plotting and ** calculating Km and Vmax */ A = findkm_summation(xdata, N); B = findkm_summation(ydata, N); C = findkm_multisum(xdata, ydata, N); D = findkm_multisum(xdata, xdata, N); /* ** To find the best fit line, Least Squares Fit: y =ax +b; ** Two Simultaneous equations, REARRANGE FOR b ** ** findkm_summation(ydata, N) - findkm_summation(xdata,N)*a - N*b =0; ** b = (findkm_summation(ydata,N) - findkm_summation(xdata,N)*a) / N; ** b = (B - A*a)/ N; ** ** C - D*a - A*((B - A*a)/ N) =0; ** C - D*a - A*B/N + A*A*a/N =0; ** C - A*B/N = D*a - A*A*a/N; */ /* REARRANGE FOR a */ a = (N*C - A*B)/ (N*D - A*A); b = (B - A*a)/ N; /* ** Equation of Line - Lineweaver burk eqn ** 1/V = (Km/Vmax)*(1/S) + 1/Vmax; */ Vmax = 1/a; Km = b/a; cutx = -1/Km; cuty = Km/Vmax; /* set limits for last point on graph */ upperXlimit = findkm_findmax(xdata,N)+3; upperYlimit = (upperXlimit)*a + b; ajFmtPrintF(outfile, "---Hanes Woolf Plot Calculations---\n"); ajFmtPrintF(outfile, "Slope of best fit line is a = %.2f\n", a); ajFmtPrintF(outfile,"Coefficient in Eqn of line y = ma +b is b " "= %.2f\n", b); ajFmtPrintF(outfile, "Where line cuts x axis = (%.2f, 0)\n", cutx); ajFmtPrintF(outfile, "Where line cuts y axis = (0, %.2f)\n", cuty); ajFmtPrintF(outfile, "Limit-point of graph for plot = (%.2f, %.2f)\n\n", upperXlimit, upperYlimit); ajFmtPrintF(outfile, "Vmax = %.2f, Km = %f\n",Vmax, Km); /* draw graphs */ if(doplot) { xygraph = ajGraphdataNewI(N); ajGraphdataAddXY(xygraph, S, V); ajGraphDataAdd(graphLB, xygraph); ajGraphdataSetTitleC(xygraph, "Michaelis Menten Plot"); ajGraphdataSetXlabelC(xygraph, "[S]"); ajGraphdataSetYlabelC(xygraph, "V"); ajGraphxySetXstartF(graphLB, 0.0); ajGraphxySetXendF(graphLB, xmax2); ajGraphxySetYstartF(graphLB, 0.0); ajGraphxySetYendF(graphLB, ymax2); ajGraphxySetXrangeII(graphLB, (ajint)0.0, (ajint)xmax2); ajGraphxySetYrangeII(graphLB, (ajint)0.0, (ajint)ymax2); ajGraphdataAddposLine(xygraph, 0.0, 0.0, S[0], V[0], (ajint)BLACK); ajGraphxyShowPointsCircle(graphLB, ajTrue); ajGraphdataSetMinmax(xygraph,0.0,xmax2,0.0,ymax2); ajGraphicsCalcRange(S,N,&amin,&amax); ajGraphicsCalcRange(V,N,&bmin,&bmax); ajGraphdataSetTruescale(xygraph,amin,amax,bmin,bmax); ajGraphdataSetTypeC(xygraph,"2D Plot Float"); xygraph2 = ajGraphdataNewI(N); ajGraphdataAddXY(xygraph2, xdata, ydata); ajGraphDataAdd(graphLB, xygraph2); ajGraphdataSetTitleC(xygraph2, "Hanes Woolf Plot"); ajGraphdataSetXlabelC(xygraph2, "[S]"); ajGraphdataSetYlabelC(xygraph2, "[S]/V"); ajGraphxySetXstartF(graphLB, cutx); ajGraphxySetXendF(graphLB, upperXlimit); ajGraphxySetYstartF(graphLB, 0.0); ajGraphxySetYendF(graphLB, upperYlimit); ajGraphxySetXrangeII(graphLB, (ajint)cutx, (ajint)upperXlimit); ajGraphxySetYrangeII(graphLB, (ajint)0.0, (ajint)upperYlimit); ajGraphxyShowPointsCircle(graphLB, ajTrue); ajGraphdataSetMinmax(xygraph2, cutx,upperXlimit,0.0,upperYlimit); ajGraphicsCalcRange(xdata,N,&amin,&amax); ajGraphicsCalcRange(ydata,N,&bmin,&bmax); ajGraphdataSetTruescale(xygraph2,amin,amax,bmin,bmax); ajGraphdataSetTypeC(xygraph2,"2D Plot"); ajGraphSetTitleC(graphLB,"FindKm"); ajGraphxySetflagOverlay(graphLB,ajFalse); ajGraphxyDisplay(graphLB, ajTrue); } AJFREE(xdata); AJFREE(ydata); AJFREE(S); AJFREE(V); ajFileClose(&infile); ajFileClose(&outfile); ajGraphxyDel(&graphLB); ajStrDel(&line); embExit(); return 0; }
int main(int argc, char *argv[]) { embInitPV("ggcsi", argc, argv, "GEMBASSY", "1.0.1"); struct soap soap; struct ns1__gcsiInputParams params; AjPSeqall seqall; AjPSeq seq; AjPStr inseq = NULL; AjPStr seqid = NULL; ajint window = 0; AjBool at = 0; AjBool purine = 0; AjBool keto = 0; AjBool pval = 0; AjPStr version = NULL; AjBool accid = ajFalse; AjPStr tmp = NULL; AjPStr parse = NULL; AjPStr gcsi = NULL; AjPStr sa = NULL; AjPStr dist = NULL; AjPStr z = NULL; AjPStr p = NULL; AjPStrTok handle = NULL; char *in0; char *result; AjPFile outf = NULL; seqall = ajAcdGetSeqall("sequence"); window = ajAcdGetInt("window"); at = ajAcdGetBoolean("at"); purine = ajAcdGetBoolean("purine"); keto = ajAcdGetBoolean("keto"); pval = ajAcdGetBoolean("pval"); version = ajAcdGetSelectSingle("gcsi"); accid = ajAcdGetBoolean("accid"); outf = ajAcdGetOutfile("outfile"); params.window = window; params.at = 0; params.purine = 0; params.keto = 0; params.p = 0; ajStrToInt(version, &(params.version)); if(at) params.at = 1; if(purine) params.purine = 1; if(keto) params.keto = 1; if(pval) params.p = 1; 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__gcsi( &soap, NULL, NULL, in0, ¶ms, &result ) == SOAP_OK) { tmp = ajStrNew(); parse = ajStrNew(); gcsi = ajStrNew(); sa = ajStrNew(); dist = ajStrNew(); z = ajStrNew(); p = ajStrNew(); ajStrAssignC(&tmp, result); ajStrExchangeCC(&tmp, "<", "\n"); ajStrExchangeCC(&tmp, ">", "\n"); handle = ajStrTokenNewC(tmp, "\n"); while (ajStrTokenNextParse(&handle, &parse)) { if (ajStrIsFloat(parse)) { if(!ajStrGetLen(gcsi)) ajStrAssignS(&gcsi, parse); else if(!ajStrGetLen(sa)) ajStrAssignS(&sa, parse); else if(!ajStrGetLen(dist)) ajStrAssignS(&dist, parse); else if(!ajStrGetLen(z)) ajStrAssignS(&z, parse); else if(!ajStrGetLen(p)) ajStrAssignS(&p, parse); } } tmp = ajFmtStr("Sequence: %S GCSI: %S SA: %S DIST: %S", seqid, gcsi, sa, dist); if(pval) tmp = ajFmtStr("%S Z: %S P: %S", tmp, z, p); ajFmtPrintF(outf, "%S\n", tmp); ajStrDel(&tmp); ajStrDel(&parse); ajStrDel(&gcsi); ajStrDel(&sa); ajStrDel(&dist); ajStrDel(&z); ajStrDel(&p); } else { soap_print_fault(&soap, stderr); } soap_destroy(&soap); soap_end(&soap); soap_done(&soap); AJFREE(in0); ajStrDel(&inseq); } ajFileClose(&outf); ajSeqallDel(&seqall); ajSeqDel(&seq); ajStrDel(&seqid); embExit(); return 0; }
int main(int argc, char **argv) { /* ACD data item variables */ AjPSeqset alignfile = NULL; AjPFile prior = NULL; AjPFile null = NULL; AjPFile pam = NULL; float pamwgt = 0.0; AjPStr nhmm = NULL; AjPStr strategy = NULL; ajint pbswitch = 0; float archpri = 0.0; AjBool binary = ajFalse; AjBool fast = ajFalse; float gapmax = 0.0; AjBool hand = ajFalse; float idlevel = 0.0; AjBool noeff = ajFalse; float swentry = 0.0; float swexit = 0.0; AjBool verbosity = ajFalse; AjPStr weighting = NULL; AjPFile hmmfile = NULL; AjPFile o = NULL; AjPFile cfile = NULL; /* Housekeeping variables */ AjPStr cmd = NULL; AjPStr rnd1 = NULL; AjPStr rnd2 = NULL; AjPStr tmp = NULL; AjPStr fmt = NULL; char option; AjBool fmtok = ajFalse; AjPStr hmmfilename = NULL; /* ACD file processing */ embInitPV("ehmmbuild",argc,argv,"HMMERNEW",VERSION); alignfile = ajAcdGetSeqset("alignfile"); prior = ajAcdGetInfile("prior"); null = ajAcdGetInfile("null"); pam = ajAcdGetInfile("pam"); pamwgt = ajAcdGetFloat("pamwgt"); nhmm = ajAcdGetString("nhmm"); strategy = ajAcdGetListSingle("strategy"); pbswitch = ajAcdGetInt("pbswitch"); archpri = ajAcdGetFloat("archpri"); binary = ajAcdGetBoolean("binary"); fast = ajAcdGetBoolean("fast"); gapmax = ajAcdGetFloat("gapmax"); hand = ajAcdGetBoolean("hand"); idlevel = ajAcdGetFloat("sidlevel"); noeff = ajAcdGetBoolean("noeff"); swentry = ajAcdGetFloat("swentry"); swexit = ajAcdGetFloat("swexit"); verbosity = ajAcdGetBoolean("verbosity"); weighting = ajAcdGetListSingle("weighting"); hmmfile = ajAcdGetOutfile("hmmfile"); o = ajAcdGetOutfile("o"); cfile = ajAcdGetOutfile("cfile"); /* MAIN APPLICATION CODE */ /* 1. Housekeeping */ cmd = ajStrNew(); rnd1 = ajStrNew(); rnd2 = ajStrNew(); tmp = ajStrNew(); fmt = ajStrNew(); hmmfilename = ajStrNew(); ajStrAssignC(&hmmfilename, ajFileGetNameC(hmmfile)); /* 2. Ensure alignfile is in format HMMER can understand. These include FASTA, GENBANK,EMBL, GCG, PIR, STOCKHOLM, SELEX, MSF,CLUSTAL and PHYLIP. EMBOSS name definitions are taken from seqInFormatDef in ajseqread.c and seqOutFormat in ajseqwrite.c */ fmtok=ajFalse; ajStrAssignS(&fmt, ajSeqsetGetFormat(alignfile)); if(ajStrMatchC(fmt, "fasta") || ajStrMatchC(fmt, "genbank") || ajStrMatchC(fmt, "embl") || ajStrMatchC(fmt, "gcg") || ajStrMatchC(fmt, "pir") || ajStrMatchC(fmt, "stockholm")|| ajStrMatchC(fmt, "selex") || ajStrMatchC(fmt, "msf") || ajStrMatchC(fmt, "clustal") || ajStrMatchC(fmt, "phylip")) fmtok = ajTrue; /* This could be replaced with code to reformat the file. */ if(!fmtok) ajFatal("Input alignment ('alignfile' ACD option) is not in format " "HMMER understands. Please use a a file in FASTA, GENBANK, " "EMBL, GCG, PIR, STOCKHOLM, SELEX, MSF,CLUSTAL or PHYLIP format."); /* 3. Build hmmbuild command line */ /* Command line is built in this order: i. Application name. ii. HMMER 'options' (in order they appear in ACD file) iii.HMMER 'options' (that don't appear in ACD file) iv. HMMER & new parameters. */ ajStrAssignS(&cmd, ajAcdGetpathC("hmmbuild")); if(prior) ajFmtPrintAppS(&cmd, " --prior %s ", ajFileGetNameC(prior)); if(null) ajFmtPrintS(&cmd, " --null %s ", ajFileGetNameC(null)); if(pam) ajFmtPrintAppS(&cmd, " --pam %s --pamwgt %f ", ajFileGetNameC(pam), pamwgt); ajFmtPrintAppS(&cmd, " -n %S ", nhmm); /* ACD option only allows one selection */ option = ajStrGetCharFirst(strategy); if(option == 'F') ajStrAppendC(&cmd, " -f "); else if(option == 'G') ajStrAppendC(&cmd, " -g "); else if(option == 'S') ajStrAppendC(&cmd, " -s "); /* else go with default ('D' option in ACD file) */ ajFmtPrintAppS(&cmd, " --pbswitch %d ", pbswitch); ajFmtPrintAppS(&cmd, " --archpri %f ", archpri); if(binary) ajStrAppendC(&cmd, " --binary "); if(fast) ajFmtPrintAppS(&cmd, " --fast --gapmax %f ", gapmax); if(hand) ajStrAppendC(&cmd, " --hand "); ajFmtPrintAppS(&cmd, " --idlevel %f ", idlevel); if(noeff) ajStrAppendC(&cmd, " --noeff "); ajFmtPrintAppS(&cmd, " --swentry %f ", swentry); ajFmtPrintAppS(&cmd, " --swexit %f ", swexit); if(verbosity) ajStrAppendC(&cmd, " --verbose "); /* ACD option only allows one selection */ option = ajStrGetCharFirst(weighting); if(option == 'B') ajStrAppendC(&cmd, " --wblosum "); else if(option == 'G') ajStrAppendC(&cmd, " --wgsc "); else if(option == 'K') ajStrAppendC(&cmd, " --wme "); else if(option == 'W') ajStrAppendC(&cmd, " --wpb "); else if(option == 'V') ajStrAppendC(&cmd, " --wvoronoi "); else if(option == 'N') ajStrAppendC(&cmd, " --wnone "); if(o) ajFmtPrintAppS(&cmd, " -o %s ", ajFileGetNameC(o)); if(cfile) ajFmtPrintAppS(&cmd, " --cfile %s ", ajFileGetNameC(cfile)); /* -A (append) always set but file will be wiped by EMBOSS first unless append: "Y" is set for "hmmfile" in the ACD file. */ ajStrAppendC(&cmd, " -A -F "); ajFmtPrintAppS(&cmd, " %S %S", hmmfilename, ajSeqsetGetFilename(alignfile)); /* 4. Close ACD files */ ajSeqsetDel(&alignfile); ajFileClose(&prior); ajFileClose(&null); ajFileClose(&pam); ajFileClose(&hmmfile); ajFileClose(&o); ajFileClose(&cfile); /* 5. Call hmmbuild */ ajFmtPrint("\n%S\n", cmd); system(ajStrGetPtr(cmd)); /* 6. Exit cleanly */ ajStrDel(&nhmm); ajStrDel(&cmd); ajStrDel(&rnd1); ajStrDel(&rnd2); ajStrDel(&tmp); ajStrDel(&fmt); ajStrDel(&hmmfilename); ajStrDel(&strategy); ajStrDel(&weighting); embExit(); return 0; }
int main(int argc, char **argv) { AjPFile outfile = NULL; AjBool full = AJFALSE; AjPStr tmpstr = NULL; embInit("embossversion", argc, argv); full = ajAcdGetBoolean("full"); outfile = ajAcdGetOutfile("outfile"); if (!full) { ajFmtPrintF(outfile,"%s\n", VERSION); } else { tmpstr = ajStrNewRes(128); ajStrAssignS(&tmpstr, ajNamValuePackage()); if (!ajStrGetLen(tmpstr)) ajStrAssignC(&tmpstr, "(unknown)"); ajFmtPrintF(outfile, "PackageName: %S\n", tmpstr); ajStrAssignS(&tmpstr, ajNamValueVersion()); if (!ajStrGetLen(tmpstr)) ajStrAssignC(&tmpstr, "(unknown)"); ajFmtPrintF(outfile, "LibraryVersion: %S\n", tmpstr); ajStrAssignS(&tmpstr, ajNamValueSystem()); if (!ajStrGetLen(tmpstr)) ajStrAssignC(&tmpstr, "(unknown)"); ajFmtPrintF(outfile, "System: %S\n", tmpstr); ajStrAssignS(&tmpstr, ajNamValueInstalldir()); if (!ajStrGetLen(tmpstr)) ajStrAssignC(&tmpstr, "(unknown)"); ajFmtPrintF(outfile, "InstallDirectory: %S\n", tmpstr); ajStrAssignS(&tmpstr, ajNamValueRootdir()); if (!ajStrGetLen(tmpstr)) ajStrAssignC(&tmpstr, "(unknown)"); ajFmtPrintF(outfile, "RootDirectory: %S\n", tmpstr); ajStrAssignS(&tmpstr, ajNamValueBasedir()); if (!ajStrGetLen(tmpstr)) ajStrAssignC(&tmpstr, "(unknown)"); ajFmtPrintF(outfile, "BaseDirectory: %S\n", tmpstr); if (!ajNamGetValueC("acdroot", &tmpstr)) ajStrAssignC(&tmpstr, "(default)"); ajFmtPrintF(outfile, "Emboss_AcdRoot: %S\n", tmpstr); if (!ajNamGetValueC("data", &tmpstr)) ajStrAssignC(&tmpstr, "(default)"); ajFmtPrintF(outfile, "Emboss_Data: %S\n", tmpstr); if (!ajNamGetValueC("filter", &tmpstr)) ajStrAssignC(&tmpstr, "(default)"); ajFmtPrintF(outfile, "Emboss_Filter: %S\n", tmpstr); if (!ajNamGetValueC("format", &tmpstr)) ajStrAssignC(&tmpstr, "(default)"); ajFmtPrintF(outfile, "Emboss_Format: %S\n", tmpstr); if (!ajNamGetValueC("graphics", &tmpstr)) ajStrAssignC(&tmpstr, "(default)"); ajFmtPrintF(outfile, "Emboss_Graphics: %S\n", tmpstr); if (!ajNamGetValueC("httpversion", &tmpstr)) ajStrAssignC(&tmpstr, "(default)"); ajFmtPrintF(outfile, "Emboss_HttpVersion: %S\n", tmpstr); if (!ajNamGetValueC("language", &tmpstr)) ajStrAssignC(&tmpstr, "(default)"); ajFmtPrintF(outfile, "Emboss_Language: %S\n", tmpstr); if (!ajNamGetValueC("options", &tmpstr)) ajStrAssignC(&tmpstr, "(default)"); ajFmtPrintF(outfile, "Emboss_Options: %S\n", tmpstr); if (!ajNamGetValueC("outdirectory", &tmpstr)) ajStrAssignC(&tmpstr, "(default)"); ajFmtPrintF(outfile, "Emboss_OutDirectory: %S\n", tmpstr); if (!ajNamGetValueC("outfeatformat", &tmpstr)) ajStrAssignC(&tmpstr, "(default)"); ajFmtPrintF(outfile, "Emboss_OutFeatFormat: %S\n", tmpstr); if (!ajNamGetValueC("outformat", &tmpstr)) ajStrAssignC(&tmpstr, "(default)"); ajFmtPrintF(outfile, "Emboss_OutFormat: %S\n", tmpstr); if (!ajNamGetValueC("proxy", &tmpstr)) ajStrAssignC(&tmpstr, "(default)"); ajFmtPrintF(outfile, "Emboss_Proxy: %S\n", tmpstr); if (!ajNamGetValueC("stdout", &tmpstr)) ajStrAssignC(&tmpstr, "(default)"); ajFmtPrintF(outfile, "Emboss_Stdout: %S\n", tmpstr); if (!ajNamGetValueC("warnrange", &tmpstr)) ajStrAssignC(&tmpstr, "(default)"); ajFmtPrintF(outfile, "Emboss_WarnRange: %S\n", tmpstr); } ajFileClose(&outfile); 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) { /* Variable declarations */ AjPOutfile outfile = NULL; AjBool obsolete = ajTrue; AjPObo obo = NULL; AjPObo oboanc = NULL; AjPObo oboparent = NULL; AjPOboall oboall = NULL; AjPOboin oboin = NULL; AjPStr oboqryup = NULL; AjPStr oboqryanc = NULL; AjPTable alltable = NULL; AjPTable newtable = NULL; AjPStr up = NULL; AjPList uplist = NULL; ajuint iterms = 0; AjPStr topid = NULL; AjPStr obodb = NULL; AjBool saved = ajFalse; /* ACD processing */ embInit("ontogetcommon", argc, argv); oboall = ajAcdGetOboall("oboterms"); outfile = ajAcdGetOutobo("outfile"); obsolete = ajAcdGetBoolean("obsolete"); oboin = ajOboinNew(); oboparent = ajOboNew(); oboanc = ajOboNew(); uplist = ajListNew(); alltable = ajTablestrNew(600); newtable = ajTablestrNew(600); while(ajOboallNext(oboall, &obo)) { saved = ajFalse; if(!obsolete && ajOboIsObsolete(obo)) continue; if(!iterms) { ajDebug("store id '%S'\n", ajOboGetId(obo)); ajStrAssignS(&obodb, ajOboGetDb(obo)); ajTablePut(alltable, ajStrNewS(ajOboGetId(obo)), NULL); saved = ajTrue; } else { ajDebug("test id '%S'\n", ajOboGetId(obo)); if(ajTableMatchS(alltable, ajOboGetId(obo))) { ajDebug("keep id '%S'\n", ajOboGetId(obo)); ajTablePut(newtable, ajStrNewS(ajOboGetId(obo)), NULL); saved = ajTrue; } } if(saved) ajStrAssignS(&topid, ajOboGetId(obo)); if(ajOboGetParents(obo, uplist)) /* that was the root */ { while(ajListstrPop(uplist, &up)) { ajDebug("up: '%S'\n", up); ajFmtPrintS(&oboqryup, "%S-id:%S", ajOboGetDb(obo), up); ajOboinQryS(oboin, oboqryup); while(ajOboinRead(oboin, oboparent)) { if(!obsolete && ajOboIsObsolete(oboparent)) continue; if(!iterms) { ajDebug("store parent '%S'\n", ajOboGetId(oboparent)); ajTablePut(alltable, ajStrNewS(ajOboGetId(oboparent)), NULL); } else { ajDebug("test parent '%S'\n", ajOboGetId(oboparent)); if(ajTableMatchS(alltable, ajOboGetId(oboparent))) { ajDebug("keep parent '%S'\n", ajOboGetId(oboparent)); ajTablePut(newtable, ajStrNewS(ajOboGetId(oboparent)), NULL); if(!saved) { ajStrAssignS(&topid, ajOboGetId(oboparent)); saved = ajTrue; } } } if(!ajOboGetParents(oboparent, uplist)) continue; } ajStrDel(&up); } } if(iterms) ajTableMergeAnd(alltable, newtable); ajDebug("id: '%S' saved %u\n", ajOboGetId(obo), ajTableGetLength(alltable)); if(!ajTableGetLength(alltable)) ajDie("Query '%S' no matching ancestor found for obo term '%S:%S'", ajOboallGetQryS(oboall), ajOboGetDb(obo), ajOboGetId(obo)); iterms++; } ajFmtPrintS(&oboqryanc, "%S-id:%S", obodb, topid); ajOboinQryS(oboin, oboqryanc); while(ajOboinRead(oboin, oboanc)) { ajObooutWrite(outfile, oboanc); } /* Memory clean-up and exit */ ajOboallDel(&oboall); ajOboinDel(&oboin); ajOboDel(&oboanc); ajOboDel(&oboparent); ajListFree(&uplist); ajTablestrFreeKey(&alltable); ajTablestrFreeKey(&newtable); ajStrDel(&oboqryup); ajStrDel(&oboqryanc); ajStrDel(&obodb); ajStrDel(&topid); ajOutfileClose(&outfile); embExit(); return 0; }
void emboss_getoptions(char *pgm, int argc, char *argv[]) { ajint numseqs=0; ajint numwts=0; AjPStr method = NULL; ancvar = false; dollo = true; jumble = false; njumble = 1; trout = true; usertree = false; goteof = false; weights = false; justwts = false; printdata = false; progress = true; treeprint = true; stepbox = false; ancseq = false; mulsets = false; msets = 1; embInitPV(pgm, argc, argv, "PHYLIPNEW",VERSION); phylostates = ajAcdGetDiscretestates("infile"); while (phylostates[numseqs]) numseqs++; phylotrees = ajAcdGetTree("intreefile"); if (phylotrees) { numtrees = 0; while (phylotrees[numtrees]) numtrees++; usertree = true; } phyloweights = ajAcdGetProperties("weights"); if (phyloweights) { weights = true; numwts = ajPhyloPropGetSize(phyloweights); } if (numseqs > 1) { mulsets = true; msets = numseqs; } else if (numwts > 1) { mulsets = true; msets = numwts; justwts = true; } method = ajAcdGetListSingle("method"); if(ajStrMatchC(method, "d")) dollo = true; else dollo = false; if(!usertree) { njumble = ajAcdGetInt("njumble"); if(njumble >0) { inseed = ajAcdGetInt("seed"); jumble = true; emboss_initseed(inseed, &inseed0, seed); } else njumble = 1; } if((mulsets) && (!jumble)) { jumble = true; inseed = ajAcdGetInt("seed"); emboss_initseed(inseed, &inseed0, seed); } phyloanc = ajAcdGetProperties("ancfile"); if(phyloanc) ancvar = true; threshold = ajAcdGetFloat("threshold"); printdata = ajAcdGetBoolean("printdata"); progress = ajAcdGetBoolean("progress"); treeprint = ajAcdGetBoolean("treeprint"); trout = ajAcdGetToggle("trout"); stepbox = ajAcdGetBoolean("stepbox"); ancseq = ajAcdGetBoolean("ancseq"); embossoutfile = ajAcdGetOutfile("outfile"); emboss_openfile(embossoutfile, &outfile, &outfilename); if(trout) { embossouttree = ajAcdGetOutfile("outtreefile"); emboss_openfile(embossouttree, &outtree, &outtreename); } printf("\nDollo and polymorphism parsimony algorithm, version %s\n\n", VERSION); fprintf(outfile,"\nDollo and polymorphism parsimony algorithm,"); fprintf(outfile," version %s\n\n",VERSION); } /* emboss_getoptions */
int main(int argc, char **argv) { AjPAlign align; AjPSeqall seqall; AjPSeq a; AjPSeq b; AjPStr alga; AjPStr algb; AjPStr ss; ajuint lena; ajuint lenb; const char *p; const char *q; ajint start1 = 0; ajint start2 = 0; float *path; ajint *compass; float* ix; float* iy; float* m; AjPMatrixf matrix; AjPSeqCvt cvt = 0; float **sub; float gapopen; float gapextend; float endgapopen; float endgapextend; ajulong maxarr = 1000; /* arbitrary. realloc'd if needed */ ajulong len; float score; AjBool dobrief = ajTrue; AjBool endweight = ajFalse; /* whether end gap penalties should be applied */ float id = 0.; float sim = 0.; float idx = 0.; float simx = 0.; AjPStr tmpstr = NULL; size_t stlen; embInit("needle", argc, argv); matrix = ajAcdGetMatrixf("datafile"); a = ajAcdGetSeq("asequence"); ajSeqTrim(a); seqall = ajAcdGetSeqall("bsequence"); gapopen = ajAcdGetFloat("gapopen"); gapextend = ajAcdGetFloat("gapextend"); endgapopen = ajAcdGetFloat("endopen"); endgapextend = ajAcdGetFloat("endextend"); dobrief = ajAcdGetBoolean("brief"); endweight = ajAcdGetBoolean("endweight"); align = ajAcdGetAlign("outfile"); gapopen = ajRoundFloat(gapopen, 8); gapextend = ajRoundFloat(gapextend, 8); AJCNEW(path, maxarr); AJCNEW(compass, maxarr); AJCNEW(m, maxarr); AJCNEW(ix, maxarr); AJCNEW(iy, maxarr); alga = ajStrNew(); algb = ajStrNew(); ss = ajStrNew(); sub = ajMatrixfGetMatrix(matrix); cvt = ajMatrixfGetCvt(matrix); lena = ajSeqGetLen(a); while(ajSeqallNext(seqall,&b)) { ajSeqTrim(b); lenb = ajSeqGetLen(b); if(lenb > (ULONG_MAX/(ajulong)(lena+1))) ajFatal("Sequences too big. Try 'stretcher' or 'supermatcher'"); len = lena*lenb; if(len>maxarr) { stlen = (size_t) len; AJCRESIZETRY(path,stlen); if(!path) ajDie("Sequences too big. Try 'stretcher'"); AJCRESIZETRY(compass,stlen); if(!compass) ajDie("Sequences too big. Try 'stretcher'"); AJCRESIZETRY(m,stlen); if(!m) ajDie("Sequences too big. Try 'stretcher'"); AJCRESIZETRY(ix,stlen); if(!ix) ajDie("Sequences too big. Try 'stretcher'"); AJCRESIZETRY(iy,stlen); if(!iy) ajDie("Sequences too big. Try 'stretcher'"); maxarr=len; } p = ajSeqGetSeqC(a); q = ajSeqGetSeqC(b); ajStrAssignC(&alga,""); ajStrAssignC(&algb,""); score = embAlignPathCalcWithEndGapPenalties(p, q, lena, lenb, gapopen, gapextend, endgapopen, endgapextend, &start1, &start2, path, sub, cvt, m, ix, iy, compass, ajTrue, endweight); embAlignWalkNWMatrixUsingCompass(p, q, &alga, &algb, lena, lenb, &start1, &start2, compass); embAlignReportGlobal(align, a, b, alga, algb, start1, start2, gapopen, gapextend, score, matrix, ajSeqGetOffset(a), ajSeqGetOffset(b)); if(!dobrief) { embAlignCalcSimilarity(alga,algb,sub,cvt,lena,lenb,&id,&sim,&idx, &simx); ajFmtPrintS(&tmpstr,"Longest_Identity = %5.2f%%\n", id); ajFmtPrintAppS(&tmpstr,"Longest_Similarity = %5.2f%%\n", sim); ajFmtPrintAppS(&tmpstr,"Shortest_Identity = %5.2f%%\n", idx); ajFmtPrintAppS(&tmpstr,"Shortest_Similarity = %5.2f%%", simx); ajAlignSetSubHeaderApp(align, tmpstr); } ajAlignWrite(align); ajAlignReset(align); } ajAlignClose(align); ajAlignDel(&align); ajSeqallDel(&seqall); ajSeqDel(&a); ajSeqDel(&b); AJFREE(compass); AJFREE(path); AJFREE(ix); AJFREE(iy); AJFREE(m); ajStrDel(&alga); ajStrDel(&algb); ajStrDel(&ss); ajStrDel(&tmpstr); 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) { AjPSeqall seqall = NULL; AjPFile dend_outfile = NULL; AjPStr tmp_dendfilename = NULL; AjPFile tmp_dendfile = NULL; AjPStr tmp_aln_outfile = NULL; AjPSeqset seqset = NULL; AjPSeqout seqout = NULL; AjPSeqin seqin = NULL; AjBool only_dend; AjBool are_prot = ajFalse; AjBool do_slow; AjBool use_dend; AjPFile dend_file = NULL; AjPStr dend_filename = NULL; ajint ktup; ajint gapw; ajint topdiags; ajint window; AjBool nopercent; AjPStr pw_matrix = NULL; AjPStr pw_dna_matrix = NULL; AjPFile pairwise_matrix = NULL; float pw_gapc; float pw_gapv; AjPStr pwmstr = NULL; char pwmc = '\0'; AjPStr pwdstr = NULL; char pwdc = '\0'; AjPStr m1str = NULL; AjPStr m2str = NULL; char m1c = '\0'; char m2c = '\0'; AjPStr matrix = NULL; AjPStr dna_matrix = NULL; AjPFile ma_matrix = NULL; float gapc; float gapv; AjBool endgaps; AjBool norgap; AjBool nohgap; ajint gap_dist; ajint maxdiv; AjPStr hgapres = NULL; AjPSeqout fil_file = NULL; AjPSeq seq = NULL; AjPStr cmd = NULL; AjPStr tmp = NULL; AjPStr tmpFilename; AjPStr line = NULL; ajint nb = 0; /* get all the parameters */ embInit("emma", argc, argv); pwmstr = ajStrNew(); pwdstr = ajStrNew(); m1str = ajStrNew(); m2str = ajStrNew(); seqall = ajAcdGetSeqall("sequence"); seqout = ajAcdGetSeqoutset("outseq"); dend_outfile = ajAcdGetOutfile("dendoutfile"); only_dend = ajAcdGetToggle("onlydend"); use_dend = ajAcdGetToggle("dendreuse"); dend_file = ajAcdGetInfile("dendfile"); if (dend_file) ajStrAssignS(&dend_filename, ajFileGetPrintnameS(dend_file)); ajFileClose(&dend_file); do_slow = ajAcdGetToggle("slowalign"); ktup = ajAcdGetInt("ktup"); gapw = ajAcdGetInt("gapw"); topdiags = ajAcdGetInt("topdiags"); window = ajAcdGetInt("window"); nopercent = ajAcdGetBoolean("nopercent"); pw_matrix = ajAcdGetListSingle("pwmatrix"); pwmc = ajStrGetCharFirst(pw_matrix); if(pwmc=='b') ajStrAssignC(&pwmstr,"blosum"); else if(pwmc=='p') ajStrAssignC(&pwmstr,"pam"); else if(pwmc=='g') ajStrAssignC(&pwmstr,"gonnet"); else if(pwmc=='i') ajStrAssignC(&pwmstr,"id"); else if(pwmc=='o') ajStrAssignC(&pwmstr,"own"); pw_dna_matrix = ajAcdGetListSingle("pwdnamatrix"); pwdc = ajStrGetCharFirst(pw_dna_matrix); if(pwdc=='i') ajStrAssignC(&pwdstr,"iub"); else if(pwdc=='c') ajStrAssignC(&pwdstr,"clustalw"); else if(pwdc=='o') ajStrAssignC(&pwdstr,"own"); pairwise_matrix = ajAcdGetInfile("pairwisedatafile"); pw_gapc = ajAcdGetFloat( "pwgapopen"); pw_gapv = ajAcdGetFloat( "pwgapextend"); matrix = ajAcdGetListSingle( "matrix"); m1c = ajStrGetCharFirst(matrix); if(m1c=='b') ajStrAssignC(&m1str,"blosum"); else if(m1c=='p') ajStrAssignC(&m1str,"pam"); else if(m1c=='g') ajStrAssignC(&m1str,"gonnet"); else if(m1c=='i') ajStrAssignC(&m1str,"id"); else if(m1c=='o') ajStrAssignC(&m1str,"own"); dna_matrix = ajAcdGetListSingle( "dnamatrix"); m2c = ajStrGetCharFirst(dna_matrix); if(m2c=='i') ajStrAssignC(&m2str,"iub"); else if(m2c=='c') ajStrAssignC(&m2str,"clustalw"); else if(m2c=='o') ajStrAssignC(&m2str,"own"); ma_matrix = ajAcdGetInfile("mamatrixfile"); gapc = ajAcdGetFloat("gapopen"); gapv = ajAcdGetFloat("gapextend"); endgaps = ajAcdGetBoolean("endgaps"); norgap = ajAcdGetBoolean("norgap"); nohgap = ajAcdGetBoolean("nohgap"); gap_dist = ajAcdGetInt("gapdist"); hgapres = ajAcdGetString("hgapres"); maxdiv = ajAcdGetInt("maxdiv"); tmp = ajStrNewC("fasta"); /* ** Start by writing sequences into a unique temporary file ** get file pointer to unique file */ fil_file = ajSeqoutNew(); tmpFilename = emma_getUniqueFileName(); if(!ajSeqoutOpenFilename( fil_file, tmpFilename)) embExitBad(); /* Set output format to fasta */ ajSeqoutSetFormatS( fil_file, tmp); while(ajSeqallNext(seqall, &seq)) { /* ** Check sequences are all of the same type ** Still to be done ** Write out sequences */ if (!nb) are_prot = ajSeqIsProt(seq); ajSeqoutWriteSeq(fil_file, seq); ++nb; } ajSeqoutClose(fil_file); if(nb < 2) ajFatal("Multiple alignments need at least two sequences"); /* Generate clustalw command line */ cmd = ajStrNewS(ajAcdGetpathC("clustalw")); /* add tmp file containing sequences */ ajStrAppendC(&cmd, " -infile="); ajStrAppendS(&cmd, tmpFilename); /* add out file name */ tmp_aln_outfile = emma_getUniqueFileName(); ajStrAppendC(&cmd, " -outfile="); ajStrAppendS(&cmd, tmp_aln_outfile); /* calculating just the nj tree or doing full alignment */ if(only_dend) ajStrAppendC(&cmd, " -tree"); else if(!use_dend) ajStrAppendC(&cmd, " -align"); /* Set sequence type from information from acd file */ if(are_prot) ajStrAppendC(&cmd, " -type=protein"); else ajStrAppendC(&cmd, " -type=dna"); /* ** set output to MSF format - will read in this file later and output ** user requested format */ ajStrAppendC(&cmd, " -output="); ajStrAppendC(&cmd, "gcg"); /* If going to do pairwise alignment */ if(!use_dend) { /* add fast pairwise alignments*/ if(!do_slow) { ajStrAppendC(&cmd, " -quicktree"); ajStrAppendC(&cmd, " -ktuple="); ajStrFromInt(&tmp, ktup); ajStrAppendS(&cmd, tmp); ajStrAppendC(&cmd, " -window="); ajStrFromInt(&tmp, window); ajStrAppendS(&cmd, tmp); if(nopercent) ajStrAppendC(&cmd, " -score=percent"); else ajStrAppendC(&cmd, " -score=absolute"); ajStrAppendC(&cmd, " -topdiags="); ajStrFromInt(&tmp, topdiags); ajStrAppendS(&cmd, tmp); ajStrAppendC(&cmd, " -pairgap="); ajStrFromInt(&tmp, gapw); ajStrAppendS(&cmd, tmp); } else { if(pairwise_matrix) { if(are_prot) ajStrAppendC(&cmd, " -pwmatrix="); else ajStrAppendC(&cmd, " -pwdnamatrix="); ajStrAppendS(&cmd, ajFileGetPrintnameS(pairwise_matrix)); } else { if(are_prot) { ajStrAppendC(&cmd, " -pwmatrix="); ajStrAppendS(&cmd, pwmstr); } else { ajStrAppendC(&cmd, " -pwdnamatrix="); ajStrAppendS(&cmd, pwdstr); } } ajStrAppendC(&cmd, " -pwgapopen="); ajStrFromFloat(&tmp, pw_gapc, 3); ajStrAppendS(&cmd, tmp); ajStrAppendC(&cmd, " -pwgapext="); ajStrFromFloat(&tmp, pw_gapv, 3); ajStrAppendS(&cmd, tmp); } } /* Multiple alignments */ /* using existing tree or generating new tree? */ if(use_dend) { ajStrAppendC(&cmd, " -usetree="); ajStrAppendS(&cmd, dend_filename); } else { /* use tmp file to hold dend file, will read back in later */ tmp_dendfilename = emma_getUniqueFileName(); ajStrAppendC(&cmd, " -newtree="); ajStrAppendS(&cmd, tmp_dendfilename); } if(ma_matrix) { if(are_prot) ajStrAppendC(&cmd, " -matrix="); else ajStrAppendC(&cmd, " -pwmatrix="); ajStrAppendS(&cmd, ajFileGetPrintnameS(ma_matrix)); } else { if(are_prot) { ajStrAppendC(&cmd, " -matrix="); ajStrAppendS(&cmd, m1str); } else { ajStrAppendC(&cmd, " -dnamatrix="); ajStrAppendS(&cmd, m2str); } } ajStrAppendC(&cmd, " -gapopen="); ajStrFromFloat(&tmp, gapc, 3); ajStrAppendS(&cmd, tmp); ajStrAppendC(&cmd, " -gapext="); ajStrFromFloat(&tmp, gapv, 3); ajStrAppendS(&cmd, tmp); ajStrAppendC(&cmd, " -gapdist="); ajStrFromInt(&tmp, gap_dist); ajStrAppendS(&cmd, tmp); ajStrAppendC(&cmd, " -hgapresidues="); ajStrAppendS(&cmd, hgapres); if(!endgaps) ajStrAppendC(&cmd, " -endgaps"); if(norgap) ajStrAppendC(&cmd, " -nopgap"); if(nohgap) ajStrAppendC(&cmd, " -nohgap"); ajStrAppendC(&cmd, " -maxdiv="); ajStrFromInt(&tmp, maxdiv); ajStrAppendS(&cmd, tmp); /* run clustalw */ /* ajFmtError("..%s..\n\n", ajStrGetPtr( cmd)); */ ajDebug("Executing '%S'\n", cmd); ajSysExecS(cmd); /* produce alignment file only if one was produced */ if(!only_dend) { /* read in tmp alignment output file to output through EMBOSS output */ seqin = ajSeqinNew(); /* ** add the Usa format to the start of the filename to tell EMBOSS ** format of file */ ajStrInsertC(&tmp_aln_outfile, 0, "msf::"); ajSeqinUsa(&seqin, tmp_aln_outfile); seqset = ajSeqsetNew(); if(ajSeqsetRead(seqset, seqin)) { ajSeqoutWriteSet(seqout, seqset); ajSeqoutClose(seqout); ajSeqinDel(&seqin); /* remove the Usa from the start of the string */ ajStrCutStart(&tmp_aln_outfile, 5); } else ajFmtError("Problem writing out EMBOSS alignment file\n"); } /* read in new tmp dend file (if produced) to output through EMBOSS */ if(tmp_dendfilename!=NULL) { tmp_dendfile = ajFileNewInNameS( tmp_dendfilename); if(tmp_dendfile!=NULL){ while(ajReadlineTrim(tmp_dendfile, &line)) ajFmtPrintF(dend_outfile, "%s\n", ajStrGetPtr( line)); ajFileClose(&tmp_dendfile); ajSysFileUnlinkS(tmp_dendfilename); } } ajSysFileUnlinkS(tmpFilename); if(!only_dend) ajSysFileUnlinkS(tmp_aln_outfile); ajStrDel(&pw_matrix); ajStrDel(&matrix); ajStrDel(&pw_dna_matrix); ajStrDel(&dna_matrix); ajStrDel(&tmp_dendfilename); ajStrDel(&dend_filename); ajStrDel(&tmp_aln_outfile); ajStrDel(&pwmstr); ajStrDel(&pwdstr); ajStrDel(&m1str); ajStrDel(&m2str); ajStrDel(&hgapres); ajStrDel(&cmd); ajStrDel(&tmp); ajStrDel(&tmpFilename); ajStrDel(&line); ajFileClose(&dend_outfile); ajFileClose(&tmp_dendfile); ajFileClose(&dend_file); ajFileClose(&pairwise_matrix); ajFileClose(&ma_matrix); ajSeqallDel(&seqall); ajSeqsetDel(&seqset); ajSeqDel(&seq); ajSeqoutDel(&seqout); ajSeqoutDel(&fil_file); ajSeqinDel(&seqin); embExit(); return 0; }
int main(int argc, char **argv) { AjPSeqset seqset = NULL; AjPStr cl = NULL; AjPSeqout seqout = NULL; AjBool full = ajFalse; AjPStr fn = NULL; AjPStr stmp = NULL; AjPStr outfname = NULL; embInitPV("echlorop", argc, argv, "CBSTOOLS", VERSION); seqset = ajAcdGetSeqset("sequence"); outfname= ajAcdGetOutfileName("outfile"); full = ajAcdGetBoolean("full"); cl = ajStrNewS(ajAcdGetpathC("chlorop")); fn = ajStrNew(); stmp = ajStrNew(); ajFilenameSetTempname(&fn); seqout = ajSeqoutNew(); if(!ajSeqoutOpenFilename(seqout, fn)) ajFatal("Cannot open temporary file %S",fn); ajSeqoutSetFormatC(seqout, "fasta"); ajSeqoutWriteSet(seqout,seqset); ajSeqoutClose(seqout); if(full) ajStrAppendC(&cl," -F"); ajFmtPrintS(&stmp," %S",fn); ajStrAppendS(&cl,stmp); #if 0 ajFmtPrint("%S\n",cl); #endif #if 1 ajSysExecOutnameAppendS(cl, outfname); #endif ajSysFileUnlinkS(fn); ajStrDel(&cl); ajStrDel(&fn); ajStrDel(&stmp); ajSeqoutDel(&seqout); ajSeqsetDel(&seqset); ajStrDel(&outfname); 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) { 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) { 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; }