示例#1
0
int main(int argc, char **argv) {
  // initialize EMBASSY info
  embInitPV("kclique", argc, argv, "KBWS", "1.0.9");

  struct soap soap;
  char*  jobid;
  char*  result;

  AjPFile    infile;
  AjPFile    outf;
  AjPStr     substr;
  AjPStr     indata = NULL;
  AjPStr     line   = NULL;

  infile = ajAcdGetInfile("infile");
  outf   = ajAcdGetOutfile("outfile");

  while (ajReadline(infile, &line)) {
    ajStrAppendS(&indata, line);
    ajStrAppendC(&indata, "\n");
  }

  soap_init(&soap);

  char* in0;
  in0 = ajCharNewS(indata);
  if ( soap_call_ns1__runClique( &soap, NULL, NULL, in0, &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);
  }

  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);
  }

  soap_destroy(&soap);
  soap_end(&soap);
  soap_done(&soap);

  ajFileClose(&infile);
  ajFileClose(&outf);
  ajStrDel(&substr);

  embExit();

  return 0;
}
示例#2
0
文件: gfile.c 项目: ktnyt/GEMBASSY
AjBool gtaiFileOutURLS(AjPStr url, AjPFile* outf, AjBool tai){
  if(tai)
    {
      CURL *curl;
      CURLcode curl_res;

      Memory *mem = malloc(sizeof(Memory*));

      mem->size = 0;
      mem->memory = NULL;

      curl_global_init(CURL_GLOBAL_ALL);

      curl = curl_easy_init();

      if(curl)
        {
          curl_easy_setopt(curl, CURLOPT_URL, ajCharNewS(url));
          curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1);
          curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_write);
          curl_easy_setopt(curl, CURLOPT_WRITEDATA, mem);
        }

      curl_res = curl_easy_perform(curl);

      if(CURLE_OK == curl_res)
        {
          char* redir;
          curl_res = curl_easy_getinfo(curl, CURLINFO_EFFECTIVE_URL, &redir);

          if((CURLE_OK == curl_res) && redir) {
            ajStrAssignC(&url, redir);
            ajStrExchangeCC(&url, "cai.csv", "tai.csv");
          }
        }

      free(mem);
      curl_easy_cleanup(curl);
      curl_global_cleanup();
    }

  return gFileOutURLS(url, outf);
}
示例#3
0
static EmbPEntry dbiblast_nextblastentry(PBlastDb db, ajint ifile,
					 const AjPStr idformat,
					 AjBool systemsort,
					 AjPStr const * fields,
					 ajint * maxFieldLen,
					 ajuint* maxidlen, ajuint* countfield,
					 AjPFile elistfile,
					 AjPFile * alistfile)
{
    ajint i;
    static ajint lastfile = -1;
    static ajint iparser  = -1;
    static ajint called   = 0;
    static ajuint tabhdr[TABLESIZE];
    static ajint iload  = TABLESIZE-1;
    static ajint irest  = 0;
    static ajint ipos   = 0;

    static ajint jpos = 0;
    ajint ir;
    ajint j;
    static ajint is = 0;
    char* token;
    static ajint nfields;
    ajint ifield;

    if(!called)
    {
	for(i=0; parser[i].Name; i++)
	    if(ajStrMatchC(idformat, parser[i].Name))
	    {
		iparser = i;
		break;
	    }

	if(iparser < 0)
	    ajFatal("idformat '%S' unknown", idformat);
	ajDebug("idformat '%S' Parser %d\n", idformat, iparser);
	ajStrSetRes(&id, HDRSIZE);
	ajStrSetRes(&acc, HDRSIZE);
	ajStrSetRes(&hline, HDRSIZE);
	called = 1;
    }

    if(!fdl)
    {
	nfields=0;
	while(fields[nfields])
	    nfields++;
	if(nfields)
	    AJCNEW(fdl, nfields);
	for(i=0; i < nfields; i++)
	    fdl[i] = ajListNew();
    }

    if(lastfile != ifile)
    {
	lastfile = ifile;
	ipos = 1;
	/*    isize = 0;*/
	irest = 0;
	iload = TABLESIZE-1;
    }

    if(!dbiblastEntry || !systemsort)
	dbiblastEntry = embDbiEntryNew(nfields);

    /* pick up the next entry, parse it and dump it */

    if(ipos > db->Size)
	return NULL;

    if( ipos >= irest)
    {
	ajDebug("ipos: %d iload: %d irest: %d\n", ipos, iload, irest);
	irest = ipos + TABLESIZE - 2;
	if(irest > db->Size)
	{
	    iload = db->Size - ipos + 1;
	    irest = db->Size;
	}

	jpos=0;
	j = dbiblast_loadtable(tabhdr, iload, db, db->TopHdr, ipos-1);
	if(!j)
	    ajDebug("No elements read");
    }

    j = dbiblast_ncblreadhdr(&hline, db, tabhdr[jpos], tabhdr[jpos+1]);

    if(!parser[iparser].Parser(hline, alistfile, systemsort, fields,
			       maxFieldLen, countfield, &id, fdl))
	ajFatal("failed to parse '%S'", hline);

    ir = ipos;

    if(ajStrGetLen(id) > *maxidlen)
	*maxidlen = ajStrGetLen(id);

    if(systemsort)
	ajFmtPrintF(elistfile, "%S %d %d %d\n", id, ir, is, ifile+1);
    else
    {
	dbiblastEntry->entry   = ajCharNewS(id);
	dbiblastEntry->rpos    = ir;
	dbiblastEntry->spos    = is;
	dbiblastEntry->filenum = ifile+1;

	/* field tokens as list, then move to dbiblastEntry->field */
	for(ifield=0; ifield < nfields; ifield++)
	{
	    dbiblastEntry->nfield[ifield] = ajListGetLength(fdl[ifield]);

	    if(dbiblastEntry->nfield[ifield])
	    {
		AJCNEW(dbiblastEntry->field[ifield],
		       dbiblastEntry->nfield[ifield]);

		i = 0;
		while(ajListPop(fdl[ifield], (void**) &token))
		    dbiblastEntry->field[ifield][i++] = token;
	    }
	    else
		dbiblastEntry->field[ifield] = NULL;
	}
    }
    ipos++;
    jpos++;

    return dbiblastEntry;
}
示例#4
0
static AjBool dbiblast_parseSimple(const AjPStr line,
				   AjPFile * alistfile,
				   AjBool systemsort, AjPStr const * fields,
				   ajint* maxFieldLen,
				   ajuint* countfield,
				   AjPStr* myid,
				   AjPList* myfdl)
{
    static AjPRegexp idexp = NULL;
    static AjPStr mytmpac    = NULL;
    char* ac;
    static ajint numFields;
    static ajint accfield = -1;
    static AjBool reset = AJTRUE;

    if(!fields)
    {
	reset = ajTrue;
	accfield = -1;
	return ajFalse;
    }

    if(reset)
    {
	numFields = 0;
	while(fields[numFields])
	{
	    if(ajStrMatchCaseC(fields[numFields], "acc"))
		accfield=numFields;
	    else if(!ajStrMatchCaseC(fields[numFields], "sv") &&
		    !ajStrMatchCaseC(fields[numFields], "des"))
		ajWarn("Simple ID parsing unknown field '%S' ignored",
		       fields[numFields]);
	    numFields++;
	}
	reset = ajFalse;
    }


    if(!idexp)
	idexp = ajRegCompC("^([^ ]+)( +([A-Za-z][A-Za-z0-9]+[0-9]))");

    if(!ajRegExec(idexp, line))
	return ajFalse;

    ajRegSubI(idexp, 1, myid);
    ajRegSubI(idexp, 3, &mytmpac);
    ajStrFmtUpper(myid);
    ajStrFmtUpper(&mytmpac); /* GCG mixes case on new SwissProt acnums */

    if(accfield >= 0)
    {
        embDbiMaxlen(&mytmpac, &maxFieldLen[accfield]);
	countfield[accfield]++;
	if(systemsort)
	    ajFmtPrintF(alistfile[accfield], "%S %S\n", *myid, mytmpac);
	else
	{
	    ac = ajCharNewS(mytmpac);
	    ajListPushAppend(myfdl[accfield], ac);
	}
    }

    ajDebug("parseSimple '%S' '%S'\n", *myid, mytmpac);

    return ajTrue;
}
int main(int argc, char *argv[])
{
  embInitPV("gaminoinfo", argc, argv, "GEMBASSY", "1.0.1");

  struct soap soap;

  AjPSeqall seqall;
  AjPSeq    seq;
  AjPStr    inseq = NULL;
  AjPStr    seqid = NULL;

  char *in0;
  char *result;

  AjPFile outf = NULL;

  seqall = ajAcdGetSeqall("sequence");
  outf   = ajAcdGetOutfile("outfile");

  while(ajSeqallNext(seqall, &seq))
    {
      soap_init(&soap);

      inseq = NULL;

      ajStrAssignS(&seqid, ajSeqGetAccS(seq));

      if(!ajStrGetLen(seqid))
         ajStrAssignS(&seqid, ajSeqGetNameS(seq));

      ajStrAppendC(&inseq, ">");
      ajStrAppendS(&inseq, ajSeqGetNameS(seq));
      ajStrAppendC(&inseq, "\n");
      ajStrAppendS(&inseq, ajSeqGetSeqS(seq));

      in0 = ajCharNewS(inseq);

      if(soap_call_ns1__amino_USCOREinfo(
	                                &soap,
					 NULL,
					 NULL,
					 in0,
					&result
                                        ) == SOAP_OK)
	{
          ajFmtPrintF(outf, "Sequence: %S\n%s\n", seqid, result);
	}
      else
	{
	  soap_print_fault(&soap, stderr);
	}

      soap_destroy(&soap);
      soap_end(&soap);
      soap_done(&soap);

      AJFREE(in0);

      ajStrDel(&inseq);
    }

  ajFileClose(&outf);

  ajSeqallDel(&seqall);
  ajSeqDel(&seq);

  embExit();

  return 0;
}
示例#6
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;
}
示例#7
0
AjBool ajDebugTest(const char* token)
{
    AjPStr filename = NULL;
    const char* debugtestname = ".debugtest";
    char* ctoken = NULL;
    AjPStr line = NULL;
    AjPStr strtoken = NULL;
    AjPStr rest = NULL;
    static ajint depth    = 0;

    struct 
    {
        ajuint count;
        ajuint max;
    } *stats;
    
    if(depth)
        return ajFalse;

    depth++;

    if(!messDebugTestInit)
    {
        filename = ajStrNewC(debugtestname);

        if(ajFilenameExists(filename))
        {
            messDebugTestFile = ajFileNewInNameS(filename);
        }
        else
        {
            ajFmtPrintS(&filename, "%s%s%s",
                        getenv("HOME"), SLASH_STRING, debugtestname); 
            if(ajFilenameExists(filename))
                messDebugTestFile = ajFileNewInNameS(filename);
        }
        ajStrDel(&filename);

        if(messDebugTestFile) 
        {
            messDebugTestTable = ajTablecharNewLen(256);

            while(ajReadlineTrim(messDebugTestFile, &line))
            {
                if(ajStrExtractFirst(line, &rest, &strtoken))
                {
                    AJNEW0(stats);
                    ctoken = ajCharNewS(strtoken);
                    if(ajStrIsInt(rest))
                        ajStrToUint(rest, &stats->max);
                    else
                        stats->max = UINT_MAX;
                    ajTablePut(messDebugTestTable, ctoken, stats);
                    ctoken = NULL;
                    stats = NULL;
                }
            }

            ajStrDel(&line);
            ajStrDel(&strtoken);
            ajStrDel(&rest);
            ajFileClose(&messDebugTestFile);
        }
        messDebugTestInit = ajTrue;
     }

    depth--;
    
    if(!messDebugTestTable)
        return ajFalse;

    depth++;
    stats = ajTableFetch(messDebugTestTable, token);
    depth--;
    

    if(!stats)
        return ajFalse;

    if(!stats->max)
        return ajTrue;

    if(stats->count++ >= stats->max)
        return ajFalse;

    return ajTrue;
}
示例#8
0
int main(int argc, char *argv[])
{
  embInitPV("gentrez", argc, argv, "GEMBASSY", "1.0.1");

  struct soap soap;

  AjPStr database = NULL;
  AjPStr query    = NULL;

  char *in0;
  char *in1;
  char *result;

  AjPFile outf = NULL;

  database = ajAcdGetString("database");
  query    = ajAcdGetString("query");
  outf     = ajAcdGetOutfile("outfile");

  in0 = ajCharNewS(database);
  in1 = ajCharNewS(query);

  soap_init(&soap);

  if(soap_call_ns1__entrez(
                          &soap,
			   NULL,
			   NULL,
			   in0,
			   in1,
			  &result
			  ) == SOAP_OK)
    {
      if(result)
        {
          ajFmtPrintF(outf, "%s", result);
        }
      else
        {
          ajFmtPrintF(outf, "No results found.\n");
        }
    }
  else
    {
      soap_print_fault(&soap, stderr);
    }

  soap_destroy(&soap);
  soap_end(&soap);
  soap_done(&soap);

  ajFileClose(&outf);

  AJFREE(in0);
  AJFREE(in1);

  ajStrDel(&database);
  ajStrDel(&query);

  embExit();

  return 0;
}
示例#9
0
int main(int argc, char *argv[])
{
  embInitPV("ggcsi", argc, argv, "GEMBASSY", "1.0.1");

  struct soap soap;
  struct ns1__gcsiInputParams params;

  AjPSeqall seqall;
  AjPSeq    seq;
  AjPStr    inseq   = NULL;
  AjPStr    seqid   = NULL;
  ajint	    window  = 0;
  AjBool    at      = 0;
  AjBool    purine  = 0;
  AjBool    keto    = 0;
  AjBool    pval    = 0;
  AjPStr    version = NULL;
  AjBool    accid   = ajFalse;
  AjPStr    tmp     = NULL;
  AjPStr    parse   = NULL;
  AjPStr    gcsi    = NULL;
  AjPStr    sa      = NULL;
  AjPStr    dist    = NULL;
  AjPStr    z       = NULL;
  AjPStr    p       = NULL;
  AjPStrTok handle  = NULL;

  char *in0;
  char *result;

  AjPFile outf = NULL;

  seqall  = ajAcdGetSeqall("sequence");
  window  = ajAcdGetInt("window");
  at      = ajAcdGetBoolean("at");
  purine  = ajAcdGetBoolean("purine");
  keto    = ajAcdGetBoolean("keto");
  pval    = ajAcdGetBoolean("pval");
  version = ajAcdGetSelectSingle("gcsi");
  accid   = ajAcdGetBoolean("accid");
  outf    = ajAcdGetOutfile("outfile");

  params.window = window;
  params.at     = 0;
  params.purine = 0;
  params.keto   = 0;
  params.p      = 0;
  ajStrToInt(version, &(params.version));

  if(at)
    params.at = 1;
  if(purine)
    params.purine = 1;
  if(keto)
    params.keto = 1;
  if(pval)
    params.p = 1;

  while(ajSeqallNext(seqall, &seq))
    {
      soap_init(&soap);

      inseq = NULL;

      ajStrAppendC(&inseq, ">");
      ajStrAppendS(&inseq, ajSeqGetNameS(seq));
      ajStrAppendC(&inseq, "\n");
      ajStrAppendS(&inseq, ajSeqGetSeqS(seq));

      ajStrAssignS(&seqid, ajSeqGetAccS(seq));

      in0 = ajCharNewS(inseq);

      if (soap_call_ns1__gcsi(
	                      &soap,
                              NULL,
                              NULL,
                              in0,
                             &params,
                             &result
                            ) == SOAP_OK)
	{
	  tmp   = ajStrNew();
	  parse = ajStrNew();
	  gcsi  = ajStrNew();
	  sa    = ajStrNew();
	  dist  = ajStrNew();
	  z     = ajStrNew();
	  p     = ajStrNew();

	  ajStrAssignC(&tmp, result);

	  ajStrExchangeCC(&tmp, "<", "\n");
	  ajStrExchangeCC(&tmp, ">", "\n");

	  handle = ajStrTokenNewC(tmp, "\n");

	  while (ajStrTokenNextParse(&handle, &parse))
	    {
	      if (ajStrIsFloat(parse))
		{
		  if(!ajStrGetLen(gcsi))
		    ajStrAssignS(&gcsi, parse);
		  else if(!ajStrGetLen(sa))
		    ajStrAssignS(&sa, parse);
		  else if(!ajStrGetLen(dist))
		    ajStrAssignS(&dist, parse);
		  else if(!ajStrGetLen(z))
		    ajStrAssignS(&z, parse);
		  else if(!ajStrGetLen(p))
		    ajStrAssignS(&p, parse);
		}
	    }

	  tmp = ajFmtStr("Sequence: %S GCSI: %S SA: %S DIST: %S",
			 seqid, gcsi, sa, dist);

	  if(pval)
	    tmp = ajFmtStr("%S Z: %S P: %S", tmp, z, p);

          ajFmtPrintF(outf, "%S\n", tmp);

	  ajStrDel(&tmp);
	  ajStrDel(&parse);
	  ajStrDel(&gcsi);
	  ajStrDel(&sa);
	  ajStrDel(&dist);
	  ajStrDel(&z);
	  ajStrDel(&p);
	}
      else
	{
	  soap_print_fault(&soap, stderr);
	}

      soap_destroy(&soap);
      soap_end(&soap);
      soap_done(&soap);

      AJFREE(in0);

      ajStrDel(&inseq);
    }

  ajFileClose(&outf);

  ajSeqallDel(&seqall);
  ajSeqDel(&seq);
  ajStrDel(&seqid);

  embExit();

  return 0;
}
示例#10
0
int main(int argc, char **argv) {

    embInitPV("kpsort", argc, argv, "KBWS", "1.0.8");

    AjPSeqall  seqall;
    AjPSeq     seq;
    AjPFile    outf;
    AjPStr     substr;

    AjPStr     org;
    AjPStr     title;

    struct soap soap;
    struct ns1__psortInputParams params;

    org = ajAcdGetString("org");
    title = ajAcdGetString("title");
    params.org = ajCharNewS(org);
    params.title = ajCharNewS(title);

    char* jobid;
    char* result;

    seqall = ajAcdGetSeqall("seqall");
    outf   = ajAcdGetOutfile("outfile");

    while(ajSeqallNext(seqall, &seq)) {

      soap_init(&soap);

      char* in0;
      in0 = ajSeqGetSeqCopyC(seq);
      //ajSeqGetNameC(seq);

      if(soap_call_ns1__runPsort( &soap, NULL, NULL, in0, &params, &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); 
      }

      soap_destroy(&soap); 
      soap_end(&soap); 
      soap_done(&soap); 
    
    }

    ajFileClose(&outf);

    ajSeqallDel(&seqall);
    ajSeqDel(&seq);
    ajStrDel(&substr);

    embExit();

    return 0;
}
示例#11
0
void emboss_copy(AjPSeqset seqset, char ***retseqs, AINFO *info)
{
    ajint n;
    ajint maxlen;
    ajint len;
    char **seqs;
    const AjPSeq seq = NULL;
    ajint i=0;
    const AjPStr fmt=NULL;
    const char *p=NULL;
    char  c='\0';
    /*
    char *q=NULL;
    AjPSelexseq   sqdata=NULL;
    AjPSelexdata sdata=NULL;
    */
    ajint cnt=0;
    info->name = NULL;
    info->rf=NULL;
    info->cs=NULL;
    info->desc=NULL;
    info->acc=NULL;
    info->au=NULL;
    info->flags=0;

    AjPStr tmpstr = NULL;

    ajSeqsetFill(seqset);

    fmt = ajSeqsetGetFormat(seqset);
    n = ajSeqsetGetSize(seqset);
    ajSeqsetFmtUpper(seqset);

    maxlen = ajSeqsetGetLen(seqset);


    /* First allocate and copy sequences */
    AJCNEW0(seqs,n);
    for(i=0; i<n; ++i)
    {
        seqs[i] = ajCharNewRes(maxlen+1);
        strcpy(seqs[i],ajSeqGetSeqC(ajSeqsetGetseqSeq(seqset,i)));
    }

    info->sqinfo = (SQINFO *) calloc (sizeof(SQINFO), n);

    for(i=0; i<n; ++i)
    {
        info->sqinfo[i].flags = 0;
        strcpy(info->sqinfo[i].name,"");
        strcpy(info->sqinfo[i].id,"");
        strcpy(info->sqinfo[i].acc,"");
        strcpy(info->sqinfo[i].desc,"");
        info->sqinfo[i].len = 0;
        info->sqinfo[i].start = 0;
        info->sqinfo[i].stop = 0;
        info->sqinfo[i].olen = 0;
        info->sqinfo[i].type = 0;
        info->sqinfo[i].ss = NULL;
        info->sqinfo[i].sa =NULL;
    }

    AJCNEW0(info->wgt,n);

    for(i=0; i<n; ++i)
    {
        info->sqinfo[i].flags = 0;
        info->wgt[i] = ajSeqsetGetseqWeight(seqset,i);
    }
    info->nseq = n;
    info->alen = maxlen;

    for(i=0; i<n; ++i)
    {
        seq = ajSeqsetGetseqSeq(seqset,i);
        if((len=ajStrGetLen(ajSeqGetNameS(seq))))
        {
            if(len>= SQINFO_NAMELEN)
                len = SQINFO_NAMELEN - 1;
            ajStrAssignSubS(&tmpstr, ajSeqGetNameS(seq), 0, len);
            strcpy(info->sqinfo[i].id,ajStrGetPtr(tmpstr));
            info->sqinfo[i].flags |= SQINFO_ID;
            strcpy(info->sqinfo[i].name,ajStrGetPtr(tmpstr));
            info->sqinfo[i].flags |= SQINFO_NAME;
        }
        if((len=ajStrGetLen(ajSeqGetAccS(seq))))
        {
            if(len>= SQINFO_NAMELEN)
                len = SQINFO_NAMELEN - 1;
            ajStrAssignSubS(&tmpstr, ajSeqGetAccS(seq), 0, len);
            strcpy(info->sqinfo[i].acc,ajStrGetPtr(tmpstr));
            info->sqinfo[i].flags |= SQINFO_ACC;
        }
    }
    seq = ajSeqsetGetseqSeq(seqset,0);
    info->cs = ajCharNewS(ajSeqGetSeqS(seq));
    info->name = ajCharNewS(ajSeqGetNameS(seq));
    info->acc = ajCharNewS(ajSeqGetAccS(seq));
    info->desc = ajCharNewS(ajSeqGetDescS(seq));
    info->rf = ajCharNewS(ajSeqGetSeqS(seq));

    /*
        info->rf = ajCharNewS(seq);

    	len = ajStrGetLen(seq->Selexdata->name);
    	info->name = ajCharNewRes(len+1);
    	strcpy(info->name,ajStrGetPtr(seq->Selexdata->name));
    	len = ajStrGetLen(seq->Selexdata->de);
    	info->desc = ajCharNewRes(len+1);

    	sdata = seq->Selexdata;
    	strcpy(info->desc,ajStrGetPtr(sdata->de));
    	len = ajStrGetLen(sdata->ac);
    	info->acc = ajCharNewRes(len+1);
    	strcpy(info->acc,ajStrGetPtr(sdata->ac));
    	len = ajStrGetLen(sdata->au);
    	info->au = ajCharNewRes(len+1);
    	strcpy(info->au,ajStrGetPtr(sdata->au));
    	if(sdata->tc[0] || sdata->tc[1])
    	{
    	    info->flags |= AINFO_TC;
    	    info->tc1 = sdata->tc[0];
    	    info->tc2 = sdata->tc[1];
    	}
    	if(sdata->nc[0] || sdata->nc[1])
    	{
    	    info->flags |= AINFO_NC;
    	    info->nc1 = sdata->nc[0];
    	    info->nc2 = sdata->nc[1];
    	}
    	if(sdata->ga[0] || sdata->ga[1])
    	{
    	    info->flags |= AINFO_GA;
    	    info->ga1 = sdata->ga[0];
    	    info->ga2 = sdata->ga[1];
    	}

    	for(i=0;i<n;++i)
    	{
    	    seq = ajSeqsetGetseqSeq(seqset,i);
    	    sqdata = seq->Selexdata->sq;
    	    if((len=ajStrGetLen(sqdata->name)))
    	    {
    		if(len<64)
    		    strcpy(info->sqinfo[i].name,ajStrGetPtr(sqdata->name));
    		else
    		    strncpy(info->sqinfo[i].name,ajStrGetPtr(sqdata->name),63);
    		info->sqinfo[i].name[63]='\0';
    		info->sqinfo[i].flags |= SQINFO_NAME;
    	    }
    / *
    	    if((len=ajStrGetLen(sqdata->id)))
    	    {
    		if(len<64)
    		    strcpy(info->sqinfo[i].id,ajStrGetPtr(sqdata->id));
    		else
    		    strncpy(info->sqinfo[i]->id,ajStrGetPtr(sqdata->id),63);
    		info->sqinfo[i].id[63]='\0';
    		info->sqinfo[i].flags |= SQINFO_ID;
    	    }
    * /

    	    strcpy(info->sqinfo[i].id,info->sqinfo[i].name);
    	    info->sqinfo[i].flags |= SQINFO_ID;
    	    if((len=ajStrGetLen(sqdata->ac)))
    	    {
    		if(len<64)
    		    strcpy(info->sqinfo[i].acc,ajStrGetPtr(sqdata->ac));
    		else
    		    strncpy(info->sqinfo[i].acc,ajStrGetPtr(sqdata->ac),63);
    		info->sqinfo[i].acc[63]='\0';
    		info->sqinfo[i].flags |= SQINFO_ACC;
    	    }
    	    if((len=ajStrGetLen(sqdata->de)))
    	    {
    		if(len<127)
    		    strcpy(info->sqinfo[i].desc,ajStrGetPtr(sqdata->de));
    		else
    		    strncpy(info->sqinfo[i].desc,ajStrGetPtr(sqdata->de),127);
    		info->sqinfo[i].desc[127]='\0';
    		info->sqinfo[i].flags |= SQINFO_DESC;
    	    }
    	    if(sqdata->start || sqdata->stop || sqdata ->len)
    	    {
    		info->sqinfo[i].start = sqdata->start;
    		info->sqinfo[i].stop  = sqdata->stop;
    		info->sqinfo[i].olen  = sqdata->len;
    		info->sqinfo[i].flags |= SQINFO_START;
    		info->sqinfo[i].flags |= SQINFO_STOP;
    		info->sqinfo[i].flags |= SQINFO_OLEN;
    	    }

    	    if(ajStrGetLen(seq->Selexdata->ss))
    	    {

    		info->sqinfo[i].ss = ajCharNewRes(maxlen+1);
    		p = ajStrGetPtr(seq->Selexdata->ss);
    		q = info->sqinfo[i].ss;
    		while((c==*p))
    		{
    		    if(c=='.' || c==' ' || c=='_' || c=='-')
    			*q++ = c;
    		    ++p;
    		}
    		*q = '\0';
    		info->sqinfo[i].flags |= SQINFO_SS;
    	    }
    	}
        }
    / *
        }
    */


    for(i=0; i<n; ++i)
    {
        info->sqinfo[i].type = kOtherSeq;
        if(ajSeqsetIsDna(seqset))
            info->sqinfo[i].type = kDNA;
        if(ajSeqsetIsRna(seqset))
            info->sqinfo[i].type = kRNA;
        if(ajSeqsetIsProt(seqset))
            info->sqinfo[i].type = kAmino;
        info->sqinfo[i].flags |= SQINFO_TYPE;

        seq = ajSeqsetGetseqSeq(seqset,i);

        p = ajSeqGetSeqC(seq);
        cnt = 0;
        while((c=*p))
        {
            if(!(c=='.' || c==' ' || c=='_' || c=='-' || c=='~'))
                ++cnt;
            ++p;
        }
        info->sqinfo[i].len = cnt;
        info->sqinfo[i].flags |= SQINFO_LEN;
    }


    *retseqs = seqs;
    ajStrDel(&tmpstr);

    return;
}
示例#12
0
int main(int argc, char **argv) {
    // initialize EMBASSY info
    embInitPV("kfetchbatch", argc, argv, "KBWS", "1.0.9");

    struct soap soap;
    struct ns1__fetchBatchInputParams params;
    char* jobid;
    char* result;
    AjPStr substr;

    AjPStr dbname;
    AjPStr idlist;
    AjPFile outf;

    dbname= ajAcdGetString("dbname");
    idlist= ajAcdGetString("idlist");
    outf=   ajAcdGetOutfile("outfile");

    // get/set parameters
    params.format = ajCharNewS(ajAcdGetString("format"));
    params.style  = ajCharNewS(ajAcdGetString("style"));

    soap_init(&soap);

    char* in0;
    in0= ajCharNewS(dbname);
    char* in1;
    in1= ajCharNewS(idlist);

    if (soap_call_ns1__runFetchBatch(&soap, NULL, NULL, in0, in1, &params, &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);
    }

    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);
    }

    soap_destroy(&soap);
    soap_end(&soap);
    soap_done(&soap);

    ajStrDel(&idlist);
    ajStrDel(&dbname);
    ajFileClose(&outf);
    ajStrDel(&substr);

    embExit();

    return 0;
}
示例#13
0
int main(int argc, char **argv) 
{
  const char      *hmmfile;	/* file to read HMMs from                  */
  HMMFILE         *hmmfp;       /* opened hmmfile for reading              */
  const char      *seqfile;     /* file to read target sequence from       */ 
  char           **rseq;        /* raw, unaligned sequences                */ 
  SQINFO          *sqinfo;      /* info associated with sequences          */
  char           **dsq;         /* digitized raw sequences                 */
  int              nseq;        /* number of sequences                     */  
  char           **aseq;        /* aligned sequences                       */
  AINFO            ainfo;       /* alignment information                   */
  float           *wgt;         /* per-sequence weights                    */
  int              i;
  struct plan7_s    *hmm;       /* HMM to align to                         */ 
  struct p7trace_s **tr;        /* traces for aligned sequences            */

  int   be_quiet;		/* TRUE to suppress verbose banner          */
  int   matchonly;		/* TRUE to show only match state syms       */
  const char *outfile;          /* optional alignment output file           */
  FILE *ofp;                    /* handle on alignment output file          */
  AjPFile ajwithali;          /* name of additional alignment file to align */
  AjPFile ajmapali;           /* name of additional alignment file to map   */
  AjBool ajmatch=ajFalse;
  AjPFile outf=NULL;
  AjPStr  outfname=NULL;
  AjPFile inf=NULL;
  AjPStr  infname=NULL;
  AjPSeqset seqset=NULL;
  AjPStr  ajseqfile=NULL;
  char*  mapali=NULL;
  char*  withali=NULL;
  
#ifdef MEMDEBUG
  unsigned long histid1, histid2, orig_size, current_size;
  orig_size = malloc_inuse(&histid1);
  fprintf(stderr, "[... memory debugging is ON ...]\n");
#endif

  /*********************************************** 
   * Parse command line
   ***********************************************/
  
  matchonly = FALSE;
  outfile   = NULL;
  be_quiet  = FALSE;
  withali   = NULL;
  mapali    = NULL;

  embInitPV("ohmmalign",argc,argv,"HMMER",VERSION);

  ajmatch = ajAcdGetBoolean("matchonly");
  if(ajmatch)
      matchonly=TRUE;
  else
      matchonly=FALSE;



  ajmapali = ajAcdGetInfile("mapalifile");
  if (ajmapali)
      mapali = ajCharNewS(ajFileGetNameS(ajmapali));
  ajFileClose(&ajmapali);
  ajwithali = ajAcdGetInfile("withalifile");
  if (ajwithali)
      withali = ajCharNewS(ajFileGetNameS(ajwithali));
  ajFileClose(&ajwithali);

  be_quiet=TRUE;



  outf = ajAcdGetOutfile("outfile");
  outfname = ajStrNewC((char *)ajFileGetNameC(outf));
  if(*ajStrGetPtr(outfname)>31)
      ajFileClose(&outf);
  outfile = ajStrGetPtr(outfname);

  inf = ajAcdGetInfile("hmmfile");
  infname = ajStrNewC((char *)ajFileGetNameC(inf));
  ajFileClose(&inf);
  hmmfile = ajStrGetPtr(infname);

  
  seqset = ajAcdGetSeqset("sequences");
  ajseqfile = ajStrNewC(ajStrGetPtr(seqset->Filename));
  seqfile = ajStrGetPtr(ajseqfile);
  

 /*********************************************** 
  * Open HMM file (might be in HMMERDB or current directory).
  * Read a single HMM from it.
  * 
  * Currently hmmalign disallows the J state and
  * only allows one domain per sequence. To preserve
  * the S/W entry information, the J state is explicitly
  * disallowed, rather than calling a Plan7*Config() function.
  * this is a workaround in 2.1 for the 2.0.x "yo!" bug.
  ***********************************************/

  if ((hmmfp = HMMFileOpen(hmmfile, "HMMERDB")) == NULL)
    ajFatal("Failed to open HMM file %s\n", hmmfile);
  if (!HMMFileRead(hmmfp, &hmm)) 
    ajFatal("Failed to read any HMMs from %s\n", hmmfile);
  HMMFileClose(hmmfp);
  if (hmm == NULL) 
    ajFatal("HMM file %s corrupt or in incorrect format? Parse failed", hmmfile);
  hmm->xt[XTE][MOVE] = 1.;	      /* only 1 domain/sequence ("global" alignment) */
  hmm->xt[XTE][LOOP] = 0.;
  P7Logoddsify(hmm, TRUE);
				/* do we have the map we might need? */
  if (mapali != NULL && ! (hmm->flags & PLAN7_MAP))
    ajFatal("HMMER: HMM file %s has no map; you can't use --mapali.", hmmfile);

  /*********************************************** 
   * Open sequence file in current directory.
   * Read all seqs from it.
   ***********************************************/
/*
  if (! SeqfileFormat(seqfile, &format, NULL))
    switch (squid_errno) {
    case SQERR_NOFILE: 
      ajFatal("Sequence file %s could not be opened for reading", seqfile);
    case SQERR_FORMAT: 
    default:           
      ajFatal("Failed to determine format of sequence file %s", seqfile);
    }
  if (! ReadMultipleRseqs(seqfile, format, &rseq, &sqinfo, &nseq))
    ajFatal("Failed to read any sequences from file %s", seqfile);
*/

  emboss_rseqs(seqset,&rseq,&sqinfo,&nseq);

  /*********************************************** 
   * Show the banner
   ***********************************************/

  be_quiet=TRUE;
  if (! be_quiet) 
    {
/*      Banner(stdout, banner); */
      printf(   "HMM file:             %s\n", hmmfile);
      printf(   "Sequence file:        %s\n", seqfile);
      printf("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n\n");
    }

  /*********************************************** 
   * Do the work
   ***********************************************/

  /* Allocations and initializations.
   */
  dsq = MallocOrDie(sizeof(char *) * nseq);
  tr  = MallocOrDie(sizeof(struct p7trace_s *) * nseq);

  /* Align each sequence to the model, collect traces
   */
  for (i = 0; i < nseq; i++)
    {
      dsq[i] = DigitizeSequence(rseq[i], sqinfo[i].len);

      if (P7ViterbiSize(sqinfo[i].len, hmm->M) <= RAMLIMIT)
	(void) P7Viterbi(dsq[i], sqinfo[i].len, hmm, &(tr[i]));
      else
	(void) P7SmallViterbi(dsq[i], sqinfo[i].len, hmm, &(tr[i]));
    }

  /* Include an aligned alignment, if desired.
   */
  if (mapali != NULL)
    include_alignment(mapali, hmm, TRUE, &rseq, &dsq, &sqinfo, &tr, &nseq);
  if (withali != NULL) 
    include_alignment(withali, hmm, FALSE, &rseq, &dsq, &sqinfo, &tr, &nseq);

  /* Turn traces into a multiple alignment
   */ 
  wgt = MallocOrDie(sizeof(float) * nseq);
  FSet(wgt, nseq, 1.0);
  P7Traces2Alignment(dsq, sqinfo, wgt, nseq, hmm->M, tr, matchonly,
		     &aseq, &ainfo);

  /*********************************************** 
   * Output the alignment
   ***********************************************/

  if (outfile != NULL && (ofp = fopen(outfile, "w")) != NULL)
    {
      WriteSELEX(ofp, aseq, &ainfo, 50);
      printf("Alignment saved in file %s\n", outfile);
      fclose(ofp);
    }
  else
    WriteSELEX(stdout, aseq, &ainfo, 50);

  /*********************************************** 
   * Cleanup and exit
   ***********************************************/
  
  for (i = 0; i < nseq; i++) 
    {
      P7FreeTrace(tr[i]);
      FreeSequence(rseq[i], &(sqinfo[i]));
      free(dsq[i]);
    }
  FreeAlignment(aseq, &ainfo);
  FreePlan7(hmm);
  free(sqinfo);
  free(rseq);
  free(dsq);
  free(wgt);
  free(tr);

  SqdClean();

  ajStrDel(&outfname);
  ajStrDel(&infname);
  ajStrDel(&ajseqfile);
  

#ifdef MEMDEBUG
  current_size = malloc_inuse(&histid2);
  if (current_size != orig_size) malloc_list(2, histid1, histid2);
  else fprintf(stderr, "[No memory leaks.]\n");
#endif

  ajSeqsetDel(&seqset);
  ajFileClose(&ajwithali);
  ajFileClose(&ajmapali);

  embExit();
  
  return 0;
}
示例#14
0
int main(int argc, char **argv) {
  // initialize EMBASSY info
  embInitPV("kcentroidfold", argc, argv, "KBWS", "1.0.9");

  // soap driver and parameter object
  struct soap soap;
  struct ns1__centroidfoldInputParams params;

  char* jobid;

  AjPSeqall seqall; // input sequence
  AjPFile   outf; // outfile
  AjPStr    goutfile; // graph file name
  AjPFile   goutf; // graph file handle

  AjPSeq     seq;
  AjPStr     inseq= NULL;

  AjPStr     substr;

  AjPStr     engine; // CONTRAfold, McCaskill, pfold or AUX
  ajint      gamma;

  // get input/output info
  seqall= ajAcdGetSeqall("seqall");
  outf= ajAcdGetOutfile("outfile");
  goutfile= ajAcdGetString("goutfile");

  // get parameters
  engine= ajAcdGetString("engine");
  gamma=  ajAcdGetInt("gamma");

  // set parameters
  params.model= ajCharNewS(engine);
  params.gamma= gamma;

  while (ajSeqallNext(seqall, &seq)) {
    // initialize
    soap_init(&soap);
    inseq= NULL;

    // convert sequence data to EMBOSS string as fasta format
    ajStrAppendC(&inseq, ">");
    ajStrAppendS(&inseq, ajSeqGetNameS(seq));
    ajStrAppendC(&inseq, "\n");
    ajStrAppendS(&inseq, ajSeqGetSeqS(seq));

    // convert EMBOSS string to char* in C
    char* in0;
    in0= ajCharNewS(inseq);

    // submit query via SOAP and get job ID
    if (soap_call_ns1__runCentroidfold(&soap, NULL, NULL, in0, &params, &jobid) == SOAP_OK) {
    } else {
      soap_print_fault(&soap, stderr);
    }

    // polling
    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);
    }

    // get result (sequence alignment text data)
    char* result;
    if(soap_call_ns1__getMultiResult(&soap, NULL, NULL, jobid, "out", &result) == SOAP_OK) {
      // convert result from C char* to EMBOSS string object
      substr= ajStrNewC(result);

      // output result (EMBOSS string) to file or STDOUT via EMBOSS
      ajFmtPrintF(outf, "%S\n", substr);
    } else {
      soap_print_fault(&soap, stderr); 
    }

    // get result (image file)
    char* image_url;
    if(soap_call_ns1__getMultiResult(&soap, NULL, NULL, jobid, "png", &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); 
    }

  }

  // destruct SOAP driver
  soap_destroy(&soap);
  soap_end(&soap);
  soap_done(&soap);

  // write output file and destruct outfile object
  ajFileClose(&outf);

  // destruct EMBOSS object
  ajSeqallDel(&seqall);
  ajSeqDel(&seq);
  ajStrDel(&substr);
  ajStrDel(&engine);

  // exit
  embExit();
    
  return 0;
}
示例#15
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, &params, &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;
}
示例#16
0
int main(int argc, char *argv[])
{
  embInitPV("gpalindrome", argc, argv, "GEMBASSY", "1.0.3");

  struct soap soap;
  struct ns1__palindromeInputParams params;

  AjPSeqall seqall;
  AjPSeq    seq;
  AjPStr    inseq = NULL;
  AjPStr    seqid = NULL;
  ajint	    shortest = 0;
  ajint	    loop = 0;
  AjBool    gtmatch = 0;

  char *in0;
  char *result;

  AjPFile outf = NULL;

  seqall   = ajAcdGetSeqall("sequence");
  shortest = ajAcdGetInt("shortest");
  loop     = ajAcdGetInt("loop");
  gtmatch  = ajAcdGetBoolean("gtmatch");
  outf     = ajAcdGetOutfile("outfile");

  params.shortest = shortest;
  params.loop     = loop;
  params.gtmatch  = gtmatch;
  params.output   = "f";

  while(ajSeqallNext(seqall, &seq))
    {
      soap_init(&soap);

      inseq = NULL;

      ajStrAppendC(&inseq, ">");
      ajStrAppendS(&inseq, ajSeqGetNameS(seq));
      ajStrAppendC(&inseq, "\n");
      ajStrAppendS(&inseq, ajSeqGetSeqS(seq));

      ajStrAssignS(&seqid, ajSeqGetAccS(seq));

      in0 = ajCharNewS(inseq);

      if(soap_call_ns1__palindrome(
				  &soap,
                                   NULL,
                                   NULL,
				   in0,
                                  &params,
                                  &result
				  ) == SOAP_OK)
        {
          ajFmtPrintF(outf, "Sequence: %S\n", seqid);

          if(!gFileOutURLC(result, &outf))
            {
              ajDie("File downloading error from:\n%s\n", result);
              embExitBad();
            }
        }
      else
        {
          soap_print_fault(&soap, stderr);
        }

      soap_destroy(&soap);
      soap_end(&soap);
      soap_done(&soap);

      AJFREE(in0);

      ajStrDel(&inseq);
    }

  ajFileClose(&outf);

  ajSeqallDel(&seqall);
  ajSeqDel(&seq);
  ajStrDel(&seqid);

  embExit();

  return 0;
}
int main(int argc, char *argv[])
{
  embInitPV("gcircularmap", argc, argv, "GEMBASSY", "1.0.1");

  struct soap soap;
  struct ns1__circular_USCOREmapInputParams params;

  AjPSeqall seqall;
  AjPSeq    seq;
  AjPStr    inseq    = NULL;
  AjPStr    seqid    = NULL;
  AjBool    accid    = ajFalse;
  AjPFile   outf     = NULL;
  AjPStr    filename = NULL;
  AjPStr    outfname = NULL;
  AjPStr    format   = NULL;

  ajint i;

  char *in0;
  char *result;

  seqall   = ajAcdGetSeqall("sequence");
  filename = ajAcdGetString("goutfile");
  accid    = ajAcdGetBoolean("accid");
  format   = ajAcdGetString("format");

  params.gmap = 0;

  i = 0;

  while(ajSeqallNext(seqall, &seq))
    {
      soap_init(&soap);

      soap.send_timeout = 0;
      soap.recv_timeout = 0;

      inseq = NULL;

      ajStrAssignS(&seqid, ajSeqGetAccS(seq));

      if(!ajStrGetLen(seqid))
        ajStrAssignS(&seqid, ajSeqGetNameS(seq));

      if(!ajStrGetLen(seqid))
        {
          ajWarn("No valid header information\n");
        }

      if(accid || !gFormatGenbank(seq, &inseq))
        {
          if(!accid)
            ajWarn("Sequence does not have features\n"
                   "Proceeding with sequence accession ID:%S\n", seqid);

          if(!gValID(seqid))
            {
              ajDie("Invalid accession ID:%S, exiting\n", seqid);
            }

          ajStrAssignS(&inseq, seqid);
        }

      in0 = ajCharNewS(inseq);

      if(soap_call_ns1__circular_USCOREmap(
	                                  &soap,
					   NULL,
					   NULL,
					   in0,
					  &params,
					  &result
                                          ) == SOAP_OK)
	{
          ++i;

          outfname = ajStrNewS(ajFmtStr("%S.%d.%S",
                                        filename,
                                        i,
                                        format));

          outf = ajFileNewOutNameS(outfname);

          if(!outf)
            {
              ajDie("File open error\n");
            }

          if(!ajStrMatchC(format, "svg"))
            {
              if(!gHttpConvertC(result, &outf, ajStrNewC("svg"), format))
                {
                  ajDie("File downloading error from:\n%s\n", result);
                }
              else
                {
                  ajFmtPrint("Created %S\n", outfname);
                }
            }
          else
            {
              if(!gHttpGetBinC(result, &outf))
                {
                  ajDie("File downloading error from:\n%s\n", result);
                }
              else
                {
                  ajFmtPrint("Created %S\n", outfname);
                }
            }

          ajStrDel(&outfname);
	}
      else
	{
	  soap_print_fault(&soap, stderr);
	}

      soap_destroy(&soap);
      soap_end(&soap);
      soap_done(&soap);

      AJFREE(in0);

      ajStrDel(&inseq);
    }

  ajSeqallDel(&seqall);
  ajSeqDel(&seq);
  ajStrDel(&seqid);

  ajStrDel(&filename);

  embExit();

  return 0;
}
示例#18
0
int main(int argc, char *argv[])
{
  embInitPV("gcgr", argc, argv, "GEMBASSY", "1.0.1");

  struct soap soap;
  struct ns1__cgrInputParams params;

  AjPSeqall seqall;
  AjPSeq    seq;
  AjPStr    inseq    = NULL;
  AjPStr    seqid    = NULL;
  ajint	    width    = 0;
  AjPFile   outf     = NULL;
  AjPStr    filename = NULL;
  AjPStr    outfname = NULL;
  AjPStr    format   = NULL;

  ajint i;

  char *in0;
  char *result;

  seqall   = ajAcdGetSeqall("sequence");
  width    = ajAcdGetInt("width");
  filename = ajAcdGetString("goutfile");
  format   = ajAcdGetString("format");

  params.width = width;

  i = 0;

  while(ajSeqallNext(seqall, &seq))
    {
      soap_init(&soap);

      inseq = NULL;

      ajStrAppendC(&inseq, ">");
      ajStrAppendS(&inseq, ajSeqGetAccS(seq));
      ajStrAppendC(&inseq, "\n");
      ajStrAppendS(&inseq, ajSeqGetSeqS(seq));

      ajStrAssignS(&seqid, ajSeqGetAccS(seq));

      in0 = ajCharNewS(inseq);

      if(soap_call_ns1__cgr(
                           &soap,
			    NULL,
			    NULL,
			    in0,
			   &params,
			   &result
                           ) == SOAP_OK)
	{
          ++i;

	  outfname = ajStrNewS(ajFmtStr("%S.%d.%S",
                                        filename,
                                        i,
                                        format));

	  outf = ajFileNewOutNameS(outfname);

          if(!outf)
            {
              ajDie("File open error\n");
            }

          if(!ajStrMatchC(format, "png"))
            {
              if(!gHttpConvertC(result, &outf, ajStrNewC("png"), format))
                {
                  ajDie("File downloading error from:\n%s\n", result);
                }
              else
                {
                  ajFmtPrint("Created %S\n", outfname);
                }
            }
          else
            {
              if(!gHttpGetBinC(result, &outf))
                {
                  ajDie("File downloading error from:\n%s\n", result);
                }
              else
                {
                  ajFmtPrint("Created %S\n", outfname);
                }
            }

	  ajStrDel(&outfname);
	}
      else
	{
	  soap_print_fault(&soap, stderr);
	}

      soap_destroy(&soap);
      soap_end(&soap);
      soap_done(&soap);

      AJFREE(in0);

      ajStrDel(&inseq);
    }

  ajSeqallDel(&seqall);
  ajSeqDel(&seq);

  ajStrDel(&filename);

  embExit();
}
示例#19
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, &params, &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;
}
示例#20
0
static EmbPEntry dbifasta_NextFlatEntry(AjPFile libr, ajint ifile,
					AjPRegexp idexp,
					ajuint type, AjBool systemsort,
					AjPStr const * fields,
					ajint* maxFieldLen,
					ajuint* maxidlen, ajuint* countfield,
					AjPFile elistfile, AjPFile* alistfile)
{
    ajint ir;
    ajint is = 0;
    char* token;
    ajint i;
    static ajint nfields;
    ajint ifield;

    if(!dbifastaGFdl)
    {
	nfields = 0;
	while(fields[nfields])
	    nfields++;
	if(nfields)
	    AJCNEW(dbifastaGFdl, nfields);
	for(i=0; i < nfields; i++)
	{
	    dbifastaGFdl[i] = ajListNew();
	}
    }

    if(!dbifastaGEntry || !systemsort)
	dbifastaGEntry = embDbiEntryNew(nfields);

    if(!dbifasta_ParseFasta(libr, &ir, maxFieldLen,
			    countfield, idexp, type,
			    alistfile, systemsort, fields))
	return NULL;

    /* id to dbifastaGEntry->entry */
    if(ajStrGetLen(dbifastaGTmpId) > *maxidlen)
	*maxidlen = ajStrGetLen(dbifastaGTmpId);

    if(systemsort)
	ajFmtPrintF(elistfile, "%S %d %d %d\n",
                    dbifastaGTmpId, ir, is, ifile+1);
    else
    {
	dbifastaGEntry->entry   = ajCharNewS(dbifastaGTmpId);
	dbifastaGEntry->rpos    = ir;
	dbifastaGEntry->spos    = is;
	dbifastaGEntry->filenum = ifile+1;

	/* field tokens as list, then move to ret->field */
	for(ifield=0; ifield < nfields; ifield++)
	{
	    dbifastaGEntry->nfield[ifield] =
            (ajuint) ajListGetLength(dbifastaGFdl[ifield]);

	    if(dbifastaGEntry->nfield[ifield])
	    {
		AJCNEW(dbifastaGEntry->field[ifield],
		       dbifastaGEntry->nfield[ifield]);

		i = 0;
		while(ajListPop(dbifastaGFdl[ifield], (void**) &token))
		    dbifastaGEntry->field[ifield][i++] = token;
	    }
	    else
		dbifastaGEntry->field[ifield] = NULL;
	}
    }

    return dbifastaGEntry;
}
示例#21
0
static AjBool dbifasta_ParseFasta(AjPFile libr, ajint* dpos,
				  ajint* maxFieldLen, ajuint* countfield,
				  AjPRegexp idexp,
				  ajuint usertype, AjPFile* alistfile,
				  AjBool systemsort, AjPStr const * fields)
{
    char* fd;
    ajlong ipos;
    static AjPStr tstr = NULL;
    static ajint numFields;
    static ajint accfield = -1;
    static ajint desfield = -1;
    static ajint svnfield = -1;
    static AjBool reset = AJTRUE;

    ajuint type = usertype;

    if(!fields)
    {
	reset = ajTrue;
	accfield = svnfield = desfield = -1;
	return ajFalse;
    }

    if(reset)
    {
	numFields = 0;
	while(fields[numFields])
	{
	    if(ajStrMatchCaseC(fields[numFields], "acc"))
		accfield=numFields;
	    else if(ajStrMatchCaseC(fields[numFields], "sv"))
		svnfield=numFields;
	    else if(ajStrMatchCaseC(fields[numFields], "des"))
		desfield=numFields;
	    else
		ajWarn("EMBL parsing unknown field '%S' ignored",
		       fields[numFields]);

	    numFields++;
	}
	reset = ajFalse;
    }

    if(!dbifastaGWrdexp)
	dbifastaGWrdexp = ajRegCompC("([A-Za-z0-9]+)");

    if(!tstr)
	tstr = ajStrNew();

    *dpos = (ajint) ajFileResetPos(libr); /* Lossy cast */

    ajReadline(libr, &dbifastaGRline);

    if(!ajStrGetLen(dbifastaGRline))
        return ajFalse;

    if(!ajRegExec(idexp,dbifastaGRline))
    {
	ajStrDelStatic(&dbifastaGTmpAc);
        type = FASTATYPE_SIMPLE;
        idexp = dbifastaGIdexp;

        if(!ajRegExec(idexp, dbifastaGRline))
        {
            ajFatal("Unrecognised ID line format: %S", dbifastaGRline);
            return ajFalse;
        }

	ajWarn("Invalid ID line for selected format: %S", dbifastaGRline);
    }

    /*
    ** each case needs to set id, tmpac, tmpsv, tmpdes
    ** using empty values if they are not found
    */

    ajStrAssignC(&dbifastaGTmpSv, "");
    ajStrAssignC(&dbifastaGTmpGi, "");
    ajStrAssignC(&dbifastaGTmpDb, "");
    ajStrAssignC(&dbifastaGTmpDes, "");
    ajStrAssignC(&dbifastaGTmpAc, "");
    ajStrAssignC(&dbifastaGTmpId, "");

    switch(type)
    {
    case FASTATYPE_SIMPLE:
	ajRegSubI(idexp,2,&dbifastaGTmpId);
	ajStrAssignS(&dbifastaGTmpAc,dbifastaGTmpId);
	ajRegPost(idexp, &dbifastaGTmpDes);
	break;
    case FASTATYPE_DBID:
	ajRegSubI(idexp,1,&dbifastaGTmpId);
	ajStrAssignS(&dbifastaGTmpAc,dbifastaGTmpId);
	ajRegPost(idexp, &dbifastaGTmpDes);
	break;
    case FASTATYPE_GCGID:
	ajRegSubI(idexp,1,&dbifastaGTmpId);
	ajStrAssignS(&dbifastaGTmpAc,dbifastaGTmpId);
	ajRegPost(idexp, &dbifastaGTmpDes);
	break;
    case FASTATYPE_NCBI:
	if(!ajSeqParseNcbi(dbifastaGRline, &dbifastaGTmpId, &dbifastaGTmpAc,
			   &dbifastaGTmpSv, &dbifastaGTmpGi, &dbifastaGTmpDb,
                           &dbifastaGTmpDes))
	{
	    ajStrDelStatic(&dbifastaGTmpAc);
	    return ajFalse;
	}
	break;
    case FASTATYPE_GCGIDACC:
	ajRegSubI(idexp,1,&dbifastaGTmpId);
	ajRegSubI(idexp,2,&dbifastaGTmpAc);
	ajRegPost(idexp, &dbifastaGTmpDes);
	break;
    case FASTATYPE_GCGACCID:
	ajRegSubI(idexp,1,&dbifastaGTmpAc);
	ajRegSubI(idexp,2,&dbifastaGTmpId);
	ajRegPost(idexp, &dbifastaGTmpDes);
	break;
    case FASTATYPE_IDACC:
	ajRegSubI(idexp,1,&dbifastaGTmpId);
	ajRegSubI(idexp,2,&dbifastaGTmpAc);
	ajRegPost(idexp, &dbifastaGTmpDes);
	break;
    case FASTATYPE_ACCID:
	ajRegSubI(idexp,1,&dbifastaGTmpAc);
	ajRegSubI(idexp,2,&dbifastaGTmpId);
	ajRegPost(idexp, &dbifastaGTmpDes);
	break;
    default:
	ajStrDelStatic(&dbifastaGTmpAc);
	return ajFalse;
    }

    ajStrFmtUpper(&dbifastaGTmpId);
    ajStrFmtUpper(&dbifastaGTmpAc);

    if(accfield >= 0)
	embDbiMaxlen(&dbifastaGTmpAc, &maxFieldLen[accfield]);
    if(svnfield >= 0)
    {
	embDbiMaxlen(&dbifastaGTmpSv, &maxFieldLen[svnfield]);
	embDbiMaxlen(&dbifastaGTmpGi, &maxFieldLen[svnfield]);
    }

    if(systemsort)
    {
	if(accfield >= 0 && ajStrGetLen(dbifastaGTmpAc))
	{
	    countfield[accfield]++;
	    ajFmtPrintF(alistfile[accfield], "%S %S\n",
                        dbifastaGTmpId, dbifastaGTmpAc);
	}
	if(svnfield >= 0 && ajStrGetLen(dbifastaGTmpSv))
	{
	    countfield[svnfield]++;
	    ajFmtPrintF(alistfile[svnfield], "%S %S\n",
                        dbifastaGTmpId, dbifastaGTmpSv);
	}
	if(svnfield >= 0 && ajStrGetLen(dbifastaGTmpGi))
	{
	    countfield[svnfield]++;
	    ajFmtPrintF(alistfile[svnfield], "%S %S\n",
                        dbifastaGTmpId, dbifastaGTmpGi);
	}
	if(desfield >= 0 && ajStrGetLen(dbifastaGTmpDes))
	    while(ajRegExec(dbifastaGWrdexp, dbifastaGTmpDes))
	    {
		ajRegSubI(dbifastaGWrdexp, 1, &dbifastaGTmpFd);
		embDbiMaxlen(&dbifastaGTmpFd, &maxFieldLen[desfield]);
		ajStrFmtUpper(&dbifastaGTmpFd);
		ajDebug("++des '%S' tmpdes '%S\n",
			dbifastaGTmpFd, dbifastaGTmpDes);
		countfield[desfield]++;
		ajFmtPrintF(alistfile[desfield], "%S %S\n",
			    dbifastaGTmpId, dbifastaGTmpFd);
		ajRegPost(dbifastaGWrdexp, &dbifastaGTmpDes);
	    }
    }
    else
    {
	if(accfield >= 0 && ajStrGetLen(dbifastaGTmpAc))
	{
	    fd = ajCharNewS(dbifastaGTmpAc);
	    ajListPushAppend(dbifastaGFdl[accfield],fd);
	    countfield[accfield]++;
	}

	if(svnfield >= 0 && ajStrGetLen(dbifastaGTmpSv))
	{
	    fd = ajCharNewS(dbifastaGTmpSv);
	    ajListPushAppend(dbifastaGFdl[svnfield], fd);
	    countfield[svnfield]++;
	}

	if(svnfield >= 0 && ajStrGetLen(dbifastaGTmpGi))
	{
	    fd = ajCharNewS(dbifastaGTmpGi);
	    ajListPushAppend(dbifastaGFdl[svnfield], fd);
	    countfield[svnfield]++;
	}

	if(desfield >= 0 && ajStrGetLen(dbifastaGTmpDes))
	    while(ajRegExec(dbifastaGWrdexp, dbifastaGTmpDes))
	    {
		ajRegSubI(dbifastaGWrdexp, 1, &dbifastaGTmpFd);
		embDbiMaxlen(&dbifastaGTmpFd, &maxFieldLen[desfield]);
		ajStrFmtUpper(&dbifastaGTmpFd);
		ajDebug("++des '%S' tmpdes: '%S'\n",
			dbifastaGTmpFd, dbifastaGTmpDes);
		fd = ajCharNewS(dbifastaGTmpFd);
		ajListPushAppend(dbifastaGFdl[desfield], fd);
		countfield[desfield]++;
		ajRegPost(dbifastaGWrdexp, &dbifastaGTmpDes);
	    }
    }

    ipos = ajFileResetPos(libr);

    while(ajReadline(libr, &dbifastaGRline))
    {
	if(ajStrGetCharFirst(dbifastaGRline) == '>')
	{
	    ajFileSeek(libr, ipos, 0);
	    return ajTrue;
	}
	ipos = ajFileResetPos(libr);
    }

    ajFileSeek(libr, ipos, 0);		/* end of file reached */

    return ajTrue;
}
示例#22
0
int main(int argc, char **argv)
{
    /*         
    ** All pointers set to NULL for safety. 
    ** Variables names and initialisation values aligned for clarity.
    */

    AjBool    boo   = ajFalse;
    ajint     n1    = 0;
    ajint     n2    = 0;
    ajlong    l1    = 0;     /* long int */
    float     f1    = 0.0;
    double    d1    = 0.0;   /* there is no long double */
    size_t    size  = 100;   /* Reserved memory size.  Could be any value you know in advance. */


    embInit("demostringnew", argc, argv);
    
    demostringnew_msg("/* Starting string values */");
    

    /* Functions with the prefix ajStr are for manipulating EMBOSS strings.
       Functions with the prefix ajChar are for manipulating C-type (char*) string 
       See filesection and datasection sections in ajstr.c */


    /*
    ** String constructor functions 
    ** See "@section constructors" in ajstr.c
    */

    /* Construct a new string with no starting value or reserved size.
       There is no equivlent function for C-type (char*) strings */
    str0  = ajStrNew ();

    /* Construct a new string with a reserved size but no starting value */
    txt1 = ajCharNewRes(size);  
    str1 = ajStrNewRes (size);    

    /* Construct a new C-type (char*) string with a starting value ... */
    txt2 = ajCharNewC ("Starting value");   /* ... copied from a C-type (char*) string */
    str2 = ajStrNewC  (txt2);                /* ... copied from a C-type (char*) string */
    txt3 = ajCharNewS (str2);                /* ... copied from a string */
    str3 = ajStrNewS  (str2);                /* ... copied from a string */

    /* Construct a new string with a reserved size and starting value ... */
    txt4 = ajCharNewResC("Starting value, reserved size", size);  /* ... copied from a C-type (char*) string)*/
    str4 = ajStrNewResC (txt4, size);                              /* ... copied from a C-type (char*) string */
    /* or str4 = ajStrNewResLenC(txt4, size, strlen(txt4)); to specify string length */
    txt5 = ajCharNewResS(str4, size);                              /* ... copied from a string */
    str5 = ajStrNewResS (str4, size);                              /* ... copied from a string */

    demostringnew_msg("/* After string constructor functions */");    





    /*
    ** String destructor functions 
    ** See "@section destructors" in ajstr.c) 
    */
    
    /* Destruct a string */
    ajCharDel(&txt1);
    ajCharDel(&txt2);
    ajCharDel(&txt3);
    ajCharDel(&txt4);
    ajCharDel(&txt5);
    ajStrDel (&str0);
    ajStrDel (&str1);
    ajStrDel (&str3);
    ajStrDel (&str5);

    /* str2 & str4 still in memory */
    demostringnew_msg("/* After string destructor functions */");    





    /*
    ** String (de)referencing functions 
    ** See "@section destructors" in ajstr.c)
    */

    str0 = ajStrNewRef(str2);
    /* or ajStrAssignRef(&str0, str2); */
    demostringnew_msg("/* After string reference */");    

    ajStrDelStatic(&str0);
    demostringnew_msg("/* After string dereference */");    





    /*
    ** String assignment functions 
    ** See "@section assignment" in ajstr.c)
    */

    /* Still only str2 & str4 in memory */

    /* Assign a string value using ... */
    ajStrAssignC(&str1, "Assigned value");     /* ... a C-type (char*) string */
    /*    or ajStrAssignLenC(&str1, "Assigned value", strlen("Assigned value")); to specify string length. */
    ajStrAssignS(&str3, str1);                 /* ... a string                */
    ajStrAssignK(&str5, 'A');                  /* ... a character             */
    demostringnew_msg("/* After string assignment 1 */");    

    ajStrAssignSubC(&str1, "Assigned value", 0, 11);
    ajStrAssignSubS(&str3, str1, 0, 9);
    demostringnew_msg("/* After string assignment 2 */");    

    /* The assignment functions allocate memory if necessary so str1, str3 and str5 will be created for you.  It's bad practice to use this mechanism however because it's not obvious the string has been allocated (and needs freeing).  Much cleaner to call the construct (ajStrNew) explicitly. */



    /* Assign a string with a reserved size and value using ... */
    ajStrAssignResC(&str1, size, "Assigned value, reserved size");  /* ... a C-type (char*) string */
    ajStrAssignResS(&str3, size, str1);                             /* ... a string                */
    demostringnew_msg("/* After string assignment 3 */");    



    /* Assign a string value only if the string is empty using ... */
    str0 = ajStrNew();
    ajStrAssignEmptyC(&str0, "New value if string was empty");    /* ... a C-type (char*) string */ 
    ajStrAssignEmptyS(&str1, str0);                               /* ... a string                */
    demostringnew_msg("/* After string assignment 4 */");    

    /* Now str0-5 in memory.  The above code is for illustrative purposes: it's much cleaner to put all the constructors / destructors at the top / bottom of the code where possible. */


    /* Assign all strings intuitive values */
    txt0 = ajCharNewResC("TEXT 0", 100);   
    txt1 = ajCharNewResC("TEXT 1", 100);   
    txt2 = ajCharNewResC("Text 2", 100);   
    txt3 = ajCharNewResC("Text 3", 100);   
    txt4 = ajCharNewResC("Text 4", 100);   
    txt5 = ajCharNewResC("Text 5", 100);
    ajStrAssignC(&str0, "STRING 0");   
    ajStrAssignC(&str1, "STRING 1");   
    ajStrAssignC(&str2, "String 2");   
    ajStrAssignC(&str3, "String 3");   
    ajStrAssignC(&str4, "String 4 WITHSOMETEXTINABLOCK");   
    ajStrAssignC(&str5, "String 5 WITHSOMETEXTINABLOCK");   
    demostringnew_msg("/* After string assignment 5 */");    





    /*
    ** String formatting functions 
    ** See "@section formatting" in ajstr.c
    */
    ajCharFmtLower(txt0);
    ajCharFmtLower(txt1);
    ajStrFmtLower(&str0);
    ajStrFmtLowerSub(&str1, 0, 2);

    ajCharFmtUpper(txt2);
    ajCharFmtUpper(txt3);
    ajStrFmtUpper(&str2);
    ajStrFmtUpperSub(&str3, 0, 2);
    demostringnew_msg("/* After string formatting 1 */");    


    ajStrFmtTitle(&str0);
    ajStrFmtQuote(&str1);
    ajStrFmtBlock(&str4, 3);
    demostringnew_msg("/* After string formatting 2 */");    


    /* See also ajStrFmtWrap, ajStrFmtWrapLeft
       ... these need checking. */





    /*
    ** String conversion functions 
    ** See "@section datatype to string conversion" in ajstr.c
    */
    n1 = n2 = l1 = 1;
    f1 = d1 = 0.5;
    ajStrFromBool( &str0, boo);
    ajStrFromInt(&str1, n1);
    ajStrFromLong(&str2, l1);
    ajStrFromFloat(&str3, f1, 5);
    ajStrFromDouble(&str4, d1, 5);
    ajStrFromDoubleExp(&str5, d1, 5);
    demostringnew_msg("/* After datatype to string conversion */");    


    /*
    ** String conversion functions 
    ** See "@section string to datatype conversion" in ajstr.c
    */
    ajStrToBool(str0, &boo);
    ajStrToInt(str1, &n1);
    ajStrToLong(str2, &l1);
    ajStrToDouble(str4, &d1);
    ajUser("/* After string to datatype conversion */\n"
	   "boo (from str0): %B\nn1 (from str1): %d\nl1 (from str2): %d", 
	   boo, n1, l1);
    ajFmtPrint("f1 (from str3): %f\nd1 (from str4): %f\n", f1, d1);
    /* Check ajUser ... doesn't support %f */
    /* See also  ajStrToHex */





    /* Assign all strings new values */
    strcpy(txt0, "Text String");
    strcpy(txt1, "TEXT STRING");
    strcpy(txt2, "Text*");
    strcpy(txt3, "Text");
    strcpy(txt4, "Text String 4");
    strcpy(txt5, "Text String 5");

    ajStrAssignC(&str0, "String");   
    ajStrAssignC(&str1, "STRING");   
    ajStrAssignC(&str2, "String*");   
    ajStrAssignC(&str3, "*String");   
    ajStrAssignC(&str4, "String 4");   
    ajStrAssignC(&str5, "String 5");   
    demostringnew_msg("/* After resetting strings */");    





    /*
    ** String comparison functions 
    ** See "@section comparison" in ajstr.c
    */
    ajUserDumpC("/* String comparison functions */");
    boo = ajCharMatchC(txt0, txt1);
    ajUser("ajCharMatchC(txt0 txt1); == %B", boo);
    boo = ajCharMatchCaseC(txt0, txt1);
    ajUser("ajCharMatchCaseC(txt0 txt1); == %B", boo);
    boo = ajCharMatchC(txt0, txt2);
    ajUser("ajCharMatchC(txt0,txt2); == %B", boo);
    boo = ajCharMatchWildC(txt0, txt2);
    ajUser("ajCharMatchWildC(txt0,txt2); == %B", boo);
    boo = ajCharMatchWildS(txt0, str2);
    ajUser("ajCharMatchWildS(txt0,str2); == %B", boo);
    /* See also ajCharMatchWildNextC, ajCharMatchWildWordC
       ... these need checking & documentation updated. */

    boo = ajCharPrefixC(txt0, txt3);
    ajUser("ajCharPrefixC(txt0, txt3); == %B", boo);
    boo = ajCharPrefixS(txt0, str0);
    ajUser("ajCharPrefixS(txt0, str0); == %B", boo);
    boo = ajCharPrefixCaseC(txt5, txt1);
    ajUser("ajCharPrefixCaseC(txt5, txt1); == %B", boo);
    boo = ajCharPrefixCaseC(txt1, txt5);
    ajUser("ajCharPrefixCaseC(txt1, txt5); == %B", boo);
    boo = ajCharPrefixCaseS(txt0, str0);
    ajUser("ajCharPrefixCaseS(txt0, str0); == %B", boo);
    boo = ajCharSuffixC(txt0, txt3);
    ajUser("ajCharSuffixC(txt0, txt3); === %B", boo);
    boo = ajCharSuffixS(txt0, str0);
    ajUser("ajCharSuffixS(txt0, str0); == %B", boo);

    /* See also ajCharSuffixCaseC, ajCharSuffixCaseC, ajCharSuffixCaseS, ajCharSuffixCaseS
       ... these need checking. */
    boo =  ajStrMatchC (str0, txt0);
    ajUser("ajStrMatchC (str0, txt0); == %B", boo);
    boo = ajStrMatchS(str0, str1);
    ajUser("ajStrMatchS(str0, str1); == %B", boo);
    boo = ajStrMatchCaseC(str0, txt0);
    ajUser("ajStrMatchCaseC(str0, txt0); == %B", boo);
    boo = ajStrMatchCaseS(str0, str0);
    ajUser("ajStrMatchCaseS(str0, str0); == %B", boo);


    /*
    ajUser("== %B", boo);

    boo = ajStrMatchWildC(str2, const char* text);
     ajStrMatchWildS  (const AjPStr thys, const AjPStr wild);
     ajStrMatchWildWordC (const AjPStr str, const char* text);
     ajStrMatchWildWordS (const AjPStr str, const AjPStr text);
     ajStrPrefixC(const AjPStr str, const char* txt2);
     ajStrPrefixS(const AjPStr str, const AjPStr str2);
     ajStrPrefixCaseC (const AjPStr str, const char* pref);
     ajStrPrefixCaseS (const AjPStr str, const AjPStr pref);
     ajStrSuffixC (const AjPStr thys, const char* suff);
     ajStrSuffixS (const AjPStr thys, const AjPStr suff);
    */





    /**************************************************************************/
    /* String substitution functions (See "@section substitution" in ajstr.c) */
    /**************************************************************************/

    /*
AjBool     ajStrExchangeCC(AjPStr* Pstr, const char* txt, const char* txtnew);
AjBool     ajStrExchangeCS(AjPStr* Pstr, const char* txt,
                           const AjPStr strnew);
AjBool     ajStrExchangeKK(AjPStr* Pstr, char chr, char chrnew);
AjBool     ajStrExchangeSC(AjPStr* Pstr, const AjPStr str,
                           const char* txtnew);
AjBool     ajStrExchangeSS(AjPStr* Pstr, const AjPStr str,
                           const AjPStr strnew);
AjBool     ajStrExchangeSetCC(AjPStr* Pstr, const char* oldc,
                              const char* newc);
AjBool     ajStrExchangeSetSS(AjPStr* Pstr, const AjPStr str,
                            const AjPStr strnew);
AjBool     ajStrRandom(AjPStr *s);
AjBool     ajStrReverse(AjPStr* Pstr);
    */


    embExit();
    return 0;
}
示例#23
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, &params, &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;
}
示例#24
0
static AjBool dbiblast_parseNcbi(const AjPStr line, AjPFile * alistfile,
				 AjBool systemsort, AjPStr const * fields,
				 ajint* maxFieldLen,
				 ajuint* countfield,
				 AjPStr* myid,
				 AjPList* fdlist)
{
    char* fd;

    static ajint numFields;
    static ajint accfield = -1;
    static ajint desfield = -1;
    static ajint svnfield = -1;
    static AjBool reset = AJTRUE;

    if(!fields)
    {
	reset = ajTrue;
	accfield = svnfield = desfield = -1;
	return ajFalse;
    }

    if(reset)
    {
	numFields = 0;
	while(fields[numFields])
	{
	    if(ajStrMatchCaseC(fields[numFields], "acc"))
		accfield=numFields;
	    else if(ajStrMatchCaseC(fields[numFields], "sv"))
		svnfield=numFields;
	    else if(ajStrMatchCaseC(fields[numFields], "des"))
		desfield=numFields;
	    else
		ajWarn("EMBL parsing unknown field '%S' ignored",
		       fields[numFields]);
	    numFields++;
	}
	reset = ajFalse;
    }

    if(!wrdexp)
	wrdexp = ajRegCompC("([A-Za-z0-9]+)");

    ajStrAssignC(&tmpdes,"");
    ajStrAssignC(&t,"");
    ajStrAssignC(&tmpac,"");
    ajStrAssignC(&tmpsv,"");
    ajStrAssignC(&tmpgi,"");
    ajStrAssignC(&tmpdb,"");

    ajFmtPrintS(&t,">%S",line);

    if(!ajSeqParseNcbi(t,myid,&tmpac,&tmpsv,&tmpgi,&tmpdb,&tmpdes))
	return ajFalse;

    if(ajStrGetLen(tmpac))
	ajStrFmtUpper(&tmpac);

    if(accfield >= 0)
	embDbiMaxlen(&tmpac, &maxFieldLen[accfield]);

    if(svnfield >= 0)
    {
	embDbiMaxlen(&tmpsv, &maxFieldLen[svnfield]);
	embDbiMaxlen(&tmpgi, &maxFieldLen[svnfield]);
    }


    ajStrFmtUpper(myid);

    /* ajDebug("parseNCBI success\n"); */

    if(systemsort)
    {
	if(accfield >= 0 && ajStrGetLen(tmpac))
	{
	    countfield[accfield]++;
	    ajFmtPrintF(alistfile[accfield], "%S %S\n", *myid, tmpac);
	}
	if(svnfield >= 0 && ajStrGetLen(tmpsv))
	{
	    countfield[svnfield]++;
	    ajFmtPrintF(alistfile[svnfield], "%S %S\n", *myid, tmpsv);
	}
	if(svnfield >= 0 && ajStrGetLen(tmpgi))
	{
	    countfield[svnfield]++;
	    ajFmtPrintF(alistfile[svnfield], "%S %S\n", *myid, tmpgi);
	}
	if(desfield >= 0 && ajStrGetLen(tmpdes))
	    while(ajRegExec(wrdexp, tmpdes))
	    {
		ajRegSubI(wrdexp, 1, &tmpfd);
		embDbiMaxlen(&tmpfd, &maxFieldLen[desfield]);
		ajStrFmtUpper(&tmpfd);
		ajDebug("++des '%S'\n", tmpfd);
		countfield[desfield]++;
		ajFmtPrintF(alistfile[desfield], "%S %S\n", *myid, tmpfd);
		ajRegPost(wrdexp, &tmpdes);
	    }
    }
    else
    {
        if(accfield >= 0 && ajStrGetLen(tmpac))
	{
	    fd = ajCharNewS(tmpac);
	    countfield[accfield]++;
	    ajListPushAppend(fdlist[accfield], fd);
	}

        if(svnfield >= 0 && ajStrGetLen(tmpsv))
	{
	    fd = ajCharNewS(tmpsv);
	    countfield[svnfield]++;
	    ajListPushAppend(fdlist[svnfield], fd);
	}

        if(svnfield >= 0 && ajStrGetLen(tmpgi))
	{
	    fd = ajCharNewS(tmpgi);
	    ajListPushAppend(fdlist[svnfield], fd);
	}

        if(desfield >= 0 && ajStrGetLen(tmpdes))
	{
	    while(ajRegExec(wrdexp, tmpdes))
	    {
		ajRegSubI(wrdexp, 1, &tmpfd);
		embDbiMaxlen(&tmpfd, &maxFieldLen[desfield]);
		ajStrFmtUpper(&tmpfd);
		ajDebug("++des '%S'\n", tmpfd);
		fd = ajCharNewS(tmpfd);
		countfield[desfield]++;
		ajListPushAppend(fdlist[desfield], fd);
		ajRegPost(wrdexp, &tmpdes);
	    }
	}
    }

    /* ajDebug("parseNCBI '%S' '%S'\n", *myid, tmpac); */

    return ajTrue;
}
示例#25
0
int main(int argc, char *argv[])
{
  embInitPV("gseqinfo", argc, argv, "GEMBASSY", "1.0.1");

  struct soap soap;

  AjPSeqall seqall;
  AjPSeq    seq;
  AjPStr    inseq  = NULL;
  AjPStr    seqid  = NULL;
  AjPStr    tmp    = NULL;
  AjPStr    parse  = NULL;
  AjPStr    numA   = NULL;
  AjPStr    numT   = NULL;
  AjPStr    numG   = NULL;
  AjPStr    numC   = NULL;
  AjPStrTok handle = NULL;

  ajint n;

  char *in0;
  char *result;

  AjBool  show = 0;
  AjPFile outf = NULL;

  seqall = ajAcdGetSeqall("sequence");

  outf = ajAcdGetOutfile("outfile");

  while(ajSeqallNext(seqall, &seq))
    {

      soap_init(&soap);

      inseq = NULL;

      ajStrAppendC(&inseq, ">");
      ajStrAppendS(&inseq, ajSeqGetNameS(seq));
      ajStrAppendC(&inseq, "\n");
      ajStrAppendS(&inseq, ajSeqGetSeqS(seq));

      ajStrAssignS(&seqid, ajSeqGetAccS(seq));

      in0 = ajCharNewS(inseq);

      if(soap_call_ns1__seqinfo(
			       &soap,
                                NULL,
                                NULL,
			        in0,
                               &result
			       ) == SOAP_OK)
        {
          tmp = ajStrNewC(result);

          ajStrExchangeCC(&tmp, "<", "\n");
          ajStrExchangeCC(&tmp, ">", "\n");

          handle = ajStrTokenNewC(tmp, "\n");

          while(ajStrTokenNextParse(handle, &parse))
            {
              if(ajStrIsInt(parse))
                if(!numA)
                  numA = ajStrNewS(parse);
                else if(!numT)
                  numT = ajStrNewS(parse);
                else if(!numG)
                  numG = ajStrNewS(parse);
                else if(!numC)
                  numC = ajStrNewS(parse);
            }
          if(show)
            ajFmtPrint("Sequence: %S A: %S T: %S G: %S C: %S\n",
                       seqid, numA, numT, numG, numC);
          else
            ajFmtPrintF(outf, "Sequence: %S A: %S T: %S G: %S C: %S\n",
                        seqid, numA, numT, numG, numC);
        }
      else
        {
          soap_print_fault(&soap, stderr);
        }

      soap_destroy(&soap);
      soap_end(&soap);
      soap_done(&soap);

      AJFREE(in0);

      ajStrDel(&inseq);
  }

  ajSeqallDel(&seqall);
  ajSeqDel(&seq);
  ajStrDel(&seqid);

  embExit();

  return 0;
}
示例#26
0
int main(int argc, char **argv) {

    embInitPV("kfetchdata", argc, argv, "KBWS", "1.0.8");

    struct soap soap;
    struct ns1__fetchDataInputParams params;
    char* jobid;
    char* result;

    AjPStr   id;
    AjPFile  outf;
    AjPStr   substr;
    AjPStr   format;
    AjPStr   style;

    id     = ajAcdGetString("id");
    outf   = ajAcdGetOutfile("outfile");
    format = ajAcdGetString("format");
    style  = ajAcdGetString("style");

    params.format = ajCharNewS(format);
    params.style  = ajCharNewS(style);

    soap_init(&soap);

    char* in0;
    in0 = ajCharNewS(id);
    if ( soap_call_ns1__runFetchData( &soap, NULL, NULL, in0, &params, &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);
    }


    soap_destroy(&soap);
    soap_end(&soap);
    soap_done(&soap);

    ajStrDel(&id);
    ajFileClose(&outf);
    ajStrDel(&substr);

    embExit();

    return 0;
}