Пример #1
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;
}
Пример #2
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;
}