int main(int argc, char **argv) { AjPSeqall seqall; AjPSeqout seqout; AjPSeqout junkout; AjPSeq seq = NULL; AjPStr exclude = NULL; AjPStr pattern = NULL; AjPStr name = NULL; AjPStr acc = NULL; embInit("notseq", argc, argv); seqout = ajAcdGetSeqoutall("outseq"); junkout = ajAcdGetSeqoutall("junkoutseq"); seqall = ajAcdGetSeqall("sequence"); exclude = ajAcdGetString("exclude"); notseq_readfile(exclude, &pattern); while(ajSeqallNext(seqall, &seq)) { ajStrAssignS(&name, ajSeqGetNameS(seq)); ajStrAssignS(&acc, ajSeqGetAccS(seq)); if(embMiscMatchPatternDelimC(name, pattern, ",;") || embMiscMatchPatternDelimC(acc, pattern, ",;")) ajSeqoutWriteSeq(junkout, seq); else /* no match, so not excluded */ ajSeqoutWriteSeq(seqout, seq); ajStrSetClear(&name); ajStrSetClear(&acc); } ajSeqoutClose(seqout); ajSeqoutClose(junkout); ajSeqallDel(&seqall); ajSeqDel(&seq); ajSeqoutDel(&seqout); ajSeqoutDel(&junkout); ajStrDel(&exclude); ajStrDel(&pattern); ajStrDel(&name); ajStrDel(&acc); embExit(); return 0; }
int main(int argc, char **argv) { AjPSeqout seqout; AjPSeqall seqall; AjPSeq seq = NULL; embInit("seqretallfeat", argc, argv); seqout = ajAcdGetSeqoutall("outseq"); seqall = ajAcdGetSeqall("sequence"); while (ajSeqallNext(seqall, &seq)) { ajSeqoutWriteSeq(seqout, seq); ajSeqTrace(seq); } ajSeqoutClose(seqout); ajFeatTest(); ajSeqallDel(&seqall); ajSeqDel(&seq); ajSeqoutDel(&seqout); embExit(); return 0; }
AjBool gFormatGenbank(AjPSeq seq, AjPStr *inseq){ AjPSeqout seqout = NULL; AjPFeattabOut featout = NULL; AjPFeattable feat = NULL; AjPStr seqline = NULL; AjPStr featline = NULL; AjPFile seqfile = NULL; AjPFile featfile = NULL; AjPStr filename = NULL; gAssignUniqueName(&filename); feat = ajSeqGetFeatCopy(seq); if(!feat) return ajFalse; seqout = ajSeqoutNew(); if(!ajSeqoutOpenFilename(seqout,filename)) embExitBad(); ajSeqoutSetFormatS(seqout,ajStrNewC("genbank")); ajSeqoutWriteSeq(seqout,seq); ajSeqoutClose(seqout); ajSeqoutDel(&seqout); seqfile = ajFileNewInNameS(filename); ajSysFileUnlinkS(filename); featout = ajFeattabOutNew(); if(!ajFeattabOutOpen(featout,filename)) return ajFalse; ajFeattableWriteGenbank(featout,feat); ajFeattableDel(&feat); //ajFeattabOutDel(&featout); ajFileClose(&(featout->Handle)); featfile = ajFileNewInNameS(filename); ajSysFileUnlinkS(filename); while(ajReadline(seqfile,&seqline)){ if(ajStrMatchC(seqline,"ORIGIN\n")){ while(ajReadline(featfile,&featline)){ ajStrAppendS(inseq, featline); } } ajStrAppendS(inseq, seqline); } ajStrDel(&seqline); ajStrDel(&featline); ajStrDel(&filename); ajFileClose(&seqfile); ajFileClose(&featfile); return ajTrue; }
int main(int argc, char **argv) { AjPSeqall seqall; AjPSeqout seqout; AjPSeq seq = NULL; AjBool firstonly; embInit("seqret", argc, argv); seqout = ajAcdGetSeqoutall("outseq"); seqall = ajAcdGetSeqall("sequence"); firstonly = ajAcdGetBoolean("firstonly"); while(ajSeqallNext(seqall, &seq)) { ajSeqoutWriteSeq(seqout, seq); if(firstonly) break; } ajSeqoutClose(seqout); ajSeqallDel(&seqall); ajSeqDel(&seq); ajSeqoutDel(&seqout); embExit(); return 0; }
int main(int argc, char **argv) { AjPSeqall seqall; AjPSeq a; AjPSeqout outf; AjPStr substr; AjPStr back; AjPStr gctable; AjPCod codon = NULL; ajint gctablenum; ajint beg; ajint end; embInit("backtranambig", argc, argv); seqall = ajAcdGetSeqall("sequence"); outf = ajAcdGetSeqoutall("outfile"); gctable = ajAcdGetListSingle("table"); ajStrToInt(gctable, &gctablenum); codon = ajCodNewCodenum(gctablenum); while(ajSeqallNext(seqall, &a)) { substr = ajStrNew(); beg = ajSeqGetBegin(a); end = ajSeqGetEnd(a); ajStrAssignSubC(&substr,ajSeqGetSeqC(a),beg-1,end-1); back = ajStrNew(); ajCodBacktranslateAmbig(&back,substr,codon); ajSeqAssignSeqS (a, back); ajSeqSetNuc(a); ajSeqoutWriteSeq(outf,a); } ajSeqoutClose(outf); ajStrDel(&back); ajStrDel(&substr); ajSeqoutDel(&outf); ajCodDel(&codon); ajStrDel(&gctable); ajSeqallDel(&seqall); ajSeqDel(&a); embExit(); return 0; }
int main(int argc, char **argv) { /* Variable Declarations */ AjPSeqset seqset = NULL; AjPSeqout seqout = NULL; AjBool bigfirst; ajuint nseqs; ajuint i; /* ACD File Processing */ embInit("sizeseq", argc, argv); seqset = ajAcdGetSeqset("sequences"); bigfirst = ajAcdGetBoolean("descending"); seqout = ajAcdGetSeqoutall("outseq"); /* Application logic */ ajSeqsetSortLen(seqset); nseqs = ajSeqsetGetSize(seqset); if(bigfirst) { for(i=nseqs; i>0; i--) ajSeqoutWriteSeq(seqout, ajSeqsetGetseqSeq(seqset,i-1)); } else { for(i=0; i<nseqs; i++) ajSeqoutWriteSeq(seqout, ajSeqsetGetseqSeq(seqset,i)); } /* Memory management and exit */ ajSeqsetDel(&seqset); ajSeqoutClose(seqout); ajSeqoutDel(&seqout); embExit(); return 0; }
int getorf_acd(int argc, char **argv) { AjPSeqout seqout; AjPSeqall seqall; AjPStr tablestr; ajuint minsize; ajuint maxsize; AjPStr findstr; AjBool methionine; AjBool circular; AjBool reverse; ajint around; embInit("getorf", argc, argv); seqout = ajAcdGetSeqoutall("outseq"); seqall = ajAcdGetSeqall("sequence"); tablestr = ajAcdGetListSingle("table"); minsize = ajAcdGetInt("minsize"); maxsize = ajAcdGetInt("maxsize"); findstr = ajAcdGetListSingle("find"); methionine = ajAcdGetBoolean("methionine"); circular = ajAcdGetBoolean("circular"); reverse = ajAcdGetBoolean("reverse"); around = ajAcdGetInt("flanking"); getorf(seqout, seqall, tablestr, minsize, maxsize, findstr, methionine, circular, reverse, around); ajSeqoutClose(seqout); ajSeqallDel(&seqall); ajSeqoutDel(&seqout); ajStrDel(&tablestr); ajStrDel(&findstr); embExit(); return 0; }
int main(int argc, char **argv) { embInitPV("kclustalw", argc, argv, "KBWS", "1.0.8"); struct soap soap; struct ns1__clustalwInputParams params; char* jobid; char* result; AjPSeqall seqall; AjPSeq seq; AjPFile outf; AjPFile outf_dnd; AjPStr substr; AjPStr inseq = NULL; AjPStr alignment; AjPStr output; AjPStr matrix; AjPStr outorder; ajint ktup; ajint window; ajint gapopen; float gapext; ajint gapdist; AjBool endgaps; ajint pairgap; ajint topdiags; AjPStr score; AjBool tossgaps; AjBool kimura; AjPStr outputtree; AjBool tree; AjBool quicktree; AjBool align; AjPStr clustering; ajint numiter; AjPStr iteration; alignment = ajAcdGetString("alignment"); output = ajAcdGetString("output"); matrix = ajAcdGetString("matrix"); outorder = ajAcdGetString("outorder"); ktup = ajAcdGetInt("ktup"); window = ajAcdGetInt("window"); gapopen = ajAcdGetInt("gapopen"); gapext = ajAcdGetFloat("gapext"); gapdist = ajAcdGetInt("gapdist"); endgaps = ajAcdGetBoolean("endgaps"); pairgap = ajAcdGetInt("pairgap"); topdiags = ajAcdGetInt("topdiags"); score = ajAcdGetString("score"); tossgaps = ajAcdGetBoolean("tossgaps"); kimura = ajAcdGetBoolean("kimura"); outputtree = ajAcdGetString("outputtree"); tree = ajAcdGetBoolean("tree"); quicktree = ajAcdGetBoolean("quicktree"); align = ajAcdGetBoolean("align"); clustering = ajAcdGetString("clustering"); numiter = ajAcdGetInt("numiter"); iteration = ajAcdGetString("iteration"); seqall = ajAcdGetSeqall("seqall"); outf = ajAcdGetOutfile("outfile"); outf_dnd = ajAcdGetOutfile("dndoutfile"); params.alignment = ajCharNewS(alignment); params.output = ajCharNewS(output); params.matrix = ajCharNewS(matrix); params.outorder = ajCharNewS(outorder); params.ktup = ktup; params.window = window; params.gapopen = gapopen; params.gapext = gapext; params.gapdist = gapdist; if (endgaps) { params.endgaps = xsd__boolean__true_; } else { params.endgaps = xsd__boolean__false_; } params.pairgap = pairgap; params.topdiags = topdiags; params.score = ajCharNewS(score); if (tossgaps) { params.tossgaps = xsd__boolean__true_; } else { params.tossgaps = xsd__boolean__false_; } if (kimura) { params.kimura = xsd__boolean__true_; } else { params.kimura = xsd__boolean__false_; } params.outputtree = ajCharNewS(outputtree); if (tree) { params.tree = xsd__boolean__true_; } else { params.tree = xsd__boolean__false_; } if (quicktree) { params.quicktree = xsd__boolean__true_; } else { params.quicktree = xsd__boolean__false_; } if (align) { params.align = xsd__boolean__true_; } else { params.align = xsd__boolean__false_; } params.clustering = ajCharNewS(clustering); params.numiter = numiter; params.iteration = ajCharNewS(iteration); AjPStr tmp = NULL; AjPStr tmpFileName = NULL; AjPSeqout fil_file; AjPStr line = NULL; /* if "AjPStr line; -> ajReadline is not success!" */ AjPStr sizestr = NULL; ajint thissize; ajint nb = 0; AjBool are_prot = ajFalse; ajint size = 0; AjPFile infile; tmp = ajStrNewC("fasta"); fil_file = ajSeqoutNew(); tmpFileName = getUniqueFileName(); if( !ajSeqoutOpenFilename(fil_file, tmpFileName) ) { embExitBad(); } ajSeqoutSetFormatS(fil_file, tmp); while (ajSeqallNext(seqall, &seq)) { if (!nb) { are_prot = ajSeqIsProt(seq); } ajSeqoutWriteSeq(fil_file, seq); ++nb; } ajSeqoutClose(fil_file); ajSeqoutDel(&fil_file); if (nb < 2) { ajFatal("Multiple alignments need at least two sequences"); } infile = ajFileNewInNameS(tmpFileName); while (ajReadline(infile, &line)) { ajStrAppendS(&inseq,line); ajStrAppendC(&inseq,"\n"); } soap_init(&soap); char* in0; in0 = ajCharNewS(inseq); if ( soap_call_ns1__runClustalw( &soap, NULL, NULL, in0, ¶ms, &jobid ) == SOAP_OK ) { fprintf(stderr,"Jobid: %s\n",jobid); } else { soap_print_fault(&soap, stderr); } int check = 0; while ( check == 0 ) { if ( soap_call_ns1__checkStatus( &soap, NULL, NULL, jobid, &check ) == SOAP_OK ) { fprintf(stderr,"*"); } else { soap_print_fault(&soap, stderr); } sleep(3); } fprintf(stderr,"\n"); char* type; type = "out"; if(soap_call_ns1__getMultiResult( &soap, NULL, NULL, jobid, type, &result )== SOAP_OK) { substr = ajStrNewC(result); fprintf(stdout, "%s\n", ajStrGetPtr(substr)); } else { soap_print_fault(&soap, stderr); } type = "aln"; if(soap_call_ns1__getMultiResult( &soap, NULL, NULL, jobid, type, &result )== SOAP_OK) { substr = ajStrNewC(result); ajFmtPrintF(outf,"%S\n",substr); } else { soap_print_fault(&soap, stderr); } type = "dnd"; if(soap_call_ns1__getMultiResult( &soap, NULL, NULL, jobid, type, &result )== SOAP_OK) { substr = ajStrNewC(result); ajFmtPrintF(outf_dnd,"%S\n",substr); } else { soap_print_fault(&soap, stderr); } ajSysFileUnlinkS(tmpFileName); soap_destroy(&soap); soap_end(&soap); soap_done(&soap); ajFileClose(&outf_dnd); ajFileClose(&outf); ajSeqallDel(&seqall); ajSeqDel(&seq); ajStrDel(&substr); 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) { AjPAlign align; AjPSeq a; AjPSeq b; AjPSeqout seqout; AjPStr m; AjPStr n; AjPStr merged = NULL; ajuint lena; ajuint lenb; const char *p; const char *q; ajint start1 = 0; ajint start2 = 0; float *path; ajint *compass; AjPMatrixf matrix; AjPSeqCvt cvt = 0; float **sub; float gapopen; float gapextend; ajulong maxarr = 1000; ajulong len; /* arbitrary. realloc'd if needed */ size_t stlen; float score; ajint begina; ajint beginb; embInit("merger", argc, argv); a = ajAcdGetSeq("asequence"); b = ajAcdGetSeq("bsequence"); seqout = ajAcdGetSeqout("outseq"); matrix = ajAcdGetMatrixf("datafile"); gapopen = ajAcdGetFloat("gapopen"); gapextend = ajAcdGetFloat("gapextend"); align = ajAcdGetAlign("outfile"); gapopen = ajRoundFloat(gapopen, 8); gapextend = ajRoundFloat(gapextend, 8); AJCNEW(path, maxarr); AJCNEW(compass, maxarr); /* ** make the two sequences lowercase so we can show which one we are ** using in the merge by uppercasing it */ ajSeqFmtLower(a); ajSeqFmtLower(b); m = ajStrNew(); n = ajStrNew(); sub = ajMatrixfGetMatrix(matrix); cvt = ajMatrixfGetCvt(matrix); begina = ajSeqGetBegin(a); beginb = ajSeqGetBegin(b); lena = ajSeqGetLen(a); lenb = ajSeqGetLen(b); if(lenb > (ULONG_MAX/(ajulong)(lena+1))) ajFatal("Sequences too big. Try 'supermatcher'"); len = lena*lenb; if(len>maxarr) { ajDebug("merger: resize path, len to %d (%d * $d)\n", len, lena, lenb); stlen = (size_t) len; AJCRESIZE(path,stlen); AJCRESIZE(compass,stlen); maxarr=len; } p = ajSeqGetSeqC(a); q = ajSeqGetSeqC(b); ajStrAssignC(&m,""); ajStrAssignC(&n,""); score = embAlignPathCalc(p,q,lena,lenb,gapopen,gapextend,path,sub,cvt, compass, ajFalse); /*score = embAlignScoreNWMatrix(path,compass,gapopen,gapextend, a,b,lena,lenb,sub,cvt, &start1,&start2);*/ embAlignWalkNWMatrix(path,a,b,&m,&n,lena,lenb, &start1,&start2,gapopen, gapextend,compass); /* ** now construct the merged sequence, uppercase the bits of the two ** input sequences which are used in the merger */ merger_Merge(align, &merged,p,q,m,n,start1,start2, ajSeqGetNameC(a),ajSeqGetNameC(b)); embAlignReportGlobal(align, a, b, m, n, start1, start2, gapopen, gapextend, score, matrix, begina, beginb); ajAlignWrite(align); ajAlignReset(align); /* write the merged sequence */ ajSeqAssignSeqS(a, merged); ajSeqoutWriteSeq(seqout, a); ajSeqoutClose(seqout); ajSeqoutDel(&seqout); ajSeqDel(&a); ajSeqDel(&b); ajAlignClose(align); ajAlignDel(&align); ajStrDel(&merged); AJFREE(compass); AJFREE(path); ajStrDel(&n); ajStrDel(&m); embExit(); return 0; }
int main(int argc, char *argv[]) { embInitPV("goligomersearch", argc, argv, "GEMBASSY", "1.0.3"); AjPSeqall seqall; AjPSeq seq; AjPStr inseq = NULL; AjPStr oligomer = NULL; AjPStr restid = NULL; AjPStr seqid = NULL; AjPStr base = NULL; AjPStr url = NULL; AjPStr _return = NULL; AjPStr tmpname = NULL; AjPSeqout tmpout = NULL; AjPFilebuff tmp = NULL; AjPStr line = NULL; AjPFile outfile = NULL; seqall = ajAcdGetSeqall("sequence"); oligomer = ajAcdGetString("oligomer"); _return = ajAcdGetSelectSingle("return"); outfile = ajAcdGetOutfile("outfile"); base = ajStrNewC("rest.g-language.org"); gAssignUniqueName(&tmpname); ajStrAppendC(&tmpname, ".fasta"); while(ajSeqallNext(seqall, &seq)) { inseq = NULL; 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/oligomer_search/%S/return=%S", base, restid, oligomer, _return); if(!gFilebuffURLS(url, &tmp)) { ajDie("Failed to download result from:\n%S\n", url); } ajBuffreadLine(tmp, &line); ajStrRemoveSetC(&line, "\n"); ajFmtPrintF(outfile, "Sequence: %S Oligomer: %S Return: %S\n", seqid, oligomer, line); ajStrDel(&url); ajStrDel(&restid); ajStrDel(&seqid); ajStrDel(&inseq); } ajFileClose(&outfile); ajSeqallDel(&seqall); ajSeqDel(&seq); ajStrDel(&base); ajStrDel(&oligomer); embExit(); return 0; }
int main(int argc, char **argv) { AjPSeqset seqset = NULL; AjPStr cl = NULL; AjPSeqout seqout = NULL; float cutoff = 0.; AjBool best = ajFalse; AjBool gff = ajFalse; AjBool two = ajFalse; AjBool kinase = ajFalse; AjPStr rsd = NULL; AjBool addseq = ajFalse; AjBool plot = ajFalse; const AjPStr ofn = NULL; AjPStr fn = NULL; AjPStr stmp = NULL; AjPFile outf = NULL; embInitPV("enetphos", argc, argv, "CBSTOOLS", VERSION); seqset = ajAcdGetSeqset("sequence"); outf = ajAcdGetOutfile("outfile"); plot = ajAcdGetBoolean("plot"); best = ajAcdGetBoolean("best"); gff = ajAcdGetBoolean("gff"); two = ajAcdGetBoolean("two"); kinase = ajAcdGetBoolean("kinase"); addseq = ajAcdGetBoolean("addseq"); cutoff = ajAcdGetFloat("cutoff"); rsd = ajAcdGetListSingle("residue"); cl = ajStrNewC("netphos "); fn = ajStrNew(); stmp = ajStrNew(); ajFilenameSetTempname(&fn); seqout = ajSeqoutNew(); if(!ajSeqoutOpenFilename(seqout, fn)) ajFatal("Cannot open temporary file %S",fn); ajSeqoutSetFormatC(seqout, "fasta"); ajSeqoutWriteSet(seqout,seqset); ajSeqoutClose(seqout); if(ajStrMatchC(rsd,"serine")) ajStrAppendC(&cl," -s"); else if(ajStrMatchC(rsd,"threonine")) ajStrAppendC(&cl," -t"); else if(ajStrMatchC(rsd,"tyrosine")) ajStrAppendC(&cl," -y"); if(plot) ajStrAppendC(&cl," -g"); if(two) ajStrAppendC(&cl," -2"); if(best) ajStrAppendC(&cl," -b"); if(gff) ajStrAppendC(&cl," -f gff"); if(kinase) ajStrAppendC(&cl," -k"); if(addseq) ajStrAppendC(&cl," -S"); ajFmtPrintS(&stmp," -c %f",cutoff); ajStrAppendS(&cl,stmp); ajFmtPrintS(&stmp," %S",fn); ajStrAppendS(&cl,stmp); ofn = ajFileGetNameS(outf); ajFmtPrintS(&stmp," > %S",ofn); ajStrAppendS(&cl,stmp); ajFileClose(&outf); #if 0 ajFmtPrint("%S\n",cl); #endif #if 1 if(system(ajStrGetPtr(cl)) == -1) ajFatal("Command %S failed",cl); #endif ajSysFileUnlink(fn); ajStrDel(&cl); ajStrDel(&fn); ajStrDel(&stmp); ajStrDel(&rsd); ajSeqoutDel(&seqout); ajSeqsetDel(&seqset); embExit(); return 0; }
int main(int argc, char *argv[]) { embInitPV("greporiter", 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; AjBool oriloc = 0; AjBool gcskew = 0; AjBool dbonly = 0; ajint difthreshold = 0; AjPFile outf = NULL; AjPFile tmpfile = NULL; AjPStr tmpname = NULL; AjPStr fstname = NULL; AjPFilebuff tmp = NULL; AjPStr line = NULL; AjPSeqout tmpout = NULL; AjPRegexp regex; AjPStr ori = NULL; AjPStr ter = NULL; seqall = ajAcdGetSeqall("sequence"); difthreshold = ajAcdGetInt("difthreshold"); oriloc = ajAcdGetBoolean("oriloc"); gcskew = ajAcdGetBoolean("gcskew"); dbonly = ajAcdGetBoolean("dbonly"); accid = ajAcdGetBoolean("accid"); outf = ajAcdGetOutfile("outfile"); base = ajStrNewC("rest.g-language.org"); gAssignUniqueName(&tmpname); gAssignUniqueName(&fstname); ajStrAppendC(&fstname, ".fasta"); while(ajSeqallNext(seqall, &seq)) { inseq = ajStrNew(); tmpout = ajSeqoutNew(); if(!accid) { if(gFormatGenbank(seq, &inseq)) { tmpfile = ajFileNewOutNameS(tmpname); if(!tmpfile) { ajDie("Output file (%S) open error\n", tmpname); } ajFmtPrintF(tmpfile, "%S", inseq); ajFileClose(&tmpfile); ajFmtPrintS(&url, "http://%S/upload/upl.pl", base); gFilePostSS(url, tmpname, &restid); ajStrDel(&url); ajSysFileUnlinkS(tmpname); } else { if(!ajSeqoutOpenFilename(tmpout, fstname)) { embExitBad(); } ajSeqoutSetFormatS(tmpout,ajStrNewC("fasta")); ajSeqoutWriteSeq(tmpout, seq); ajSeqoutClose(tmpout); ajSeqoutDel(&tmpout); ajFmtPrintS(&url, "http://%S/upload/upl.pl", base); gFilePostSS(url, fstname, &restid); ajStrDel(&url); ajSysFileUnlinkS(fstname); } } 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/rep_ori_ter/oriloc=%d/gcskew=%d/" "difthreshold=%d/dbonly=%d/", base, restid, oriloc, gcskew, difthreshold, dbonly); if(!gFilebuffURLS(url, &tmp)) { ajDie("Failed to download result from:\n%S\n", url); } ajBuffreadLine(tmp, &line); regex = ajRegCompC("([0-9]+),([0-9]+)"); if(ajRegExec(regex, line)) { if(ajRegSubI(regex, 1, &ori), ajRegSubI(regex, 2, &ter)) { ajFmtPrint("%S Origin: %S Terminus %S\n", seqid, ori, ter); } } ajStrDel(&url); ajStrDel(&restid); ajStrDel(&seqid); ajStrDel(&inseq); } ajFileClose(&outf); ajSeqallDel(&seqall); ajSeqDel(&seq); ajStrDel(&base); embExit(); return 0; }
int main(int argc, char **argv) { AjPSeqset seqset = NULL; AjPStr cl = NULL; AjPSeqout seqout = NULL; AjBool full = ajFalse; AjPStr fn = NULL; AjPStr stmp = NULL; AjPStr outfname = NULL; embInitPV("echlorop", argc, argv, "CBSTOOLS", VERSION); seqset = ajAcdGetSeqset("sequence"); outfname= ajAcdGetOutfileName("outfile"); full = ajAcdGetBoolean("full"); cl = ajStrNewS(ajAcdGetpathC("chlorop")); fn = ajStrNew(); stmp = ajStrNew(); ajFilenameSetTempname(&fn); seqout = ajSeqoutNew(); if(!ajSeqoutOpenFilename(seqout, fn)) ajFatal("Cannot open temporary file %S",fn); ajSeqoutSetFormatC(seqout, "fasta"); ajSeqoutWriteSet(seqout,seqset); ajSeqoutClose(seqout); if(full) ajStrAppendC(&cl," -F"); ajFmtPrintS(&stmp," %S",fn); ajStrAppendS(&cl,stmp); #if 0 ajFmtPrint("%S\n",cl); #endif #if 1 ajSysExecOutnameAppendS(cl, outfname); #endif ajSysFileUnlinkS(fn); ajStrDel(&cl); ajStrDel(&fn); ajStrDel(&stmp); ajSeqoutDel(&seqout); ajSeqsetDel(&seqset); ajStrDel(&outfname); embExit(); return 0; }
int main(int argc, char *argv[]) { embInitPV("gseqinfo", argc, argv, "GEMBASSY", "1.0.3"); AjPSeqall seqall; AjPSeq seq; AjPStr inseq = NULL; AjPStr ori = NULL; AjPStr ter = NULL; AjPStr restid = NULL; AjPStr seqid = NULL; AjPStr base = NULL; AjPStr url = NULL; AjPStr tmpname = NULL; AjPSeqout tmpout = NULL; AjPFile outf = NULL; seqall = ajAcdGetSeqall("sequence"); outf = ajAcdGetOutfile("outfile"); 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/seqinfo/", base, restid); ajFmtPrintF(outf, "Sequence: %S\n", seqid); if(!gFileOutURLS(url, &outf)) { ajDie("Failed to download result from:\n%S\n", url); } ajStrDel(&url); ajStrDel(&restid); ajStrDel(&seqid); ajStrDel(&inseq); } ajFileClose(&outf); ajSeqallDel(&seqall); ajSeqDel(&seq); ajStrDel(&base); embExit(); return 0; }
int main(int argc, char **argv) { AjPSeqall seqall; AjPSeqout seqout; AjPSeq seq; ajint size; ajint overlap; ajint len; ajint pos; AjBool addover; AjBool feature; AjPStr outseq_name = ajStrNew(); ajint start; ajint end; embInit("splitter", argc, argv); seqout = ajAcdGetSeqoutall("outseq"); seqall = ajAcdGetSeqall("sequence"); size = ajAcdGetInt("size"); overlap = ajAcdGetInt("overlap"); addover = ajAcdGetBoolean("addoverlap"); feature = ajAcdGetBoolean("feature"); while(ajSeqallNext(seqall, &seq)) { ajSeqTrim(seq); len = ajSeqGetLen(seq); pos = 0; ajStrAssignC(&outseq_name, ""); if (!addover) { while(pos+size <= len-1) { start = pos; end = pos+size-1; splitter_MakeSubSeqName (&outseq_name, seq, start, end); splitter_ProcessChunk (seqout, seq, start, end, outseq_name, feature); pos += size-overlap; } } else { while(pos+size+overlap < len-1) { start = pos; end = pos+size+overlap-1; splitter_MakeSubSeqName (&outseq_name, seq, start, end); splitter_ProcessChunk (seqout, seq, start, end, outseq_name, feature); pos += size; } } splitter_MakeSubSeqName(&outseq_name, seq, pos, len-1); splitter_ProcessChunk (seqout, seq, pos, len-1, outseq_name, feature); } ajSeqoutClose(seqout); ajSeqallDel(&seqall); ajSeqoutDel(&seqout); ajSeqDel(&seq); ajStrDel(&outseq_name); embExit(); return 0; }
int main(int argc, char *argv[]) { embInitPV("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) { /* ACD data item variables */ AjPSeqset dataset = NULL; AjPFile bfile = NULL; AjPFile plib = NULL; AjPStr mod = NULL; ajint nmotifs = 0; AjBool text = ajFalse; AjPStr prior = NULL; float evt = 0.0; ajint nsites = 0; ajint minsites = 0; ajint maxsites = 0; float wnsites = 0.0; ajint w = 0; ajint minw = 0; ajint maxw = 0; AjBool nomatrim = ajFalse; ajint wg = 0; ajint ws = 0; AjBool noendgaps = ajFalse; AjBool revcomp = ajFalse; AjBool pal = ajFalse; AjBool nostatus = ajFalse; ajint maxiter = 0; float distance = 0.0; float b = 0.0; float spfuzz = 0.0; AjPStr spmap = NULL; AjPStr cons = NULL; ajint maxsize = 0; ajint p = 0; ajint time = 0; AjPStr sf = NULL; ajint heapsize = 64; AjBool xbranch = ajFalse; AjBool wbranch = ajFalse; ajint bfactor = 0; AjPFile outtext = NULL; /* Housekeeping variables */ AjPStr cmd = NULL; AjPStr ssname = NULL; AjPSeqout outseq = NULL; AjPStr tmp = NULL; char option; /* ACD file processing */ embInitPV("ememetext",argc,argv,"MEME",VERSION); dataset = ajAcdGetSeqset("dataset"); bfile = ajAcdGetInfile("bfile"); plib = ajAcdGetInfile("plibfile"); mod = ajAcdGetSelectSingle("mod"); nmotifs = ajAcdGetInt("nmotifs"); text = ajAcdGetBoolean("text"); prior = ajAcdGetSelectSingle("prior"); evt = ajAcdGetFloat("evt"); nsites = ajAcdGetInt("nsites"); minsites = ajAcdGetInt("minsites"); maxsites = ajAcdGetInt("maxsites"); wnsites = ajAcdGetFloat("wnsites"); w = ajAcdGetInt("w"); minw = ajAcdGetInt("minw"); maxw = ajAcdGetInt("maxw"); nomatrim = ajAcdGetBoolean("nomatrim"); wg = ajAcdGetInt("wg"); ws = ajAcdGetInt("ws"); noendgaps = ajAcdGetBoolean("noendgaps"); revcomp = ajAcdGetBoolean("revcomp"); pal = ajAcdGetBoolean("pal"); nostatus = ajAcdGetBoolean("nostatus"); maxiter = ajAcdGetInt("maxiter"); distance = ajAcdGetFloat("distance"); b = ajAcdGetFloat("b"); spfuzz = ajAcdGetFloat("spfuzz"); spmap = ajAcdGetSelectSingle("spmap"); cons = ajAcdGetString("cons"); maxsize = ajAcdGetInt("maxsize"); p = ajAcdGetInt("p"); time = ajAcdGetInt("time"); sf = ajAcdGetString("sf"); heapsize = ajAcdGetInt("heapsize"); xbranch = ajAcdGetBoolean("xbranch"); wbranch = ajAcdGetBoolean("wbranch"); bfactor = ajAcdGetInt("bfactor"); outtext = ajAcdGetOutfile("outtext"); outseq = ajAcdGetSeqoutset("outseq"); /* MAIN APPLICATION CODE */ /* 1. Housekeeping */ cmd = ajStrNew(); tmp = ajStrNew(); /* 2. Re-write dataset to a temporary file in a format (fasta) MEME ** can understand. ** Can't just pass the name of dataset to MEME as the name provided ** might be a USA which MEME would not understand. */ ssname = ajStrNewS(ajFileGetNameS(outseq->File)); ajSeqoutSetFormatC(outseq, "fasta"); ajSeqoutWriteSet(outseq, dataset); ajSeqoutClose(outseq); ajSeqoutDel(&outseq); /* 3. Build ememe command line */ /* Command line is built in this order: i. Application name. ii. Original MEME options (in order they appear in ACD file) iii.Original MEME options (that don't appear in ACD file) iv. EMBASSY MEME new qualifiers and parameters. */ ajStrAssignS(&cmd, ajAcdGetpathC("meme")); ajFmtPrintAppS(&cmd, " %S", ssname); if(bfile) ajFmtPrintAppS(&cmd, " -bfile %s ", ajFileGetNameC(bfile)); if(plib) ajFmtPrintAppS(&cmd, " -plib %s ", ajFileGetNameC(plib)); option = ajStrGetCharFirst(mod); if(option == 'o') ajStrAppendC(&cmd, " -mod oops "); else if(option == 'z') ajStrAppendC(&cmd, " -mod zoops "); else if(option == 'a') ajStrAppendC(&cmd, " -mod anr "); if(nmotifs != 1) ajFmtPrintAppS(&cmd, " -nmotifs %d ", nmotifs); if(text) ajFmtPrintAppS(&cmd, " -text "); ajFmtPrintAppS(&cmd, " -prior %S ", prior); if(evt != -1) ajFmtPrintAppS(&cmd, " -evt %f ", evt); if(nsites != -1) ajFmtPrintAppS(&cmd, " -nsites %d ", nsites); else { if(minsites != -1) ajFmtPrintAppS(&cmd, " -minsites %d ", minsites); if(maxsites != -1) ajFmtPrintAppS(&cmd, " -maxsites %d ", maxsites); } if(wnsites < 0.7999 || wnsites > .8001) ajFmtPrintAppS(&cmd, " -wnsites %f ", wnsites); if(w != -1) ajFmtPrintAppS(&cmd, " -w %d ", w); if(minw != 8) ajFmtPrintAppS(&cmd, " -minw %d ", minw); if(maxw != 50) ajFmtPrintAppS(&cmd, " -maxw %d ", maxw); if(nomatrim) ajFmtPrintAppS(&cmd, " -nomatrim "); if(wg != 11) ajFmtPrintAppS(&cmd, " -wg %d ", wg); if(ws != 1) ajFmtPrintAppS(&cmd, " -ws %d ", ws); if(noendgaps) ajFmtPrintAppS(&cmd, " -noendgaps "); if(revcomp) ajFmtPrintAppS(&cmd, " -revcomp "); if(pal && ajSeqsetIsNuc(dataset)) ajFmtPrintAppS(&cmd, " -pal "); if(nostatus) ajFmtPrintAppS(&cmd, " -nostatus "); if(maxiter != 50) ajFmtPrintAppS(&cmd, " -maxiter %d ", maxiter); if(distance < 0.00099 || distance > 0.00101) ajFmtPrintAppS(&cmd, " -distance %f ", distance); if(b != -1) ajFmtPrintAppS(&cmd, " -b %f ", b); if(spfuzz != -1) ajFmtPrintAppS(&cmd, " -spfuzz %f ", spfuzz); if(!ajStrMatchC(spmap,"default")) ajFmtPrintAppS(&cmd, " -spmap %S ", spmap); if(MAJSTRGETLEN(cons)) ajFmtPrintAppS(&cmd, "-cons %S", cons); if(maxsize != -1) ajFmtPrintAppS(&cmd, " -maxsize %d ", maxsize); if(p > 0) ajFmtPrintAppS(&cmd, " -p %d ", p); if(time > 0) ajFmtPrintAppS(&cmd, " -time %d ", time); if(MAJSTRGETLEN(sf)) ajFmtPrintAppS(&cmd, " -sf %S", sf); if(heapsize != 64) ajFmtPrintAppS(&cmd, " -heapsize %d ", heapsize); if(xbranch) ajFmtPrintAppS(&cmd, " -x_branch"); if(wbranch) ajFmtPrintAppS(&cmd, " -w_branch"); if(bfactor != 3) ajFmtPrintAppS(&cmd, " -bfactor %d ", bfactor); if(ajSeqsetIsProt(dataset)) ajFmtPrintAppS(&cmd, "-protein "); else ajFmtPrintAppS(&cmd, "-dna "); ajFmtPrintAppS(&cmd, " -text"); ajFmtPrintAppS(&cmd, " > %S ", ajFileGetNameS(outtext)); /* 4. Close files from ACD before calling meme */ ajFileClose(&bfile); ajFileClose(&plib); /* 5. Call meme */ /* ajFmtPrint("\n%S\n", cmd); */ system(ajStrGetPtr(cmd)); /* 6. Exit cleanly */ ajSeqsetDel(&dataset); ajStrDel(&cons); ajStrDel(&sf); ajStrDel(&mod); ajStrDel(&prior); ajStrDel(&spmap); ajStrDel(&cmd); ajStrDel(&ssname); ajStrDel(&tmp); ajFileClose(&bfile); ajFileClose(&plib); ajFileClose(&outtext); ajSeqoutDel(&outseq); 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) { AjPSeqset seqset = NULL; AjPStr cl = NULL; AjPSeqout seqout = NULL; AjBool pc = ajFalse; AjBool sigp = ajFalse; AjBool plot = ajFalse; const AjPStr ofn = NULL; AjPStr fn = NULL; AjPStr stmp = NULL; AjPFile outf = NULL; embInitPV("eprop", argc, argv, "CBSTOOLS", VERSION); seqset = ajAcdGetSeqset("sequence"); outf = ajAcdGetOutfile("outfile"); plot = ajAcdGetBoolean("plot"); pc = ajAcdGetBoolean("pcprediction"); sigp = ajAcdGetBoolean("signalp"); cl = ajStrNewC("prop "); fn = ajStrNew(); stmp = ajStrNew(); ajFilenameSetTempname(&fn); seqout = ajSeqoutNew(); if(!ajSeqoutOpenFilename(seqout, fn)) ajFatal("Cannot open temporary file %S",fn); ajSeqoutSetFormatC(seqout, "fasta"); ajSeqoutWriteSet(seqout,seqset); ajSeqoutClose(seqout); if(plot) ajStrAppendC(&cl," -g"); if(pc) ajStrAppendC(&cl," -p"); if(sigp) ajStrAppendC(&cl," -s"); ajFmtPrintS(&stmp," %S",fn); ajStrAppendS(&cl,stmp); ofn = ajFileGetNameS(outf); ajFmtPrintS(&stmp," > %S",ofn); ajStrAppendS(&cl,stmp); ajFileClose(&outf); #if 0 ajFmtPrint("%S\n",cl); #endif #if 1 if(system(ajStrGetPtr(cl)) == -1) ajFatal("Command %S failed",cl); #endif ajSysFileUnlink(fn); ajStrDel(&cl); ajStrDel(&fn); ajStrDel(&stmp); ajSeqoutDel(&seqout); ajSeqsetDel(&seqset); embExit(); return 0; }
int main(int argc, char **argv) { AjPSeqall seqall; AjPSeqout seqout; AjPSeq seq; ajint before; ajint after; AjBool join; AjPFeattable featab; AjBool featinname; AjPStr describe; /* feature filter criteria */ AjPStr source = NULL; AjPStr feattype = NULL; ajint sense; float minscore; float maxscore; AjPStr tag = NULL; AjPStr value = NULL; AjBool testscore = AJFALSE; embInit("extractfeat", argc, argv); seqall = ajAcdGetSeqall("sequence"); seqout = ajAcdGetSeqout("outseq"); before = ajAcdGetInt("before"); after = ajAcdGetInt("after"); join = ajAcdGetBoolean("join"); featinname = ajAcdGetBoolean("featinname"); describe = ajAcdGetString("describe"); /* feature filter criteria */ source = ajAcdGetString("source"); feattype = ajAcdGetString("type"); sense = ajAcdGetInt("sense"); minscore = ajAcdGetFloat("minscore"); maxscore = ajAcdGetFloat("maxscore"); tag = ajAcdGetString("tag"); value = ajAcdGetString("value"); testscore = (minscore || maxscore); if(minscore && !maxscore) if(minscore > maxscore) maxscore = minscore; if(!minscore && maxscore) if(minscore > maxscore) minscore = maxscore; while(ajSeqallNext(seqall, &seq)) { /* get the feature table of the sequence */ featab = ajSeqGetFeatCopy(seq); /* delete features in the table that don't match our criteria */ extractfeat_FeatureFilter(featab, source, feattype, sense, testscore, minscore, maxscore, tag, value); /* extract the features */ extractfeat_FeatSeqExtract(seq, seqout, featab, before, after, join, featinname, describe); ajFeattableDel(&featab); } ajSeqoutClose(seqout); ajSeqoutDel(&seqout); ajSeqallDel(&seqall); ajSeqDel(&seq); ajStrDel(&describe); ajStrDel(&source); ajStrDel(&feattype); ajStrDel(&tag); ajStrDel(&value); embExit(); return 0; }
int main(int argc, char **argv) { AjPSeqout outseq = NULL; AjPList list = NULL; AjPSeq seq = NULL; AjPStr insert = NULL; AjPStr seqstr = NULL; AjPStr* seqr = NULL; AjPFile data = NULL; ajint start = 0; ajint length = 0; ajint amount = 0; ajint scmax = 0; ajint extra = 0; embInit("makeprotseq", argc, argv); data = ajAcdGetInfile("pepstatsfile"); insert = ajAcdGetString("insert"); start = ajAcdGetInt("start"); length = ajAcdGetInt("length"); amount = ajAcdGetInt("amount"); outseq = ajAcdGetSeqoutall("outseq"); list = ajListstrNew(); /* this is checked by acd if(amount <=0 || length <= 0) ajFatal("Amount or length is 0 or less. " "Unable to create any sequences"); */ /* if insert, make sure sequence is large enough */ if(ajStrGetLen(insert)) { length -= ajStrGetLen(insert); /* start= start <= 1 ? 0 : --start; */ /* checked in acd */ start--; if(length <= 0) ajFatal("Sequence smaller than inserted part. " "Unable to create sequences."); } /* make the list of AjPStr to be used in sequence creation */ if(data) { ajDebug("Distribution datafile '%s' given checking type\n", ajFileGetPrintnameC(data)); seqstr = ajStrNew(); ajReadlineTrim(data,&seqstr); if(ajStrFindC(seqstr,"PEPSTATS") == 0) { makeprotseq_parse_pepstats(&list,data); } else { ajWarn("Not pepstats file. Making completely random sequences."); makeprotseq_default_chars(&list); } ajStrDel(&seqstr); ajFileClose(&data); } else makeprotseq_default_chars(&list); /* if insert, make sure type is correct */ /* typecheking code is not working, uncomment and test after it is if(ajStrGetLen(insert)) { seqstr = ajStrNew(); if(prot) ajStrAssignC(&seqstr,"pureprotein"); if(!ajSeqTypeCheckS(&insert,seqstr)) ajFatal("Insert not the same sequence type as sequence itself."); ajStrDel(&seqstr); } */ /* array allows fast creation of a sequences */ scmax = (ajuint) ajListstrToarray(list,&seqr); if(!scmax) ajFatal("No strings in list. No characters to make the sequence."); ajDebug("Distribution array done.\nscmax '%d', extra '%d', first '%S'\n", scmax,extra,seqr[0]); ajRandomSeed(); while(amount-- > 0) { seqstr = makeprotseq_random_sequence(seqr,scmax,length); if(ajStrGetLen(insert)) ajStrInsertS(&seqstr,start,insert); ajStrFmtLower(&seqstr); seq = ajSeqNew(); ajSeqAssignSeqS(seq, seqstr); ajSeqSetProt(seq); ajSeqoutWriteSeq(outseq, seq); ajSeqDel(&seq); ajStrDel(&seqstr); } ajSeqoutClose(outseq); ajSeqoutDel(&outseq); ajListstrFreeData(&list); ajStrDel(&insert); AJFREE(seqr); embExit(); return 0; }
int main(int argc, char **argv) { // initialize EMBASSY info embInitPV("kweblogo", argc, argv, "KBWS", "1.0.9"); // soap driver and parameter object struct soap soap; struct ns1__weblogoInputParams params; char* jobid; AjPSeqall seqall; AjPSeq seq; AjPStr substr; AjPStr inseq = NULL; // get input sequence seqall= ajAcdGetSeqall("seqall"); // get/set parameters params.format = ajCharNewS(ajAcdGetString("format")); AjPStr tmp= NULL; AjPStr tmpFileName= NULL; AjPSeqout fil_file; AjPStr line= NULL; /* if "AjPStr line; -> ajReadline is not success!" */ AjPStr sizestr= NULL; ajint thissize; ajint nb= 0; AjBool are_prot= ajFalse; ajint size= 0; AjPFile infile; AjPFile goutf; AjPStr goutfile; goutfile= ajAcdGetString("goutfile"); tmp= ajStrNewC("fasta"); fil_file= ajSeqoutNew(); tmpFileName= getUniqueFileName(); if(!ajSeqoutOpenFilename(fil_file, tmpFileName)) { embExitBad(); } ajSeqoutSetFormatS(fil_file, tmp); while (ajSeqallNext(seqall, &seq)) { if (!nb) { are_prot = ajSeqIsProt(seq); } ajSeqoutWriteSeq(fil_file, seq); ++nb; } ajSeqoutClose(fil_file); ajSeqoutDel(&fil_file); if (nb < 2) { ajFatal("Multiple alignments need at least two sequences"); } infile = ajFileNewInNameS(tmpFileName); while (ajReadline(infile, &line)) { ajStrAppendS(&inseq,line); ajStrAppendC(&inseq,"\n"); } soap_init(&soap); char* in0; in0= ajCharNewS(inseq); if (soap_call_ns1__runWeblogo( &soap, NULL, NULL, in0, ¶ms, &jobid) == SOAP_OK) { } else { soap_print_fault(&soap, stderr); } int check= 0; while (check == 0 ) { if (soap_call_ns1__checkStatus(&soap, NULL, NULL, jobid, &check) == SOAP_OK) { } else { soap_print_fault(&soap, stderr); } sleep(3); } char* image_url; if (soap_call_ns1__getResult(&soap, NULL, NULL, jobid, &image_url) == SOAP_OK) { goutf= ajFileNewOutNameS(goutfile); if (!goutf) { // can not open image output file ajFmtError("Problem writing out image file"); embExitBad(); } if (!gHttpGetBinC(image_url, &goutf)) { // can not download image file ajFmtError("Problem downloading image file"); embExitBad(); } } else { soap_print_fault(&soap, stderr); } // delete temporary multi-fasta sequence file ajSysFileUnlinkS(tmpFileName); // destruct SOAP driver soap_destroy(&soap); soap_end(&soap); soap_done(&soap); // destruct EMBOSS object ajSeqallDel(&seqall); ajSeqDel(&seq); ajStrDel(&substr); // exit embExit(); return 0; }
int main(int argc, char **argv) { /* ACD data item variables */ AjPFile hmmfile = NULL; AjPSeqset seqfile = NULL; AjPFile mapali = NULL; AjPFile withali = NULL; AjPAlign o = NULL; AjBool m = ajFalse; AjBool q = ajFalse; /* Housekeeping variables */ AjPStr cmd = NULL; AjPStr fmt = NULL; AjBool fmtok = ajFalse; AjPStr rnd = NULL; AjPSeqout rndo = NULL; /* ACD file processing */ embInitPV("ehmmalign",argc,argv,"HMMERNEW",VERSION); hmmfile = ajAcdGetInfile("hmmfile"); seqfile = ajAcdGetSeqset("seqfile"); mapali = ajAcdGetInfile("mapali"); withali = ajAcdGetInfile("withali"); o = ajAcdGetAlign("o"); m = ajAcdGetBoolean("m"); q = ajAcdGetBoolean("q"); /* MAIN APPLICATION CODE */ /* 1. Housekeeping */ cmd = ajStrNew(); fmt = ajStrNew(); rnd = ajStrNew(); /* 2. Re-write seqfile to a temporary file in a format (fasta) HMMER can understand. We cannot just pass the name of seqfile to HMMER as the name provided might be a USA which HMMER would not understand. */ ajFilenameSetTempname(&rnd); rndo = ajSeqoutNew(); if(!ajSeqoutOpenFilename(rndo, rnd)) ajFatal("Terminal ajSeqFileNewOut failure. Email EMBOSS helpdesk!\n"); ajSeqoutSetFormatC(rndo, "fasta"); ajSeqoutWriteSet(rndo, seqfile); ajSeqoutClose(rndo); ajSeqoutDel(&rndo); /* 3. Build hmmalign command line */ /* Command line is built in this order: i. Application name. ii. HMMER 'options' (in order they appear in ACD file) iii.HMMER 'options' (that don't appear in ACD file) iv. HMMER & new parameters. */ ajFmtPrintS(&cmd, "%S ", ajAcdGetpathC("hmmalign")); if(mapali) ajFmtPrintAppS(&cmd, " --mapali %s ", ajFileGetNameC(mapali)); if(withali) ajFmtPrintAppS(&cmd, " --withali %s ", ajFileGetNameC(withali)); if(m) ajStrAppendC(&cmd, " -m "); if(q) ajStrAppendC(&cmd, " -q "); /* Ensure output alignment is in user-specified format. */ fmtok=ajTrue; ajStrAssignS(&fmt, ajAlignGetFormat(o)); /* fasta and a2m are identical formats. */ if(ajStrMatchC(fmt, "fasta")) ajStrAssignC(&fmt, "A2M"); else if(ajStrMatchC(fmt, "a2m")) ajStrAssignC(&fmt, "A2M"); else if(ajStrMatchC(fmt, "msf")) ajStrAssignC(&fmt, "MSF"); else if(ajStrMatchC(fmt, "phylip")) ajStrAssignC(&fmt, "PHYLIP"); /* hmmer also supports stockholm, SELEX & Clustal output, EMBOSS does not. EMBOSS supports unknown/multiple/simple and srs output, hmmer does not. */ else fmtok = ajFalse; if(!fmtok) { /* This could be replaced with code to reformat the file. */ ajWarn("Specified output alignment format ('o' ACD option) is " "not understood by HMMER. Using stockholm format instead."); ajStrAssignC(&fmt, "Stockholm"); } /* rnd is the name of the rewritten seqfile. MUST specify FASTA format explicitly. */ ajFmtPrintAppS(&cmd, " --informat FASTA --outformat %S -o %s %s %S", fmt, ajAlignGetFilename(o), ajFileGetNameC(hmmfile), rnd); /* 4. Close ACD files */ ajFileClose(&hmmfile); ajSeqsetDel(&seqfile); ajFileClose(&mapali); ajFileClose(&withali); ajAlignClose(o); ajAlignDel(&o); /* 5. Call hmmalign */ ajFmtPrint("\n%S\n\n", cmd); ajSysExecS(cmd); /* 6. Exit cleanly */ ajSysFileUnlinkS(rnd); ajStrDel(&cmd); ajStrDel(&fmt); ajStrDel(&rnd); embExit(); return 0; }
int main(int argc, char **argv) { embInitPV("kmafft", argc, argv, "KBWS", "1.0.8"); struct soap soap; struct ns1__mafftInputParams params; char* jobid; char* result; AjPSeqall seqall; AjPSeq seq; AjPFile outf; AjPStr substr; AjPStr inseq = NULL; AjPStr strategy; AjPStr outorder; float op; float ep; AjPStr scorematrix; AjBool homologs; AjBool showhomologs; float threshold; AjPStr referenceseq; AjPStr harrplot; strategy = ajAcdGetString("strategy"); outorder = ajAcdGetString("outorder"); op = ajAcdGetFloat("op"); ep = ajAcdGetFloat("ep"); scorematrix = ajAcdGetString("scorematrix"); homologs = ajAcdGetBoolean("homologs"); showhomologs = ajAcdGetBoolean("showhomologs"); threshold = ajAcdGetFloat("threshold"); referenceseq = ajAcdGetString("referenceseq"); harrplot = ajAcdGetString("harrplot"); seqall = ajAcdGetSeqall("seqall"); outf = ajAcdGetOutfile("outfile"); params.strategy = ajCharNewS(strategy); params.outorder = ajCharNewS(outorder); params.op = op; params.ep = ep; params.scorematrix = ajCharNewS(scorematrix); if (homologs) { params.homologs = xsd__boolean__true_; } else { params.homologs = xsd__boolean__false_; } if (showhomologs) { params.showhomologs = xsd__boolean__true_; } else { params.showhomologs = xsd__boolean__false_; } params.threshold = threshold; params.referenceseq = ajCharNewS(referenceseq); params.harrplot = ajCharNewS(harrplot); AjPStr tmp = NULL; AjPStr tmpFileName = NULL; AjPSeqout fil_file; AjPStr line = NULL; /* if "AjPStr line; -> ajReadline is not success!" */ AjPStr sizestr = NULL; ajint thissize; ajint nb = 0; AjBool are_prot = ajFalse; ajint size = 0; AjPFile infile; tmp = ajStrNewC("fasta"); fil_file = ajSeqoutNew(); tmpFileName = getUniqueFileName(); if( !ajSeqoutOpenFilename(fil_file, tmpFileName) ) { embExitBad(); } ajSeqoutSetFormatS(fil_file, tmp); while (ajSeqallNext(seqall, &seq)) { if (!nb) { are_prot = ajSeqIsProt(seq); } ajSeqoutWriteSeq(fil_file, seq); ++nb; } ajSeqoutClose(fil_file); ajSeqoutDel(&fil_file); if (nb < 2) { ajFatal("Multiple alignments need at least two sequences"); } infile = ajFileNewInNameS(tmpFileName); while (ajReadline(infile, &line)) { ajStrAppendS(&inseq,line); ajStrAppendC(&inseq,"\n"); } soap_init(&soap); char* in0; in0 = ajCharNewS(inseq); if ( soap_call_ns1__runMafft( &soap, NULL, NULL, in0, ¶ms, &jobid ) == SOAP_OK ) { fprintf(stderr,"Jobid: %s\n",jobid); } else { soap_print_fault(&soap, stderr); } int check = 0; while ( check == 0 ) { if ( soap_call_ns1__checkStatus( &soap, NULL, NULL, jobid, &check ) == SOAP_OK ) { fprintf(stderr,"*"); } else { soap_print_fault(&soap, stderr); } sleep(3); } fprintf(stderr,"\n"); if ( soap_call_ns1__getResult( &soap, NULL, NULL, jobid, &result ) == SOAP_OK ) { substr = ajStrNewC(result); ajFmtPrintF(outf,"%S\n",substr); } else { soap_print_fault(&soap, stderr); } ajSysFileUnlinkS(tmpFileName); soap_destroy(&soap); soap_end(&soap); soap_done(&soap); ajFileClose(&outf); ajSeqallDel(&seqall); ajSeqDel(&seq); ajStrDel(&substr); embExit(); return 0; }
int main(int argc, char **argv) { AjPSeqout seqout; AjPSeq seq; AjPStr name = NULL; AjPStr desc = NULL; AjPStr temp = NULL; AjBool append; embInit("descseq", argc, argv); seqout = ajAcdGetSeqout("outseq"); seq = ajAcdGetSeq("sequence"); append = ajAcdGetBoolean("append"); name = ajAcdGetString("name"); desc = ajAcdGetString("description"); /* if appending, then do this */ if(append) { /* is there a name? */ if(ajStrGetLen(name)) { ajStrAssignS(&temp, ajSeqGetNameS(seq)); ajStrAppendS(&temp, name); ajSeqAssignNameS(seq, temp); } /* is there a description? */ if(ajStrGetLen(desc)) { ajStrAssignS(&temp, ajSeqGetDescS(seq)); ajStrAppendS(&temp, desc); ajSeqAssignDescS(seq, temp); } /* otherwise, just overwrite the existing values */ } else { /* is there a name? */ if(ajStrGetLen(name)) ajSeqAssignNameS(seq, name); /* is there a description? */ if(ajStrGetLen(desc)) ajSeqAssignDescS(seq, desc); } ajSeqoutWriteSeq(seqout, seq); ajSeqoutClose(seqout); ajSeqDel(&seq); ajSeqoutDel(&seqout); ajStrDel(&name); ajStrDel(&desc); ajStrDel(&temp); embExit(); return 0; }
int main(int argc, char **argv) { embInitPV("kdnapenny", argc, argv, "KBWS", "1.0.8"); struct soap soap; char* jobid; char* result; AjPSeqall seqall; AjPSeq seq; AjPFile outf; AjPStr substr; AjPStr inseq = NULL; seqall = ajAcdGetSeqall("seqall"); outf = ajAcdGetOutfile("outfile"); AjPStr tmp = NULL; AjPStr tmpFileName = NULL; AjPSeqout fil_file; AjPStr line = NULL; AjPStr sizestr = NULL; ajint thissize = 0; ajint nb = 0; AjBool are_prot = ajFalse; ajint size = 0; AjPFile infile; tmp = ajStrNewC("fasta"); fil_file = ajSeqoutNew(); tmpFileName = getUniqueFileName(); if( !ajSeqoutOpenFilename(fil_file, tmpFileName) ) { embExitBad(); } ajSeqoutSetFormatS(fil_file, tmp); while (ajSeqallNext(seqall, &seq)) { if (!nb) { are_prot = ajSeqIsProt(seq); } ajSeqoutWriteSeq(fil_file, seq); ++nb; } ajSeqoutClose(fil_file); ajSeqoutDel(&fil_file); if (nb < 2) { ajFatal("Multiple alignments need at least two sequences"); } infile = ajFileNewInNameS(tmpFileName); while (ajReadline(infile, &line)) { ajStrAppendS(&inseq,line); ajStrAppendC(&inseq,"\n"); } soap_init(&soap); char* in0; in0 = ajCharNewS(inseq); if ( soap_call_ns1__runDnapenny( &soap, NULL, NULL, in0, &jobid ) == SOAP_OK ) { fprintf(stderr,"Jobid: %s\n",jobid); } else { soap_print_fault(&soap, stderr); } int check = 0; while ( check == 0 ) { if ( soap_call_ns1__checkStatus( &soap, NULL, NULL, jobid, &check ) == SOAP_OK ) { fprintf(stderr,"*"); } else { soap_print_fault(&soap, stderr); } sleep(3); } fprintf(stderr, "\n"); if ( soap_call_ns1__getResult( &soap, NULL, NULL, jobid, &result ) == SOAP_OK ) { substr = ajStrNewC(result); ajFmtPrintF(outf,"%S\n",substr); } else { soap_print_fault(&soap, stderr); } ajSysFileUnlinkS(tmpFileName); soap_destroy(&soap); soap_end(&soap); soap_done(&soap); ajFileClose(&outf); ajSeqallDel(&seqall); ajSeqDel(&seq); ajStrDel(&substr); embExit(); return 0; }
int main(int argc, char **argv) { /* ACD data item variables */ AjPFile hmmfile = NULL; AjPSeqall seqfile = NULL; AjBool nuc = 0; ajint A = 0; float E = 0.0; float T = 0.0; ajint Z = 0; AjBool acc = ajFalse; AjBool compat = ajFalse; ajint cpu = 0; AjBool cutga = ajFalse; AjBool cuttc = ajFalse; AjBool cutnc = ajFalse; float dome = 0.0; float domt = 0.0; AjBool forward = ajFalse; AjBool nulltwo = ajFalse; AjBool pvm = ajFalse; AjBool xnu = ajFalse; AjPStr outname = NULL; /* Housekeeping variables */ AjPStr cmd = NULL; AjPStr rnd = NULL; AjPSeqout rndo = NULL; AjPSeq seq = NULL; /* ACD file processing */ embInitPV("ehmmpfam",argc,argv,"HMMERNEW",VERSION); hmmfile = ajAcdGetInfile("hmmfile"); seqfile = ajAcdGetSeqall("seqfile"); nuc = ajAcdGetBoolean("nuc"); A = ajAcdGetInt("A"); E = ajAcdGetFloat("E"); T = ajAcdGetFloat("T"); Z = ajAcdGetInt("Z"); acc = ajAcdGetBoolean("acc"); compat = ajAcdGetBoolean("compat"); cpu = ajAcdGetInt("cpu"); cutga = ajAcdGetBoolean("cutga"); cuttc = ajAcdGetBoolean("cuttc"); cutnc = ajAcdGetBoolean("cutnc"); dome = ajAcdGetFloat("dome"); domt = ajAcdGetFloat("domt"); forward = ajAcdGetBoolean("forward"); nulltwo = ajAcdGetBoolean("nulltwo"); pvm = ajAcdGetBoolean("pvm"); xnu = ajAcdGetBoolean("xnu"); outname = ajAcdGetOutfileName("outfile"); /* MAIN APPLICATION CODE */ /* 1. Housekeeping */ cmd = ajStrNew(); rnd = ajStrNew(); /* 2. Re-write seqfile to a temporary file in a format (fasta) HMMER can understand. We cannot just pass the name of seqfile to HMMER as the name provided might be a USA which HMMER would not understand. */ ajFilenameSetTempname(&rnd); rndo = ajSeqoutNew(); if(!ajSeqoutOpenFilename(rndo, rnd)) ajFatal("Terminal ajSeqFileNewOut failure. Email EMBOSS helpdesk!\n"); ajSeqoutSetFormatC(rndo, "fasta"); while(ajSeqallNext(seqfile, &seq)) ajSeqoutWriteSeq(rndo, seq); ajSeqoutClose(rndo); ajSeqoutDel(&rndo); /* 2. Build hmmpfam command line */ /* Command line is built in this order: i. Application name. ii. HMMER 'options' (in order they appear in ACD file) iii.HMMER 'options' (that don't appear in ACD file) iv. HMMER & new parameters. */ ajStrAssignS(&cmd, ajAcdGetpathC("hmmpfam")); if(nuc) ajStrAppendC(&cmd, " -n "); ajFmtPrintAppS(&cmd, " -A %d -E %f -T %f -Z %d", A, E, T, Z); if(acc) ajStrAppendC(&cmd, " --acc "); if(compat) ajStrAppendC(&cmd, " --compat "); if(cpu) ajFmtPrintAppS(&cmd, " --cpu %d ", cpu); if(cutga) ajStrAppendC(&cmd, " --cutga "); if(cuttc) ajStrAppendC(&cmd, " --cuttc "); if(cutnc) ajStrAppendC(&cmd, " --cutnc "); ajFmtPrintAppS(&cmd, " --domE %f --domT %f ", dome, domt); if(forward) ajStrAppendC(&cmd, " --forward "); if(nulltwo) ajStrAppendC(&cmd, " --null2 "); if(pvm) ajStrAppendC(&cmd, " --pvm "); if(xnu) ajStrAppendC(&cmd, " --xnu "); /* Note output redirected to outname. rnd is the name of the rewritten seqfile. MUST specify FASTA format explicitly. */ ajFmtPrintAppS(&cmd, " --informat FASTA %s %S", ajFileGetNameC(hmmfile), rnd); /* 3. Close ACD files. */ ajFileClose(&hmmfile); ajSeqallDel(&seqfile); /* 4. Call hmmpfam. Use C system call instead of ajSystem so that redirect in cmd works ok. */ ajFmtPrint("\n%S\n\n", cmd); ajSysExecOutnameAppendS(cmd,outname); /* 5. Exit cleanly */ ajSysFileUnlinkS(rnd); ajStrDel(&cmd); ajStrDel(&rnd); ajStrDel(&outname); embExit(); return 0; }
int main(int argc, char **argv) { /* Variable Declarations */ AjPSeqset seqset = NULL; AjPMatrixf fmat = NULL; float thresh; float threshlow; float threshup; float gapopen; float gapextend; AjPSeqout seqout = NULL; AjPSeqout seqoutred = NULL; AjPStr mode = NULL; ajint moden; ajuint i; /* toggle "feature" from ACD not retrieved ... no need */ const AjPSeq seq = NULL; AjPList list = NULL; /* List for redundancy removal. */ AjPUint keep = NULL; /* 1: Sequence in list was non-redundant, 0: redundant. */ ajuint nseq = 0; /* No. seqs. in list. */ ajint nseqnr = 0; /* No. non-redundant seqs. in list. */ /* ACD File Processing */ embInit("skipredundant", argc, argv); seqset = ajAcdGetSeqset("sequences"); mode = ajAcdGetListSingle("mode"); fmat = ajAcdGetMatrixf("datafile"); thresh = ajAcdGetFloat("threshold"); threshlow = ajAcdGetFloat("minthreshold"); threshup = ajAcdGetFloat("maxthreshold"); gapopen = ajAcdGetFloat("gapopen"); gapextend = ajAcdGetFloat("gapextend"); seqout = ajAcdGetSeqoutall("outseq"); seqoutred = ajAcdGetSeqoutall("redundantoutseq"); /* Application logic */ list = ajListNew(); skipredundant_SeqsetToList(list, seqset); keep = ajUintNew(); ajStrToInt(mode, &moden); if(moden == 1) /* Remove redundancy at a single threshold % sequence similarity */ { if((!embDmxSeqNR(list, &keep, &nseqnr, fmat, gapopen, gapextend, thresh, ajFalse))) ajFatal("embDmxSeqNR unexpected failure!"); } else if (moden == 2) /* 2: Remove redundancy outside a range of acceptable threshold % similarity */ { if((!embDmxSeqNRRange(list, &keep, &nseqnr, fmat, gapopen, gapextend, threshlow, threshup, ajFalse))) ajFatal("embDmxSeqNRRange unexpected failure!"); } else ajFatal("Invalid mode (not 1 or 2) which should never occur (check ACD file!)"); nseq = ajSeqsetGetSize(seqset); for(i=0; i<nseq; i++) { seq = ajSeqsetGetseqSeq(seqset, i); if(ajUintGet(keep, i)) ajSeqoutWriteSeq(seqout, seq); else if(seqoutred) ajSeqoutWriteSeq(seqoutred, seq); } /* Memory management and exit */ ajSeqsetDel(&seqset); ajMatrixfDel(&fmat); ajStrDel(&mode); ajSeqoutClose(seqout); ajSeqoutDel(&seqout); if(seqoutred) { ajSeqoutClose(seqoutred); ajSeqoutDel(&seqoutred); } skipredundant_ClearList(list); ajListFree(&list); ajUintDel(&keep); embExit(); return 0; }
int main(int argc, char **argv) { AjPSeqall nucseq; /* input nucleic sequences */ AjPSeqset protseq; /* input aligned protein sequences */ AjPSeqout seqout; AjPSeq nseq; /* next nucleic sequence to align */ const AjPSeq pseq; /* next protein sequence use in alignment */ AjPTrn trnTable; AjPSeq pep; /* translation of nseq */ AjPStr tablelist; ajint table; AjPSeqset outseqset; /* set of aligned nucleic sequences */ ajint proteinseqcount = 0; AjPStr degapstr = NULL; /* used to check if it matches with START removed */ AjPStr degapstr2 = NULL; AjPStr codon = NULL; /* holds temporary codon to check if is START */ char aa; /* translated putative START codon */ ajint type; /* returned type of the putative START codon */ /* start position of guide protein in translation */ ajlong pos = 0; AjPSeq newseq = NULL; /* output aligned nucleic sequence */ ajint frame; embInit("tranalign", argc, argv); nucseq = ajAcdGetSeqall("asequence"); protseq = ajAcdGetSeqset("bsequence"); tablelist = ajAcdGetListSingle("table"); seqout = ajAcdGetSeqoutset("outseq"); outseqset = ajSeqsetNew(); degapstr = ajStrNew(); /* initialise the translation table */ ajStrToInt(tablelist, &table); trnTable = ajTrnNewI(table); ajSeqsetFill(protseq); while(ajSeqallNext(nucseq, &nseq)) { if((pseq = ajSeqsetGetseqSeq(protseq, proteinseqcount++)) == NULL) ajErr("No guide protein sequence available for " "nucleic sequence %S", ajSeqGetNameS(nseq)); ajDebug("Aligning %S and %S\n", ajSeqGetNameS(nseq), ajSeqGetNameS(pseq)); /* get copy of pseq string with no gaps */ ajStrAssignS(°apstr, ajSeqGetSeqS(pseq)); ajStrRemoveGap(°apstr); /* ** for each translation frame look for subset of pep that ** matches pseq */ for(frame = 1; frame <4; frame++) { ajDebug("trying frame %d\n", frame); pep = ajTrnSeqOrig(trnTable, nseq, frame); degapstr2 = ajStrNew(); ajStrAssignRef(°apstr2, degapstr); pos = ajStrFindCaseS(ajSeqGetSeqS(pep), degapstr); /* ** we might have a START codon that should be translated as 'M' ** we need to check if there is a match after a possible START ** codon */ if(pos == -1 && ajStrGetLen(degapstr) > 1 && (ajStrGetPtr(degapstr)[0] == 'M' || ajStrGetPtr(degapstr)[0] == 'm')) { /* see if pep minus the first character is a match */ ajStrCutStart(°apstr2, 1); pos = ajStrFindCaseS(ajSeqGetSeqS(pep), degapstr2); /* ** pos is >= 1 if we have a match that is after the first ** residue */ if(pos >= 1) { /* point back at the putative START Methionine */ pos--; /* test if first codon is a START */ codon = ajStrNew(); ajStrAssignSubS(&codon, ajSeqGetSeqS(nseq), (pos*3)+frame-1, (pos*3)+frame+2); type = ajTrnCodonstrTypeS(trnTable, codon, &aa); if(type != 1) { /* first codon is not a valid START, force a mismatch */ pos = -1; } ajStrDel(&codon); } else { /* force 'pos == 0' to be treated as a mismatch */ pos = -1; } } ajStrDel(°apstr2); ajSeqDel(&pep); if(pos != -1) break; } if(pos == -1) ajErr("Guide protein sequence %S not found in nucleic sequence %S", ajSeqGetNameS(pseq), ajSeqGetNameS(nseq)); else { ajDebug("got a match with frame=%d\n", frame); /* extract the coding region of nseq with gaps */ newseq = ajSeqNew(); ajSeqSetNuc(newseq); ajSeqAssignNameS(newseq, ajSeqGetNameS(nseq)); ajSeqAssignDescS(newseq, ajSeqGetDescS(nseq)); tranalign_AddGaps(newseq, nseq, pseq, (pos*3)+frame-1); /* output the gapped nucleic sequence */ ajSeqsetApp(outseqset, newseq); ajSeqDel(&newseq); } ajStrRemoveWhiteExcess(°apstr); } ajSeqoutWriteSet(seqout, outseqset); ajSeqoutClose(seqout); ajTrnDel(&trnTable); ajSeqsetDel(&outseqset); ajStrDel(°apstr); ajStrDel(°apstr2); ajSeqallDel(&nucseq); ajSeqDel(&nseq); ajSeqoutDel(&seqout); ajSeqsetDel(&protseq); ajStrDel(&tablelist); embExit(); return 0; }