AjBool gFormatGenbank(AjPSeq seq, AjPStr *inseq){
  AjPSeqout     seqout   = NULL;
  AjPFeattabOut featout  = NULL;
  AjPFeattable  feat     = NULL;
  AjPStr        seqline  = NULL;
  AjPStr        featline = NULL;
  AjPFile       seqfile  = NULL;
  AjPFile       featfile = NULL;
  AjPStr        filename = NULL;

  gAssignUniqueName(&filename);
  feat = ajSeqGetFeatCopy(seq);

  if(!feat)
    return ajFalse;

  seqout = ajSeqoutNew();

  if(!ajSeqoutOpenFilename(seqout,filename))
    embExitBad();

  ajSeqoutSetFormatS(seqout,ajStrNewC("genbank"));
  ajSeqoutWriteSeq(seqout,seq);
  ajSeqoutClose(seqout);
  ajSeqoutDel(&seqout);

  seqfile = ajFileNewInNameS(filename);
  ajSysFileUnlinkS(filename);

  featout = ajFeattabOutNew();

  if(!ajFeattabOutOpen(featout,filename))
    return ajFalse;

  ajFeattableWriteGenbank(featout,feat);

  ajFeattableDel(&feat);
  //ajFeattabOutDel(&featout);
  ajFileClose(&(featout->Handle));

  featfile = ajFileNewInNameS(filename);
  ajSysFileUnlinkS(filename);

  while(ajReadline(seqfile,&seqline)){
    if(ajStrMatchC(seqline,"ORIGIN\n")){
      while(ajReadline(featfile,&featline)){
	ajStrAppendS(inseq, featline);
      }
    }
    ajStrAppendS(inseq, seqline);
  }

  ajStrDel(&seqline);
  ajStrDel(&featline);
  ajStrDel(&filename);
  ajFileClose(&seqfile);
  ajFileClose(&featfile);

  return ajTrue;
}
Exemple #2
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;
}
Exemple #3
0
void ajMessExitDebug(void)
{
    ajFileClose(&messDebugFile);
    ajStrDel(&messDebugName);
    ajFileClose(&messDebugTestFile);
    ajStrDel(&messDebugName);

    return;
}
Exemple #4
0
AjBool gHttpGetBinS(AjPStr url, AjPFile* outf)
{
  AjPFile file = NULL;
  AjPStr  line = NULL;
  AjPStr  host = NULL;
  AjPStr  path = NULL;
  AjPStr  get  = NULL;
  ajint   port = 80;
  ajuint  http = 0;
  FILE   *fp;

  AjPRegexp crlf = NULL;

  char buf[8];

  AjOSysSocket sock;

  get = ajStrNew();

  ajHttpUrlDeconstruct(url, &port, &host, &path);

  while(file==NULL || gHttpRedirect(file, &host, &port, &path))
    {
      if(ajStrGetCharFirst(path) != '/')
	ajStrInsertK(&path, 0, '/');

      ajFmtPrintS(&get, "GET http://%S:%d%S HTTP/1.1\r\n", host, port, path);

      fp = ajHttpOpen(NULL, host, port, get, &sock);

      file = ajFileNewFromCfile(fp);

      if(!file)
	return ajFalse;
    }

  ajStrDel(&get);

  crlf = ajRegCompC("^\r?\n$");

  while(ajReadline(file, &line))
    {
      if(ajRegExec(crlf, line))
	break;
    }

  while(ajReadbinBinary(file, 1, 1, buf))
    {
      ajWritebinBinary(*outf, 1, 1, buf);
    }

  ajFileClose(outf);
  ajFileClose(&file);

  return ajTrue;
}
Exemple #5
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;
}
Exemple #6
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;
}
Exemple #7
0
int main(int argc, char **argv)
{
    AjPSeqset seqset;
    AjPSeqall seqall;
    AjPSeq seq;
    ajint i = 0;
    AjPStr kimout = NULL;
    AjPStr dir = NULL;
    AjPFile obofile = NULL;
    AjPFile resfile = NULL;
    AjPDir taxdir = NULL;

    embInit("ajtest", argc, argv);

    seqall = ajAcdGetSeqall ("sequence");
    seqset = ajAcdGetSeqset ("bsequence");
    dir = ajAcdGetOutdirName("outdir");
    obofile = ajAcdGetInfile ("obofile");
    taxdir = ajAcdGetDirectory ("taxdir");
    resfile = ajAcdGetInfile ("dbxreffile");

    ajUser("Directory '%S'", dir);
    ajUser("Set of %d", ajSeqsetGetSize(seqset));
    while(ajSeqallNext (seqall, &seq))
    {
	ajUser ("%3d <%S>", i++, ajSeqGetUsaS(seq));
	ajFmtPrintS(&kimout, "kim%d.out", i);
	ajtest_kim (kimout, seq);
    }

    ajSeqDel(&seq);
    ajSeqallDel(&seqall);
    ajSeqsetDel(&seqset);
    ajStrDel(&kimout);
    ajStrDel(&dir);

    if(taxdir)
        ajTaxLoad(taxdir);
    ajDirDel(&taxdir);

    if(obofile)
        ajOboParseObofile(obofile, "");
    ajFileClose(&obofile);

    if(resfile)
        ajResourceParse(resfile, "");
    ajFileClose(&resfile);

    embExit();

    return 0;
}
Exemple #8
0
int main(int argc, Char *argv[])
{  /* main program */
  long i;

#ifdef MAC
  argc = 1;                /* macsetup("Contml","");                */
  argv[0] = "Contml";
#endif
  init(argc, argv);
  emboss_getoptions("fcontml", argc, argv);
  progname = argv[0];

  ibmpc = IBMCRT;
  ansi = ANSICRT;
  firstset = true;
  doinit();

  for (ith = 1; ith <= datasets; ith++) {
    getinput();
    if (ith == 1)
      firstset = false;
    if (datasets > 1) {
      fprintf(outfile, "Data set # %ld:\n\n", ith);
      if (progress)
        printf("\nData set # %ld:\n", ith);
    }
    for (jumb = 1; jumb <= njumble; jumb++)
      maketree();
    if (usertree)
      for (i = 0; i < MAXSHIMOTREES; i++)
        free(l0gf[i]);
  }
  FClose(outfile);
  FClose(outtree);
#ifdef MAC
  fixmacfile(outfilename);
  fixmacfile(outtreename);
#endif
  printf("\nDone.\n\n");
#ifdef WIN32
  phyRestoreConsoleAttributes();
#endif
  ajPhyloFreqDel(&phylofreq);
  ajPhyloTreeDelarray(&phylotrees);

  ajFileClose(&embossoutfile);
  ajFileClose(&embossouttree);

  embExit();
  return 0;
}
Exemple #9
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;
}
Exemple #10
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;
}
Exemple #11
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;
}
static void remap_read_equiv(AjPFile *equfile, AjPTable *table,
			     AjBool commercial)
{
    AjPStr line;
    AjPStr key;
    AjPStr value;

    const char *p;

    line = ajStrNew();

    while(ajReadlineTrim(*equfile,&line))
    {
        p = ajStrGetPtr(line);

        if(!*p || *p=='#' || *p=='!')
            continue;
        p = ajSysFuncStrtok(p," \t\n");
        key = ajStrNewC(p);
        p = ajSysFuncStrtok(NULL," \t\n");
        value = ajStrNewC(p);
	if(!commercial)
	    ajStrTrimEndC(&value,"*");
        ajTablePut(*table,(void *)key, (void *)value);
    }

    ajFileClose(equfile);
    ajStrDel(&line);

    return;
}
static void remap_read_file_of_enzyme_names(AjPStr *enzymes)
{
    AjPFile file = NULL;
    AjPStr line;
    const char *p = NULL;

    if(ajStrFindC(*enzymes, "@") == 0)
    {
	ajStrTrimC(enzymes, "@");	/* remove the @ */
	file = ajFileNewInNameS(*enzymes);
	if(file == NULL)
	    ajFatal("Cannot open the file of enzyme names: '%S'", enzymes);

	/* blank off the enzyme file name and replace with the enzyme names */
	ajStrSetClear(enzymes);
	line = ajStrNew();
	while(ajReadlineTrim(file, &line))
	{
	    p = ajStrGetPtr(line);
	    if(!*p || *p == '#' || *p == '!')
		continue;
	    ajStrAppendS(enzymes, line);
	    ajStrAppendC(enzymes, ",");
	}
	ajStrDel(&line);

	ajFileClose(&file);
    }

    return;
}
Exemple #14
0
static ajuint jaspscan_readmatrix(const AjPStr mfname, float ***matrix)
{

    AjPFile inf  = NULL;
    AjPStr line  = NULL;

    ajuint i = 0;
    ajuint cols = 0;

    AJCNEW0(*matrix,4);

    line = ajStrNew();

    inf = ajFileNewInNameS(mfname);
    if(!inf)
	ajFatal("Cannot open matrix file %S",mfname);

    i = 0;
    while(ajReadlineTrim(inf,&line))
    {
	if(!i)
	    cols = ajStrParseCountC(line," \n");

	(*matrix)[i++] = ajArrFloatLine(line," \n",1,cols);
    }
    


    ajStrDel(&line);
    ajFileClose(&inf);
    
    return cols;;
}
void embIepPkRead(double *pK)
{
    AjPFile inf = NULL;
    AjPStr line;
    const char *p;
    double  amino    = 8.6;
    double  carboxyl = 3.6;
    char ch;
    ajint i;


    inf = ajDatafileNewInNameC(PKFILE);

    if(!inf)
	ajFatal("%s file not found",PKFILE);

    for(i=0;i<EMBIEPSIZE;++i)
	pK[i]=0.0;

    line = ajStrNew();

    while(ajReadline(inf,&line))
    {
	p = ajStrGetPtr(line);

	if(*p=='#' || *p=='!' || *p=='\n' || *p=='\r')
	    continue;

	if(ajStrPrefixCaseC(line,"Amino"))
	{
	    p = ajSysFuncStrtok(p," \t\n\r");
	    p = ajSysFuncStrtok(NULL," \t\n\r");
	    sscanf(p,"%lf",&amino);
	    continue;
	}

	if(ajStrPrefixCaseC(line,"Carboxyl"))
	{
	    p = ajSysFuncStrtok(p," \t\n\r");
	    p = ajSysFuncStrtok(NULL," \t\n\r");
	    sscanf(p,"%lf",&carboxyl);
	    continue;
	}

	p  = ajSysFuncStrtok(p," \t\n\r");
	ch = ajSysCastItoc(toupper((ajint)*p));
	p  = ajSysFuncStrtok(NULL," \t\n\r");
	sscanf(p,"%lf",&pK[ajBasecodeToInt(ch)]);
    }

    pK[EMBIEPAMINO]    = amino;
    pK[EMBIEPCARBOXYL] = carboxyl;

    ajStrDel(&line);
    ajFileClose(&inf);

    return;
}
Exemple #16
0
int main(int argc, char **argv)
{
    /* ACD data item variables */
    AjPFile database = NULL;

    /* Housekeeping variables */
    AjPStr        cmd = NULL;
    AjPStr        tmp = NULL;





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

    database   = ajAcdGetInfile("database");





    /* MAIN APPLICATION CODE */
    /* 1. Housekeeping */
    cmd = ajStrNew();
    tmp = ajStrNew();


    /* 2. Build hmmindex command line */
    /* Command line is built in this order: 
       i.  Application name.
       ii. HMMER 'options' (in order they appear in ACD file)
       iii.HMMER 'options' (that don't appear in ACD file)
       iv. HMMER & new parameters.
       */
    ajFmtPrintS(&cmd, "%S ", ajAcdGetpathC("hmmindex"));
    ajStrAppendC(&cmd, ajFileGetNameC(database));

    
    /* 3. Close ACD files. */
    ajFileClose(&database);


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

    /* 5. Exit cleanly */
    ajStrDel(&cmd);
    ajStrDel(&tmp);
    
    embExit();

    return 0;
}
static void jaspextract_writematrixfile(const AjPTable mtable,
                                        const AjPStr directory)
{
    AjPStr wild   = NULL;
    AjPList flist = NULL;
    AjPStr key    = NULL;
    AjPStr fname  = NULL;
    AjPStr dest   = NULL;
    const AjPStr value  = NULL;
    
    AjPFile outf = NULL;
    
    const char *p = NULL;
    char *q = NULL;
    
    wild = ajStrNewC("*.pfm");
    flist = ajListNew();
    key   = ajStrNew();
    dest  = ajStrNew();
    
    ajFmtPrintS(&dest,"%S%c%s",directory,SLASH_CHAR,MATRIXFILE);
    
    outf = ajFileNewOutNameS(dest);
    if(!outf)
        ajFatal("Cannot open output file %S",dest);

    ajFilelistAddPathWild(flist, directory, wild);

    while(ajListPop(flist,(void**)&fname))
    {
        ajFilenameTrimPath(&fname);        

        p = ajStrGetPtr(fname);
        q = strrchr(p,(int)'.');
        ajStrAssignSubC(&key,p,0,q-p-1);
        
        value = ajTableFetchS(mtable, key);

        if(value)
            ajFmtPrintF(outf,"%S",value);

        ajStrDel(&fname);
    }
    
        
    ajFileClose(&outf);
    
    ajStrDel(&wild);
    ajStrDel(&dest);
    ajStrDel(&key);
    ajListFree(&flist);
    
    return;
}
Exemple #18
0
static void jaspextract_readmatrixlist(AjPTable mtable, const AjPStr directory)
{
    const AjPStr datadir = NULL;

    AjPStr matrixfile = NULL;
    AjPFile inf = NULL;

    AjPStr line  = NULL;
    AjPStr key   = NULL;
    AjPStr value = NULL;
    
    matrixfile = ajStrNew();
    

    datadir = ajDatafileValuePath();
    if(!datadir)
        ajFatal("jaspextract: Cannot determine the EMBOSS data directory");
    
    ajFmtPrintS(&matrixfile,"%S%s",directory,MATRIXFILE);

    if(!ajFilenameExistsRead(matrixfile))
        ajFatal("jaspextract: Directory (%S) doesn't appear to be a JASPAR "
                "one\nNo matrix_list.txt file found",directory);


    inf  = ajFileNewInNameS(matrixfile);
    if(!inf)
        ajFatal("Cannot open input file: %S",matrixfile);

    while(ajReadline(inf,&line))
    {
        key = ajStrNew();
        
        if(ajFmtScanS(line,"%S",&key) != 1)
        {
            ajStrDel(&key);
            continue;
        }

        value = ajStrNew();
        ajStrAssignS(&value,line);

        ajTablePut(mtable,(void *)key, (void *)value);
    }
    

    ajFileClose(&inf);
    
    ajStrDel(&matrixfile);
    ajStrDel(&line);
        
    return;
}
Exemple #19
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;
}
Exemple #20
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;
}
Exemple #21
0
static void assemoutBamIndex(AjPOutfile outf)
{
    char *fname = ajCharNewC(ajFileGetNameC(ajOutfileGetFile(outf)));
    AjPSeqBamBgzf gzfile = outf->OutData;

    ajSeqBamBgzfClose(gzfile);
    ajFileClose(&outf->File);

    ajBamIndexBuild(fname);

    AJFREE(fname);

    return;
}
static void dastestSaveMappedFeatures(const AjPFeattable fttable,
                                      const AjPStr ffname,
                                      AjPFile outf, ajint maxfeatures)
{
    AjPFeature feature  = NULL;
    AjIList iterfts     = NULL;
    AjPFeattabOut ftout = NULL;
    AjPFile ffile = NULL;
    AjPStr ffnamee = ajStrNew();

    ajint i=0;

    if (fttable == NULL)
    {
	ajWarn("null feature table, %S", ffname);
	return;
    }

    ajFmtPrintS(&ffnamee, "%S.mapped.dasgff", ffname);
    ffile = ajFileNewOutNameS(ffnamee);

    iterfts = ajListIterNew(fttable->Features);
    ftout= ajFeattabOutNewCSF("gff3",NULL,"",ffile);

    ajFmtPrintF(outf, "Number of features %d\n",
	    ajListGetLength(fttable->Features));

    while(!ajListIterDone(iterfts) && i++ < maxfeatures)
    {
	feature = ajListIterGet(iterfts);
	ajFmtPrintF(outf,
		"feature id:%S orientation:%c start:%d stop:%d\n",
		feature->Label,
		feature->Strand,
		feature->Start, feature->End);
    }

    ajListIterDel(&iterfts);

    ajFeattableWriteDasgff(ftout, fttable);

    ajFeattabOutDel(&ftout);
    ajFileClose(&ffile);
    ajStrDel(&ffnamee);

    return;
}
Exemple #23
0
AjBool gGetFileContent(AjPStr* content, AjPStr filename){
  AjPFile file    = NULL;
  AjPStr  line    = NULL;

  if((file = ajFileNewInNameS(filename)) == NULL)
    return ajFalse;

  while(ajReadline(file, &line))
    ajStrAppendS(content, line);

  if(file)
    ajFileClose(&file);

  ajSysFileUnlinkS(filename);

  return ajTrue;
}
Exemple #24
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;
}
static void dbiblast_memfclosefile(PMemFile* pfd)
{
    PMemFile fd;

    if(!pfd)
	return;

    if(!*pfd)
	return;

    fd = *pfd;
    ajFileClose(&fd->File);
    ajStrDel(&fd->Name);

    AJFREE(*pfd);

    return;
}
Exemple #26
0
static void ajtest_kim (const AjPStr seqout_name, const AjPSeq subseq)
{
    AjPFile seqout_file = ajFileNewOutNameS(seqout_name);
    AjPSeqout named_seqout = ajSeqoutNewFile(seqout_file);

    AjPStr format_str = ajStrNew();

    ajStrAssignC(&format_str, "embl");

    ajSeqoutSetFormatS(named_seqout, format_str);

    ajSeqoutWriteSeq(named_seqout, subseq);

    ajSeqoutDel(&named_seqout);
    ajFileClose(&seqout_file);
    ajStrDel(&format_str);

    return;
}
Exemple #27
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;
}
Exemple #28
0
static void emira_doinfiles(AjPStr *cl, AjPTable table)
{
    ajuint i;
    AjPStr squal = NULL;
    AjPStr prefix = NULL;
    AjPStr key    = NULL;
    AjPStr value  = NULL;
    AjPFile infile = NULL;
    
    prefix = ajStrNew();
    key    = ajStrNew();
    
    i = 0;

    while(mirainfiles[i].qname)
    {
	infile = ajAcdGetInfile(mirainfiles[i].qname);
	if(infile)
	   squal = ajStrNewS(ajFileGetName(infile));
	else
	    squal = ajStrNewS(ajAcdGetValueDefault(mirainfiles[i].qname));
	ajStrAssignC(&key,mirainfiles[i].mname);
	ajStrAssignC(&prefix,"");

	value = ajTableFetch(table, key);
	if(value)
	    ajStrAssignS(&prefix,value);

	if(!ajStrMatchC(squal,mirainfiles[i].def))
	    ajFmtPrintAppS(cl," -%S%s=%S",prefix,mirainfiles[i].mname,
			   squal);
	ajStrDel(&squal);
	ajFileClose(&infile);
	++i;
    }

    ajStrDel(&key);
    ajStrDel(&prefix);
    
    return;
}
Exemple #29
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;
}
Exemple #30
0
static void notseq_readfile(const AjPStr exclude, AjPStr *pattern)
{
    AjPFile file = NULL;
    AjPStr line;
    AjPStr filename = NULL;
    const char *p = NULL;

    if(ajStrFindC(exclude, "@") != 0)
    {
	ajStrAssignS(pattern, exclude);
    }
    else
    {
	ajStrAssignS(&filename, exclude);
        ajStrTrimC(&filename, "@");       /* remove the @ */
        file = ajFileNewInNameS(filename);
        if(file == NULL)
            ajFatal("Cannot open the file of sequence names: '%S'", filename);

        /* blank off the file name and replace with the sequence names */
        ajStrSetClear(pattern);
        line = ajStrNew();
        while(ajReadlineTrim(file, &line))
        {
            p = ajStrGetPtr(line);

            if(!*p || *p == '#' || *p == '!')
		continue;

            ajStrAppendS(pattern, line);
            ajStrAppendC(pattern, ",");
        }
        ajStrDel(&line);
        ajStrDel(&filename);

        ajFileClose(&file);
    }

    return;
}