Ejemplo n.º 1
0
int main(int argc, char **argv)
{
    /* Variable declarations */
    AjPFile outf = NULL;    
    AjPXmlall xmlall = NULL;

    AjPXml xml     = NULL;

    /* ACD processing */
    embInit("xmltext", argc, argv);

    xmlall    = ajAcdGetXmlall("xml");
    outf   = ajAcdGetOutfile("outfile");
    
    while(ajXmlallNext(xmlall, &xml))
    {
        ajFmtPrintF(outf,"%S",ajXmlGetEntry(xml));
    }

    /* Memory clean-up and exit */

    ajXmlallDel(&xmlall);
    ajXmlDel(&xml);

    ajFileClose(&outf);
   
    embExit();

    return 0;
}
Ejemplo n.º 2
0
int main(int argc, char **argv)
{
    /* Variable declarations */
    AjPFile outfile = NULL;    
    AjPResourceall resourceall = NULL;

    AjPResource resource = NULL;

    /* ACD processing */
    embInit("drtext", argc, argv);

    resourceall = ajAcdGetResourceall("resources");
    outfile   = ajAcdGetOutfile("outfile");
    
    while(ajResourceallNext(resourceall, &resource))
    {
        ajFmtPrintF(outfile,"%S",ajResourceGetEntry(resource));
    }

    ajResourceallDel(&resourceall);
    ajResourceDel(&resource);
    ajFileClose(&outfile);
   
    embExit();

    return 0;
}
Ejemplo n.º 3
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;
}
Ejemplo n.º 4
0
int main(int argc, char **argv)
{
    AjPSeqall seqall;
    AjPSeq seq = NULL;
    AjPFile primerFile;		  /* read the primer pairs from a file */
    AjPFile outf;
    AjPList primerList;

    ajint mmp = 0;

    embInit("primersearch", argc, argv);

    seqall     = ajAcdGetSeqall("seqall");
    outf       = ajAcdGetOutfile("outfile");
    primerFile = ajAcdGetInfile("infile");
    mmp        = ajAcdGetInt("mismatchpercent");

    /* build list of forward/reverse primer pairs as read from primerfile */
    primerList = ajListNew();

    /* read in primers from primerfile, classify and compile them */
    primersearch_read_primers(&primerList,primerFile, mmp);

    /* check there are primers to be searched */
    if(!ajListGetLength(primerList))
    {
	ajErr("No suitable primers found - exiting");
	embExitBad();
	return 0;

    }

    /* query sequences one by one */
    while(ajSeqallNext(seqall,&seq))
	primersearch_primer_search(primerList, seq);

    /* output the results */
    primersearch_print_hits(primerList, outf);

    /* delete all nodes of list, then the list itself */
    ajListMap(primerList, primersearch_free_primer, NULL);
    ajListFree(&primerList);
    ajListFree(&primerList);

    ajFileClose(&outf);

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

    ajFileClose(&primerFile);

    embExit();

    return 0;
}
Ejemplo n.º 5
0
/* @prog scopparse ************************************************************
**
** Converts raw scop classification files to a file in embl-like format.
**
******************************************************************************/
int main(int argc, char **argv)
{
    AjPFile inf1         = NULL;
    AjPFile inf2         = NULL;
    AjPFile outf         = NULL;
    AjPList list         = NULL;    
    AjPScop tmp          = NULL;
    AjBool  nosegments   = ajFalse;
    AjBool  nomultichain = ajFalse;
    AjBool  nominor      = ajFalse;
       




    /* Read data from acd. */
    embInitPV("scopparse", argc, argv, "DOMAINATRIX",VERSION);
    inf1         =  ajAcdGetInfile("classfile");
    inf2         =  ajAcdGetInfile("desinfile");
    outf         = ajAcdGetOutfile("dcffile");
    nosegments   =  ajAcdGetBoolean("nosegments");
    nomultichain =  ajAcdGetBoolean("nomultichain");
    nominor      =  ajAcdGetBoolean("nominor");


    /*
    ajFmtPrint("nosegments: %B\n", nosegments);
    ajFmtPrint("nomultichain: %B\n", nomultichain);
    ajFmtPrint("nominor: %B\n", nominor);
    */

    /* Main body of code. */
    list = ajScopReadAllRawNew(inf1, inf2, nomultichain);
    while(ajListPop(list, (void **) &tmp))
    {
	if(((!nosegments) || (tmp->N == 1)) &&
	   ((!nominor) || ((tmp->Sunid_Class == 46456) ||  /* All alpha*/
			   (tmp->Sunid_Class == 48724) ||  /* All beta */
			   (tmp->Sunid_Class == 51349) ||  /* a/b      */
			   (tmp->Sunid_Class == 53931))))  /* a+b      */
	    ajScopWrite(outf, tmp);
	ajScopDel(&tmp);
    }
    

    /* Memory management. */
    ajFileClose(&outf);
    ajFileClose(&inf1);
    ajFileClose(&inf2);
    ajListFree(&list);

    ajExit();
    return 0;
}
Ejemplo n.º 6
0
int main(int argc, char **argv)
{
    AjPFile listf    = NULL; /* File to be read - caths.list.v2.4.      */
    AjPFile domf     = NULL; /* File to be read - domlist.v2.4.         */
    AjPFile namesf   = NULL; /* File to be read - CAT.names.all.v2.4.   */
    AjPFile outf     = NULL; /* Output file.                            */
    AjPFile logf     = NULL; /* Log file.                               */
    AjPList list     = NULL; /* List of CATH objects.                   */
    AjPCath tmp      = NULL; /* Temp. pointer.                          */
    
    
    embInitPV("cathparse", argc, argv, "DOMAINATRIX",VERSION);

    listf  =  ajAcdGetInfile("listfile");   
    domf   =  ajAcdGetInfile("domfile");    
    namesf =  ajAcdGetInfile("namesfile");  
    outf   =  ajAcdGetOutfile("outfile");   
    logf   =  ajAcdGetOutfile("logfile");   

    
    list = ajCathReadAllRawNew(listf, domf, namesf, logf);
    while(ajListPop(list, (void **) &tmp))
    {	
	ajCathWrite(outf, tmp);
	ajCathDel(&tmp);
    }



    /* Close CATH parsable files and output file */
    ajFileClose(&listf); 
    ajFileClose(&domf); 
    ajFileClose(&namesf); 
    ajFileClose(&outf); 
    ajFileClose(&logf); 
    ajListFree(&list);

    ajExit();
    return 0;
}
Ejemplo n.º 7
0
int main(int argc, char **argv)
{
    /* Variable Declarations */
    AjPFile outf;
    AjPStr code = NULL;
    char    code1;
    ajuint i;
    ajuint iend;

    /* ACD File Processing */
    embInit("infobase", argc, argv);
    code = ajAcdGetString("code");
    outf = ajAcdGetOutfile("outfile");


    /* Application logic */

    ajStrFmtUpper(&code);
    iend = ajStrGetLen(code);
    ajFmtPrintF(outf, "%4s %-10s %-10s %s\n",
                "Code", "Ambiguity", "Complement", "Mnemonic");
    for(i=0;i<iend;i++)
    {
        code1=ajStrGetCharPos(code,i);
        if(ajBaseExistsChar(code1))
        {
            ajFmtPrintF(outf, "%-4c %-10S %-10c %S\n",
                        code1, ajBaseGetCodes(code1),
                        ajBaseAlphacharComp(code1),
                        ajBaseGetMnemonic(code1));
        }
        else
        {
            ajFmtPrintF(outf, "%-4c %-10s %-10c %s\n",
                        code1, ".",
                        '.',
                        "invalid");

        }
        
    }
    
    

    /* Memory management and exit */
    ajStrDel(&code);
    ajFileClose(&outf);

    embExit();

    return 0;
}
Ejemplo n.º 8
0
int main(int argc, char **argv)
{
    /* Variable Declarations */
    AjPFile   inf     = NULL;
    AjPFile   outf    = NULL; 

    AjPStr    line    = NULL;  /* Line from inf     */
    AjPStr    option  = NULL;
    AjBool    doall   = AJFALSE;
    AjBool    doend   = AJFALSE;
    AjBool    doexcess = AJFALSE;

    /* ACD File Processing */
    embInit("nospace", argc, argv);
    inf  = ajAcdGetInfile("infile");
    outf = ajAcdGetOutfile("outfile");
    option = ajAcdGetListSingle("menu");

    if(ajStrMatchC(option, "all"))
        doall = ajTrue;
    else if(ajStrMatchC(option, "end"))
        doend = ajTrue;
    else if(ajStrMatchC(option, "excess"))
        doexcess = ajTrue;

    /* Application logic */
    line    = ajStrNew();

    while(ajReadline(inf,&line))
      {
          if(doall)
              ajStrRemoveWhite(&line);
          else if(doend)
              ajStrTrimWhiteEnd(&line);
          else if(doexcess)
              ajStrRemoveWhiteExcess(&line);
	ajFmtPrintF(outf, "%S\n", line);
      }

    /* Memory management and exit */
    ajFileClose(&inf);
    ajFileClose(&outf);

    ajStrDel(&line);
    ajStrDel(&option);

    embExit();

    return 0;
}
Ejemplo n.º 9
0
int main(int argc, char **argv)
{
    AjPSeqall seqall;
    AjPSeq seq;
    AjPFile outf;
    AjPCod codon;
    AjPStr substr;
    ajint beg;
    ajint end;
    ajint ccnt;


    embInit("cusp", argc, argv);

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

    ccnt   = 0;
    substr = ajStrNew();
    codon  = ajCodNewCodenum(0);
    ajCodSetNameS(codon, ajFileGetPrintnameS(outf));

    while(ajSeqallNext(seqall, &seq))
    {
	beg = ajSeqallGetseqBegin(seqall);
	end  = ajSeqallGetseqEnd(seqall);
	ajStrAssignSubS(&substr,ajSeqGetSeqS(seq),beg-1,end-1);
	ajCodSetTripletsS(codon,substr,&ccnt);
    }

    ajCodCalcUsage(codon,ccnt);

    ajCodSetDescC(codon, "CUSP codon usage file");
    ajCodWrite(codon, outf);
    ajFileClose(&outf);

    ajStrDel(&substr);
    ajCodDel(&codon);

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

    embExit();

    return 0;
}
Ejemplo n.º 10
0
int main(int argc, char **argv)
{
    AjPSeqall seqall;
    AjPSeq seq;
    AjPTable table = 0;
    AjPFile outf;
    ajint wordsize;
    ajint mincount;

    embInit("wordcount", argc, argv);

    seqall = ajAcdGetSeqall("sequence1");

    wordsize = ajAcdGetInt("wordsize");
    outf     = ajAcdGetOutfile("outfile");
    mincount = ajAcdGetInt("mincount");

    embWordLength(wordsize);

    while (ajSeqallNext(seqall, &seq))
    {
        embWordGetTable(&table, seq);		/* get table of words   */
    }

    embWordPrintTableFI(table, mincount, outf); /* print table of words */
    /*
     **  test if table can be added to
     **  if(getWordTable(&table, seq, wordcount)) ?? get table of words ??
     **  {
     **       printWordTable(table);              ?? print table of words ??
     **  }
     */
    embWordFreeTable(&table);	/* free table of words */

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

    embExit();

    return 0;
}
Ejemplo n.º 11
0
int main(int argc, char **argv)
{
    AjPSeq seq = NULL;
    AjPFile outf = NULL;

    embInitPV("myseq", argc, argv, "myemboss",VERSION);

    seq = ajAcdGetSeq("sequence");
    outf = ajAcdGetOutfile("outfile");


    ajFmtPrintF(outf, "Sequence properties\n");
    ajFmtPrintF(outf, "===================\n");
    ajFmtPrintF(outf, "Name: %S\n", ajSeqGetNameS(seq));
    ajFmtPrintF(outf, "Usa: %S\n", ajSeqGetUsaS(seq));
    ajFmtPrintF(outf, "Length: %d\n", ajSeqGetLen(seq));
    ajFileClose(&outf);

    embExit();
    return 0;
}
Ejemplo n.º 12
0
int main(int argc, char **argv)
{
    AjPSeqall seqall;
    AjPFile outf;
    AjPSeq seq = NULL;
    AjPList xrefs = NULL;
    ajuint nrefs;
    AjPSeqXref xref = NULL;

    embInit("seqxref", argc, argv);

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

    xrefs = ajListNew();

    while(ajSeqallNext(seqall, &seq))
    {
        nrefs = ajSeqGetXrefs(seq, xrefs);
        ajSeqxreflistSort(xrefs);

        ajFmtPrintF(outf, "#%S: %u\n", ajSeqGetUsaS(seq), nrefs);

        while(ajListPop(xrefs, (void**)&xref))
        {
            ajFmtPrintF(outf, "%S:%S\n", xref->Db, xref->Id);
            ajSeqxrefDel(&xref);
        }
    }

    ajListFree(&xrefs);
    ajSeqDel(&seq);
    
    ajFileClose(&outf);
    ajSeqallDel(&seqall);

    embExit();

    return 0;
}
Ejemplo n.º 13
0
void   emboss_getoptions(char *pgm, int argc, char *argv[])
{

  ajint numseqs=0;
  ajint numwts=0;
  AjPStr method = NULL;

  ancvar = false;
  dollo = true;
  jumble = false;
  njumble = 1;
  trout = true;
  usertree = false;
  goteof = false;
  weights = false;
  justwts = false;
  printdata = false;
  progress = true;
  treeprint = true;
  stepbox = false;
  ancseq = false;
  mulsets = false;
  msets = 1;

  embInitPV(pgm, argc, argv, "PHYLIPNEW",VERSION);

    phylostates = ajAcdGetDiscretestates("infile");


    while (phylostates[numseqs])
	numseqs++;


    phylotrees = ajAcdGetTree("intreefile");
    if (phylotrees)
    {
        numtrees = 0;
        while (phylotrees[numtrees])
            numtrees++;
        usertree = true;
    }

    phyloweights = ajAcdGetProperties("weights");
    if (phyloweights)
    {
      weights = true;
      numwts = ajPhyloPropGetSize(phyloweights);
    }

    if (numseqs > 1) {
      mulsets = true;
      msets = numseqs;
    }
    else if (numwts > 1) {
      mulsets = true;
      msets = numwts;
      justwts = true;
    }


    method = ajAcdGetListSingle("method");

    if(ajStrMatchC(method, "d")) dollo = true;
    else dollo = false;

   if(!usertree) {  
      njumble = ajAcdGetInt("njumble");
      if(njumble >0) {
        inseed = ajAcdGetInt("seed");
        jumble = true; 
        emboss_initseed(inseed, &inseed0, seed);
      }
      else njumble = 1;
    }

    if((mulsets) && (!jumble)) {
      jumble = true;
      inseed = ajAcdGetInt("seed");
      emboss_initseed(inseed, &inseed0, seed);
    }

    phyloanc = ajAcdGetProperties("ancfile");
    if(phyloanc) ancvar = true;


    threshold = ajAcdGetFloat("threshold");

    printdata = ajAcdGetBoolean("printdata");
    progress = ajAcdGetBoolean("progress");
    treeprint = ajAcdGetBoolean("treeprint");
    trout = ajAcdGetToggle("trout");
    stepbox = ajAcdGetBoolean("stepbox");
    ancseq = ajAcdGetBoolean("ancseq");

     embossoutfile = ajAcdGetOutfile("outfile");   
     emboss_openfile(embossoutfile, &outfile, &outfilename);
     
     if(trout) {
     embossouttree = ajAcdGetOutfile("outtreefile");
     emboss_openfile(embossouttree, &outtree, &outtreename);
     }

    printf("\nDollo and polymorphism parsimony algorithm, version %s\n\n", VERSION);


    fprintf(outfile,"\nDollo and polymorphism parsimony algorithm,");
    fprintf(outfile," version %s\n\n",VERSION);


}  /* emboss_getoptions */
Ejemplo n.º 14
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;
}
Ejemplo n.º 15
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;
}
Ejemplo n.º 16
0
int main(int argc, char **argv)
{
    /* Variable Declarations */
    AjPStr code = NULL;
    AjPFile mfptr = NULL;
    AjPFile wfptr = NULL;
    AjPFile outf = NULL;

    EmbPPropMolwt *mwdata;
    EmbPPropAmino *aadata;

    float *dhstat = NULL;

    char    code1;
    AjPStr  code3 = NULL;
    ajint idx    = 0;
    ajuint i;
    ajuint iend;
    AjPStr  propstr = NULL;
    float charge;
    char csign;

    /* ACD File Processing */
    embInit("inforesidue", argc, argv);
    code = ajAcdGetString("code");
    mfptr   = ajAcdGetDatafile("aadata");
    wfptr   = ajAcdGetDatafile("mwdata");
    outf = ajAcdGetOutfile("outfile");

    aadata = embPropEaminoRead(mfptr);
    mwdata = embPropEmolwtRead(wfptr);
    if(!embReadAminoDataFloatC(DAYHOFF_FILE,&dhstat,(float)0.001))
        ajFatal("Set the EMBOSS_DATA environment variable");


    /* Application logic */

    ajStrFmtUpper(&code);
    iend = ajStrGetLen(code);
    ajFmtPrintF(outf, "%-4s %-5s %-20s %6s %9s %-30s %s\n",
                "Code", "Short", "Mnemonic",
                "Charge", "MolWt",
                "Properties", "Ambiguity");
    for(i=0; i<iend; i++)
    {
        code1=ajStrGetCharPos(code,i);
        if(ajResidueExistsChar(code1))
        {
            idx = ajBasecodeToInt(code1);
            ajResidueToTriplet(code1, &code3);
            ajStrFmtTitle(&code3);

            if(!embPropGetProperties(aadata[idx], &propstr))
                ajStrAssignC(&propstr, "(none)");

            charge = embPropGetCharge(aadata[idx]);
            if(charge > 0.0)
                csign = '+';
            else if(charge < 0.0)
                csign = '-';
            else
                csign = ' ';

            ajFmtPrintF(outf, "%-4c %-5S %-20S %3c%3.1f %9.4f %-30S %S\n",
                        code1, code3, ajResidueGetMnemonic(code1),
                        csign, fabs(charge),
                        embPropMolwtGetMolwt(mwdata[idx]),
                        propstr, ajResidueGetCodes(code1));
        }
        else
        {
            ajFmtPrintF(outf, "%-4c %-5s %-20s %6s %9s %-30s %s\n",
                        code1, ".", "invalid", ".", ".", ".", ".");

        }

    }



    /* Memory management and exit */
    ajStrDel(&code);
    ajStrDel(&code3);
    ajStrDel(&propstr);
    ajFileClose(&outf);
    ajFileClose(&mfptr);
    ajFileClose(&wfptr);
    ajFileClose(&outf);
    embPropAminoDel(&aadata);
    embPropMolwtDel(&mwdata);
    AJFREE(dhstat);

    embExit();

    return 0;
}
Ejemplo n.º 17
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;
}
Ejemplo n.º 18
0
int main(int argc, char *argv[])
{
  embInitPV("gdeltagcskew", argc, argv, "GEMBASSY", "1.0.3");

  AjPSeqall seqall;
  AjPSeq    seq;
  AjPStr    inseq = NULL;

  AjBool at     = 0;
  AjBool purine = 0;
  AjBool keto   = 0;
  AjPStr method = 0;

  AjBool accid  = ajFalse;
  AjPStr restid = NULL;
  AjPStr seqid  = NULL;

  AjPStr base = NULL;
  AjPStr url  = NULL;

  AjPFile tmpfile = NULL;
  AjPStr  tmpname = NULL;
  AjPFilebuff tmp = NULL;

  AjPStr line = NULL;

  AjPFile outf = NULL;

  seqall = ajAcdGetSeqall("sequence");
  at     = ajAcdGetBoolean("at");
  purine = ajAcdGetBoolean("purine");
  keto   = ajAcdGetBoolean("keto");
  method = ajAcdGetSelectSingle("method");
  accid  = ajAcdGetBoolean("accid");
  outf   = ajAcdGetOutfile("outfile");

  base = ajStrNewC("rest.g-language.org");

  gAssignUniqueName(&tmpname);

  while(ajSeqallNext(seqall, &seq))
    {
      inseq = NULL;

      if(!accid)
        {
          if(gFormatGenbank(seq, &inseq))
            {
              tmpfile = ajFileNewOutNameS(tmpname);
              if(!tmpfile)
                {
                  ajDie("Output file (%S) open error\n", tmpname);
                }
              ajFmtPrintF(tmpfile, "%S", inseq);
              ajFileClose(&tmpfile);
              ajFmtPrintS(&url, "http://%S/upload/upl.pl", base);
              gFilePostSS(url, tmpname, &restid);
              ajStrDel(&url);
              ajSysFileUnlinkS(tmpname);
            }
          else
            {
              ajWarn("Sequence does not have features\n"
                     "Proceeding with sequence accession ID\n");
              accid = ajTrue;
            }
        }

      ajStrAssignS(&seqid, ajSeqGetAccS(seq));

      if(ajStrGetLen(seqid) == 0)
        {
          ajStrAssignS(&seqid, ajSeqGetNameS(seq));
        }

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

      if(accid)
        {
          ajStrAssignS(&restid, seqid);
          if(ajStrGetLen(seqid) == 0)
            {
              ajDie("Cannot proceed without header with -accid\n");
            }

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

      url = ajStrNew();

      ajFmtPrintS(&url, "http://%S/%S/delta_gcskew/", base, restid);

      if(!gFilebuffURLS(url, &tmp))
        {
          ajDie("Failed to download result from:\n%S\n", url);
        }

      ajBuffreadLine(tmp, &line);

      ajStrRemoveSetC(&line, "\n");

      ajFmtPrintF(outf, "Sequence: %S DELTA-GCskew %S\n", seqid, line);

      ajStrDel(&url);
      ajStrDel(&restid);
      ajStrDel(&seqid);
      ajStrDel(&inseq);
    }

  ajFileClose(&outf);

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

  embExit();

  return 0;
}
Ejemplo n.º 19
0
int main(int argc, char **argv)
{
    /* ACD data item variables */
    AjPSeqset alignfile = NULL; 
    AjPFile       prior = NULL;
    AjPFile        null = NULL;
    AjPFile         pam = NULL;
    float        pamwgt = 0.0;
    AjPStr         nhmm = NULL;
    AjPStr     strategy = NULL;
    ajint      pbswitch = 0;
    float       archpri = 0.0;
    AjBool      binary  = ajFalse;
    AjBool         fast = ajFalse;
    float        gapmax = 0.0;
    AjBool         hand = ajFalse;
    float       idlevel = 0.0;
    AjBool        noeff = ajFalse;
    float       swentry = 0.0;
    float        swexit = 0.0;
    AjBool    verbosity = ajFalse;
    AjPStr    weighting = NULL;
    AjPFile     hmmfile = NULL;
    AjPFile           o = NULL;
    AjPFile       cfile = NULL;

    /* Housekeeping variables */
    AjPStr          cmd = NULL;
    AjPStr         rnd1 = NULL;
    AjPStr         rnd2 = NULL;
    AjPStr          tmp = NULL;
    AjPStr          fmt = NULL;
    char         option;
    AjBool        fmtok = ajFalse;
    AjPStr  hmmfilename = NULL;
    




    /* ACD file processing */
    embInitPV("ehmmbuild",argc,argv,"HMMERNEW",VERSION);

    alignfile = ajAcdGetSeqset("alignfile");
    prior     = ajAcdGetInfile("prior");
    null      = ajAcdGetInfile("null");
    pam       = ajAcdGetInfile("pam");
    pamwgt    = ajAcdGetFloat("pamwgt");
    nhmm      = ajAcdGetString("nhmm");
    strategy  = ajAcdGetListSingle("strategy");
    pbswitch  = ajAcdGetInt("pbswitch");
    archpri   = ajAcdGetFloat("archpri");
    binary    = ajAcdGetBoolean("binary");
    fast      = ajAcdGetBoolean("fast");
    gapmax    = ajAcdGetFloat("gapmax");
    hand      = ajAcdGetBoolean("hand");
    idlevel   = ajAcdGetFloat("sidlevel");
    noeff     = ajAcdGetBoolean("noeff");
    swentry   = ajAcdGetFloat("swentry");
    swexit    = ajAcdGetFloat("swexit");
    verbosity = ajAcdGetBoolean("verbosity");
    weighting = ajAcdGetListSingle("weighting");
    hmmfile   = ajAcdGetOutfile("hmmfile");
    o         = ajAcdGetOutfile("o");
    cfile     = ajAcdGetOutfile("cfile");





    /* MAIN APPLICATION CODE */
    /* 1. Housekeeping */
    cmd  = ajStrNew();
    rnd1 = ajStrNew();
    rnd2 = ajStrNew();
    tmp  = ajStrNew();
    fmt  = ajStrNew();
    hmmfilename = ajStrNew();

    ajStrAssignC(&hmmfilename, ajFileGetNameC(hmmfile));


    /* 2. Ensure alignfile is in format HMMER can understand.  These include
       FASTA, GENBANK,EMBL, GCG, PIR, STOCKHOLM, SELEX, MSF,CLUSTAL and PHYLIP.
       EMBOSS name definitions are taken from seqInFormatDef in ajseqread.c and
       seqOutFormat in ajseqwrite.c */
    fmtok=ajFalse;
    ajStrAssignS(&fmt, ajSeqsetGetFormat(alignfile));
    if(ajStrMatchC(fmt, "fasta")    ||
       ajStrMatchC(fmt, "genbank")  ||
       ajStrMatchC(fmt, "embl")     ||
       ajStrMatchC(fmt, "gcg")      ||
       ajStrMatchC(fmt, "pir")      ||
       ajStrMatchC(fmt, "stockholm")||
       ajStrMatchC(fmt, "selex")    ||
       ajStrMatchC(fmt, "msf")      ||
       ajStrMatchC(fmt, "clustal")  ||
       ajStrMatchC(fmt, "phylip"))
	fmtok = ajTrue;
    /* This could be replaced with code to reformat the file. */
    if(!fmtok)
	ajFatal("Input alignment ('alignfile' ACD option) is not in format "
		"HMMER understands. Please use a a file in FASTA, GENBANK, "
		"EMBL, GCG, PIR, STOCKHOLM, SELEX, MSF,CLUSTAL or PHYLIP format.");
    

    /* 3. Build hmmbuild command line */
    /* Command line is built in this order: 
       i.  Application name.
       ii. HMMER 'options' (in order they appear in ACD file)
       iii.HMMER 'options' (that don't appear in ACD file)
       iv. HMMER & new parameters.
       */
    ajStrAssignS(&cmd, ajAcdGetpathC("hmmbuild"));
    if(prior)
	ajFmtPrintAppS(&cmd, " --prior %s ", ajFileGetNameC(prior));
    if(null)
	ajFmtPrintS(&cmd, " --null %s ", ajFileGetNameC(null));
    if(pam)
	ajFmtPrintAppS(&cmd, " --pam %s  --pamwgt %f ", ajFileGetNameC(pam), pamwgt);
    ajFmtPrintAppS(&cmd, " -n %S ", nhmm);

    /* ACD option only allows one selection */
    option = ajStrGetCharFirst(strategy);
    if(option == 'F')
	ajStrAppendC(&cmd, " -f ");
    else if(option == 'G')
	ajStrAppendC(&cmd, " -g ");
    else if(option == 'S')
	ajStrAppendC(&cmd, " -s ");
    /* else go with default ('D' option in ACD file) */
    ajFmtPrintAppS(&cmd, " --pbswitch %d ", pbswitch);
    ajFmtPrintAppS(&cmd, " --archpri %f ", archpri);
    if(binary)
	ajStrAppendC(&cmd, " --binary ");
    if(fast)
	ajFmtPrintAppS(&cmd, " --fast --gapmax %f ", gapmax);
    if(hand)
	ajStrAppendC(&cmd, " --hand ");
    ajFmtPrintAppS(&cmd, " --idlevel %f ", idlevel);
    if(noeff)
	ajStrAppendC(&cmd, " --noeff ");
    ajFmtPrintAppS(&cmd, " --swentry %f ", swentry);
    ajFmtPrintAppS(&cmd, " --swexit %f ", swexit);
    if(verbosity)
	ajStrAppendC(&cmd, " --verbose ");

    /* ACD option only allows one selection */
    option = ajStrGetCharFirst(weighting);
    if(option == 'B')
	ajStrAppendC(&cmd, " --wblosum ");
    else if(option == 'G')
	ajStrAppendC(&cmd, " --wgsc ");
    else if(option == 'K')
	ajStrAppendC(&cmd, " --wme ");
    else if(option == 'W')
	ajStrAppendC(&cmd, " --wpb ");
    else if(option == 'V')
	ajStrAppendC(&cmd, " --wvoronoi ");
    else if(option == 'N')
	ajStrAppendC(&cmd, " --wnone ");
    if(o)
	ajFmtPrintAppS(&cmd, " -o %s ", ajFileGetNameC(o));
    if(cfile)
	ajFmtPrintAppS(&cmd, " --cfile %s ", ajFileGetNameC(cfile));
    /* -A (append) always set but file will be wiped by EMBOSS first unless 
       append: "Y" is set for "hmmfile" in the ACD file. */
    ajStrAppendC(&cmd, " -A -F ");
    ajFmtPrintAppS(&cmd, " %S %S", hmmfilename, ajSeqsetGetFilename(alignfile));


    /* 4. Close ACD files */
    ajSeqsetDel(&alignfile);
    ajFileClose(&prior);
    ajFileClose(&null);
    ajFileClose(&pam);
    ajFileClose(&hmmfile);
    ajFileClose(&o);
    ajFileClose(&cfile);


    /* 5. Call hmmbuild */
    ajFmtPrint("\n%S\n", cmd); 
    system(ajStrGetPtr(cmd));    


    /* 6. Exit cleanly */
    ajStrDel(&nhmm);
    ajStrDel(&cmd);
    ajStrDel(&rnd1);
    ajStrDel(&rnd2);
    ajStrDel(&tmp);
    ajStrDel(&fmt);
    ajStrDel(&hmmfilename);
    ajStrDel(&strategy);
    ajStrDel(&weighting);
    
    embExit();

    return 0;
}
Ejemplo n.º 20
0
int main(int argc, char **argv)
{
    AjPFile infile = NULL;
    AjPFile outfile = NULL;
    AjPStr line;
    AjPGraph graphLB = NULL;
    AjPGraphdata xygraph  = NULL;
    AjPGraphdata xygraph2 = NULL;
    AjBool doplot;

    ajint N=0;

    float *xdata = NULL;
    float *ydata = NULL;
    float *V = NULL;
    float *S = NULL;

    float a;
    float b;
    float upperXlimit;
    float upperYlimit;

    float A;
    float B;
    float C;
    float D;
    float xmin;
    float xmax;
    float ymin;
    float ymax;
    float xmin2;
    float xmax2;
    float ymin2;
    float ymax2;

    float Vmax;
    float Km;
    float cutx;
    float cuty;

    float amin = 0.;
    float amax = 0.;
    float bmin = 0.;
    float bmax = 0.;


    embInit("findkm", argc, argv);

    infile  = ajAcdGetInfile("infile");
    outfile = ajAcdGetOutfile ("outfile");
    doplot  = ajAcdGetBoolean("plot");
    graphLB = ajAcdGetGraphxy("graphLB");
    line = ajStrNew();


    /* Determine N by reading infile */

    while(ajReadlineTrim(infile, &line))
        if(ajStrGetLen(line) >0)
	    N++;


    /* only allocate memory to the arrays */

    AJCNEW(xdata, N);
    AJCNEW(ydata, N);
    AJCNEW(S, N);
    AJCNEW(V, N);

    ajFileSeek(infile, 0L, 0);

    N=0;
    while(ajReadlineTrim(infile, &line))
    {
	if(ajStrGetLen(line) > 0)
        {
            sscanf(ajStrGetPtr(line),"%f %f",&S[N],&V[N]);
            if(S[N] > 0.0 && V[N] > 0.0)
            {
                xdata[N] = S[N];
                ydata[N] = S[N]/V[N];
		N++;
            }
        }
    }


    /* find the max and min values for the graph parameters*/
    xmin = (float)0.5*findkm_findmin(xdata, N);
    xmax = (float)1.5*findkm_findmax(xdata, N);
    ymin = (float)0.5*findkm_findmin(ydata, N);
    ymax = (float)1.5*findkm_findmax(ydata, N);

    xmin2 = (float)0.5*findkm_findmin(S, N);
    xmax2 = (float)1.5*findkm_findmax(S, N);
    ymin2 = (float)0.5*findkm_findmin(V, N);
    ymax2 = (float)1.5*findkm_findmax(V, N);



    /*
    ** In case the casted ints turn out to be same number on the axis,
    ** make the max number larger than the min so graph can be seen.
    */

    if((ajint)xmax == (ajint)xmin)
        ++xmax;
    if((ajint)ymax == (ajint)ymin)
        ++ymax;


    if((ajint)xmax2 == (ajint)xmin2)
        ++xmax2;
    if((ajint)ymax2 == (ajint)ymin2)
        ++ymax2;



    /*
    ** Gaussian Elimination for Best-fit curve plotting and
    ** calculating Km and Vmax
    */

    A = findkm_summation(xdata, N);
    B = findkm_summation(ydata, N);

    C = findkm_multisum(xdata, ydata, N);
    D = findkm_multisum(xdata, xdata, N);


    /*
    ** To find the best fit line, Least Squares Fit:    y =ax +b;
    ** Two Simultaneous equations, REARRANGE FOR b
    **
    ** findkm_summation(ydata, N) - findkm_summation(xdata,N)*a - N*b =0;
    ** b = (findkm_summation(ydata,N) - findkm_summation(xdata,N)*a) /  N;
    ** b = (B - A*a)/ N;
    **
    ** C - D*a - A*((B - A*a)/ N) =0;
    ** C - D*a - A*B/N + A*A*a/N =0;
    ** C - A*B/N = D*a - A*A*a/N;
    */

    /* REARRANGE FOR a */

    a = (N*C - A*B)/ (N*D - A*A);
    b = (B - A*a)/ N;

    /*
    ** Equation of Line - Lineweaver burk eqn
    ** 1/V = (Km/Vmax)*(1/S) + 1/Vmax;
    */


    Vmax = 1/a;
    Km = b/a;

    cutx = -1/Km;
    cuty = Km/Vmax;

    /* set limits for last point on graph */

    upperXlimit = findkm_findmax(xdata,N)+3;
    upperYlimit = (upperXlimit)*a + b;

    ajFmtPrintF(outfile, "---Hanes Woolf Plot Calculations---\n");
    ajFmtPrintF(outfile, "Slope of best fit line is a = %.2f\n", a);
    ajFmtPrintF(outfile,"Coefficient in Eqn of line y = ma +b is b "
		"= %.2f\n", b);

    ajFmtPrintF(outfile, "Where line cuts x axis = (%.2f, 0)\n", cutx);
    ajFmtPrintF(outfile, "Where line cuts y axis = (0, %.2f)\n", cuty);
    ajFmtPrintF(outfile, "Limit-point of graph for plot = (%.2f, %.2f)\n\n",
		upperXlimit, upperYlimit);
    ajFmtPrintF(outfile, "Vmax = %.2f, Km = %f\n",Vmax, Km);

    /* draw graphs */

    if(doplot)
    {
	xygraph = ajGraphdataNewI(N);
	ajGraphdataAddXY(xygraph, S, V);
	ajGraphDataAdd(graphLB, xygraph);
	ajGraphdataSetTitleC(xygraph, "Michaelis Menten Plot");
	ajGraphdataSetXlabelC(xygraph, "[S]");
	ajGraphdataSetYlabelC(xygraph, "V");

	ajGraphxySetXstartF(graphLB, 0.0);
	ajGraphxySetXendF(graphLB, xmax2);
	ajGraphxySetYstartF(graphLB, 0.0);
	ajGraphxySetYendF(graphLB, ymax2);
	ajGraphxySetXrangeII(graphLB, (ajint)0.0, (ajint)xmax2);
	ajGraphxySetYrangeII(graphLB, (ajint)0.0, (ajint)ymax2);
	ajGraphdataAddposLine(xygraph, 0.0, 0.0, S[0], V[0], (ajint)BLACK);
	ajGraphxyShowPointsCircle(graphLB, ajTrue);
	ajGraphdataSetMinmax(xygraph,0.0,xmax2,0.0,ymax2);


	ajGraphicsCalcRange(S,N,&amin,&amax);
	ajGraphicsCalcRange(V,N,&bmin,&bmax);
	ajGraphdataSetTruescale(xygraph,amin,amax,bmin,bmax);
	ajGraphdataSetTypeC(xygraph,"2D Plot Float");

	xygraph2 = ajGraphdataNewI(N);
	ajGraphdataAddXY(xygraph2, xdata, ydata);
	ajGraphDataAdd(graphLB, xygraph2);

	ajGraphdataSetTitleC(xygraph2, "Hanes Woolf Plot");
	ajGraphdataSetXlabelC(xygraph2, "[S]");
	ajGraphdataSetYlabelC(xygraph2, "[S]/V");

	ajGraphxySetXstartF(graphLB, cutx);
	ajGraphxySetXendF(graphLB, upperXlimit);
	ajGraphxySetYstartF(graphLB, 0.0);
	ajGraphxySetYendF(graphLB, upperYlimit);
	ajGraphxySetXrangeII(graphLB, (ajint)cutx, (ajint)upperXlimit);
	ajGraphxySetYrangeII(graphLB, (ajint)0.0, (ajint)upperYlimit);

	ajGraphxyShowPointsCircle(graphLB, ajTrue);
	ajGraphdataSetMinmax(xygraph2, cutx,upperXlimit,0.0,upperYlimit);
	ajGraphicsCalcRange(xdata,N,&amin,&amax);
	ajGraphicsCalcRange(ydata,N,&bmin,&bmax);
	ajGraphdataSetTruescale(xygraph2,amin,amax,bmin,bmax);
	ajGraphdataSetTypeC(xygraph2,"2D Plot");



	ajGraphSetTitleC(graphLB,"FindKm");
	ajGraphxySetflagOverlay(graphLB,ajFalse);
	ajGraphxyDisplay(graphLB, ajTrue);
    }

    AJFREE(xdata);
    AJFREE(ydata);

    AJFREE(S);
    AJFREE(V);

    ajFileClose(&infile);
    ajFileClose(&outfile);

    ajGraphxyDel(&graphLB);
    ajStrDel(&line);

    embExit();

    return 0;
}
Ejemplo n.º 21
0
int main(int argc, char **argv)
{
    ajint begin, end;
    AjPSeqall seqall;
    AjPSeq seq;
    EmbPShow ss;
    AjPFile outfile;
    AjPStr tablename;
    ajint table;
    AjPRange uppercase;
    AjPRange highlight;
    AjBool threeletter;
    AjBool numberseq;
    AjBool nameseq;
    ajint width;
    ajint length;
    ajint margin;
    AjBool description;
    ajint offset;
    AjBool html;
    AjPStr descriptionline;
    ajint orfminsize;
    AjPTrn trnTable;
    AjBool translation;
    AjBool reverse;
    AjBool cutlist;
    AjBool flat;
    EmbPMatMatch mm = NULL;

    AjPStr *framelist;
    AjBool frames[6];   /* frames to be translated 1 to 3, -1 to -3 */
	 
    /* stuff for tables and lists of enzymes and hits */
    ajint default_mincuts = 1;
    ajint default_maxcuts = 2000000000;
    AjPTable hittable; /* enzyme hits */

    /* stuff lifted from Alan's 'restrict.c' */
    AjPStr enzymes = NULL;
    ajint mincuts;
    ajint maxcuts;
    ajint sitelen;
    AjBool single;
    AjBool blunt;
    AjBool sticky;
    AjBool ambiguity;
    AjBool plasmid;
    AjBool commercial;
    AjBool limit;
    AjBool methyl;
    AjPFile enzfile  = NULL;
    AjPFile equfile  = NULL;
    AjPFile methfile = NULL;
    AjPTable retable = NULL;
    ajint hits;
    AjPList restrictlist = NULL;

    embInit("remap", argc, argv);

    seqall      = ajAcdGetSeqall("sequence");
    outfile     = ajAcdGetOutfile("outfile");
    tablename   = ajAcdGetListSingle("table");
    uppercase   = ajAcdGetRange("uppercase");
    highlight   = ajAcdGetRange("highlight");
    threeletter = ajAcdGetBoolean("threeletter");
    numberseq   = ajAcdGetBoolean("number");
    width       = ajAcdGetInt("width");
    length      = ajAcdGetInt("length");
    margin      = ajAcdGetInt("margin");
    nameseq     = ajAcdGetBoolean("name");
    description = ajAcdGetBoolean("description");
    offset      = ajAcdGetInt("offset");
    html        = ajAcdGetBoolean("html");
    orfminsize  = ajAcdGetInt("orfminsize");
    translation = ajAcdGetBoolean("translation");
    reverse     = ajAcdGetBoolean("reverse");
    cutlist     = ajAcdGetBoolean("cutlist");
    flat        = ajAcdGetBoolean("flatreformat");
    framelist   = ajAcdGetList("frame");
    
    /*  restriction enzyme stuff */
    mincuts    = ajAcdGetInt("mincuts");
    maxcuts    = ajAcdGetInt("maxcuts");
    sitelen    = ajAcdGetInt("sitelen");
    single     = ajAcdGetBoolean("single");
    blunt      = ajAcdGetBoolean("blunt");
    sticky     = ajAcdGetBoolean("sticky");
    ambiguity  = ajAcdGetBoolean("ambiguity");
    plasmid    = ajAcdGetBoolean("plasmid");
    commercial = ajAcdGetBoolean("commercial");
    limit      = ajAcdGetBoolean("limit");
    enzymes    = ajAcdGetString("enzymes");
    methfile   = ajAcdGetDatafile("mfile");
    methyl     = ajAcdGetBoolean("methylation");
    
    if(!blunt  && !sticky)
	ajFatal("Blunt/Sticky end cutters shouldn't both be disabled.");

    /* get the number of the genetic code used */
    ajStrToInt(tablename, &table);
    trnTable = ajTrnNewI(table);

    /* read the local file of enzymes names */
    remap_read_file_of_enzyme_names(&enzymes);

    /* get the frames to be translated */
    remap_GetFrames(framelist, frames);
	 
    while(ajSeqallNext(seqall, &seq))
    {
	/* get begin and end positions */
	begin = ajSeqGetBegin(seq)-1;
	end   = ajSeqGetEnd(seq)-1;

	/* do the name and description */
	if(nameseq)
	{
	    if(html)
		ajFmtPrintF(outfile, "<H2>%S</H2>\n",
				   ajSeqGetNameS(seq));
	    else
		ajFmtPrintF(outfile, "%S\n", ajSeqGetNameS(seq));
	}

	if(description)
	{
	    /*
	    **  wrap the description line at the width of the sequence
	    **  plus margin
	    */
	    if(html)
		ajFmtPrintF(outfile, "<H3>%S</H3>\n",
				   ajSeqGetDescS(seq));
	    else
	    {
		descriptionline = ajStrNew();
		ajStrAssignS(&descriptionline, ajSeqGetDescS(seq));
		ajStrFmtWrap(&descriptionline, width+margin);
		ajFmtPrintF(outfile, "%S\n", descriptionline);
		ajStrDel(&descriptionline);
	    }
	}

	/* get the restriction cut sites */
	/*
	**  most of this is lifted from the program 'restrict.c' by Alan
	**  Bleasby
	 */
	if(single)
	    maxcuts=mincuts=1;
	retable = ajTablestrNew(EQUGUESS);
	enzfile = ajDatafileNewInNameC(ENZDATA);
	if(!enzfile)
	    ajFatal("Cannot locate enzyme file. Run REBASEEXTRACT");

	if(limit)
	{
	    equfile = ajDatafileNewInNameC(EQUDATA);
	    if(!equfile)
		limit = ajFalse;
	    else
		remap_read_equiv(&equfile, &retable, commercial);
	}

	ajFileSeek(enzfile, 0L, 0);
	restrictlist = ajListNew();
	/* search for hits, but don't use mincuts and maxcuts criteria yet */
	hits = embPatRestrictMatch(seq, begin+1, end+1, enzfile, methfile,
                                   enzymes, sitelen,plasmid, ambiguity,
                                   default_mincuts, default_maxcuts, blunt,
                                   sticky, commercial, methyl,
				   restrictlist);

	ajDebug("Remap found %d hits\n", hits);

	if(hits)
	{
	    /* this bit is lifted from printHits */
	    embPatRestrictRestrict(restrictlist, hits, !limit,
					  ajFalse);
	    if(limit)
		remap_RestrictPreferred(restrictlist,retable);
	}


	ajFileClose(&enzfile);
	ajFileClose(&methfile);


	/*
	** Remove those violating the mincuts and maxcuts
	** criteria, but save them in hittable for printing out later.
	** Keep a count of how many hits each enzyme gets in hittable.
	*/
        hittable = ajTablestrNewCase(TABLEGUESS);
	remap_RemoveMinMax(restrictlist, hittable, mincuts, maxcuts);


	/* make the Show Object */
	ss = embShowNew(seq, begin, end, width, length, margin, html, offset);

	if(html)
	    ajFmtPrintF(outfile, "<PRE>");

	/* create the format to display */
	embShowAddBlank(ss);
	embShowAddRE(ss, 1, restrictlist, plasmid, flat);
	embShowAddSeq(ss, numberseq, threeletter, uppercase, highlight);

	if(!numberseq)
	    embShowAddTicknum(ss);
	embShowAddTicks(ss);

	if(reverse)
	{
	    embShowAddComp(ss, numberseq);
	    embShowAddRE(ss, -1, restrictlist, plasmid, flat);
	}


	if(translation)
	{
	    if(reverse)
		embShowAddBlank(ss);

            if(frames[0])	    
	      embShowAddTran(ss, trnTable, 1, threeletter,
			     numberseq, NULL, orfminsize,
			     AJFALSE, AJFALSE, AJFALSE, AJFALSE);
            if(frames[1])
	      embShowAddTran(ss, trnTable, 2, threeletter,
			     numberseq, NULL, orfminsize,
			     AJFALSE, AJFALSE, AJFALSE, AJFALSE);
            if(frames[2])
	      embShowAddTran(ss, trnTable, 3, threeletter,
			     numberseq, NULL, orfminsize,
			     AJFALSE, AJFALSE, AJFALSE, AJFALSE);
	    
	    if(reverse)
	    {
		embShowAddTicks(ss);
                if(frames[5])
		  embShowAddTran(ss, trnTable, -3, threeletter,
			         numberseq, NULL, orfminsize,
			         AJFALSE, AJFALSE, AJFALSE, AJFALSE);
                if(frames[4])
		  embShowAddTran(ss, trnTable, -2, threeletter,
			         numberseq, NULL, orfminsize,
			         AJFALSE, AJFALSE, AJFALSE, AJFALSE);
                if(frames[3])
		  embShowAddTran(ss, trnTable, -1, threeletter,
			         numberseq, NULL, orfminsize,
			         AJFALSE, AJFALSE, AJFALSE, AJFALSE);
	    }
	}

	embShowPrint(outfile, ss);

	/* display a list of the Enzymes that cut and don't cut */
	if(cutlist)
	{
	    remap_CutList(outfile, hittable,
	    		limit, html, mincuts, maxcuts);
	    remap_NoCutList(outfile, hittable, html, enzymes, blunt,
			sticky, sitelen, commercial, ambiguity, 
			limit, retable);
	}

	/* add a gratuitous newline at the end of the sequence */
	ajFmtPrintF(outfile, "\n");

	/* tidy up */
	embShowDel(&ss);

	while(ajListPop(restrictlist,(void **)&mm))
	    embMatMatchDel(&mm);
	ajListFree(&restrictlist);

        remap_DelTable(&hittable);

	ajTablestrFree(&retable);
    }


    ajTrnDel(&trnTable);

    ajSeqallDel(&seqall);
    ajSeqDel(&seq);
    ajFileClose(&outfile);
    ajStrDel(&tablename);
    ajStrDel(&enzymes);
    ajStrDelarray(&framelist);

    ajRangeDel(&uppercase);
    ajRangeDel(&highlight);

    embExit();

    return 0;
}
Ejemplo n.º 22
0
int main(int argc, char *argv[])
{
  embInitPV("gp2", argc, argv, "GEMBASSY", "1.0.1");

  AjPSeqall seqall;
  AjPSeq    seq;
  AjPStr    inseq = NULL;

  AjBool accid  = ajFalse;
  AjPStr restid = NULL;
  AjPStr seqid  = NULL;

  AjPStr base = NULL;
  AjPStr url  = NULL;

  AjPFile tmpfile = NULL;
  AjPStr  tmpname = NULL;

  AjPFile outf = NULL;

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

  base = ajStrNewC("rest.g-language.org");

  gAssignUniqueName(&tmpname);

  while(ajSeqallNext(seqall, &seq))
    {
      inseq = NULL;

      if(!accid)
        {
          if(gFormatGenbank(seq, &inseq))
            {
              tmpfile = ajFileNewOutNameS(tmpname);
              if(!tmpfile)
                {
                  ajDie("Output file (%S) open error\n", tmpname);
                }
              ajFmtPrintF(tmpfile, "%S", inseq);
              ajFileClose(&tmpfile);
              ajFmtPrintS(&url, "http://%S/upload/upl.pl", base);
              gFilePostSS(url, tmpname, &restid);
              ajStrDel(&url);
              ajSysFileUnlinkS(tmpname);
            }
          else
            {
              ajDie("Sequence does not have features\n"
                    "Proceeding with sequence accession ID\n");
              accid = ajTrue;
            }
        }

      if(accid)
        {
          ajStrAssignS(&restid, ajSeqGetAccS(seq));
          if(!ajStrGetLen(restid))
            {
              ajStrAssignS(&restid, ajSeqGetNameS(seq));
            }
          if(!ajStrGetLen(restid))
            {
              ajDie("No valid header information\n");
            }
        }

      ajStrAssignS(&seqid, ajSeqGetAccS(seq));

      url = ajStrNew();

      ajFmtPrintS(&url, "http://%S/%S/P2/output=f/tag=gene", base, restid);

      ajFmtPrintF(outf, "Sequence: %S\n", seqid);
      if(!gFileOutURLS(url, &outf))
        {
          ajDie("Failed to download result from:\n%S\n", url);
        }

      ajStrDel(&url);
      ajStrDel(&inseq);
    }

  ajFileClose(&outf);

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

  embExit();

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

  AjPSeqall seqall;
  AjPSeq    seq;
  AjPStr    inseq = NULL;

  AjPStr position   = 0;
  ajint  PatLen     = 0;
  ajint  upstream   = 0;
  ajint  downstream = 0;

  AjBool accid  = ajFalse;
  AjPStr restid = NULL;
  AjPStr seqid  = NULL;

  AjPStr base = NULL;
  AjPStr url  = NULL;

  AjPFile tmpfile = NULL;
  AjPStr  tmpname = NULL;

  AjBool      plot = 0;
  AjPFile     outf = NULL;
  AjPFilebuff buff = NULL;
  AjPGraph    mult = NULL;

  gPlotParams gpp;
  AjPStr      title = NULL;

  seqall     = ajAcdGetSeqall("sequence");
  position   = ajAcdGetSelectSingle("position");
  PatLen     = ajAcdGetInt("patlen");
  upstream   = ajAcdGetInt("upstream");
  downstream = ajAcdGetInt("downstream");
  accid      = ajAcdGetBoolean("accid");

  plot = ajAcdGetToggle("plot");
  outf = ajAcdGetOutfile("outfile");
  mult = ajAcdGetGraphxy("graph");

  base = ajStrNewC("rest.g-language.org");

  gAssignUniqueName(&tmpname);

  while(ajSeqallNext(seqall, &seq))
    {
      inseq = NULL;

      if(!accid)
        {
          if(gFormatGenbank(seq, &inseq))
            {
              gAssignUniqueName(&tmpname);

              tmpfile = ajFileNewOutNameS(tmpname);

              if(!tmpfile)
                {
                  ajFmtError("Output file (%S) open error\n", tmpname);
                  embExitBad();
                }

              ajFmtPrintF(tmpfile, "%S", inseq);
              ajFileClose(&tmpfile);
              ajFmtPrintS(&url, "http://%S/upload/upl.pl", base);
              gFilePostSS(url, tmpname, &restid);
              ajStrDel(&url);
              ajSysFileUnlinkS(tmpname);
            }
          else
            {
              ajFmtError("Sequence does not have features\n"
                         "Proceeding with sequence accession ID\n");
              accid = ajTrue;
            }
        }

      if(accid)
        {
          ajStrAssignS(&seqid, ajSeqGetAccS(seq));

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

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

          ajStrAssignS(&restid, seqid);
        }

      ajStrAssignS(&seqid, ajSeqGetAccS(seq));

      url = ajStrNew();

      ajFmtPrintS(&url, "http://%S/%S/base_information_content/position=%S/"
                  "PatLen=%d/upstream=%d/downstream=%d/output=f/tag=gene",
                  base, restid, position, PatLen, upstream, downstream);

      if(plot)
        {
          title = ajStrNew();

          ajStrAppendC(&title, argv[0]);
          ajStrAppendC(&title, " of ");
          ajStrAppendS(&title, seqid);

          gpp.title = ajStrNewS(title);
          gpp.xlab = ajStrNewC("position");
          gpp.ylab = ajStrNewC("information content");

          if(!gFilebuffURLS(url, &buff))
            {
              ajDie("File downloading error from:\n%S\n", url);
            }

          if(!gPlotFilebuff(buff, mult, &gpp))
            {
              ajDie("Error in plotting\n");
            }

          AJFREE(gpp.title);
          AJFREE(gpp.xlab);
          AJFREE(gpp.ylab);
          ajStrDel(&title);
          ajFilebuffDel(&buff);
        }
      else
        {
          ajFmtPrintF(outf, "Sequence: %S\n", seqid);
          if(!gFileOutURLS(url, &outf))
            {
              ajDie("File downloading error from:\n%S\n", url);
            }
        }
    }

  ajFileClose(&outf);

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

  ajStrDel(&position);

  embExit();

  return 0;
}
Ejemplo n.º 24
0
int main(int argc, char **argv)
{
    AjPDasServer server   = NULL;
    AjPDasSource source   = NULL;
    AjPDasSegment segment = NULL;

    AjPStr host  = NULL;
    AjPStr path  = NULL;
    AjPFile outf = NULL;

    ajint port = 80;

    AjBool sequencesourcesonly;
    AjBool entrypoints;
    AjBool showtestqueries;
    AjBool runtestqueries = ajTrue;
    AjBool quickexit = ajFalse;

    ajint itest=0;
    ajint j=0;

    ajint maxtests=0;
    ajint maxfeatures=0;
    ajint maxsegments=0;

    AjIList iter     = NULL;
    AjIList coordsi  = NULL;
    AjIList itereps  = NULL;
    AjPFilebuff buff = NULL;
    AjPUrlref uo        = NULL;
    AjPList segments = NULL;
    AjPStr ffname    = NULL;
    AjPStr url       = NULL;

    AjPStr dbhttpver = ajStrNew();
    AjPStr dbname    = ajStrNew();
    AjPStr dbproxy   = ajStrNew();

    AjPStr servername   = NULL;
    AjPTable titlecount = NULL;
    const ajuint* count;
    int k=0;

    embInit("dastest", argc, argv);

    host = ajAcdGetString("host");
    path = ajAcdGetString("path");
    port = ajAcdGetInt("port");
    sequencesourcesonly = ajAcdGetBoolean("sequencesourcesonly");
    entrypoints = ajAcdGetBoolean("entrypoints");
    showtestqueries = ajAcdGetBoolean("showtestqueries");
    runtestqueries  = ajAcdGetBoolean("runtestqueries");

    servername = ajAcdGetString("servername");

    outf   = ajAcdGetOutfile("outfile");

    maxtests     = ajAcdGetInt("maxtests");
    maxfeatures = ajAcdGetInt("maxfeatures");
    maxsegments = ajAcdGetInt("maxsegments");

    server = ajDasServerNew();

    if(runtestqueries)
    {
	url = ajStrNew();

	if(!ajNamServer(servername))
	{
	    ajWarn("following das server is required to be defined "
		    "for test queries...");
	    ajWarn("\nSERVER %S [\n"
		    "   type: \"sequence\"\n"
		    "   method: \"das\"\n"
		    "   url: \"http://%S%S\"\n"
		    "]\n",servername, host,path);
	    ajWarn("ignoring -runtestqueries option...");
	    runtestqueries = ajFalse;
	}
	else
	{
	    ajNamSvrGetUrl(servername, &url);
	    ajHttpUrlDeconstruct(url, &port, &host, &path);

	    ajStrDel(&url);
	}
    }

    ajDasServerSethostS(server,host);
    ajDasServerSetport(server,port);


    if(ajStrGetCharLast(path)!='/')
	ajStrAppendK(&path,'/');

    ajStrAppendC(&path,"sources");

    ajDasServerSetpathS(server,path);

    ajFmtPrintF(outf,"host = %S\npath = %S\nport = %d\n",
	    server->host, server->path, server->port);


    /*
     * TODO: stop using http-read but instead use
     *       ajNamSvrListListDatabases(svrname, dbnames);
     */

    buff = ajHttpRead(dbhttpver, dbname, dbproxy, host, port, path);

    if(!buff)
	ajExitAbort();

    ajFilebuffHtmlNoheader(buff);

    ajDasParseRegistry(buff, server->sources);
    ajFmtPrintF(outf,"DAS sources and descriptions\n\n");

    titlecount = dastestGetTitleCount(server);

    iter = ajListIterNew(server->sources);

    while(!ajListIterDone(iter) && !quickexit)
    {
	source = ajListIterGet(iter);


	if ((sequencesourcesonly && !source->sequence)
		|| ajStrMatchC(source->title,"cath") || k++ <50)
	    continue;

	ajFmtPrintF(outf,"%-30S %-50S\n%S\n",source->uri,source->title,
		source->description);

	if(entrypoints && source->entry_points)
	{
	    uo = ajHttpUrlrefNew();

	    ajHttpUrlrefParseC(&uo, ajStrGetPtr(source->entry_points_uri));

	    if(ajStrGetLen(uo->Port))
		ajStrToInt(uo->Port, &port);
	    else
		port = 80;

	    ajFilebuffDel(&buff);
	    buff = ajHttpRead(dbhttpver, dbname, dbproxy,
	                      uo->Host, port, uo->Absolute);
	    ajHttpUrlrefDel(&uo);

	    if(!buff)
		continue;

	    ajFilebuffHtmlNoheader(buff);

	    segments = ajListNew();
	    ajDasParseEntrypoints(buff, segments);

	    itereps = ajListIterNew(segments);

	    ajFmtPrintF(outf, "Number of entry points %d\n",
		    ajListGetLength(segments));

	    j=0;

	    while(!ajListIterDone(itereps))
	    {
		segment = ajListIterGet(itereps);

		if (j++ < maxsegments)
		    ajFmtPrintF(outf,
		            "segment id:%S orientation:%S start:%d stop:%d\n",
		            segment->id,
		            segment->orientation,
		            segment->start, segment->stop);

		ajDasSegmentDel(&segment);
	    }

	    ajListIterDel(&itereps);
	    ajListFree(&segments);
	}

	if(showtestqueries || runtestqueries)
	{
	    AjPDasCoordinate coord;

	    coordsi = ajListIterNew(source->coordinates);

	    while(!ajListIterDone(coordsi) && !quickexit)
	    {
		coord = ajListIterGet(coordsi);
		ajDebug("coordinate uri:%S taxid:%S source:%S test_range:%S\n",
			coord->uri,
			coord->taxid,
			coord->source,
			coord->test_range);

		if(showtestqueries)
		{
		    if(source->sequence)
			ajFmtPrintF(outf,
			       "example/test entry = '%S?segment=%S'\n",
			       source->sequence_query_uri,coord->test_range);

		    if(source->features)
			ajFmtPrintF(outf,
			       "example/test entry = '%S?segment=%S'\n",
			       source->features_query_uri,coord->test_range);

		}

		if(runtestqueries)
		{
		    AjPStr idqry = ajStrNew();
		    AjPStr entry = NULL;
		    AjPSeq seq   = NULL;
		    ajint ibegin = 0;
		    ajint iend   = 0;
		    AjPStr example = NULL;

		    example = ajDasTestrangeParse(coord->test_range,
		                                  &entry, &ibegin, &iend);

		    if(ajStrGetLen(entry))
		    {
			count = ajTableFetchS(titlecount, source->title);
			dbname = ajDasSourceGetDBname(source, *count>1);

			if (source->features)
			{
			    AjPStr qpath=NULL;

			    uo = ajHttpUrlrefNew();

			    ajFmtPrintS(&idqry,"dasgff::%S:%S:%S",
				    servername,
				    dbname,
				    entry);
			    ajFmtPrintF(outf,
				    "feature query: %S  start:%d end:%d\n",
				    idqry,
				    ibegin, iend);


			    ajHttpUrlrefParseC(&uo,
				    ajStrGetPtr(source->features_query_uri));
			    ajHttpUrlrefSplitPort(uo);

			    ajFmtPrintS(&qpath,"%S?segment=%S",
				    uo->Absolute,entry);

			    if(iend>0)
				ajFmtPrintAppS(&qpath,":%d,%d",ibegin, iend);

			    if(ajStrGetLen(uo->Port))
				ajStrToInt(uo->Port, &port);
			    else
				port = 80;

			    ajDebug("calling ajHttpRead to get the raw"
				    " output; host:%S port:%d path:%S\n",
				    uo->Host, port, qpath);

			    ajFilebuffDel(&buff);
			    buff = ajHttpRead(dbhttpver, dbname, dbproxy,
			                      uo->Host, port, qpath);

			    if(buff)
			    {
				AjPFeattable ft;

				ajFmtPrintS(&ffname, "%S.%S", source->uri,
					    entry);

				ajFilebuffHtmlNoheader(buff);

				dastestSaveRawFeatures(buff, ffname);

				ajDebug("now using EMBOSS feature queries\n");

				ft = dastestFeatureQuery(idqry,
                                                         ibegin, iend);

				dastestSaveMappedFeatures(ft, ffname,
                                                          outf, maxfeatures);

				ajStrDel(&ffname);
				ajFeattableDel(&ft);
			    }

			    ajHttpUrlrefDel(&uo);
			    ajStrDel(&qpath);

			    if(++itest>=maxtests)
				quickexit = ajTrue;
			}
			else if(source->sequence)
			{
			    seq = ajSeqNewRes(iend-ibegin+1);

			    ajFmtPrintS(&idqry,"%S:%S:%S",
				    servername, dbname, entry);
			    ajFmtPrintF(outf,
				    "sequence query: %S  start:%d end:%d\n",
				    idqry,
				    ibegin, iend);
			    ajSeqGetFromUsaRange(idqry, ajFalse, ibegin, iend,
				    seq);
			    ajFmtPrintF(outf,
				    "length of sequence returned: %d\n",
				    ajSeqGetLen(seq));

			    if(ajSeqGetLen(seq)>0)
				ajFmtPrintF(outf,
				        "sequence returned (first 100 bases):"
					" %-100.100s\n",
					ajSeqGetSeqC(seq));

			    ajSeqDel(&seq);

			}

			ajStrDel(&dbname);
		    }

		    ajStrDel(&entry);
		    ajStrDel(&idqry);
		    ajStrDel(&example);
		}
	    }
	    ajListIterDel(&coordsi);
	}

    }

    ajListIterDel(&iter);

    ajDasServerDel(&server);
    ajFilebuffDel(&buff);

    ajStrDel(&host);
    ajStrDel(&path);
    ajStrDel(&servername);

    ajStrDel(&dbhttpver);
    ajStrDel(&dbname);
    ajStrDel(&dbproxy);

    ajFileClose(&outf);

    ajTableDelValdel(&titlecount, ajMemFree);

    embExit();

    return 0;
}
Ejemplo n.º 25
0
int main(int argc, char **argv)
{
    AjPFile     key_inf=NULL;	/* File pointer for keywords file.           */
    AjPFile     sp_inf =NULL;	/* File pointer for swissprot database.      */
    AjPFile     outf   =NULL;	/* File pointer for output file.             */
    AjPTerms    keyptr =NULL;	/* Pointer to terms structure.               */
    EmbPHitlist  hitptr =NULL;	/* Pointer to hitlist structure.             */
    


 
   
    /* Read data from acd */
    embInitPV("seqwords",argc,argv,"DOMSEARCH",VERSION);

    key_inf  = ajAcdGetInfile("keyfile");
    sp_inf  = ajAcdGetInfile("spfile");
    outf =  ajAcdGetOutfile("outfile");
    

    /* Start of main application loop. */
    /* Read next list of terms from input file. */
    while((seqwords_TermsRead(key_inf, &keyptr)))
    {
	/* Rewind swissprot file pointer to the top. */
	ajFileSeek(sp_inf, 0, 0);
	

	/* Allocate memory for hitlist. */
	AJNEW0(hitptr);


	/* Do search of swissprot. */
	seqwords_keysearch(sp_inf, keyptr, &hitptr);


	/* Copy scop records from terms to hitlist structure. */
	hitptr->Type = keyptr->Type;
	ajStrAssignRef(&hitptr->Class, keyptr->Class); 
	ajStrAssignRef(&hitptr->Architecture, keyptr->Architecture); 
	ajStrAssignRef(&hitptr->Topology, keyptr->Topology); 
	ajStrAssignRef(&hitptr->Fold, keyptr->Fold); 
	ajStrAssignRef(&hitptr->Superfamily, keyptr->Superfamily);
	ajStrAssignRef(&hitptr->Family, keyptr->Family);
	

	/* Write output file. */
	embHitlistWriteFasta(outf, hitptr);


	/* Free memory for hitlist & keyptr*/
	embHitlistDel(&hitptr);
	seqwords_TermsDel(&keyptr);
    }
    seqwords_TermsDel(&keyptr);    
    
    /* Tidy up*/
    ajFileClose(&key_inf);
    ajFileClose(&sp_inf);
    ajFileClose(&outf);

    embExit();
    return 0;
}
Ejemplo n.º 26
0
int main(int argc, char **argv)
{
    AjPSeq seq;
    AjPGraph graph = 0;
    AjPFile   outf = NULL;
    AjPFile file   = NULL;
    AjPStr buffer  = NULL;
    float twist[4][4][4];
    float roll[4][4][4];
    float tilt[4][4][4];
    float rbend;
    float rcurve;
    float bendscale;
    float curvescale;
    float twistsum = (float) 0.0;
    float pi       = (float) 3.14159;
    float pifac    = (pi/(float) 180.0);
    float pi2      = pi/(float) 2.0;
    ajint *iseq    = NULL;
    float *x;
    float *y;
    float *xave;
    float *yave;
    float *curve;
    float *bend;
    const char *ptr;
    ajint i;
    ajint ii;
    ajint k;
    ajint j;
    char residue[2];
    float maxbend;
    float minbend;
    float bendfactor;
    float maxcurve;
    float mincurve;
    float curvefactor;

    float fxp;
    float fyp;
    float yincr;
    float yy1;
    ajint ixlen;
    ajint iylen;
    ajint ixoff;
    ajint iyoff;
    float ystart;
    float defheight;
    float currentheight;
    ajint count;
    ajint portrait = 0;
    ajint title    = 0;
    ajint numres;
    ajint ibeg;
    ajint iend;
    ajint ilen;
    AjPStr sstr = NULL;
    ajint ipos;
    float dx;
    float dy;
    float rxsum;
    float rysum;
    float yp1;
    float yp2;
    double td;
    
    embInit("banana", argc, argv);
    seq    = ajAcdGetSeq("sequence");
    file   = ajAcdGetDatafile("anglesfile");
    outf   = ajAcdGetOutfile("outfile");
    graph  = ajAcdGetGraph("graph");
    numres = ajAcdGetInt("residuesperline");

    ibeg = ajSeqGetBegin(seq);
    iend = ajSeqGetEnd(seq);

    ajStrAssignSubS(&sstr, ajSeqGetSeqS(seq), ibeg-1, iend-1);
    ilen = ajStrGetLen(sstr);

    AJCNEW0(iseq,ilen+1);
    AJCNEW0(x,ilen+1);
    AJCNEW0(y,ilen+1);
    AJCNEW0(xave,ilen+1);
    AJCNEW0(yave,ilen+1);
    AJCNEW0(curve,ilen+1);
    AJCNEW0(bend,ilen+1);

    ptr= ajStrGetPtr(sstr);

    for(ii=0;ii<ilen;ii++)
    {
	if(*ptr=='A' || *ptr=='a')
	    iseq[ii+1] = 0;
	else if(*ptr=='T' || *ptr=='t')
	    iseq[ii+1] = 1;
	else if(*ptr=='G' || *ptr=='g')
	    iseq[ii+1] = 2;
	else if(*ptr=='C' || *ptr=='c')
	    iseq[ii+1] = 3;
	else
	    ajErr("%c is not an ATCG hence not valid",*ptr);

	ptr++;
    }


    if(!file)
	ajErr("Banana failed to open angle file");

    ajReadline(file,&buffer);		/* 3 junk lines */
    ajReadline(file,&buffer);
    ajReadline(file,&buffer);

    for(k=0;k<4;k++)
	for(ii=0;ii<4;ii++)
	{
	    if(ajReadline(file,&buffer))
	    {
		sscanf(ajStrGetPtr(buffer),"%f,%f,%f,%f",
		       &twist[ii][0][k],&twist[ii][1][k],&twist[ii][2][k],
		       &twist[ii][3][k]);
	    }
	    else
		ajErr("Error reading angle file");

	    for(j=0;j<4;j++)
		twist[ii][j][k] *= pifac;
	}


    for(k=0;k<4;k++)
	for(ii=0;ii<4;ii++)
	    if(ajReadline(file,&buffer))
	    {
		sscanf(ajStrGetPtr(buffer),"%f,%f,%f,%f",&roll[ii][0][k],
		       &roll[ii][1][k],&roll[ii][2][k],&roll[ii][3][k]);
	    }
	    else
		ajErr("Error reading angle file");


    for(k=0;k<4;k++)
	for(ii=0;ii<4;ii++)
	    if(ajReadline(file,&buffer))
		sscanf(ajStrGetPtr(buffer),"%f,%f,%f,%f",&tilt[ii][0][k],
		       &tilt[ii][1][k],&tilt[ii][2][k],&tilt[ii][3][k]);
	    else
		ajErr("Error reading angle file");


    if(ajReadline(file,&buffer))
	sscanf(ajStrGetPtr(buffer),"%f,%f,%f,%f",&rbend,&rcurve,
	       &bendscale,&curvescale);
    else
	ajErr("Error reading angle file");

    ajFileClose(&file);
    ajStrDel(&buffer);


    for(ii=1;ii<ilen-1;ii++)
    {
	twistsum += twist[iseq[ii]][iseq[ii+1]][iseq[ii+2]];
	dx = (roll[iseq[ii]][iseq[ii+1]][iseq[ii+2]]*sinfban(twistsum)) +
	    (tilt[iseq[ii]][iseq[ii+1]][iseq[ii+2]]*sinfban(twistsum-pi2));
	dy = roll[iseq[ii]][iseq[ii+1]][iseq[ii+2]]*cosfban(twistsum) +
	    tilt[iseq[ii]][iseq[ii+1]][iseq[ii+2]]*cosfban(twistsum-pi2);

	x[ii+1] = x[ii]+dx;
	y[ii+1] = y[ii]+dy;

    }

    for(ii=6;ii<ilen-6;ii++)
    {
	rxsum = 0.0;
	rysum = 0.0;
	for(k=-4;k<=4;k++)
	{
	    rxsum+=x[ii+k];
	    rysum+=y[ii+k];
	}
	rxsum+=(x[ii+5]*(float)0.5);
	rysum+=(y[ii+5]*(float)0.5);
	rxsum+=(x[ii-5]*(float)0.5);
	rysum+=(y[ii-5]*(float)0.5);

	xave[ii] = rxsum*(float)0.1;
	yave[ii] = rysum*(float)0.1;
    }

    for(i=(ajint)rbend+1;i<=ilen-(ajint)rbend-1;i++)
    {
	td = sqrt(((x[i+(ajint)rbend]-x[i-(ajint)rbend])*
		   (x[i+(ajint)rbend]-x[i-(ajint)rbend])) +
		  ((y[i+(ajint)rbend]-y[i-(ajint)rbend])*
		   (y[i+(ajint)rbend]-y[i-(ajint)rbend])));
	bend[i] = (float) td;
	bend[i]*=bendscale;
    }

    for(i=(ajint)rcurve+6;i<=ilen-(ajint)rcurve-6;i++)
    {
	td = sqrt(((xave[i+(ajint)rcurve]-
		    xave[i-(ajint)rcurve])*(xave[i+(ajint)rcurve]-
					    xave[i-(ajint)rcurve]))+
		  ((yave[i+(ajint)rcurve]-yave[i-(ajint)rcurve])*
		   (yave[i+(ajint)rcurve]-yave[i-(ajint)rcurve])));
	curve[i] = (float) td;
    }
    

    if(outf)
    {
	ajFmtPrintF(outf,"Base   Bend      Curve\n");
	ptr = ajStrGetPtr(sstr);
	for(ii=1;ii<=ilen;ii++)
	{
	    ajFmtPrintF(outf,"%c    %6.1f   %6.1f\n",
			*ptr, bend[ii], curve[ii]);
	    ptr++;
	}
	ajFileClose(&outf);
    }

    if(graph)
    {
	maxbend  = minbend  = 0.0;
	maxcurve = mincurve = 0.0;
	for(ii=1;ii<=ilen;ii++)
	{
	    if(bend[ii] > maxbend)
		maxbend = bend[ii];
	    if(bend[ii] < minbend)
		minbend = bend[ii];
	    if(curve[ii] > maxcurve)
		maxcurve = curve[ii];
	    if(curve[ii] < mincurve)
		mincurve = curve[ii];
	}

	ystart = 75.0;

	ajGraphAppendTitleS(graph, ajSeqGetUsaS(seq));

        ajGraphicsSetPagesize(960, 768);

	ajGraphOpenWin(graph,(float)-1.0, (float)numres+(float)10.0,
		       (float)0.0, ystart+(float)5.0);

	ajGraphicsGetParamsPage(&fxp,&fyp,&ixlen,&iylen,&ixoff,&iyoff);

	if(portrait)
        {
            ixlen = 768;
            iylen = 960;
        }
        else
        {
            ixlen = 960;
            iylen = 768;
        }

	ajGraphicsGetCharsize(&defheight,&currentheight);
	if(!currentheight)
	{
	    defheight = currentheight = (float) 4.440072;
	    currentheight = defheight *
		((float)ixlen/ ((float)(numres)*(currentheight+(float)1.0)))
		    /currentheight;
	}
	ajGraphicsSetCharscale(((float)ixlen/((float)(numres)*
					  (currentheight+(float)1.0)))/
			    currentheight);
	ajGraphicsGetCharsize(&defheight,&currentheight);

	yincr = (currentheight + (float)3.0)*(float)0.3;

	if(!title)
	    yy1 = ystart;
	else
	    yy1 = ystart-(float)5.0;

	count = 1;

	residue[1]='\0';

	bendfactor = (3*yincr)/maxbend;
	curvefactor = (3*yincr)/maxcurve;

	ptr = ajStrGetPtr(sstr);

	yy1 = yy1-(yincr*((float)5.0));
	for(ii=1;ii<=ilen;ii++)
	{
	    if(count > numres)
	    {
		yy1 = yy1-(yincr*((float)5.0));
		if(yy1<1.0)
		{
		    if(!title)
			yy1=ystart;
		    else
			yy1 = ystart-(float)5.0;

		    yy1 = yy1-(yincr*((float)5.0));
		    ajGraphNewpage(graph,AJFALSE);
		}
		count = 1;
	    }
	    residue[0] = *ptr;

	    ajGraphicsDrawposTextAtend((float)(count)+(float)2.0,yy1,residue);

	    if(ii>1 && ii < ilen)
	    {
		yp1 = yy1+yincr + (bend[ii]*bendfactor);
		yp2 = yy1+yincr + (bend[ii+1]*bendfactor);
		ajGraphicsDrawposLine((float)count+(float)1.5,yp1,
			    (float)(count)+(float)2.5,yp2);
	    }

	    ipos = ilen-(ajint)rcurve-7;
	    if(ipos < 0)
		ipos = 0;

	    if(ii>rcurve+5 && ii<ipos)
	    {
		yp1 = yy1+yincr + (curve[ii]*curvefactor);
		yp2 = yy1+yincr + (curve[ii+1]*curvefactor);
		ajGraphicsDrawposLine((float)count+(float)1.7,yp1,
			    (float)(count)+(float)2.3,yp2);
	    }

	    ajGraphicsDrawposLine((float)count+(float)1.5,yy1+yincr,
			(float)(count)+(float)2.5,yy1+yincr);

	    count++;
	    ptr++;
	}

	ajGraphicsClose();
    }

    AJFREE(iseq);
    AJFREE(x);
    AJFREE(y);
    AJFREE(xave);
    AJFREE(yave);
    AJFREE(curve);
    AJFREE(bend);

    ajStrDel(&sstr);

    ajSeqDel(&seq);
    ajFileClose(&file);
    ajFileClose(&outf);
    ajGraphxyDel(&graph);

    embExit();

    return 0;
}
Ejemplo n.º 27
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;
}
Ejemplo n.º 28
0
int main(int argc, char **argv)
{
    AjPSeqall seqall;
    AjPSeq seq    = NULL;
    AjPFile outf  = NULL;
    AjPStr strand = NULL;
    AjPStr substr = NULL;
    AjPStr bases  = NULL;

    ajint begin;
    ajint end;
    ajint len;

    ajint minlen;
    float minobsexp;
    float minpc;

    ajint window;
    ajint shift;
    ajint plotstart;
    ajint plotend;

    float  *xypc   = NULL;
    float  *obsexp = NULL;
    AjBool *thresh = NULL;
    float  obsexpmax;

    ajint i;
    ajint maxarr;


    embInit("newcpgreport",argc,argv);

    seqall    = ajAcdGetSeqall("sequence");
    window    = ajAcdGetInt("window");
    shift     = ajAcdGetInt("shift");
    outf      = ajAcdGetOutfile("outfile");
    minobsexp = ajAcdGetFloat("minoe");
    minlen    = ajAcdGetInt("minlen");
    minpc     = ajAcdGetFloat("minpc");

    substr = ajStrNew();
    bases  = ajStrNewC("CG");
    maxarr = 0;

    while(ajSeqallNext(seqall, &seq))
    {
	begin = ajSeqallGetseqBegin(seqall);
	end   = ajSeqallGetseqEnd(seqall);
	strand = ajSeqGetSeqCopyS(seq);
	ajStrFmtUpper(&strand);

	ajStrAssignSubC(&substr,ajStrGetPtr(strand),--begin,--end);
	len=ajStrGetLen(substr);

	if(len > maxarr)
	{
	    AJCRESIZE(obsexp, len);
	    AJCRESIZE(thresh, len);
	    AJCRESIZE(xypc, len);
	    maxarr = len;
	}
	for(i=0;i<len;++i)
	    obsexp[i]=xypc[i]=0.0;


	newcpgreport_findbases(substr, len, window, shift, obsexp,
			       xypc, bases, &obsexpmax, &plotstart, &plotend);

	newcpgreport_identify(outf, obsexp, xypc, thresh, 0, len, shift,
			      ajStrGetPtr(bases), ajSeqGetNameC(seq), minlen,
			      minobsexp, minpc, ajStrGetPtr(strand));

	ajStrDel(&strand);
    }

    ajStrDel(&bases);

    ajSeqDel(&seq);
    ajStrDel(&substr);
    ajFileClose(&outf);

    AJFREE(obsexp);
    AJFREE(thresh);
    AJFREE(xypc);

    ajSeqallDel(&seqall);

    embExit();

    return 0;
}
Ejemplo n.º 29
0
void emboss_getoptions(char *pgm, int argc, char *argv[])
{
  AjPStr test = NULL; 
  AjPStr outputformat = NULL;
  AjPStr typeofseq = NULL;
  AjPStr justweights = NULL;
  AjBool rewrite = false;

  long inseed, inseed0;
 
  data = genefreqs;
  seq = dna;
  bootstrap = false;
  jackknife = false;
  permute = false;
  ild = false;
  lockhart = false;
  blocksize = 1;
  regular = true;
  fracsample = 1.0;
  all = true;
  reps = 100;
  weights = false;
  mixture = false;
  ancvar = false;
  categories = false;
  justwts = false;
  printdata = false;
  dotdiff = true;
  progress = true;
  interleaved = true;
  xml = false;
  nexus = false;
  factors = false;
  enzymes = false;

  embInitPV(pgm, argc, argv, "PHYLIPNEW",VERSION);

    phylofreqs = ajAcdGetFrequencies("infile");






    test = ajAcdGetListSingle("test");
    
    if(ajStrMatchC(test, "b")) {
      bootstrap = true;
      regular = ajAcdGetToggle("regular");
      if(regular) fracsample = 1.0;
      else {
        fracsample = ajAcdGetFloat("fracsample");
        fracsample = fracsample/100.0;
      }      
      blocksize = ajAcdGetInt("blocksize");
    }
    else if(ajStrMatchC(test, "j")) {
      jackknife = true;
      regular = ajAcdGetToggle("regular");
      if(regular) fracsample = 0.5;
      else {
        fracsample = ajAcdGetFloat("fracsample");
        fracsample = fracsample/100.0;
      }
    }
    else if(ajStrMatchC(test, "c")) permute = true;
    else if(ajStrMatchC(test, "o")) ild = true;
    else if(ajStrMatchC(test, "s")) lockhart = true;
    else if(ajStrMatchC(test, "r")) rewrite = true;

    


    if(rewrite) {
      if (data == seqs) {
        outputformat = ajAcdGetListSingle("rewriteformat");
	if(ajStrMatchC(outputformat, "n")) nexus = true;
	else if(ajStrMatchC(outputformat, "x")) xml = true;
        
        if( (nexus) || (xml) ) {
          typeofseq = ajAcdGetListSingle("seqtype");
          if(ajStrMatchC(typeofseq, "d"))  seq = dna;
          else if(ajStrMatchC(typeofseq, "r")) seq = rna;
          else if(ajStrMatchC(typeofseq, "p")) seq = protein;
	}
      }

    }
    else{
      reps = ajAcdGetInt("reps");
      inseed = ajAcdGetInt("seed");
      emboss_initseed(inseed, &inseed0, seed);

      if(jackknife || bootstrap || permute) {
        phyloweights = ajAcdGetProperties("weights");
        if(phyloweights) weights = true;
      }


        if(!permute) {
          justweights = ajAcdGetListSingle("justweights"); 
          if(ajStrMatchC(justweights, "j")) justwts = true;
        }

      }


    printdata = ajAcdGetBoolean("printdata");
    if(printdata) dotdiff = ajAcdGetBoolean("dotdiff");
    progress = ajAcdGetBoolean("progress");


    embossoutfile = ajAcdGetOutfile("outfile");   
    emboss_openfile(embossoutfile, &outfile, &outfilename);

    printf("\n bootstrap: %s",(bootstrap ? "true" : "false"));
    printf("\njackknife: %s",(jackknife ? "true" : "false"));
    printf("\n permute: %s",(permute ? "true" : "false"));
    printf("\n lockhart: %s",(lockhart ? "true" : "false"));
    printf("\n ild: %s",(ild ? "true" : "false"));
    printf("\n justwts: %s \n",(justwts ? "true" : "false"));

     

}  /* emboss_getoptions */
Ejemplo n.º 30
0
int main(int argc, char **argv)
{
    AjPSeqset seq1;
    AjPSeqset seq2;
    AjPFile list;
    ajint n1;
    ajint n2;
    ajint *lengths1;
    ajint *lengths2;
    ajuint *order1;
    ajuint *order2;
    ajint *hits1;
    ajint *hits2;
    ajint curr1;
    ajint curr2;
    ajint tmp1;
    ajint tmp2 = 0;
    ajint i;
    AjPStr operator;
    ajint OperatorCode=0;


    embInit("listor", argc, argv);

    seq1     = ajAcdGetSeqset("firstsequences");
    seq2     = ajAcdGetSeqset("secondsequences");
    list     = ajAcdGetOutfile("outfile");
    operator = ajAcdGetListSingle("operator");

    /* get the operator value */
    switch(ajStrGetCharFirst(operator))
    {
    case 'O':
	OperatorCode = L_OR;
	break;
    case 'A':
	OperatorCode = L_AND;
	break;
    case 'X':
	OperatorCode = L_XOR;
	break;
    case 'N':
	OperatorCode = L_NOT;
	break;
    default:
	ajFatal("Invalid operator type: %S", operator);
	embExitBad();
    }


    /* get the order of seqset 1 by length */
    n1 = ajSeqsetGetSize(seq1);

    /* lengths of seq1 entries */
    lengths1 = AJCALLOC0(n1, sizeof(ajint));

    /* seq1 entries which match seq2 */
    hits1    = AJCALLOC0(n1, sizeof(ajint));

    /* seq1 entries in length order */
    order1   = AJCALLOC0(n1, sizeof(ajint));
    for(i=0; i<n1; i++)
    {
	lengths1[i] = ajSeqGetLen(ajSeqsetGetseqSeq(seq1, i));
	order1[i]   = i;
	hits1[i]    = -1;
    }
    ajSortIntIncI(lengths1, order1, n1);

    /* get the order of seqset 2 by length */
    n2 = ajSeqsetGetSize(seq2);
    lengths2 = AJCALLOC0(n2, sizeof(ajint));
    hits2    = AJCALLOC0(n2, sizeof(ajint));
    order2   = AJCALLOC0(n2, sizeof(ajint));

    for(i=0; i<n2; i++)
    {
	lengths2[i] = ajSeqGetLen(ajSeqsetGetseqSeq(seq2, i));
	order2[i]   = i;
	hits2[i]    = -1;
    }
    ajSortIntIncI(lengths2, order2, n2);

    /*
    ** go down the two sequence sets, by size order, looking for identical
    **lengths
    */
    curr1 = 0;
    curr2 = 0;
    while(curr1 < n1 &&  curr2 < n2)
    {
	if(lengths1[order1[curr1]] < lengths2[order2[curr2]])
	    /* seq1 is shorter - increment curr1 index */
	    curr1++;
	else if(lengths1[order1[curr1]] > lengths2[order2[curr2]])
	    /* seq2 is shorter - increment curr2 index */
	    curr2++;
	else
	{
	    /* identical lengths - check all seq1/seq2 entries of this len */
	    for(tmp1=curr1; tmp1<n1
		 && lengths1[order1[tmp1]] == lengths2[order2[curr2]]; tmp1++)
		for(tmp2=curr2; tmp2<n2 && lengths2[order2[tmp2]] ==
		    lengths2[order2[curr2]]; tmp2++)
		    /* check to see if the sequences are identical */
		    if(!ajStrCmpCaseS(ajSeqGetSeqS(ajSeqsetGetseqSeq(seq1,
							     order1[tmp1])),
				      ajSeqGetSeqS(ajSeqsetGetseqSeq(seq2,
				      order2[tmp2]))))
		    {
			hits1[order1[tmp1]] = order2[tmp2];
			hits2[order2[tmp2]] = order1[tmp1];
		    }

	    curr1 = tmp1;
	    curr2 = tmp2;
	}
    }

    /* output the required entries to the list file */
    listor_Output(list, OperatorCode, seq1, seq2, hits1, hits2, n1, n2);


    AJFREE(lengths1);
    AJFREE(lengths2);
    AJFREE(order1);
    AJFREE(order2);
    AJFREE(hits1);
    AJFREE(hits2);
    ajFileClose(&list);
    ajStrDel(&operator);

    ajSeqsetDel(&seq1);
    ajSeqsetDel(&seq2);

    embExit();

    return 0;
}