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; }
void emboss_getoptions(char *pgm, int argc, char *argv[]) { AjPStr datatype = NULL; global = false; jumble = false; njumble = 1; lengths = false; outgrno = 1; outgropt = false; all = true; contchars = false; trout = true; usertree = false; printdata = false; progress = true; treeprint = true; mulsets = false; datasets = 1; embInitPV (pgm, argc, argv, "PHYLIPNEW",VERSION); phylofreq = ajAcdGetFrequencies("infile"); phylotrees = ajAcdGetTree("intreefile"); if (phylotrees) { numtrees = 0; while (phylotrees[numtrees]) numtrees++; usertree = true; lengths = ajAcdGetBoolean("lengths"); } datatype = ajAcdGetListSingle("datatype"); if(ajStrMatchC(datatype, "c")) contchars = true; outgrno = ajAcdGetInt("outgrno"); if(outgrno != 0) outgropt = true; else outgrno = 1; if(!usertree) { global = ajAcdGetBoolean("global"); njumble = ajAcdGetInt("njumble"); if(njumble >0) { inseed = ajAcdGetInt("seed"); jumble = true; emboss_initseed(inseed, &inseed0, seed); } else njumble = 1; } printdata = ajAcdGetBoolean("printdata"); progress = ajAcdGetBoolean("progress"); treeprint = ajAcdGetBoolean("treeprint"); trout = ajAcdGetToggle("trout"); embossoutfile = ajAcdGetOutfile("outfile"); embossouttree = ajAcdGetOutfile("outtreefile"); emboss_openfile(embossoutfile, &outfile, &outfilename); if(trout) emboss_openfile(embossouttree, &outtree, &outtreename); fprintf(outfile, "\nContinuous character Maximum Likelihood"); fprintf(outfile, " method version %s\n\n",VERSION); ajStrDel(&datatype); } /* emboss_getoptions */
int main(int argc, char **argv) { AjPSeq seq1; AjPSeq seq2; ajint wordlen; AjPTable seq1MatchTable = 0; AjPList matchlist = NULL; AjPGraph graph = NULL; AjPGraph xygraph = NULL; AjBool boxit; /* ** Different ticks as they need to be different for x and y due to ** length of string being important on x */ ajuint acceptableticksx[]= { 1,10,50,100,500,1000,1500,10000, 500000,1000000,5000000 }; ajuint acceptableticks[]= { 1,10,50,100,200,500,1000,2000,5000,10000,15000, 500000,1000000,5000000 }; ajint numbofticks = 10; float xmargin; float ymargin; float ticklen; float tickgap; float onefifth = 0.0; ajint i; float k; float max; char ptr[10]; ajint begin1; ajint begin2; ajint end1; ajint end2; ajuint len1; ajuint len2; float fbegin1; float fbegin2; float fend1; float fend2; float flen1; float flen2; AjBool stretch; embInit("dottup", argc, argv); wordlen = ajAcdGetInt("wordsize"); seq1 = ajAcdGetSeq("asequence"); seq2 = ajAcdGetSeq("bsequence"); graph = ajAcdGetGraph("graph"); boxit = ajAcdGetBoolean("boxit"); stretch = ajAcdGetToggle("stretch"); xygraph = ajAcdGetGraphxy("xygraph"); begin1 = ajSeqGetBegin(seq1); begin2 = ajSeqGetBegin(seq2); end1 = ajSeqGetEnd(seq1); end2 = ajSeqGetEnd(seq2); len1 = end1 - begin1 + 1; len2 = end2 - begin2 + 1; flen1 = (float) len1; flen2 = (float) len2; fbegin1 = (float) begin1; fbegin2 = (float) begin2; fend1 = (float) end1; fend2 = (float) end2; offset1 = fbegin1; offset2 = fbegin2; ajSeqTrim(seq1); ajSeqTrim(seq2); embWordLength(wordlen); if(embWordGetTable(&seq1MatchTable, seq1)) matchlist = embWordBuildMatchTable(seq1MatchTable, seq2, ajTrue); if(stretch) { dottup_stretchplot(xygraph,matchlist,seq1,seq2,begin1,begin2,end1, end2); if(matchlist) embWordMatchListDelete(&matchlist); /* free the match structures */ } else { /* only here if stretch is false */ max= flen1; if(flen2 > max) max = flen2; xmargin = ymargin = max * (float)0.15; ajGraphOpenWin(graph, fbegin1-ymargin,fend1+ymargin, fbegin2-xmargin,(float)fend2+xmargin); ajGraphicsSetCharscale(0.5); if(matchlist) dottup_plotMatches(matchlist); if(boxit) { ajGraphicsDrawposRect(fbegin1, fbegin2, fend1, fend2); i = 0; while(acceptableticksx[i]*numbofticks < len1) i++; if(i<=13) tickgap = (float) acceptableticksx[i]; else tickgap = (float) acceptableticksx[10]; ticklen = xmargin * (float) 0.1; onefifth = xmargin * (float)0.2; ajGraphicsDrawposTextAtmid(fbegin1+flen1*(float)0.5, fbegin1-(onefifth*(float)3.0), ajGraphGetYlabelC(graph)); if(len2/len1 > 10 ) { /* a lot smaller then just label start and end */ ajGraphicsDrawposLine(fbegin1,fbegin2,fbegin1, fbegin2-ticklen); sprintf(ptr,"%u",ajSeqGetOffset(seq1)); ajGraphicsDrawposTextAtmid(fbegin1,fbegin2-(onefifth),ptr); ajGraphicsDrawposLine(fend1,fbegin2, fend1,fbegin2-ticklen); sprintf(ptr,"%d",end1); ajGraphicsDrawposTextAtmid(fend1,fbegin2-(onefifth),ptr); } else for(k=fbegin1;k<fend1;k+=tickgap) { ajGraphicsDrawposLine(k,fbegin2,k,fbegin2-ticklen); sprintf(ptr,"%d",(ajint)k); ajGraphicsDrawposTextAtmid( k,fbegin2-(onefifth),ptr); } i = 0; while(acceptableticks[i]*numbofticks < len2) i++; tickgap = (float) acceptableticks[i]; ticklen = ymargin*(float)0.1; onefifth = ymargin*(float)0.2; ajGraphicsDrawposTextAtlineJustify(fbegin1-(onefifth*(float)4.), fbegin2+flen2*(float)0.5, fbegin2-(onefifth*(float)4.), fbegin2+flen2, ajGraphGetXlabelC(graph), 0.5); if(len1/len2 > 10 ) { /* a lot smaller then just label start and end */ ajGraphicsDrawposLine(fbegin1,fbegin2,fbegin1-ticklen, fbegin2); sprintf(ptr,"%u",ajSeqGetOffset(seq2)); ajGraphicsDrawposTextAtend(fbegin1-(onefifth),fbegin2,ptr); ajGraphicsDrawposLine(fbegin1,fend2,fbegin1-ticklen, fend2); sprintf(ptr,"%d",end2); ajGraphicsDrawposTextAtend(fbegin2-(onefifth),fend2,ptr); } else for(k=fbegin2;k<fend2;k+=tickgap) { ajGraphicsDrawposLine(fbegin1,k,fbegin1-ticklen,k); sprintf(ptr,"%d",(ajint)k); ajGraphicsDrawposTextAtend(fbegin1-(onefifth),k,ptr); } } } ajGraphicsClose(); ajSeqDel(&seq1); ajSeqDel(&seq2); ajGraphxyDel(&graph); ajGraphxyDel(&xygraph); embWordFreeTable(&seq1MatchTable); if(matchlist) embWordMatchListDelete(&matchlist); /* free the match structures */ embExit(); return 0; }
int main(int argc, char *argv[]) { embInitPV("gviewcds", argc, argv, "GEMBASSY", "1.0.1"); AjPSeqall seqall; AjPSeq seq; AjPStr inseq = NULL; ajint length = 0; ajint gap = 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; AjPPStr names = NULL; ajint i; seqall = ajAcdGetSeqall("sequence"); length = ajAcdGetInt("length"); gap = ajAcdGetInt("gap"); 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/view_cds/length=%d/gap=%d/" "output=f/tag=gene", base, restid, length, gap); if(plot) { if((names = (AjPPStr)malloc(sizeof(AjPStr) * 5)) == NULL) { ajDie("Error in memory allocation, exiting\n"); } names[0] = NULL; names[1] = ajStrNewC("A"); names[2] = ajStrNewC("T"); names[3] = ajStrNewC("G"); names[4] = ajStrNewC("C"); title = ajStrNew(); ajStrAppendC(&title, argv[0]); ajStrAppendC(&title, " of "); ajStrAppendS(&title, seqid); gpp.title = ajStrNewS(title); gpp.xlab = ajStrNewC("position"); gpp.ylab = ajStrNewC("percentage"); gpp.names = names; if(!gFilebuffURLS(url, &buff)) { ajDie("File downloading error from:\n%S\n", url); } if(!gPlotFilebuff(buff, mult, &gpp)) { ajDie("Error in plotting\n"); } i = 0; while(names[i]) { AJFREE(names[i]); ++i; } AJFREE(names); 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); embExit(); return 0; }
int main(int argc, char **argv) { AjPSeqall seqall; AjPSeqout seqout; AjPSeq seq = NULL; AjPStr str = NULL; AjPStr desc = NULL; ajint tail3; ajint tail5 = 0; ajint minlength; ajint mismatches; AjBool reverse; AjBool fiveprime; AjBool cvttolower; embInit("trimest", argc, argv); seqall = ajAcdGetSeqall("sequence"); seqout = ajAcdGetSeqoutall("outseq"); minlength = ajAcdGetInt("minlength"); mismatches = ajAcdGetInt("mismatches"); reverse = ajAcdGetBoolean("reverse"); fiveprime = ajAcdGetBoolean("fiveprime"); cvttolower = ajAcdGetToggle("tolower"); str = ajStrNew(); while(ajSeqallNext(seqall, &seq)) { /* get sequence description */ ajStrAssignS(&desc, ajSeqGetDescS(seq)); /* get positions to cut in 5' poly-T and 3' poly-A tails */ if(fiveprime) tail5 = trimest_get_tail(seq, 5, minlength, mismatches); tail3 = trimest_get_tail(seq, 3, minlength, mismatches); /* get a COPY of the sequence string */ ajStrAssignS(&str, ajSeqGetSeqS(seq)); /* cut off longest of 3' or 5' tail */ if(tail5 > tail3) { /* if 5' poly-T tail, then reverse the sequence */ ajDebug("Tail=%d\n", tail5); if(cvttolower) trimest_tolower(&str, 0, tail5-1); else ajStrKeepRange(&str, tail5, ajSeqGetLen(seq)-1); ajStrAppendC(&desc, " [poly-T tail removed]"); } else if(tail3 > tail5) { /* remove 3' poly-A tail */ ajDebug("Tail=%d\n", tail3); if(cvttolower) trimest_tolower(&str, ajSeqGetLen(seq)-tail3, ajSeqGetLen(seq)); else ajStrKeepRange(&str, 0, ajSeqGetLen(seq)-tail3-1); ajStrAppendC(&desc, " [poly-A tail removed]"); } /* write sequence out */ ajSeqAssignSeqS(seq, str); /* reverse complement if poly-T found */ if(tail5 > tail3 && reverse) { ajSeqReverseForce(seq); ajStrAppendC(&desc, " [reverse complement]"); } /* set description */ ajSeqAssignDescS(seq, desc); ajSeqoutWriteSeq(seqout, seq); } ajSeqoutClose(seqout); ajStrDel(&str); ajStrDel(&desc); ajSeqallDel(&seqall); ajSeqDel(&seq); ajSeqoutDel(&seqout); 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("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) { ajint famn = 0; /* Counter for the families. */ ajint nset = 0; /* No. entries in family. */ ajint last_nodeid = 0; /* SCOP Sunid of last family that was processed. */ AjPStr last_node = NULL; /* Last family that was processed. */ AjPStr exec = NULL; /* The UNIX command line to be executed. */ AjPStr out = NULL; /* Name of stamp alignment file. */ AjPStr align = NULL; /* Name of sequence alignment file. */ AjPStr alignc = NULL; /* Name of structure alignment file. */ AjPStr log = NULL; /* Name of STAMP log file. */ AjPStr dom = NULL; /* Name of file containing single domain. */ AjPStr set = NULL; /* Name of file containing set of domains. */ AjPStr scan = NULL; /* Name of temp. file used by STAMP. */ AjPStr sort = NULL; /* Name of temp. file used by STAMP. */ AjPStr name = NULL; /* Base name of STAMP temp files. */ AjPStr pdbnames = NULL; /* Names of domain pdb files to be passed to TCOFFEEE. */ AjPDir pdb = NULL; /* Path of domain coordinate files (pdb format input). */ AjPDirout daf = NULL; /* Path of sequence alignment files for output. */ AjPDirout super = NULL; /* Path of structure alignment files for output. */ AjPDirout singlets = NULL; /* Path of FASTA singlet sequence files for output. */ AjPStr temp1 = NULL; /* A temporary string. */ AjPFile dcfin = NULL; /* File pointer for original Escop.dat file.*/ AjPFile domf = NULL; /* File pointer for single domain file. */ AjPFile setf = NULL; /* File pointer for domain set file. */ AjPFile logf = NULL; /* Log file. */ AjPDomain domain = NULL; /* Pointer to domain structure. */ AjPDomain prevdomain = NULL; /* Pointer to previous domain structure. */ ajint type = 0; /* Type of domain (ajSCOP or ajCATH) in the DCF file. */ AjPStr *node = NULL; /* Node of alignment . */ ajint noden = 0; /*1: Class (SCOP), 2: Fold (SCOP) etc, see ACD file. */ AjPStr *mode = NULL; /* Mode of operation from acd*/ ajint moden = 0; /* Program mode, 1: MODE_STAMP, 2: MODE_TCOFFEE (not yet implemented). */ AjBool keepsinglets= ajFalse; /*Whether to retain sequences of singlet families and write them to an output file. */ AjPStr temp = NULL; /* A temporary string. */ AjPStr cmd = NULL; /* The command line to execute t-coffee. */ /* Initialise strings etc*/ last_node = ajStrNew(); exec = ajStrNew(); out = ajStrNew(); align = ajStrNew(); alignc = ajStrNew(); log = ajStrNew(); dom = ajStrNew(); set = ajStrNew(); scan = ajStrNew(); sort = ajStrNew(); name = ajStrNew(); temp = ajStrNew(); temp1 = ajStrNew(); cmd = ajStrNew(); pdbnames = ajStrNew(); /* Read data from acd. */ embInitPV("domainalign",argc,argv,"DOMALIGN",VERSION); dcfin = ajAcdGetInfile("dcfinfile"); pdb = ajAcdGetDirectory("pdbdir"); daf = ajAcdGetOutdir("dafoutdir"); super = ajAcdGetOutdir("superoutdir"); singlets = ajAcdGetOutdir("singletsoutdir"); node = ajAcdGetList("node"); mode = ajAcdGetList("mode"); keepsinglets = ajAcdGetToggle("keepsinglets"); logf = ajAcdGetOutfile("logfile"); /* Convert the selected node and mode to an integer. */ if(!(ajStrToInt(node[0], &noden))) ajFatal("Could not parse ACD node option"); if(!(ajStrToInt(mode[0], &moden))) ajFatal("Could not parse ACD node option"); /* Initialise random number generator for naming of temp. files. */ ajRandomSeed(); ajFilenameSetTempname(&name); /* Create names for temp. files. */ ajStrAssignS(&log, name); ajStrAppendC(&log, ".log"); ajStrAssignS(&dom, name); ajStrAppendC(&dom, ".dom"); ajStrAssignS(&set, name); ajStrAppendC(&set, ".set"); ajStrAssignS(&scan, name); ajStrAppendC(&scan, ".scan"); ajStrAssignS(&sort, name); ajStrAppendC(&sort, ".sort"); ajStrAssignS(&out, name); ajStrAppendC(&out, ".out"); /* Initialise last_node with something that is not in SCOP. */ ajStrAssignC(&last_node,"!!!!!"); /* Open STAMP domain set file. */ if(moden == MODE_STAMP) { if(!(setf=ajFileNewOutNameS(set))) ajFatal("Could not open domain set file\n"); } /* Get domain type. */ type = ajDomainDCFType(dcfin); /* Start of main application loop. */ while((domain=(ajDomainReadCNew(dcfin, "*", type)))) { /* A new family. */ if(((domain->Type == ajSCOP) && (((noden==1) && (last_nodeid != domain->Scop->Sunid_Class)) || ((noden==2) && (last_nodeid != domain->Scop->Sunid_Fold)) || ((noden==3) && (last_nodeid != domain->Scop->Sunid_Superfamily))|| ((noden==4) && (last_nodeid != domain->Scop->Sunid_Family)))) || ((domain->Type == ajCATH) && (((noden==5) && (last_nodeid != domain->Cath->Class_Id)) || ((noden==6) && (last_nodeid != domain->Cath->Arch_Id)) || ((noden==7) && (last_nodeid != domain->Cath->Topology_Id)) || ((noden==8) && (last_nodeid != domain->Cath->Superfamily_Id)) || ((noden==9) && (last_nodeid != domain->Cath->Family_Id))))) { /* If we have done the first family. */ if(famn) { /* Create the output file for the alignment - the name will be the same as the Sunid for the DOMAIN family. */ domainalign_writeid(prevdomain, noden, daf, super, &align, &alignc); if(moden == MODE_STAMP) { /* Close domain set file. */ ajFileClose(&setf); /* Call STAMP. */ /* Family with 2 or more entries. */ if(nset > 1) { domainalign_stamp(prevdomain, domain, daf, super, singlets, align, alignc, dom, name, set, scan, sort, log, out, keepsinglets, moden, noden, nset, logf); } else if(keepsinglets) /* Singlet family. */ domainalign_keepsinglets(prevdomain, noden, singlets, logf); /* Open STAMP domain set file. */ if(!(setf=ajFileNewOutNameS(set))) ajFatal("Could not open domain set file\n"); } else { /* Call TCOFEE. */ if(nset > 1) domainalign_tcoffee(prevdomain, out, align, alignc, pdbnames, noden, logf); else if(keepsinglets) /* Singlet family. */ domainalign_keepsinglets(prevdomain, noden, singlets, logf); } /* Set the number of members of the new family to zero. */ nset = 0; /* Clear TCOFFEE argument. */ ajStrSetClear(&pdbnames); } /* Open, write and close STAMP domain file. */ if(moden == MODE_STAMP) { if(!(domf=ajFileNewOutNameS(dom))) ajFatal("Could not open domain file\n"); ajStrAssignS(&temp, ajDomainGetId(domain)); ajStrFmtLower(&temp); ajFmtPrintF(domf, "%S %S { ALL }\n", temp, temp); ajFileClose(&domf); } /* Copy current family name to last_node. */ domainalign_writelast(domain, noden, &last_node, &last_nodeid); /* Copy current domain pointer to prevdomain. */ ajDomainDel(&prevdomain); prevdomain=NULL; ajDomainCopy(&prevdomain, domain); /* Increment family counter. */ famn++; } ajStrAssignS(&temp, ajDomainGetId(domain)); ajStrFmtLower(&temp); /* Write STAMP domain set file. */ if(moden == MODE_STAMP) ajFmtPrintF(setf, "%S %S { ALL }\n", temp, temp); /* Write TCOFFEE argument. */ else { ajStrAppendS(&pdbnames, ajDirGetPath(pdb)); ajStrAppendS(&pdbnames, temp); ajStrAppendC(&pdbnames, "."); ajStrAppendS(&pdbnames, ajDirGetExt(pdb)); ajStrAppendC(&pdbnames, " "); } ajDomainDel(&domain); /* Increment number of members in family. */ nset++; } /* End of main application loop. */ domain=prevdomain; ajFmtPrint("\nProcessing node %d\n", last_nodeid); /* Create the output file for the alignment - the name will be the same as the Sunid for the DOMAIN family. */ domainalign_writeid(prevdomain, noden, daf, super, &align, &alignc); /* Code to process last family. */ if(moden == MODE_STAMP) { /*Close domain set file. */ ajFileClose(&setf); /* ajFmtPrint("\n***** SECOND CALL\n");. */ if(nset > 1) { domainalign_stamp(prevdomain, domain, daf, super, singlets, align, alignc, dom, name, set, scan, sort, log, out, keepsinglets, moden, noden, nset, logf); } else if(keepsinglets) /* Singlet family. */ domainalign_keepsinglets(prevdomain, noden, singlets, logf); } else { /* Call TCOFEE. */ if(nset > 1) domainalign_tcoffee(prevdomain, out, align, alignc, pdbnames, noden, logf); else if(keepsinglets) /* Singlet family. */ domainalign_keepsinglets(prevdomain, noden, singlets, logf); } /* Remove all temporary files. */ ajSysFileUnlinkS(log); ajSysFileUnlinkS(dom); ajSysFileUnlinkS(set); ajSysFileUnlinkS(scan); ajSysFileUnlinkS(sort); ajSysFileUnlinkS(out); ajStrAssignS(&temp, name); ajStrAppendC(&temp, ".mat"); ajSysFileUnlinkS(temp); /* Tidy up*/ ajDomainDel(&domain); ajFileClose(&dcfin); ajStrDel(&last_node); ajStrDel(&exec); ajStrDel(&log); ajStrDel(&dom); ajStrDel(&set); ajStrDel(&scan); ajStrDel(&sort); ajStrDel(&name); ajStrDel(&out); ajStrDel(&align); ajStrDel(&alignc); ajStrDel(&pdbnames); ajDirDel(&pdb); ajDiroutDel(&daf); ajDiroutDel(&super); ajDiroutDel(&singlets); ajStrDel(&temp); ajStrDel(&temp1); ajStrDel(&node[0]); AJFREE(node); ajStrDel(&mode[0]); AJFREE(mode); ajFileClose(&logf); ajExit(); return 0; }
int main(int argc, char **argv) { AjPFile outf = NULL; AjPSeq sequence = NULL; AjPStr substr = NULL; AjPStr seqstr = NULL; AjPStr revstr = NULL; AjPStr p1; AjPStr p2; PPrimer eric = NULL; PPrimer fred = NULL; PPrimer f; PPrimer r; PPair pair; AjPList forlist = NULL; AjPList revlist = NULL; AjPList pairlist = NULL; AjBool targetrange; AjBool isDNA = ajTrue; AjBool dolist = ajFalse; ajint primerlen = 0; ajint minprimerlen = 0; ajint maxprimerlen = 0; ajint minprodlen = 0; ajint maxprodlen = 0; ajint prodlen = 0; ajint seqlen = 0; ajint stepping_value = 1; ajint targetstart = 0; ajint targetend = 0; ajint limit = 0; ajint limit2 = 0; ajint lastpos = 0; ajint startpos = 0; ajint endpos = 0; ajint begin; ajint end; ajint v1; ajint v2; ajint overlap; float minpmGCcont = 0.; float maxpmGCcont = 0.; float minprodGCcont = 0.; float maxprodGCcont = 0.; float prodTm; float prodGC; ajint i; ajint j; ajint neric=0; ajint nfred=0; ajint npair=0; float minprimerTm = 0.0; float maxprimerTm = 0.0; float saltconc = 0.0; float dnaconc = 0.0; embInit ("prima", argc, argv); substr = ajStrNew(); forlist = ajListNew(); revlist = ajListNew(); pairlist = ajListNew(); p1 = ajStrNew(); p2 = ajStrNew(); sequence = ajAcdGetSeq("sequence"); outf = ajAcdGetOutfile("outfile"); minprimerlen = ajAcdGetInt("minprimerlen"); maxprimerlen = ajAcdGetInt("maxprimerlen"); minpmGCcont = ajAcdGetFloat("minpmGCcont"); maxpmGCcont = ajAcdGetFloat("maxpmGCcont"); minprimerTm = ajAcdGetFloat("mintmprimer"); maxprimerTm = ajAcdGetFloat("maxtmprimer"); minprodlen = ajAcdGetInt("minplen"); maxprodlen = ajAcdGetInt("maxplen"); minprodGCcont = ajAcdGetFloat("minpgccont"); maxprodGCcont = ajAcdGetFloat("maxpgccont"); saltconc = ajAcdGetFloat("saltconc"); dnaconc = ajAcdGetFloat("dnaconc"); targetrange = ajAcdGetToggle("targetrange"); targetstart = ajAcdGetInt("targetstart"); targetend = ajAcdGetInt("targetend"); overlap = ajAcdGetInt("overlap"); dolist = ajAcdGetBoolean("list"); seqstr = ajSeqGetSeqCopyS(sequence); ajStrFmtUpper(&seqstr); begin = ajSeqGetBegin(sequence); end = ajSeqGetEnd(sequence); seqlen = end-begin+1; ajStrAssignSubC(&substr,ajStrGetPtr(seqstr),begin-1,end-1); revstr = ajStrNewC(ajStrGetPtr(substr)); ajSeqstrReverse(&revstr); AJCNEW0(entropy, seqlen); AJCNEW0(enthalpy, seqlen); AJCNEW0(energy, seqlen); /* Initialise Tm calculation arrays */ ajMeltTempSave(ajStrGetPtr(substr),0,seqlen,saltconc,dnaconc,1, &entropy, &enthalpy, &energy); ajFmtPrintF(outf, "\n\nINPUT SUMMARY\n"); ajFmtPrintF(outf, "*************\n\n"); if(targetrange) ajFmtPrintF (outf, "Prima of %s from positions %d to %d bps\n", ajSeqGetNameC(sequence),targetstart, targetend); else ajFmtPrintF(outf, "Prima of %s\n", ajSeqGetNameC(sequence)); ajFmtPrintF(outf, "PRIMER CONSTRAINTS:\n"); ajFmtPrintF (outf, "PRIMA DOES NOT ALLOW PRIMER SEQUENCE AMBIGUITY OR "); ajFmtPrintF(outf,"DUPLICATE PRIMER ENDPOINTS\n"); ajFmtPrintF(outf, "Primer size range is %d-%d\n",minprimerlen,maxprimerlen); ajFmtPrintF(outf, "Primer GC content range is %.2f-%.2f\n",minpmGCcont, maxpmGCcont); ajFmtPrintF(outf,"Primer melting Temp range is %.2f - %.2f C\n", minprimerTm, maxprimerTm); ajFmtPrintF (outf, "PRODUCT CONSTRAINTS:\n"); ajFmtPrintF(outf,"Product GC content range is %.2f-%.2f\n", minprodGCcont, maxprodGCcont); ajFmtPrintF(outf, "Salt concentration is %.2f (mM)\n", saltconc); ajFmtPrintF(outf, "DNA concentration is %.2f (nM)\n", dnaconc); if(targetrange) ajFmtPrintF(outf, "Targeted range to amplify is from %d to %d\n", targetstart,targetend); else { ajFmtPrintF(outf,"Considering all suitable Primer pairs with "); ajFmtPrintF(outf,"Product length ranges %d to %d\n\n\n", minprodlen, maxprodlen); } ajFmtPrintF(outf, "\n\nPRIMER/PRODUCT PAIR CALCULATIONS & OUTPUT\n"); ajFmtPrintF(outf, "*****************************************\n\n"); if(seqlen-minprimerlen < 0) ajFatal("Sequence too short"); if(targetrange) { ajStrAssignSubC(&p1,ajStrGetPtr(substr),targetstart-begin,targetend-begin); prodGC = ajMeltGC(substr,seqlen); prodTm = ajMeltTempProd(prodGC,saltconc,seqlen); if(prodGC<minprodGCcont || prodGC>maxprodGCcont) { ajFmtPrintF(outf, "Product GC content [%.2f] outside acceptable range\n", prodGC); embExitBad(); return 0; } prima_testtarget(substr, revstr, targetstart-begin, targetend-begin, minprimerlen, maxprimerlen, seqlen, minprimerTm, maxprimerTm, minpmGCcont, maxpmGCcont, minprodGCcont, maxprodGCcont, saltconc, dnaconc, pairlist, &npair); } if(!targetrange) { limit = seqlen-minprimerlen-minprodlen+1; lastpos = seqlen-minprodlen; limit2 = maxprodlen-minprodlen; /* Outer loop selects all possible product start points */ for(i=minprimerlen; i<limit; ++i) { startpos = i; ajDebug("Position in sequence %d\n",startpos); endpos = i+minprodlen-1; /* Inner loop selects all possible product lengths */ for(j=0; j<limit2; ++j, ++endpos) { if(endpos>lastpos) break; v1 = endpos-startpos+1; ajStrAssignSubC(&p1,ajStrGetPtr(substr),startpos,endpos); prodGC = ajMeltGC(p1,v1); prodTm = ajMeltTempProd(prodGC,saltconc,v1); if(prodGC<minprodGCcont || prodGC>maxprodGCcont) continue; /* Only accept primers with acceptable Tm and GC */ neric = 0; nfred = 0; prima_testproduct(substr, startpos, endpos, primerlen, minprimerlen, maxprimerlen,minpmGCcont, maxpmGCcont, minprimerTm, maxprimerTm, minprodlen, maxprodlen, prodTm, prodGC, seqlen, &eric,&fred,forlist,revlist,&neric,&nfred, stepping_value, saltconc,dnaconc, isDNA, begin); if(!neric) continue; /* Now reject those primers with self-complementarity */ prima_reject_self(forlist,revlist,&neric,&nfred); if(!neric) continue; /* Reject any primers that could bind elsewhere in the sequence */ prima_test_multi(forlist,revlist,&neric,&nfred,substr,revstr, seqlen); /* Now select the least complementary pair (if any) */ prima_best_primer(forlist, revlist, &neric, &nfred); if(!neric) continue; AJNEW(pair); ajListPop(forlist,(void **)&f); ajListPop(revlist,(void **)&r); pair->f = f; pair->r = r; ++npair; ajListPush(pairlist,(void *)pair); } } } if(!targetrange) { /* Get rid of primer pairs nearby the top scoring ones */ prima_TwoSortscorepos(&pairlist); prima_prune_nearby(pairlist, &npair, maxprimerlen-1); ajListSort(pairlist,prima_PosCompare); prima_check_overlap(pairlist,&npair,overlap); } if(npair) { if(!targetrange) ajFmtPrintF(outf,"%d pairs found\n\n",npair); else ajFmtPrintF(outf, "Closest primer pair to specified product is:\n\n"); if((maxprimerlen<26 && seqlen<999999 && !dolist)) ajFmtPrintF(outf,"\n\t\tForward\t\t\t\t\tReverse\n\n"); } for(i=0;i<npair;++i) { if(!targetrange) ajFmtPrintF(outf,"[%d]\n",i+1); ajListPop(pairlist,(void **)&pair); prodlen = pair->r->start - (pair->f->start + pair->f->primerlen); if((maxprimerlen<26 && seqlen<999999 && !dolist)) { v1 = pair->f->start; v2 = v1 + pair->f->primerlen -1; ajStrAssignSubS(&p1,substr,v1,v2); ajFmtPrintF(outf,"%6d %-25.25s %d\t", v1+begin, ajStrGetPtr(p1), v2+begin); v1 = pair->r->start; v2 = v1 + pair->r->primerlen -1; ajStrAssignSubS(&p2,substr,v1,v2); ajSeqstrReverse(&p2); ajFmtPrintF(outf, "%6d %-25.25s %d\n", v1+begin, ajStrGetPtr(p2), v2+begin); ajFmtPrintF(outf," Tm %.2f C (GC %.2f%%)\t\t ", pair->f->primerTm,pair->f->primGCcont*100.); ajFmtPrintF(outf,"Tm %.2f C (GC %.2f%%)\n", pair->r->primerTm,pair->r->primGCcont*100.); ajFmtPrintF(outf," Length: %-32dLength: %d\n", pair->f->primerlen,pair->r->primerlen); ajFmtPrintF(outf," Tma: %.2f C\t\t\t", ajAnneal(pair->f->primerTm,pair->f->prodTm)); ajFmtPrintF(outf," Tma: %.2f C\n\n\n", ajAnneal(pair->r->primerTm,pair->f->prodTm)); ajFmtPrintF(outf," Product GC: %.2f%%\n", pair->f->prodGC * 100.0); ajFmtPrintF(outf," Product Tm: %.2f C\n", pair->f->prodTm); ajFmtPrintF(outf," Length: %d\n\n\n",prodlen); } else { ajFmtPrintF(outf," Product from %d to %d\n",pair->f->start+ pair->f->primerlen+begin,pair->r->start-1+begin); ajFmtPrintF(outf," Tm: %.2f C GC: %.2f%%\n", pair->f->prodTm,pair->f->prodGC*(float)100.); ajFmtPrintF(outf," Length: %d\n\n\n",prodlen); v1 = pair->f->start; v2 = v1 + pair->f->primerlen -1; ajStrAssignSubS(&p1,substr,v1,v2); ajFmtPrintF(outf," Forward: 5' %s 3'\n",ajStrGetPtr(p1)); ajFmtPrintF(outf," Start: %d\n",v1+begin); ajFmtPrintF(outf," End: %d\n",v2+begin); ajFmtPrintF(outf," Tm: %.2f C\n", pair->f->primerTm); ajFmtPrintF(outf," GC: %.2f%%\n", pair->f->primGCcont*(float)100.); ajFmtPrintF(outf," Len: %d\n", pair->f->primerlen); ajFmtPrintF(outf," Tma: %.2f C\n\n\n", ajAnneal(pair->f->primerTm,pair->f->prodTm)); v1 = pair->r->start; v2 = v1 + pair->r->primerlen -1; ajStrAssignSubS(&p2,substr,v1,v2); ajSeqstrReverse(&p2); ajStrAssignSubS(&p1,substr,v1,v2); ajFmtPrintF(outf," Reverse: 5' %s 3'\n",ajStrGetPtr(p1)); ajFmtPrintF(outf," Start: %d\n",v1+begin); ajFmtPrintF(outf," End: %d\n",v2+begin); ajFmtPrintF(outf," Tm: %.2f C\n", pair->r->primerTm); ajFmtPrintF(outf," GC: %.2f%%\n", pair->r->primGCcont*(float)100.); ajFmtPrintF(outf," Len: %d\n", pair->r->primerlen); ajFmtPrintF(outf," Tma: %.2f C\n\n\n", ajAnneal(pair->r->primerTm,pair->f->prodTm)); } prima_PrimerDel(&pair->f); prima_PrimerDel(&pair->r); AJFREE(pair); } ajStrDel(&seqstr); ajStrDel(&revstr); ajStrDel(&substr); ajStrDel(&p1); ajStrDel(&p2); ajListFree(&forlist); ajListFree(&revlist); ajListFree(&pairlist); ajFileClose(&outf); ajSeqDel(&sequence); AJFREE(entropy); AJFREE(enthalpy); AJFREE(energy); embExit(); return 0; }
int main(int argc, char **argv) { AjPSeq seq = NULL; AjPStr strand = NULL; AjPStr substr = NULL; AjPStr squares = NULL; AjPStr diamonds = NULL; AjPStr octags = NULL; AjBool amphipathic; AjPStr txt = NULL; AjPGraph graph = NULL; ajint begin; ajint end; ajint lc; ajint i; ajint j; ajint r; ajint count; ajint pstart; ajint pstop; float xmin = 0.0; float xmax = 150.0; float ymin = 0.0; float ymax = 112.5; float xstart; float ystart; float ch = (float)1.8; float xinc; float yinc; AjPStr fstr = NULL; float x; float y; embInit("pepnet", argc, argv); seq = ajAcdGetSeq("sequence"); graph = ajAcdGetGraph("graph"); octags = ajAcdGetString("octags"); squares = ajAcdGetString("squares"); diamonds = ajAcdGetString("diamonds"); amphipathic = ajAcdGetToggle("amphipathic"); ajStrFmtUpper(&octags); ajStrFmtUpper(&squares); ajStrFmtUpper(&diamonds); if(amphipathic) { ajStrAssignC(&squares,"ACFGILMVWY"); ajStrAssignC(&diamonds,""); ajStrAssignC(&octags,""); } substr = ajStrNew(); txt = ajStrNew(); fstr = ajStrNew(); begin = ajSeqGetBegin(seq); end = ajSeqGetEnd(seq); strand = ajSeqGetSeqCopyS(seq); ajStrFmtUpper(&strand); ajStrAssignSubC(&substr,ajStrGetPtr(strand),begin-1,end-1); ajGraphAppendTitleS(graph, ajSeqGetUsaS(seq)); ajGraphOpenWin(graph, xmin,xmax,ymin,ymax); for(count=begin-1,r=0;count<end;count+=231) { if (count > begin) ajGraphNewpage(graph, ajFalse); pstart=count; pstop = AJMIN(end-1, count+230); ajGraphicsSetCharscale(0.75); xstart = 145.0; ystart = 80.0; yinc = ch * (float)2.5; xinc = yinc / (float)2.5; x = xstart; for(i=pstart;i<=pstop;i+=7) { lc = i; if(x < 10.0*xinc) { x = xstart; ystart -= (float)7.5*yinc; } y=ystart; ajFmtPrintS(&txt,"%d",i+1); ajGraphicsSetFgcolour(RED); ajGraphicsDrawposTextJustify(x-xinc,y-yinc-1,ajStrGetPtr(txt),0.5); for(j=0;j<4;++j) { x -= xinc; y += yinc; if(lc <= pstop) pepnet_plotresidue(*(ajStrGetPtr(substr)+r),x,y, ajStrGetPtr(squares),ajStrGetPtr(octags), ajStrGetPtr(diamonds)); ++r; ++lc; } y=ystart+yinc/(float)2.0; for(j=4;j<7;++j) { x -= xinc; y += yinc; if(lc <= pstop) pepnet_plotresidue(*(ajStrGetPtr(substr)+r),x,y, ajStrGetPtr(squares),ajStrGetPtr(octags), ajStrGetPtr(diamonds)); ++r; ++lc; } } } ajGraphicsClose(); ajGraphxyDel(&graph); ajStrDel(&strand); ajStrDel(&fstr); ajSeqDel(&seq); ajStrDel(&substr); ajStrDel(&squares); ajStrDel(&diamonds); ajStrDel(&octags); ajStrDel(&txt); embExit(); return 0; }
int main(int argc, char **argv, char **env) { AjPList newlist = NULL; AjPList glist; AjPList alpha; AjPList appglist; AjPList applist; AjPList appgroups = NULL; AjPFile outfile = NULL; AjPStr search = NULL; AjBool html; AjBool groups; AjBool emboss; AjBool embassy; AjBool explode; AjBool colon; AjPStr showembassy = NULL; AjPStr package = NULL; embInit("seealso", argc, argv); search = ajAcdGetString("search"); outfile = ajAcdGetOutfile("outfile"); html = ajAcdGetToggle("html"); groups = ajAcdGetBoolean("groups"); emboss = ajAcdGetBoolean("emboss"); embassy = ajAcdGetBoolean("embassy"); showembassy = ajAcdGetString("showembassy"); explode = ajAcdGetBoolean("explode"); colon = ajAcdGetBoolean("colon"); glist = ajListNew(); alpha = ajListNew(); appglist = ajListNew(); applist = ajListNew(); /* is a search string specified - should be tested in seealso.acd */ if(!ajStrGetLen(search)) ajFatal("No application specified."); /* ** get the groups and program information - don't want to ignore ** applications that don't work well under GUIs */ /* everything */ embGrpGetProgGroups(appglist, applist, env, ajTrue, ajTrue, NULL, explode, colon, ajFalse); /* what the user asked for */ embGrpGetProgGroups(glist, alpha, env, emboss, embassy, showembassy, explode, colon, ajFalse); newlist = ajListNew(); embGrpKeySearchSeeAlso(newlist, &appgroups, &package, applist, glist, search); if(appgroups == NULL) { ajErr("No applications match."); ajExitBad(); } if(groups) embGrpOutputGroupsList(outfile, appgroups, ajFalse, html, ajFalse, package); else embGrpOutputGroupsList(outfile, newlist, ajTrue, html, ajFalse, package); embGrpGroupsListDel(&newlist); embGrpGroupsListDel(&glist); embGrpGroupsListDel(&alpha); embGrpGroupsListDel(&appglist); embGrpGroupsListDel(&applist); /* embGrpGroupsListDel(&appgroups); */ /* appgroup points to another list*/ ajFileClose(&outfile); ajStrDel(&search); ajStrDel(&showembassy); ajStrDel(&package); embExit(); return 0; }
int main(int argc, char **argv, char **env) { AjPList newlist = NULL; AjPList glist; /* list of groups pointing to lists of programs */ AjPList alpha; /* alphabetical list of all programs */ AjPFile outfile = NULL; AjPStr search = NULL; AjBool showkey; AjBool html; AjBool groups; AjBool alphabetic; AjBool emboss; AjBool embassy; AjBool explode; AjBool colon; AjBool gui; AjPStr showembassy; AjBool sensitive = ajFalse; AjBool subclasses = ajTrue; AjBool obsolete = ajFalse; embInit("wossoutput", argc, argv); search = ajAcdGetString("identifier"); outfile = ajAcdGetOutfile("outfile"); html = ajAcdGetToggle("html"); showkey = ajAcdGetBoolean("showkeywords"); groups = ajAcdGetBoolean("groups"); alphabetic = ajAcdGetBoolean("alphabetic"); emboss = ajAcdGetBoolean("emboss"); embassy = ajAcdGetBoolean("embassy"); showembassy = ajAcdGetString("showembassy"); explode = ajAcdGetBoolean("explode"); colon = ajAcdGetBoolean("colon"); gui = ajAcdGetBoolean("gui"); sensitive = ajAcdGetBoolean("sensitive"); subclasses = ajAcdGetBoolean("subclasses"); obsolete = ajAcdGetBoolean("obsolete"); glist = ajListNew(); alpha = ajListNew(); /* get the groups and program information */ embGrpGetProgGroups(glist, alpha, env, emboss, embassy, showembassy, explode, colon, gui); /* is a search string specified */ newlist = ajListNew(); if(alphabetic) embGrpSearchProgsEdam(newlist, alpha, search, "output", sensitive, subclasses, obsolete); else embGrpSearchProgsEdam(newlist, glist, search, "output", sensitive, subclasses, obsolete); embGrpOutputGroupsList(outfile, newlist, !groups, html, showkey, showembassy); ajFileClose(&outfile); embGrpGroupsListDel(&newlist); embGrpGroupsListDel(&glist); embGrpGroupsListDel(&alpha); ajFileClose(&outfile); ajStrDel(&search); ajStrDel(&showembassy); embExit(); return 0; }
int main(int argc, char **argv) { AjPSeq seq = NULL; AjPStr strand = NULL; AjPStr substr = NULL; AjPStr squares = NULL; AjPStr diamonds = NULL; AjPStr octags = NULL; AjBool wheel; AjBool amphipathic; AjPGraph graph=0; AjBool first; AjBool startloop; ajint begin; ajint end; ajint len; ajint steps; ajint turns; ajint lc; ajint i; ajint j; ajint k; float xmin = (float) -1.0; float xmax = (float) 1.0; float ymin = (float) -0.75; float ymax = (float) 0.75; float minresplot = (float) 36.0; float resgap = (float) 0.0533; float wheelgap = (float) 0.00; float nresgap = (float) 0.08; float angle; float oldangle; float ang; float radius; float wradius; float xx1; float xx2; float yy1; float yy2; embInit("pepwheel", argc, argv); seq = ajAcdGetSeq("sequence"); steps = ajAcdGetInt("steps"); turns = ajAcdGetInt("turns"); graph = ajAcdGetGraph("graph"); octags = ajAcdGetString("octags"); squares = ajAcdGetString("squares"); diamonds = ajAcdGetString("diamonds"); wheel = ajAcdGetBoolean("wheel"); amphipathic = ajAcdGetToggle("amphipathic"); ajStrFmtUpper(&octags); ajStrFmtUpper(&squares); ajStrFmtUpper(&diamonds); if(amphipathic) { ajStrAssignC(&squares,"ACFGILMVWY"); ajStrAssignC(&diamonds,""); ajStrAssignC(&octags,""); } substr = ajStrNew(); begin = ajSeqGetBegin(seq); end = ajSeqGetEnd(seq); ajDebug("begin: %d end: %d\n", begin, end); strand = ajSeqGetSeqCopyS(seq); ajStrFmtUpper(&strand); ajStrAssignSubC(&substr,ajStrGetPtr(strand),begin-1,end-1); len = ajStrGetLen(substr); ajGraphAppendTitleS(graph, ajSeqGetUsaS(seq)); ajGraphOpenWin(graph,xmin,xmax,ymin,ymax); ajGraphicsSetFgcolour(AJB_BLACK); ang = ((float)360.0 / (float)steps) * (float)turns; first = ajTrue; angle = (float) 90.0 + ang; if(end-begin > (ajint)minresplot) wradius = (float) 0.2; else wradius = (float) 0.40; for(i=0,lc=0,radius=wradius+wheelgap;i<len;i+=steps) { wradius += wheelgap; startloop = ajTrue; k = AJMIN(i+steps, end); for(j=i;j<k;++j) { oldangle = angle; angle = oldangle-ang; if(first) startloop = first = ajFalse; else { if(startloop) { if(wheel) { ajCvtPolToRec(wradius-wheelgap,oldangle,&xx1,&yy1); ajCvtPolToRec(wradius,angle,&xx2,&yy2); ajGraphicsDrawposLine(xx1,yy1,xx2,yy2); } startloop=ajFalse; } else if(wheel) { ajCvtPolToRec(wradius,oldangle,&xx1,&yy1); ajCvtPolToRec(wradius,angle,&xx2,&yy2); ajGraphicsDrawposLine(xx1,yy1,xx2,yy2); } } pepwheel_plotresidue(*(ajStrGetPtr(substr)+lc),radius+resgap,angle, ajStrGetPtr(squares),ajStrGetPtr(octags), ajStrGetPtr(diamonds), xmin,xmax,ymin,ymax); ++lc; if(lc==len) break; } radius += nresgap; } ajGraphicsClose(); ajGraphxyDel(&graph); ajStrDel(&strand); ajStrDel(&substr); ajSeqDel(&seq); ajStrDel(&squares); ajStrDel(&diamonds); ajStrDel(&octags); embExit(); return 0; }
int main(int argc, char **argv) { AjPSeqset seqset; AjPSeqall seqall; AjPSeq queryseq; const AjPSeq targetseq; ajint wordlen; AjPTable wordsTable = NULL; AjPList* matchlist = NULL; AjPFile logfile; AjPFeattable* seqsetftables = NULL; AjPFeattable seqallseqftable = NULL; AjPFeattabOut ftoutforseqsetseq = NULL; AjPFeattabOut ftoutforseqallseq = NULL; AjPAlign align = NULL; AjIList iter = NULL; ajint targetstart; ajint querystart; ajint len; ajuint i, j; ajulong nAllMatches = 0; ajulong sumAllScore = 0; AjBool dumpAlign = ajTrue; AjBool dumpFeature = ajTrue; AjBool checkmode = ajFalse; EmbPWordRK* wordsw = NULL; ajuint npatterns = 0; ajuint seqsetsize; ajuint nmatches; ajuint* nmatchesseqset; ajuint* lastlocation; /* Cursors for Rabin-Karp search. */ /* Shows until what point the query sequence was * scanned for a pattern sequences in the seqset. */ char* paddedheader = NULL; const char* header; AjPStr padding; header = "Pattern %S #pat-sequences #all-matches avg-match-length\n"; padding = ajStrNew(); embInit("wordmatch", argc, argv); wordlen = ajAcdGetInt("wordsize"); seqset = ajAcdGetSeqset("asequence"); seqall = ajAcdGetSeqall("bsequence"); logfile = ajAcdGetOutfile("logfile"); dumpAlign = ajAcdGetToggle("dumpalign"); dumpFeature = ajAcdGetToggle("dumpfeat"); if(dumpAlign) { align = ajAcdGetAlign("outfile"); ajAlignSetExternal(align, ajTrue); } seqsetsize = ajSeqsetGetSize(seqset); ajSeqsetTrim(seqset); AJCNEW0(matchlist, seqsetsize); AJCNEW0(seqsetftables, seqsetsize); AJCNEW0(nmatchesseqset, seqsetsize); if (dumpFeature) { ftoutforseqsetseq = ajAcdGetFeatout("aoutfeat"); ftoutforseqallseq = ajAcdGetFeatout("boutfeat"); } checkmode = !dumpFeature && !dumpAlign; embWordLength(wordlen); ajFmtPrintF(logfile, "Small sequence/file for constructing" " target patterns: %S\n", ajSeqsetGetUsa(seqset)); ajFmtPrintF(logfile, "Large sequence/file to be scanned" " for patterns: %S\n", ajSeqallGetUsa(seqall)); ajFmtPrintF(logfile, "Number of sequences in the patterns file: %u\n", seqsetsize); ajFmtPrintF(logfile, "Pattern/word length: %u\n", wordlen); for(i=0;i<seqsetsize;i++) { targetseq = ajSeqsetGetseqSeq(seqset, i); embWordGetTable(&wordsTable, targetseq); } AJCNEW0(lastlocation, seqsetsize); if(ajTableGetLength(wordsTable)>0) { npatterns = embWordRabinKarpInit(wordsTable, &wordsw, wordlen, seqset); ajFmtPrintF(logfile, "Number of patterns/words found: %u\n", npatterns); while(ajSeqallNext(seqall,&queryseq)) { for(i=0;i<seqsetsize;i++) { lastlocation[i]=0; if (!checkmode) matchlist[i] = ajListstrNew(); } nmatches = embWordRabinKarpSearch( ajSeqGetSeqS(queryseq), seqset, (EmbPWordRK const *)wordsw, wordlen, npatterns, matchlist, lastlocation, checkmode); nAllMatches += nmatches; if (checkmode) continue; for(i=0;i<seqsetsize;i++) { if(ajListGetLength(matchlist[i])>0) { iter = ajListIterNewread(matchlist[i]) ; while(embWordMatchIter(iter, &targetstart, &querystart, &len, &targetseq)) { if(dumpAlign) { ajAlignDefineSS(align, targetseq, queryseq); ajAlignSetScoreI(align, len); /* ungapped alignment means same length * for both sequences */ ajAlignSetSubRange(align, targetstart, 1, len, ajSeqIsReversed(targetseq), ajSeqGetLen(targetseq), querystart, 1, len, ajSeqIsReversed(queryseq), ajSeqGetLen(queryseq)); } } if(dumpAlign) { ajAlignWrite(align); ajAlignReset(align); } if(ajListGetLength(matchlist[i])>0 && dumpFeature) { embWordMatchListConvToFeat(matchlist[i], &seqsetftables[i], &seqallseqftable, targetseq, queryseq); ajFeattableWrite(ftoutforseqallseq, seqallseqftable); ajFeattableDel(&seqallseqftable); } ajListIterDel(&iter); } embWordMatchListDelete(&matchlist[i]); } } /* search completed, now report statistics */ for(i=0;i<npatterns;i++) { sumAllScore += wordsw[i]->lenMatches; for(j=0;j<wordsw[i]->nseqs;j++) nmatchesseqset[wordsw[i]->seqindxs[j]] += wordsw[i]->nSeqMatches[j]; } ajFmtPrintF(logfile, "Number of sequences in the file scanned " "for patterns: %u\n", ajSeqallGetCount(seqall)); ajFmtPrintF(logfile, "Number of all matches: %Lu" " (wordmatch finds exact matches only)\n", nAllMatches); if(nAllMatches>0) { ajFmtPrintF(logfile, "Sum of match lengths: %Lu\n", sumAllScore); ajFmtPrintF(logfile, "Average match length: %.2f\n", sumAllScore*1.0/nAllMatches); ajFmtPrintF(logfile, "\nDistribution of the matches among pattern" " sequences:\n"); ajFmtPrintF(logfile, "-----------------------------------------" "-----------\n"); for(i=0;i<ajSeqsetGetSize(seqset);i++) { if (nmatchesseqset[i]>0) ajFmtPrintF(logfile, "%-42s: %8u\n", ajSeqGetNameC(ajSeqsetGetseqSeq(seqset, i)), nmatchesseqset[i]); ajFeattableWrite(ftoutforseqsetseq, seqsetftables[i]); ajFeattableDel(&seqsetftables[i]); } ajFmtPrintF(logfile, "\nPattern statistics:\n"); ajFmtPrintF(logfile, "-------------------\n"); if(wordlen>7) ajStrAppendCountK(&padding, ' ', wordlen-7); paddedheader = ajFmtString(header,padding); ajFmtPrintF(logfile, paddedheader); for(i=0;i<npatterns;i++) if (wordsw[i]->nMatches>0) ajFmtPrintF(logfile, "%-7s: %12u %12u %17.2f\n", wordsw[i]->word->fword, wordsw[i]->nseqs, wordsw[i]->nMatches, wordsw[i]->lenMatches*1.0/wordsw[i]->nMatches); } } for(i=0;i<npatterns;i++) { for(j=0;j<wordsw[i]->nseqs;j++) AJFREE(wordsw[i]->locs[j]); AJFREE(wordsw[i]->locs); AJFREE(wordsw[i]->seqindxs); AJFREE(wordsw[i]->nnseqlocs); AJFREE(wordsw[i]->nSeqMatches); AJFREE(wordsw[i]); } embWordFreeTable(&wordsTable); AJFREE(wordsw); AJFREE(matchlist); AJFREE(lastlocation); AJFREE(nmatchesseqset); AJFREE(seqsetftables); if(dumpAlign) { ajAlignClose(align); ajAlignDel(&align); } if(dumpFeature) { ajFeattabOutDel(&ftoutforseqsetseq); ajFeattabOutDel(&ftoutforseqallseq); } ajFileClose(&logfile); ajSeqallDel(&seqall); ajSeqsetDel(&seqset); ajSeqDel(&queryseq); ajStrDel(&padding); AJFREE(paddedheader); 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; const AjPSeq seq1; const AjPSeq seq2; ajint wordlen; AjPTable seq1MatchTable = NULL; AjPList matchlist ; AjPGraph graph = 0; ajuint i; ajuint j; float total=0; ajuint acceptableticks[]= { 1,10,50,100,200,500,1000,1500,10000,50000, 100000,500000,1000000,5000000 }; ajint numbofticks = 10; ajint gap,tickgap; AjBool boxit = AJTRUE; AjBool dumpfeat = AJFALSE; float xmargin; float ymargin; float k; char ptr[10]; float ticklen; float onefifth; AjPFeattable *tabptr = NULL; AjPFeattabOut seq1out = NULL; AjPStr sajb = NULL; float flen1; float flen2; ajuint tui; embInit("polydot", argc, argv); wordlen = ajAcdGetInt("wordsize"); seqset = ajAcdGetSeqset("sequences"); graph = ajAcdGetGraph("graph"); gap = ajAcdGetInt("gap"); boxit = ajAcdGetBoolean("boxit"); seq1out = ajAcdGetFeatout("outfeat"); dumpfeat = ajAcdGetToggle("dumpfeat"); sajb = ajStrNew(); embWordLength(wordlen); AJCNEW(lines,ajSeqsetGetSize(seqset)); AJCNEW(pts,ajSeqsetGetSize(seqset)); AJCNEW(tabptr,ajSeqsetGetSize(seqset)); for(i=0;i<ajSeqsetGetSize(seqset);i++) { seq1 = ajSeqsetGetseqSeq(seqset, i); total += ajSeqGetLen(seq1); } total +=(float)(gap*(ajSeqsetGetSize(seqset)-1)); xmargin = total*(float)0.15; ymargin = total*(float)0.15; ticklen = xmargin*(float)0.1; onefifth = xmargin*(float)0.2; i = 0; while(acceptableticks[i]*numbofticks < ajSeqsetGetLen(seqset)) i++; if(i<=13) tickgap = acceptableticks[i]; else tickgap = acceptableticks[13]; ajGraphAppendTitleS(graph, ajSeqsetGetUsa(seqset)); ajGraphOpenWin(graph, (float)0.0-xmargin,(total+xmargin)*(float)1.35, (float)0.0-ymargin, total+ymargin); ajGraphicsSetCharscale((float)0.3); for(i=0;i<ajSeqsetGetSize(seqset);i++) { which = i; seq1 = ajSeqsetGetseqSeq(seqset, i); tui = ajSeqGetLen(seq1); flen1 = (float) tui; if(embWordGetTable(&seq1MatchTable, seq1)){ /* get table of words */ for(j=0;j<ajSeqsetGetSize(seqset);j++) { seq2 = ajSeqsetGetseqSeq(seqset, j); tui = ajSeqGetLen(seq2); flen2 = (float) tui; if(boxit) ajGraphicsDrawposRect(xstart,ystart, xstart+flen1, ystart+flen2); matchlist = embWordBuildMatchTable(seq1MatchTable, seq2, ajTrue); if(matchlist) polydot_plotMatches(matchlist); if(i<j && dumpfeat) embWordMatchListConvToFeat(matchlist,&tabptr[i], &tabptr[j],seq1, seq2); if(matchlist) /* free the match structures */ embWordMatchListDelete(&matchlist); if(j==0) { for(k=0.0;k<ajSeqGetLen(seq1);k+=tickgap) { ajGraphicsDrawposLine(xstart+k,ystart,xstart+k, ystart-ticklen); sprintf(ptr,"%d",(ajint)k); ajGraphicsDrawposTextAtmid(xstart+k, ystart-(onefifth), ptr); } ajGraphicsDrawposTextAtmid( xstart+(flen1/(float)2.0), ystart-(3*onefifth), ajStrGetPtr(ajSeqsetGetseqNameS(seqset, i))); } if(i==0) { for(k=0.0;k<ajSeqGetLen(seq2);k+=tickgap) { ajGraphicsDrawposLine(xstart,ystart+k,xstart-ticklen, ystart+k); sprintf(ptr,"%d",(ajint)k); ajGraphicsDrawposTextAtend(xstart-(onefifth), ystart+k, ptr); } ajGraphicsDrawposTextAtlineJustify( xstart-(3*onefifth), ystart+(flen2/(float)2.0), xstart-(3*onefifth),ystart+flen2, ajStrGetPtr(ajSeqsetGetseqNameS(seqset, j)),0.5); } ystart += flen2+(float)gap; } } embWordFreeTable(&seq1MatchTable); seq1MatchTable = NULL; xstart += flen1+(float)gap; ystart = 0.0; } ajGraphicsDrawposTextAtstart(total+onefifth,total-(onefifth), "No. Length Lines Points Sequence"); for(i=0;i<ajSeqsetGetSize(seqset);i++) { seq1 = ajSeqsetGetseqSeq(seqset, i); ajFmtPrintS(&sajb,"%3u %6d %5d %6d %s",i+1, ajSeqGetLen(seq1),lines[i], pts[i],ajSeqGetNameC(seq1)); ajGraphicsDrawposTextAtstart(total+onefifth,total-(onefifth*(i+2)), ajStrGetPtr(sajb)); } if(dumpfeat && seq1out) { for(i=0;i<ajSeqsetGetSize(seqset);i++) { ajFeattableWrite(seq1out, tabptr[i]); ajFeattableDel(&tabptr[i]); } } ajGraphicsClose(); ajGraphxyDel(&graph); ajStrDel(&sajb); AJFREE(lines); AJFREE(pts); AJFREE(tabptr); ajSeqsetDel(&seqset); ajFeattabOutDel(&seq1out);; embExit(); return 0; }
int main(int argc, char **argv) { AjPList list = NULL; AjPSeq seq; AjPSeq seq2; AjPStr aa0str = 0; AjPStr aa1str = 0; const char *s1; const char *s2; char *strret = NULL; ajuint i; ajuint j; ajuint k; ajint l; ajint abovethresh; ajint total; ajint starti = 0; ajint startj = 0; ajint windowsize; float thresh; AjPGraph graph = NULL; AjPGraph xygraph = NULL; float flen1; float flen2; ajuint len1; ajuint len2; AjPTime ajtime = NULL; time_t tim; AjBool boxit=AJTRUE; /* Different ticks as they need to be different for x and y due to length of string being important on x */ ajuint acceptableticksx[]= { 1,10,50,100,500,1000,1500,10000, 500000,1000000,5000000 }; ajuint acceptableticks[]= { 1,10,50,100,200,500,1000,2000,5000,10000,15000, 500000,1000000,5000000 }; ajint numbofticks = 10; float xmargin; float ymargin; float ticklen; float tickgap; float onefifth; float k2; float max; char ptr[10]; AjPMatrix matrix = NULL; ajint** sub; AjPSeqCvt cvt; AjPStr subt = NULL; ajint b1; ajint b2; ajint e1; ajint e2; AjPStr se1; AjPStr se2; ajint ithresh; AjBool stretch; PPoint ppt = NULL; float xa[1]; float ya[1]; AjPGraphdata gdata=NULL; AjPStr tit = NULL; AjIList iter = NULL; float x1 = 0.; float x2 = 0.; float y1 = 0.; float y2 = 0.; ajuint tui; se1 = ajStrNew(); se2 = ajStrNew(); embInit("dotmatcher", argc, argv); seq = ajAcdGetSeq("asequence"); seq2 = ajAcdGetSeq("bsequence"); stretch = ajAcdGetToggle("stretch"); graph = ajAcdGetGraph("graph"); xygraph = ajAcdGetGraphxy("xygraph"); windowsize = ajAcdGetInt("windowsize"); ithresh = ajAcdGetInt("threshold"); matrix = ajAcdGetMatrix("matrixfile"); sub = ajMatrixGetMatrix(matrix); cvt = ajMatrixGetCvt(matrix); thresh = (float)ithresh; ajtime = ajTimeNew(); tim = time(0); ajTimeSetLocal(ajtime, tim); b1 = ajSeqGetBegin(seq); b2 = ajSeqGetBegin(seq2); e1 = ajSeqGetEnd(seq); e2 = ajSeqGetEnd(seq2); len1 = ajSeqGetLen(seq); len2 = ajSeqGetLen(seq2); tui = ajSeqGetLen(seq); flen1 = (float) tui; tui = ajSeqGetLen(seq2); flen2 = (float) tui; ajStrAssignSubC(&se1,ajSeqGetSeqC(seq),b1-1,e1-1); ajStrAssignSubC(&se2,ajSeqGetSeqC(seq2),b2-1,e2-1); ajSeqAssignSeqS(seq,se1); ajSeqAssignSeqS(seq2,se2); s1 = ajStrGetPtr(ajSeqGetSeqS(seq)); s2 = ajStrGetPtr(ajSeqGetSeqS(seq2)); aa0str = ajStrNewRes(1+len1); /* length plus trailing blank */ aa1str = ajStrNewRes(1+len2); list = ajListNew(); for(i=0;i<len1;i++) ajStrAppendK(&aa0str,(char)ajSeqcvtGetCodeK(cvt, *s1++)); for(i=0;i<len2;i++) ajStrAppendK(&aa1str,(char)ajSeqcvtGetCodeK(cvt, *s2++)); max = (float)len1; if(len2 > max) max = (float) len2; xmargin = ymargin = max *(float)0.15; ticklen = xmargin*(float)0.1; onefifth = xmargin*(float)0.2; subt = ajStrNewC((strret= ajFmtString("(windowsize = %d, threshold = %3.2f %D)", windowsize,thresh,ajtime))); if(!stretch) { if( ajStrGetLen(ajGraphGetSubtitleS(graph)) <=1) ajGraphSetSubtitleS(graph,subt); ajGraphOpenWin(graph, (float)0.0-ymargin,(max*(float)1.35)+ymargin, (float)0.0-xmargin,(float)max+xmargin); ajGraphicsDrawposTextAtmid(flen1*(float)0.5, (float)0.0-(xmargin/(float)2.0), ajGraphGetXlabelC(graph)); ajGraphicsDrawposTextAtlineJustify((float)0.0-(xmargin*(float)0.75), flen2*(float)0.5, (float)0.0-(xmargin*(float)0.75),flen1, ajGraphGetYlabelC(graph),0.5); ajGraphicsSetCharscale(0.5); } s1= ajStrGetPtr(aa0str); s2 = ajStrGetPtr(aa1str); for(j=0; (ajint)j < (ajint)len2-windowsize;j++) { i =0; total = 0; abovethresh =0; k = j; for(l=0;l<windowsize;l++) total = total + sub[(ajint)s1[i++]][(ajint)s2[k++]]; if(total >= thresh) { abovethresh=1; starti = i-windowsize; startj = k-windowsize; } while(i < len1 && k < len2) { total = total - sub[(ajint)s1[i-windowsize]] [(ajint)s2[k-windowsize]]; total = total + sub[(ajint)s1[i]][(ajint)s2[k]]; if(abovethresh) { if(total < thresh) { abovethresh = 0; /* draw the line */ dotmatcher_pushpoint(&list,(float)starti,(float)startj, (float)i-1,(float)k-1,stretch); } } else if(total >= thresh) { starti = i-windowsize; startj = k-windowsize; abovethresh= 1; } i++; k++; } if(abovethresh) /* draw the line */ dotmatcher_pushpoint(&list,(float)starti,(float)startj, (float)i-1,(float)k-1, stretch); } for(i=0; (ajint)i < (ajint)len1-windowsize;i++) { j = 0; total = 0; abovethresh =0; k = i; for(l=0;l<windowsize;l++) total = total + sub[(ajint)s1[k++]][(ajint)s2[j++]]; if(total >= thresh) { abovethresh=1; starti = k-windowsize; startj = j-windowsize; } while(k < len1 && j < len2) { total = total - sub[(ajint)s1[k-windowsize]] [(ajint)s2[j-windowsize]]; total = total + sub[(ajint)s1[k]][(ajint)s2[j]]; if(abovethresh) { if(total < thresh) { abovethresh = 0; /* draw the line */ dotmatcher_pushpoint(&list,(float)starti,(float)startj, (float)k-1,(float)j-1,stretch); } } else if(total >= thresh) { starti = k-windowsize; startj = j-windowsize; abovethresh= 1; } j++; k++; } if(abovethresh) /* draw the line */ dotmatcher_pushpoint(&list,(float)starti,(float)startj, (float)k-1,(float)j-1, stretch); } if(boxit && !stretch) { ajGraphicsDrawposRect(0.0,0.0,flen1, flen2); i=0; while(acceptableticksx[i]*numbofticks < len1) i++; if(i<=13) tickgap = (float)acceptableticksx[i]; else tickgap = (float)acceptableticksx[10]; ticklen = xmargin*(float)0.1; onefifth = xmargin*(float)0.2; if(len2/len1 > 10 ) { /* if a lot smaller then just label start and end */ ajGraphicsDrawposLine((float)0.0,(float)0.0,(float)0.0,(float)0.0-ticklen); sprintf(ptr,"%d",b1-1); ajGraphicsDrawposTextAtmid((float)0.0,(float)0.0-(onefifth),ptr); ajGraphicsDrawposLine(flen1,(float)0.0, flen1,(float)0.0-ticklen); sprintf(ptr,"%d",len1+b1-1); ajGraphicsDrawposTextAtmid(flen1,(float)0.0-(onefifth),ptr); } else for(k2=0.0;k2<len1;k2+=tickgap) { ajGraphicsDrawposLine(k2,(float)0.0,k2,(float)0.0-ticklen); sprintf(ptr,"%d",(ajint)k2+b1-1); ajGraphicsDrawposTextAtmid(k2,(float)0.0-(onefifth),ptr); } i = 0; while(acceptableticks[i]*numbofticks < len2) i++; tickgap = (float)acceptableticks[i]; ticklen = ymargin*(float)0.01; onefifth = ymargin*(float)0.02; if(len1/len2 > 10 ) { /* if a lot smaller then just label start and end */ ajGraphicsDrawposLine((float)0.0,(float)0.0,(float)0.0-ticklen,(float)0.0); sprintf(ptr,"%d",b2-1); ajGraphicsDrawposTextAtend((float)0.0-(onefifth),(float)0.0,ptr); ajGraphicsDrawposLine((float)0.0,flen2,(float)0.0-ticklen, flen2); sprintf(ptr,"%d",len2+b2-1); ajGraphicsDrawposTextAtend((float)0.0-(onefifth),flen2,ptr); } else for(k2=0.0;k2<len2;k2+=tickgap) { ajGraphicsDrawposLine((float)0.0,k2,(float)0.0-ticklen,k2); sprintf(ptr,"%d",(ajint)k2+b2-1); ajGraphicsDrawposTextAtend((float)0.0-(onefifth),k2,ptr); } } if(!stretch) ajGraphicsClose(); else /* the xy graph for -stretch */ { tit = ajStrNew(); ajFmtPrintS(&tit,"%S",ajGraphGetTitleS(xygraph)); gdata = ajGraphdataNewI(1); xa[0] = (float)b1; ya[0] = (float)b2; ajGraphSetTitleC(xygraph,ajStrGetPtr(tit)); ajGraphSetXlabelC(xygraph,ajSeqGetNameC(seq)); ajGraphSetYlabelC(xygraph,ajSeqGetNameC(seq2)); ajGraphdataSetTypeC(gdata,"2D Plot Float"); ajGraphdataSetTitleS(gdata,subt); ajGraphdataSetMinmax(gdata,(float)b1,(float)e1,(float)b2, (float)e2); ajGraphdataSetTruescale(gdata,(float)b1,(float)e1,(float)b2, (float)e2); ajGraphxySetXstartF(xygraph,(float)b1); ajGraphxySetXendF(xygraph,(float)e1); ajGraphxySetYstartF(xygraph,(float)b2); ajGraphxySetYendF(xygraph,(float)e2); ajGraphxySetXrangeII(xygraph,b1,e1); ajGraphxySetYrangeII(xygraph,b2,e2); if(list) { iter = ajListIterNewread(list); while((ppt = ajListIterGet(iter))) { x1 = ppt->x1+b1-1; y1 = ppt->y1+b2-1; x2 = ppt->x2+b1-1; y2 = ppt->y2+b2-1; ajGraphAddLine(xygraph,x1,y1,x2,y2,0); AJFREE(ppt); } ajListIterDel(&iter); } ajGraphdataAddXY(gdata,xa,ya); ajGraphDataReplace(xygraph,gdata); ajGraphxyDisplay(xygraph,ajFalse); ajGraphicsClose(); ajStrDel(&tit); } ajListFree(&list); ajSeqDel(&seq); ajSeqDel(&seq2); ajGraphxyDel(&graph); ajGraphxyDel(&xygraph); ajMatrixDel(&matrix); ajTimeDel(&ajtime); /* deallocate memory */ ajStrDel(&aa0str); ajStrDel(&aa1str); ajStrDel(&se1); ajStrDel(&se2); ajStrDel(&subt); AJFREE(strret); /* created withing ajFmtString */ embExit(); return 0; }
void emboss_getoptions(char *pgm, int argc, char *argv[]) { /* get from user the relevant parameters for the plotter and diagram */ boolean getgrows; int m, n; AjPStr getstyle = NULL; AjPStr plottercode = NULL; AjPStr getpreviewer = NULL; AjPStr getnodeposition = NULL; embInitPV(pgm, argc, argv, "PHYLIPNEW",VERSION); n = (int)((pagex-hpmargin-0.01)/(paperx-hpmargin)+1.0); m = (int)((pagey-vpmargin-0.01)/(papery-vpmargin)+1.0); phylotrees = ajAcdGetTree("intreefile"); plottercode = ajAcdGetListSingle("plotter"); getplotter(ajStrGetCharFirst(plottercode)); preview = true; getpreviewer = ajAcdGetListSingle("previewer"); /* sets plotter variable */ if(ajStrMatchC(getpreviewer, "n")) { preview = false; previewer = other; /* Added by Dan F. */ } else if(ajStrMatchC(getpreviewer, "i")) previewer = ibm; else if(ajStrMatchC(getpreviewer, "m")) previewer = mac; else if(ajStrMatchC(getpreviewer, "x")) previewer = xpreview; else if(ajStrMatchC(getpreviewer, "w")) previewer = winpreview; else if(ajStrMatchC(getpreviewer, "i")) previewer = tek; else if(ajStrMatchC(getpreviewer, "i")) previewer = decregis; else if(ajStrMatchC(getpreviewer, "o")) previewer = other; getgrows = ajAcdGetBoolean("grows"); if(getgrows) grows = horizontal; else grows = vertical; getstyle = ajAcdGetListSingle("style"); if(ajStrMatchC(getstyle, "c")) style = cladogram; else if(ajStrMatchC(getstyle, "p")) style = phenogram; else if(ajStrMatchC(getstyle, "e")) style = eurogram; else if(ajStrMatchC(getstyle, "s")) style = swoopogram; else if(ajStrMatchC(getstyle, "v")) style = curvogram; else if(ajStrMatchC(getstyle, "o")) { style = circular; treedepth = 1.0; } uselengths = ajAcdGetBoolean("lengths"); labelrotation = ajAcdGetFloat("labelrotation"); if(plotter==ray) { xmargin = ajAcdGetFloat("xrayshade"); ymargin = ajAcdGetFloat("yrayshade"); } else { xmargin = ajAcdGetFloat("xmargin"); ymargin = ajAcdGetFloat("ymargin"); } rescaled = ajAcdGetToggle("rescaled"); if(rescaled) bscale = ajAcdGetFloat("bscale"); treedepth = ajAcdGetFloat("treedepth"); stemlength = ajAcdGetFloat("stemlength"); nodespace = ajAcdGetFloat("nodespace"); nodespace = 1.0 / nodespace; m = ajAcdGetFloat("pagesheight"); n = ajAcdGetFloat("pageswidth"); paperx = ajAcdGetFloat("paperx"); papery = ajAcdGetFloat("papery"); hpmargin = ajAcdGetFloat("hpmargin"); vpmargin = ajAcdGetFloat("vpmargin"); pagex = ((double)n * (paperx-hpmargin)+hpmargin); pagey = ((double)m * (papery-vpmargin)+vpmargin); getnodeposition = ajAcdGetListSingle("nodeposition"); if(ajStrMatchC(getnodeposition, "i")) nodeposition = intermediate; else if(ajStrMatchC(getnodeposition, "w")) nodeposition = weighted; else if(ajStrMatchC(getnodeposition, "c")) nodeposition = centered; else if(ajStrMatchC(getnodeposition, "i")) nodeposition = inner; else if(ajStrMatchC(getnodeposition, "v")) nodeposition = vshaped; embossplotfile = ajAcdGetOutfile("plotfile"); emboss_openfile(embossplotfile, &plotfile, &pltfilename); } /* getparms */
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) { /* Global details */ AjBool explain_flag; AjBool file_flag; AjPStr* task; AjBool do_primer; AjBool do_hybrid; ajint num_return; ajint first_base_index; /* "Sequence" Input Tags */ AjPSeqall sequence; AjPRange included_region; AjPRange target; AjPRange excluded_region; AjPStr left_input; AjPStr right_input; /* Primer details */ AjBool pick_anyway; AjPFile mispriming_library; float max_mispriming; float pair_max_mispriming; ajint gc_clamp; ajint opt_size; ajint min_size; ajint max_size; float opt_tm; float min_tm; float max_tm; float max_diff_tm; float opt_gc_percent; float min_gc; float max_gc; float salt_conc; float dna_conc; ajint num_ns_accepted; float self_any; float self_end; ajint max_poly_x; /* Sequence Quality. These are not (yet) implemented */ /* AjPFile sequence_quality; ajint min_quality; ajint min_end_quality; ajint quality_range_min; ajint quality_range_max; */ /* Product details */ ajint product_opt_size; AjPRange product_size_range; float product_opt_tm; float product_min_tm; float product_max_tm; /* Objective Function Penalty Weights for Primers */ float max_end_stability; /* these are not (yet) implemented */ /* float inside_penalty; float outside_penalty; */ /* Primer penalties */ /* these are not (yet) implemented */ /* Internal Oligo "Sequence" Input Tags */ AjPRange internal_oligo_excluded_region; /* Internal Oligo "Global" Input Tags */ AjPStr internal_oligo_input; ajint internal_oligo_opt_size; ajint internal_oligo_min_size; ajint internal_oligo_max_size; float internal_oligo_opt_tm; float internal_oligo_min_tm; float internal_oligo_max_tm; float internal_oligo_opt_gc_percent; float internal_oligo_min_gc; float internal_oligo_max_gc; float internal_oligo_salt_conc; float internal_oligo_dna_conc; float internal_oligo_self_any; float internal_oligo_self_end; ajint internal_oligo_max_poly_x; AjPFile internal_oligo_mishyb_library; float internal_oligo_max_mishyb; /* ajint internal_oligo_min_quality; */ /* Internal Oligo penalties */ /* these are not (yet) implemented */ /* EMBOSS-wrapper-specific stuff */ AjPFile outfile; /* other variables */ AjPStr result = NULL; AjPStr strand = NULL; AjPStr substr = NULL; AjPSeq seq = NULL; ajint begin = 0; ajint end; FILE* stream; AjPStr taskstr = NULL; const AjPStr program = NULL; /* pipe variables */ int *pipeto; /* pipe to feed the exec'ed program input */ int *pipefrom; /* pipe to get the exec'ed program output */ embInit("eprimer3", argc, argv); /* Global details */ explain_flag = ajAcdGetBoolean("explainflag"); file_flag = ajAcdGetBoolean("fileflag"); task = ajAcdGetList("task"); do_primer = ajAcdGetToggle("primer"); do_hybrid = ajAcdGetToggle("hybridprobe"); num_return = ajAcdGetInt("numreturn"); first_base_index = ajAcdGetInt("firstbaseindex"); /* "Sequence" Input Tags */ sequence = ajAcdGetSeqall("sequence"); included_region = ajAcdGetRange("includedregion"); target = ajAcdGetRange("targetregion"); excluded_region = ajAcdGetRange("excludedregion"); left_input = ajAcdGetString("forwardinput"); right_input = ajAcdGetString("reverseinput"); /* Primer details */ pick_anyway = ajAcdGetBoolean("pickanyway"); mispriming_library = ajAcdGetInfile("mispriminglibraryfile"); max_mispriming = ajAcdGetFloat("maxmispriming"); pair_max_mispriming = ajAcdGetFloat("pairmaxmispriming"); gc_clamp = ajAcdGetInt("gcclamp"); opt_size = ajAcdGetInt("osize"); min_size = ajAcdGetInt("minsize"); max_size = ajAcdGetInt("maxsize"); opt_tm = ajAcdGetFloat("otm"); min_tm = ajAcdGetFloat("mintm"); max_tm = ajAcdGetFloat("maxtm"); max_diff_tm = ajAcdGetFloat("maxdifftm"); opt_gc_percent = ajAcdGetFloat("ogcpercent"); min_gc = ajAcdGetFloat("mingc"); max_gc = ajAcdGetFloat("maxgc"); salt_conc = ajAcdGetFloat("saltconc"); dna_conc = ajAcdGetFloat("dnaconc"); num_ns_accepted = ajAcdGetInt("numnsaccepted"); self_any = ajAcdGetFloat("selfany"); self_end = ajAcdGetFloat("selfend"); max_poly_x = ajAcdGetInt("maxpolyx"); AJCNEW0(pipeto,2); AJCNEW0(pipefrom,2); /* Sequence Quality */ /* these are not (yet) implemented */ /* sequence_quality = ajAcdGetInfile("sequencequality"); min_quality = ajAcdGetInt("minquality"); min_end_quality = ajAcdGetInt("minendquality"); quality_range_min = ajAcdGetInt("qualityrangemin"); quality_range_max = ajAcdGetInt("qualityrangemax"); */ /* Product details */ product_opt_size = ajAcdGetInt("psizeopt"); product_size_range = ajAcdGetRange("prange"); product_opt_tm = ajAcdGetFloat("ptmopt"); product_min_tm = ajAcdGetFloat("ptmmin"); product_max_tm = ajAcdGetFloat("ptmmax"); /* Objective Function Penalty Weights for Primers */ max_end_stability = ajAcdGetFloat("maxendstability"); /* these are not (yet) implemented */ /* inside_penalty = ajAcdGetFloat("insidepenalty"); outside_penalty = ajAcdGetFloat("outsidepenalty"); */ /* Primer penalties */ /* these are not (yet) implemented */ /* Internal Oligo "Sequence" Input Tags */ internal_oligo_excluded_region = ajAcdGetRange("oexcludedregion"); internal_oligo_input = ajAcdGetString("oligoinput"); /* Internal Oligo "Global" Input Tags */ internal_oligo_opt_size = ajAcdGetInt("osizeopt"); internal_oligo_min_size = ajAcdGetInt("ominsize"); internal_oligo_max_size = ajAcdGetInt("omaxsize"); internal_oligo_opt_tm = ajAcdGetFloat("otmopt"); internal_oligo_min_tm = ajAcdGetFloat("otmmin"); internal_oligo_max_tm = ajAcdGetFloat("otmmax"); internal_oligo_opt_gc_percent = ajAcdGetFloat("ogcopt"); internal_oligo_min_gc = ajAcdGetFloat("ogcmin"); internal_oligo_max_gc = ajAcdGetFloat("ogcmax"); internal_oligo_salt_conc = ajAcdGetFloat("osaltconc"); internal_oligo_dna_conc = ajAcdGetFloat("odnaconc"); internal_oligo_self_any = ajAcdGetFloat("oanyself"); internal_oligo_self_end = ajAcdGetFloat("oendself"); internal_oligo_max_poly_x = ajAcdGetInt("opolyxmax"); internal_oligo_mishyb_library = ajAcdGetInfile("mishyblibraryfile"); internal_oligo_max_mishyb = ajAcdGetFloat("omishybmax"); /* internal_oligo_min_quality = ajAcdGetInt("oligominquality"); */ /* Internal Oligo penalties */ /* these are not (yet) implemented */ /* EMBOSS-wrapper-specific stuff */ outfile = ajAcdGetOutfile("outfile"); ajStrRemoveWhite(&left_input); ajStrRemoveWhite(&right_input); /* ** OK - we will now try to do a separate fork-exec for each sequence. */ result = ajStrNew(); while(ajSeqallNext(sequence, &seq)) { program = ajAcdGetpathC("primer3_core"); if(!ajSysExecRedirectC(ajStrGetPtr(program),&pipeto,&pipefrom)) ajFatal("eprimer3: Could not exec primer3_core"); stream = eprimer3_start_write(pipeto[1]); /* send primer3 Primer "Global" parameters */ eprimer3_send_bool(stream, "PRIMER_EXPLAIN_FLAG", explain_flag); eprimer3_send_bool(stream, "PRIMER_FILE_FLAG", file_flag); if(do_hybrid) { if(!ajStrCmpC(task[0], "1")) ajStrAssignC(&taskstr, "pick_pcr_primers_and_hyb_probe"); else if(!ajStrCmpC(task[0], "2")) ajStrAssignC(&taskstr, "pick_left_only"); else if(!ajStrCmpC(task[0], "3")) ajStrAssignC(&taskstr, "pick_right_only"); else if(!ajStrCmpC(task[0], "4")) ajStrAssignC(&taskstr, "pick_hyb_probe_only"); if (!do_primer) ajStrAssignC(&taskstr, "pick_hyb_probe_only"); } else { if(!ajStrCmpC(task[0], "1")) ajStrAssignC(&taskstr, "pick_pcr_primers"); else if(!ajStrCmpC(task[0], "2")) ajStrAssignC(&taskstr, "pick_left_only"); else if(!ajStrCmpC(task[0], "3")) ajStrAssignC(&taskstr, "pick_right_only"); else if(!ajStrCmpC(task[0], "4")) ajStrAssignC(&taskstr, "pick_hyb_probe_only"); } eprimer3_send_string(stream, "PRIMER_TASK", taskstr); eprimer3_send_int(stream, "PRIMER_NUM_RETURN", num_return); eprimer3_send_int(stream, "PRIMER_FIRST_BASE_INDEX", first_base_index); eprimer3_send_bool(stream, "PRIMER_PICK_ANYWAY", pick_anyway); /* mispriming library may not have been specified */ if(mispriming_library) eprimer3_send_stringC(stream, "PRIMER_MISPRIMING_LIBRARY", ajFileGetPrintnameC(mispriming_library)); eprimer3_send_float(stream, "PRIMER_MAX_MISPRIMING", max_mispriming); eprimer3_send_float(stream, "PRIMER_PAIR_MAX_MISPRIMING", pair_max_mispriming); eprimer3_send_int(stream, "PRIMER_GC_CLAMP", gc_clamp); eprimer3_send_int(stream, "PRIMER_OPT_SIZE", opt_size); eprimer3_send_int(stream, "PRIMER_MIN_SIZE", min_size); eprimer3_send_int(stream, "PRIMER_MAX_SIZE", max_size); eprimer3_send_float(stream, "PRIMER_OPT_TM", opt_tm); eprimer3_send_float(stream, "PRIMER_MIN_TM", min_tm); eprimer3_send_float(stream, "PRIMER_MAX_TM", max_tm); eprimer3_send_float(stream, "PRIMER_MAX_DIFF_TM", max_diff_tm); eprimer3_send_float(stream, "PRIMER_OPT_GC_PERCENT", opt_gc_percent); eprimer3_send_float(stream, "PRIMER_MIN_GC", min_gc); eprimer3_send_float(stream, "PRIMER_MAX_GC", max_gc); eprimer3_send_float(stream, "PRIMER_SALT_CONC", salt_conc); eprimer3_send_float(stream, "PRIMER_DNA_CONC", dna_conc); eprimer3_send_int(stream, "PRIMER_NUM_NS_ACCEPTED", num_ns_accepted); eprimer3_send_float(stream, "PRIMER_SELF_ANY", self_any); eprimer3_send_float(stream, "PRIMER_SELF_END", self_end); eprimer3_send_int(stream, "PRIMER_MAX_POLY_X", max_poly_x); eprimer3_send_int(stream, "PRIMER_PRODUCT_OPT_SIZE", product_opt_size); eprimer3_send_range2(stream, "PRIMER_PRODUCT_SIZE_RANGE", product_size_range); eprimer3_send_float(stream, "PRIMER_PRODUCT_OPT_TM", product_opt_tm); eprimer3_send_float(stream, "PRIMER_PRODUCT_MIN_TM", product_min_tm); eprimer3_send_float(stream, "PRIMER_PRODUCT_MAX_TM", product_max_tm); eprimer3_send_float(stream, "PRIMER_MAX_END_STABILITY", max_end_stability); /* send primer3 Internal Oligo "Global" parameters */ eprimer3_send_int(stream, "PRIMER_INTERNAL_OLIGO_OPT_SIZE", internal_oligo_opt_size); eprimer3_send_int(stream, "PRIMER_INTERNAL_OLIGO_MIN_SIZE", internal_oligo_min_size); eprimer3_send_int(stream, "PRIMER_INTERNAL_OLIGO_MAX_SIZE", internal_oligo_max_size); eprimer3_send_float(stream, "PRIMER_INTERNAL_OLIGO_OPT_TM", internal_oligo_opt_tm); eprimer3_send_float(stream, "PRIMER_INTERNAL_OLIGO_MIN_TM", internal_oligo_min_tm); eprimer3_send_float(stream, "PRIMER_INTERNAL_OLIGO_MAX_TM", internal_oligo_max_tm); eprimer3_send_float(stream, "PRIMER_INTERNAL_OLIGO_OPT_GC_PERCENT", internal_oligo_opt_gc_percent); eprimer3_send_float(stream, "PRIMER_INTERNAL_OLIGO_MIN_GC", internal_oligo_min_gc); eprimer3_send_float(stream, "PRIMER_INTERNAL_OLIGO_MAX_GC", internal_oligo_max_gc); eprimer3_send_float(stream, "PRIMER_INTERNAL_OLIGO_SALT_CONC", internal_oligo_salt_conc); eprimer3_send_float(stream, "PRIMER_INTERNAL_OLIGO_DNA_CONC", internal_oligo_dna_conc); eprimer3_send_float(stream, "PRIMER_INTERNAL_OLIGO_SELF_ANY", internal_oligo_self_any); eprimer3_send_float(stream, "PRIMER_INTERNAL_OLIGO_SELF_END", internal_oligo_self_end); eprimer3_send_int(stream, "PRIMER_INTERNAL_OLIGO_MAX_POLY_X", internal_oligo_max_poly_x); /* ** internal oligo mishybridising library may not have been ** specified */ if(internal_oligo_mishyb_library) eprimer3_send_stringC(stream, "PRIMER_INTERNAL_OLIGO_MISHYB_LIBRARY", ajFileGetPrintnameC(internal_oligo_mishyb_library)); eprimer3_send_float(stream, "PRIMER_INTERNAL_OLIGO_MAX_MISHYB", internal_oligo_max_mishyb); /* ** Start sequence-specific stuff */ begin = ajSeqallGetseqBegin(sequence) - 1; end = ajSeqallGetseqEnd(sequence) - 1; strand = ajSeqGetSeqCopyS(seq); ajStrFmtUpper(&strand); ajStrAssignSubC(&substr,ajStrGetPtr(strand), begin, end); /* send flags to turn on using optimal product size */ eprimer3_send_float(stream, "PRIMER_PAIR_WT_PRODUCT_SIZE_GT", (float)0.05); eprimer3_send_float(stream, "PRIMER_PAIR_WT_PRODUCT_SIZE_LT", (float)0.05); /* send primer3 Primer "Sequence" parameters */ eprimer3_send_string(stream, "SEQUENCE", substr); /* if no ID name, use the USA */ if(ajStrMatchC(ajSeqGetNameS(seq),"")) eprimer3_send_string(stream, "PRIMER_SEQUENCE_ID", ajSeqGetUsaS(seq)); else eprimer3_send_string(stream, "PRIMER_SEQUENCE_ID", ajSeqGetNameS(seq)); eprimer3_send_range(stream, "INCLUDED_REGION", included_region, begin); eprimer3_send_range(stream, "TARGET", target, begin); eprimer3_send_range(stream, "EXCLUDED_REGION", excluded_region, begin); eprimer3_send_string(stream, "PRIMER_LEFT_INPUT", left_input); eprimer3_send_string(stream, "PRIMER_RIGHT_INPUT", right_input); /* send primer3 Internal Oligo "Sequence" parameters */ eprimer3_send_range(stream, "PRIMER_INTERNAL_OLIGO_EXCLUDED_REGION", internal_oligo_excluded_region, begin); eprimer3_send_string(stream, "PRIMER_INTERNAL_OLIGO_INPUT", internal_oligo_input); /* end the primer3 input sequence record with a '=' */ eprimer3_send_end(stream); /* and close the ouput pipe stream */ eprimer3_end_write(stream); /* read the primer3 output */ eprimer3_read(pipefrom[0], &result); eprimer3_report(outfile, result, num_return, begin); ajStrSetClear(&result); #ifndef WIN32 close(pipeto[1]); close(pipefrom[0]); #endif } /* end of sequence loop */ ajStrDel(&result); ajSeqDel(&seq); ajStrDel(&strand); ajStrDel(&substr); ajFileClose(&outfile); ajStrDel(&taskstr); ajStrDelarray(&task); ajSeqallDel(&sequence); ajSeqDel(&seq); ajRangeDel(&included_region); ajRangeDel(&target); ajRangeDel(&excluded_region); ajRangeDel(&product_size_range); ajRangeDel(&internal_oligo_excluded_region); ajStrDel(&left_input); ajStrDel(&right_input); ajStrDel(&internal_oligo_input); AJFREE(pipeto); AJFREE(pipefrom); ajFileClose(&mispriming_library); embExit(); return 0; }
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 */
/* @prog seqnr ************************************************************** ** ** Removes redundancy from DHF files (domain hits files) or other files of ** sequences. ** ****************************************************************************/ int main(int argc, char **argv) { /* Variable declarations */ AjPList in = NULL; /* Names of domain hits files (input). */ AjPStr inname = NULL; /* Full name of the current DHF file. */ AjPFile inf = NULL; /* Current DHF file. */ EmbPHitlist infhits = NULL; /* Hitlist from DHF file */ AjBool dosing = ajFalse; /* Filter using singlet sequences. */ AjPDir singlets = NULL; /* Singlets (input). */ AjBool dosets = ajFalse; /* Filter using sets of sequences. */ AjPDir insets = NULL; /* Sets (input). */ AjPStr mode = NULL; /* Mode of operation */ ajint moden = 0; /* Mode 1: single threshold for redundancy removal, 2: lower and upper thresholds for redundancy removal. */ float thresh = 0.0; /* Threshold for non-redundancy. */ float threshlow = 0.0; /* Threshold (lower limit). */ float threshup = 0.0; /* Threshold (upper limit). */ AjPMatrixf matrix = NULL; /* Substitution matrix. */ float gapopen = 0.0; /* Gap insertion penalty. */ float gapextend = 0.0; /* Gap extension penalty. */ AjPDirout out = NULL; /* Domain hits files (output). */ AjPFile outf = NULL; /* Current DHF file (output). */ AjBool dored = ajFalse; /* True if redundant hits are output. */ AjPDirout outred = NULL; /* DHF files for redundant hits (output).*/ AjPFile redf = NULL; /* Current DHF file redundancy (output). */ AjPStr outname = NULL; /* Name of output file (re-used). */ AjPFile logf = NULL; /* Log file pointer. */ AjBool ok = ajFalse; /* Housekeeping. */ AjPSeqset seqset = NULL; /* Seqset (re-used). */ AjPSeqin seqin = NULL; /* Seqin (re-used). */ AjPList seq_list = NULL; /* Main list for redundancy removal. */ EmbPDmxNrseq seq_tmp = NULL; /* Temp. pointer for making seq_list. */ ajint seq_siz = 0; /* Size of seq_list. */ AjPUint keep = NULL; /* 1: Sequence in seq_list was classed as non-redundant, 0: redundant. */ AjPUint nokeep = NULL; /* Inversion of keep array. */ ajint nseqnr = 0; /* No. non-redundant seqs. in seq_list. */ AjPStr filtername= NULL; /* Name of filter file (re-used). */ AjPFile filterf = NULL; /* Current filter file. */ EmbPHitlist hitlist = NULL; /* Hitlist from input file (re-used). */ AjPScopalg scopalg = NULL; /* Scopalg from input file. */ ajint x = 0; /* Housekeeping. */ /* Read data from acd. */ embInitPV("seqnr",argc,argv,"DOMSEARCH",VERSION); in = ajAcdGetDirlist("dhfinpath"); dosing = ajAcdGetToggle("dosing"); singlets = ajAcdGetDirectory("singletsdir"); dosets = ajAcdGetToggle("dosets"); insets = ajAcdGetDirectory("insetsdir"); mode = ajAcdGetListSingle("mode"); thresh = ajAcdGetFloat("thresh"); threshlow = ajAcdGetFloat("threshlow"); threshup = ajAcdGetFloat("threshup"); matrix = ajAcdGetMatrixf("matrix"); gapopen = ajAcdGetFloat("gapopen"); gapextend = ajAcdGetFloat("gapextend"); out = ajAcdGetOutdir("dhfoutdir"); dored = ajAcdGetToggle("dored"); outred = ajAcdGetOutdir("redoutdir"); logf = ajAcdGetOutfile("logfile"); /* Housekeeping. */ filtername = ajStrNew(); outname = ajStrNew(); if(!(ajStrToInt(mode, &moden))) ajFatal("Could not parse ACD node option"); /* Process each DHF (input) in turn. */ while(ajListPop(in,(void **)&inname)) { ajFmtPrint("Processing %S\n", inname); ajFmtPrintF(logf, "//\n%S\n", inname); seq_list = ajListNew(); keep = ajUintNew(); nokeep = ajUintNew(); /**********************************/ /* Open DHF file */ /**********************************/ if((inf = ajFileNewInNameS(inname)) == NULL) ajFatal("Could not open DHF file %S", inname); /* Read DHF file. */ ok = ajFalse; if(!(infhits = embHitlistReadFasta(inf))) { ajWarn("embHitlistReadFasta call failed in seqnr"); ajFmtPrintF(logf, "embHitlistReadFasta call failed in seqnr\n"); /* Read sequence set instead. */ seqset = ajSeqsetNew(); seqin = ajSeqinNew(); ajSeqinUsa(&seqin, inname); if(!(ajSeqsetRead(seqset, seqin))) ajFatal("SeqsetRead failed in seqsearch_psialigned"); if(ajSeqsetGetSize(seqset)) ok = ajTrue; } else if(infhits->N) ok = ajTrue; /* Close DHF file. */ ajFileClose(&inf); /* Process empty DHF files (should never occur). */ if(!ok) { ajWarn("Empty input file %S\n", inname); ajFmtPrintF(logf, "Empty input file %S\n", inname); if(infhits) embHitlistDel(&infhits); if(seqset) ajSeqsetDel(&seqset); if(seqin) ajSeqinDel(&seqin); continue; } /* 1. Create list of sequences from the main input directory.. */ if(infhits) { for(x=0; x<infhits->N; x++) { AJNEW0(seq_tmp); seq_tmp->Seq = ajSeqNew(); ajStrAssignS(&seq_tmp->Seq->Acc,infhits->hits[x]->Acc); ajStrAssignS(&seq_tmp->Seq->Seq,infhits->hits[x]->Seq); ajListPushAppend(seq_list,seq_tmp); } } else { for(x=0;x<ajSeqsetGetSize(seqset);x++) { AJNEW0(seq_tmp); seq_tmp->Seq = ajSeqNew(); ajStrAssignS(&seq_tmp->Seq->Acc, ajSeqsetGetseqAccS(seqset, x)); ajStrAssignS(&seq_tmp->Seq->Seq, ajSeqsetGetseqSeqS(seqset, x)); ajListPushAppend(seq_list,seq_tmp); } ajSeqsetDel(&seqset); ajSeqinDel(&seqin); } /**********************************/ /* Open singlets filter file */ /**********************************/ if(dosing) { /* Open singlets file. */ ajStrAssignS(&filtername, inname); ajFilenameTrimPathExt(&filtername); ajStrInsertS(&filtername, 0, ajDirGetPath(singlets)); ajStrAppendC(&filtername, "."); ajStrAppendS(&filtername, ajDirGetExt(singlets)); if((filterf = ajFileNewInNameS(filtername)) == NULL) { ajWarn("Could not open DHF file %S", filtername); ajFmtPrint("Could not open singlets filter file %S", filtername); } else { /* Read DHF file. */ ok = ajFalse; if(!(hitlist = embHitlistReadFasta(filterf))) { ajWarn("embHitlistReadFasta call failed in seqnr"); ajFmtPrintF(logf, "embHitlistReadFasta call failed in seqnr\n"); /* Read sequence set instead. */ seqset = ajSeqsetNew(); seqin = ajSeqinNew(); ajSeqinUsa(&seqin, inname); if(!(ajSeqsetRead(seqset, seqin))) ajFatal("SeqsetRead failed in seqnr"); if(ajSeqsetGetSize(seqset)) ok = ajTrue; } else if(hitlist->N) ok = ajTrue; /* Close DHF file. */ ajFileClose(&filterf); /* Process empty DHF files (should never occur). */ if(!ok) { ajWarn("Empty singlets filter file %S\n", filtername); ajFmtPrintF(logf, "Empty singlets filter file %S\n", filtername); /* No continue this time. */ } /* 2. Add sequences from filter directories to List but mark them up (they are considered in the redundancy calculation but never appear in the output files). */ if(hitlist) { for(x=0; x<hitlist->N; x++) { AJNEW0(seq_tmp); seq_tmp->Seq = ajSeqNew(); seq_tmp->Garbage = ajTrue; ajStrAssignS(&seq_tmp->Seq->Acc,hitlist->hits[x]->Acc); ajStrAssignS(&seq_tmp->Seq->Seq,hitlist->hits[x]->Seq); ajListPushAppend(seq_list,seq_tmp); } embHitlistDel(&hitlist); } else { for(x=0;x<ajSeqsetGetSize(seqset);x++) { AJNEW0(seq_tmp); seq_tmp->Seq = ajSeqNew(); seq_tmp->Garbage = ajTrue; ajStrAssignS(&seq_tmp->Seq->Acc, ajSeqsetGetseqAccS(seqset, x)); ajStrAssignS(&seq_tmp->Seq->Seq, ajSeqsetGetseqSeqS(seqset, x)); ajListPushAppend(seq_list,seq_tmp); } ajSeqsetDel(&seqset); ajSeqinDel(&seqin); } } } /**********************************/ /* Open sets filter file */ /**********************************/ if(dosets) { /* Open sets file. */ ajStrAssignS(&filtername, inname); ajFilenameTrimPathExt(&filtername); ajStrInsertS(&filtername, 0, ajDirGetPath(insets)); ajStrAppendC(&filtername, "."); ajStrAppendS(&filtername, ajDirGetExt(insets)); if((filterf = ajFileNewInNameS(filtername)) == NULL) { ajWarn("Could not open DAF file %S", filtername); ajFmtPrint("Could not open sets filter file %S", filtername); } else { /* Read DAF file. */ ok = ajFalse; if(!(ajDmxScopalgRead(filterf, &scopalg))) { ajWarn("ajDmxScopalgRead call failed in seqnr"); ajFmtPrintF(logf, "ajDmxScopalgRead call failed in seqnr\n"); /* Read sequence set instead. */ seqset = ajSeqsetNew(); seqin = ajSeqinNew(); ajSeqinUsa(&seqin, inname); if(!(ajSeqsetRead(seqset, seqin))) ajFatal("SeqsetRead failed in seqnr"); if(ajSeqsetGetSize(seqset)) ok = ajTrue; } else if(scopalg->N) ok = ajTrue; /* Close DHF file. */ ajFileClose(&filterf); /* Process empty DHF files (should never occur). */ if(!ok) { ajWarn("Empty sets filter file %S\n", filtername); ajFmtPrintF(logf, "Empty sets filter file %S\n", filtername); /* No continue this time. */ } /* 2. Add sequences from filter directories to List but mark them up (they are considered in the redundancy calculation but never appear in the output files).. */ if(scopalg) { for(x=0; x<scopalg->N; x++) { AJNEW0(seq_tmp); seq_tmp->Seq = ajSeqNew(); seq_tmp->Garbage = ajTrue; ajStrAssignS(&seq_tmp->Seq->Acc,scopalg->Codes[x]); ajStrAssignS(&seq_tmp->Seq->Seq,scopalg->Seqs[x]); /* Remove gap char's & whitespace. */ ajStrRemoveGap(&seq_tmp->Seq->Seq); ajListPushAppend(seq_list,seq_tmp); } ajDmxScopalgDel(&scopalg); } else { for(x=0;x<ajSeqsetGetSize(seqset);x++) { AJNEW0(seq_tmp); seq_tmp->Seq = ajSeqNew(); seq_tmp->Garbage = ajTrue; ajStrAssignS(&seq_tmp->Seq->Acc, ajSeqsetGetseqAccS(seqset, x)); ajStrAssignS(&seq_tmp->Seq->Seq, ajSeqsetGetseqSeqS(seqset, x)); ajListPushAppend(seq_list,seq_tmp); } ajSeqsetDel(&seqset); ajSeqinDel(&seqin); } } } /* 4. Identify redundant domains.. */ if(moden == 1) { if((!embDmxSeqNR(seq_list, &keep, &nseqnr, matrix, gapopen, gapextend, thresh, ajTrue))) ajFatal("embDmxSeqNR failure in seqnr"); } else { if((!embDmxSeqNRRange(seq_list, &keep, &nseqnr, matrix, gapopen, gapextend, threshlow, threshup, ajTrue))) ajFatal("embDmxSeqNR failure in seqnr"); } seq_siz = ajListGetLength(seq_list); for(x=0; x<seq_siz; x++) if(ajUintGet(keep, x) == 1) ajUintPut(&nokeep, x, 0); else ajUintPut(&nokeep, x, 1); /* Create output files. */ ajStrAssignS(&outname, inname); ajFilenameTrimPathExt(&outname); outf = ajFileNewOutNameDirS(outname, out); if(dored) redf = ajFileNewOutNameDirS(outname, outred); /* 5. Write non-redundant domains to main output directory. 6. If specified, write redundant domains to output directory. */ embHitlistWriteSubsetFasta(outf, infhits, keep); if(dored) embHitlistWriteSubsetFasta(redf, infhits, nokeep); embHitlistDel(&infhits); ajFileClose(&outf); ajFileClose(&redf); ajStrDel(&inname); while(ajListPop(seq_list, (void **) &seq_tmp)) { ajSeqDel(&seq_tmp->Seq); AJFREE(seq_tmp); } ajListFree(&seq_list); ajUintDel(&keep); ajUintDel(&nokeep); } /* Tidy up. */ ajListFree(&in); if(singlets) ajDirDel(&singlets); if(insets) ajDirDel(&insets); ajDiroutDel(&out); if(outred) ajDiroutDel(&outred); ajFileClose(&logf); ajMatrixfDel(&matrix); ajStrDel(&filtername); ajStrDel(&outname); ajStrDel(&mode); embExit(); return 0; }