示例#1
0
static void jaspscan_GetFileList(const AjPStr dir, const AjPStr jaspdir,
				 const char *wild, AjPList list)
{
    AjPList tlist = NULL;
    AjPStr jdir = NULL;
    AjPStr wstr = NULL;
    AjPStr str  = NULL;
    
    tlist = ajListNew();
    jdir  = ajStrNew();
    wstr  = ajStrNew();
    

    ajFmtPrintS(&jdir,"%S%S",dir,jaspdir);
    if(!ajDirnameFixExists(&jdir))
	ajFatal("EMBOSS_DATA undefined or 'jaspextract' needs to be run");

    ajFmtPrintS(&wstr,"%s%s",wild,J_EXT);

    ajFilelistAddPathWild(tlist,jdir,wstr);

    if(!ajListGetLength(tlist))
	ajWarn("Matrix file(s) %S not found",wstr);

    while(ajListPop(tlist,(void **)&str))
	ajListPushAppend(list,(void *)str);

    ajStrDel(&wstr);
    ajStrDel(&jdir);

    ajListFree(&tlist);

    return;
}
示例#2
0
static void eprimer3_send_range2(FILE * stream, const char * tag,
                                 const AjPRange value)
{
    AjPStr str;
    ajuint n;
    ajuint start;
    ajuint end;

    str=ajStrNew();

    if(ajRangeGetSize(value))
    {
        ajFmtPrintS(&str, "%s=", tag);
        eprimer3_write(str, stream);
        ajStrSetClear(&str);

        for(n=0; n < ajRangeGetSize(value); n++)
        {
            ajRangeElementGetValues(value, n, &start, &end);
            ajFmtPrintS(&str, "%d-%d ", start, end);
            eprimer3_write(str, stream);
            ajStrSetClear(&str);
        }

        ajFmtPrintS(&str, "\n");
        eprimer3_write(str, stream);
    }

    ajStrDel(&str);

    return;
}
示例#3
0
文件: tfscan.c 项目: WenchaoLin/JAMg
static void tfscan_print_hits(AjPList *l,
			      ajint hits, AjPReport outf,
			      const AjPTable t,
			      const AjPSeq seq, ajuint minlength,
			      const  AjPTable btable)
{
    ajint i;
    EmbPMatMatch m;
    const AjPStr acc = NULL;
    const AjPStr bf  = NULL;
    AjPFeattable ftable = NULL;
    AjPFeature gf  = NULL;
    AjPStr type = ajStrNewC("SO:0000235");
    AjPStr tmpstr = NULL;

    ftable = ajFeattableNewSeq(seq);

    /*ajFmtPrintF(outf,"TFSCAN of %s from %d to %d\n\n",ajStrGetPtr(name),
      begin,end);*/

    for(i=0;i<hits;++i)
    {
	ajListPop(*l,(void **)&m);
	acc = ajTableFetchS(t, m->seqname);

	if(m->len >= minlength)
        {
	    /*ajFmtPrintF(outf,"%-20s %-8s %-5d %-5d %s\n",
                        ajStrGetPtr(m->seqname),
			ajStrGetPtr(acc),m->start,
			m->start+m->len-1,ajStrGetPtr(s));*/
            if(m->forward)
                gf = ajFeatNew(ftable, ajUtilGetProgram(), type,
                               m->start,
                               m->start+m->len-1,
                               (float) m->score,
                               '+',0);
            else
                gf = ajFeatNew(ftable, ajUtilGetProgram(), type,
                               m->start,
                               m->start+m->len-1,
                               (float) m->score,
                               '-',0);
            ajFmtPrintS(&tmpstr, "*acc %S", acc);
            ajFeatTagAddSS(gf, NULL, tmpstr);
            bf  = ajTableFetchS(btable, m->seqname);
            ajFmtPrintS(&tmpstr, "*factor %S", bf);
            ajFeatTagAddSS(gf, NULL, tmpstr);
        }

	embMatMatchDel(&m);
    }

    ajReportWrite(outf, ftable, seq);
    ajFeattableDel(&ftable);
    ajStrDel(&tmpstr);
    ajStrDel(&type);

    return;
}
示例#4
0
AjPPatternSeq ajPatternSeqNewList (AjPPatlistSeq plist,
				   const AjPStr name, const AjPStr pat,
				   ajuint mismatch)
{
    AjPPatternSeq pthis;

    if (!ajStrGetLen(pat))
	return NULL;

    AJNEW0(pthis);

    if(ajStrGetLen(name))
	ajStrAssignS (&pthis->Name,name);
    else
	ajFmtPrintS(&pthis->Name, "pattern%d",
		    1+ajListGetLength(plist->Patlist));

    ajStrAssignS(&pthis->Pattern,pat);
    pthis->Protein  = plist->Protein;
    pthis->Mismatch = mismatch;

    ajPatlistAddSeq(plist,pthis);

    return pthis;
}
示例#5
0
AjPPatternRegex ajPatternRegexNewList(AjPPatlistRegex plist,
				      const AjPStr name,
				      const AjPStr pat)
{
    AjPPatternRegex pthis;

    if (!ajStrGetLen(pat))
	return NULL;

    AJNEW0(pthis);

    if(ajStrGetLen(name))
	ajStrAssignS (&pthis->Name,name);
    else
	ajFmtPrintS(&pthis->Name, "regex%d",
		    1+ajListGetLength(plist->Patlist));

    ajStrAssignS  (&pthis->Pattern,pat);
    pthis->Type = plist->Type;

    pthis->Compiled = ajRegComp(pthis->Pattern);
    ajPatlistAddRegex (plist,pthis);

    return pthis;
}
示例#6
0
void ajDebug(const char* fmt, ...)
{
    va_list args;
    static ajint debugset = 0;
    static ajint depth    = 0;
    AjPStr bufstr         = NULL;
    
    if(depth)
    {				   /* recursive call, get out quick */
	if(messDebugFile)
	{
	    va_start(args, fmt);
	    ajFmtVPrintF(messDebugFile, fmt, args);
	    va_end(args);
	}

	return;
    }

    depth++;

    if(!debugset && acdDebugSet)
    {
	messDebug = acdDebug;

	if(messDebug)
	{
	    ajFmtPrintS(&messDebugName, "%s.dbg", ajStrGetPtr(acdProgram));
	    messDebugFile = ajFileNewOutNameS(messDebugName);

	    if(!messDebugFile)
		ajFatal("Cannot open debug file %S",messDebugName);

	    if(ajNamGetValueC("debugbuffer", &bufstr))
	    {
		ajStrToBool(bufstr, &acdDebugBuffer);
	    }

	    if(!acdDebugBuffer)
		ajFileSetUnbuffer(messDebugFile);

	    ajFmtPrintF(messDebugFile, "Debug file %F buffered:%B\n",
			 messDebugFile, acdDebugBuffer);
	    ajStrDel(&bufstr);
	}

	debugset = 1;
    }

    if(messDebug)
    {
	va_start(args, fmt);
	ajFmtVPrintF(messDebugFile, fmt, args);
	va_end(args);
    }

    depth--;

    return;
}
示例#7
0
/* @funcstatic domainalign_tcoffee ********************************************
**
** Call TCOFFEE and process files.
**
** @param [r] domain [AjPDomain] Domain being aligned
** @param [r] in [AjPStr] Name of TCOFFEE input file
** @param [r] align [AjPStr] Name of sequence alignment file for output
** @param [r] alignc [AjPStr] Name of structure alignment file for output
** @param [r] pdbnames [AjPStr] Names of pdb files to be passed to TCOFFEEE 
** @param [r] noden [ajint] Node-level of alignment
** @param [r] logf [AjPFile] Log file.
**
** @return [void] True on success
** @@
****************************************************************************/
static void domainalign_tcoffee(AjPDomain domain, 
				AjPStr    in, 
				AjPStr    align, 
				AjPStr    alignc, 
				AjPStr    pdbnames, 
				ajint     noden, 
				AjPFile   logf)
			 
{
    AjPStr    exec      = NULL;	/* The UNIX command line to be executed*/

    exec     = ajStrNew();


    /* '-in' is indeed a file sepecifier. 
       The 'pdb1 pdb2 pdb3' string contains the file (including the path) of the 
       clean domain cordinate files (pdb format) for the structural alifnment 
       e.g. d1vsc_2.ent. 
       '-outfile' is the clustal format alignment output file. */

    ajFmtPrintS(&exec,"t_coffee -in %S sap_pair", pdbnames);
    ajFmtPrint("%S > %S\n", exec, in);
    ajSysExecOutnameS(exec, in);

    /* Process tcoffee alignment file and generate alignment file 
       for output. */
    domainalign_ProcessTcoffeeFile(in, align, domain, noden, logf);

    ajStrDel(&exec);

    return;
}
示例#8
0
文件: gfile.c 项目: ktnyt/GEMBASSY
ajint gValID(AjPStr id){
  AjPFilebuff buff = NULL;
  AjPStr      url  = NULL;
  AjPStr      line = NULL;
  AjPRegexp   pval = NULL;

  url = ajStrNewC("http://web.sfc.keio.ac.jp/~t11080hi/valID/valID.cgi?id=");
  url = ajStrNew();
  ajFmtPrintS(&url, "http://rest.g-language.org/%S", id);

  //ajStrAppendS(&url, id);

  if(!gFilebuffURLS(url, &buff)) {
    return ajFalse;
  }

  return ajTrue;

  ajBuffreadLine(buff, &line);

  pval = ajRegCompC("^0");

  if(ajRegExec(pval, line))
    return ajFalse;

  return ajTrue;
}
示例#9
0
static void infoalign_OutputStr(AjPFile outfile, const AjPStr str, AjBool html,
				 AjBool after, ajuint minlength)
{
    AjPStr marginfmt;

    marginfmt = ajStrNewRes(10);

    /* ajFmtPrintF doesn't seem to deal with formats like "%-*S" correctly */
    ajFmtPrintS(&marginfmt, "%%-%dS", minlength);

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

    if(html || !after || minlength == NOLIMIT)
	ajFmtPrintF(outfile, "%S", str);
    else
	/*
	**  Format:
	**  If this is the last item, don't put spaces or TABs after it.
	**  Try to fit the name in 'minlength' spaces, else just add a
	**  TAB after it
	*/
	ajFmtPrintF(outfile, ajStrGetPtr(marginfmt), str);

    if(html)
	ajFmtPrintF(outfile, "</td>\n");
    else
	if(after &&  ajStrGetLen(str) >= minlength)
	    ajFmtPrintF(outfile, "\t");

    ajStrDel(&marginfmt);

    return;
}
示例#10
0
文件: gfile.c 项目: ktnyt/GEMBASSY
void gAssignUniqueName(AjPStr *string) {
  static char ext[2] = "A";

  ajFmtPrintS(string, "%08d%s", getpid(), ext);

  if( ++ext[0] > 'Z' ) {
    ext[0] = 'A';
  }
}
示例#11
0
文件: ghttp.c 项目: ktnyt/GEMBASSY
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;
}
示例#12
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;
}
示例#14
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;
}
示例#15
0
static AjPStr getUniqueFileName(void) {
  static char ext[2] = "A";
  AjPStr filename    = NULL;

  ajFmtPrintS(&filename, "%08d%s",getpid(), ext);

  if( ++ext[0] > 'Z' ) {
    ext[0] = 'A';
  }

  return filename;
}
示例#16
0
static void digest_report_hits(AjPFeattable TabRpt, AjPList l, ajint be,
			       const char* s)
{
    AjPFeature gf = NULL;
    EmbPPropFrag fr;
    AjPStr t;
    ajint len;
    AjPStr tmpStr = NULL;
    size_t stlen;
    
    t   = ajStrNew();
    stlen = strlen(s);
    len = (ajint) stlen;

    while(ajListPop(l,(void **)&fr))
    {
	ajStrAssignSubC(&t,s,fr->start,fr->end);
	gf = ajFeatNewII(TabRpt,fr->start+be,fr->end+be);
	ajFmtPrintS(&tmpStr, "*molwt %.3f", fr->molwt);
	ajFeatTagAdd(gf,  NULL, tmpStr);
	if(fr->start>0)
	{
	    ajFmtPrintS(&tmpStr, "*cterm %c", *(s+(fr->start)-1));
	    ajFeatTagAdd(gf,  NULL, tmpStr);
	}

	if(fr->end<len-1)
	{
	    ajFmtPrintS(&tmpStr, "*nterm %c", *(s+(fr->end+1)));
	    ajFeatTagAdd(gf,  NULL, tmpStr);
	}

	AJFREE(fr);
    }

    ajStrDel(&t);
    ajStrDel(&tmpStr);

    return;
}
示例#17
0
/* @funcstatic domainalign_writelast ******************************************
**
** House-keeping function.
**
** @param [r] domain [AjPDomain]    Domain.
** @param [r] noden  [ajint]        Node number.
** @param [r] last_node [AjPStr *]  Last node.  
** @param [r] last_nodeid [ajint *] Id of last node.
** 
** @return [void]
** 
** @@
****************************************************************************/
static void domainalign_writelast(AjPDomain domain, 
				  ajint noden, 
				  AjPStr *last_node, 
				  ajint *last_nodeid)
{
    if(noden==1) 
    {
	ajStrAssignS(last_node, domain->Scop->Class);
	*last_nodeid = domain->Scop->Sunid_Class;
    }		       
    else if (noden==2)
    {
	ajStrAssignS(last_node, domain->Scop->Fold);
	*last_nodeid = domain->Scop->Sunid_Fold;
    }
    else if (noden==3)
    {
	ajStrAssignS(last_node, domain->Scop->Superfamily);
	*last_nodeid = domain->Scop->Sunid_Superfamily;
    }
    else if (noden==4)
    {
	ajStrAssignS(last_node, domain->Scop->Family);
	*last_nodeid = domain->Scop->Sunid_Family;
    } 	
    else if (noden==5)
    {
	ajStrAssignS(last_node, domain->Cath->Class);
	*last_nodeid = domain->Cath->Class_Id ;
    } 
    else if (noden==6)
    {
	ajStrAssignS(last_node, domain->Cath->Architecture);
	*last_nodeid = domain->Cath->Arch_Id;
    } 
    else if (noden==7)
    {
	ajStrAssignS(last_node, domain->Cath->Topology);
	*last_nodeid = domain->Cath->Topology_Id;
    } 
    else if (noden==8)
    {
	ajStrAssignS(last_node, domain->Cath->Superfamily);
	*last_nodeid = domain->Cath->Superfamily_Id;
    } 
    else if (noden==9)
    {
	/* There is no text describing the CATH families. */
	ajFmtPrintS(last_node, "%d", domain->Cath->Family_Id);
	*last_nodeid = domain->Cath->Family_Id;
    } 
}
示例#18
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;
}
示例#19
0
文件: ajresource.c 项目: ICO2S/emboss
static void resourceMakeQry(const AjPResource thys, AjPStr* qry)
{
    ajDebug("resourceMakeQry (Id <%S> Formatstr <%S> Db <%S> "
	    "Filename <%S>)\n",
	    thys->Id, thys->Formatstr, thys->Db,
	    thys->Filename);

    /* ajResourceTrace(thys); */

    if(ajStrGetLen(thys->Db))
	ajFmtPrintS(qry, "%S-id:%S", thys->Db, thys->Id);
    else
    {
	ajFmtPrintS(qry, "%S::%S:%S", thys->Formatstr,
                    thys->Filename,thys->Id);
    }

    ajDebug("      result: <%S>\n",
	    *qry);

    return;
}
示例#20
0
static void eprimer3_send_float(FILE * stream, const char * tag, float value)
{
    AjPStr str;

    str = ajStrNew();

    ajFmtPrintS(&str, "%s=%f\n", tag, value);
    eprimer3_write(str, stream);

    ajStrDel(&str);

    return;
}
示例#21
0
ajuint ajPatlistRegexDoc (AjPPatlistRegex plist, AjPStr* Pdoc)
{
    AjPPatternRegex pat = NULL;

    ajFmtPrintS(Pdoc, "%-12S %S\n", "Pattern_name", "Pattern");

    while (ajPatlistRegexGetNext(plist, &pat))
	ajFmtPrintAppS(Pdoc, "%-12S %S\n",
		       ajPatternRegexGetName(pat),
		       ajPatternRegexGetPattern(pat));

    return ajListGetLength(plist->Patlist);
}
示例#22
0
static void eprimer3_send_bool(FILE * stream, const char * tag, AjBool value)
{
    AjPStr str;

    str = ajStrNew();

    ajFmtPrintS(&str, "%s=%d\n", tag, value?1:0);
    eprimer3_write(str, stream);

    ajStrDel(&str);

    return;
}
示例#23
0
ajuint ajPatlistSeqDoc (AjPPatlistSeq plist, AjPStr* Pdoc)
{
    AjPPatternSeq pat = NULL;

    ajFmtPrintS(Pdoc, "%-12s %8s %s\n",
		   "Pattern_name", "Mismatch", "Pattern");
    while (ajPatlistSeqGetNext(plist, &pat))
    {
	ajFmtPrintAppS(Pdoc, "%-12S %8d %S\n",
		       ajPatternSeqGetName(pat),
		       ajPatternSeqGetMismatch(pat),
		       ajPatternSeqGetPattern(pat));
    }
    return ajListGetLength(plist->Patlist);
}
示例#24
0
int main(int argc, char **argv)
{
    /* Variable Declarations */
    AjPSeqset seqset = NULL;
    AjPAlign  align  = NULL;
    AjPStr    name     = NULL;
    AjPStr    comment  = NULL;
    AjBool    append   = ajFalse;

    AjPStr    header   = NULL;


    /* ACD File Processing */
    embInit("aligncopy", argc, argv);
    seqset      = ajAcdGetSeqset("sequences");
    align       = ajAcdGetAlign("outfile");
    name       = ajAcdGetString("name");
    comment    = ajAcdGetString("comment");
    append     = ajAcdGetBoolean("append");


    /* Application logic */
    ajAlignDefine(align, seqset);

    if(ajStrGetLen(name))
        ajFmtPrintS(&header, "Alignment: %S\n\n", name);
    ajStrAppendS(&header, comment);
    if(append)
      ajAlignSetHeaderApp(align, header);
    else
      ajAlignSetHeader(align, header);

    ajAlignWrite(align);
    ajAlignClose(align);


    /* Memory management and exit */
    ajSeqsetDel(&seqset);
    ajAlignDel(&align);

    ajStrDel(&name);
    ajStrDel(&comment);
    ajStrDel(&header);

    embExit();

    return 0;
}
示例#25
0
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;
}
示例#26
0
static void eprimer3_send_stringC(FILE *stream, const char *tag,
                                  const char *value)
{
    AjPStr str;

    str = ajStrNew();

    if(strlen(value))
    {
        ajFmtPrintS(&str, "%s=%s\n", tag, value);
        eprimer3_write(str, stream);
    }

    ajStrDel(&str);

    return;
}
示例#27
0
文件: emma.c 项目: WenchaoLin/JAMg
static AjPStr emma_getUniqueFileName(void)
{
    static char ext[2] = "A";
    AjPStr filename    = NULL;

    /*
    ** A kludge to make filenames greater than 5 characters. This
    ** sometimes, but by no means always, helped bypass a memory
    ** allocation bug in versions of clustalw before 1.83.
    ** You should update your clustalw.
    */
    ajFmtPrintS(&filename, "%08d%s",getpid(), ext);

    if(++ext[0] > 'Z')
	ext[0] = 'A';


    return filename;
}
示例#28
0
static void jaspextract_openoutdirs(void)
{
    const AjPStr datadir = NULL;
    AjPStr dir = NULL;
    const char *p = NULL;
    
    ajuint i = 0;
    
    datadir = ajDatafileValuePath();
    if(!datadir)
        ajFatal("jaspextract: Cannot determine the EMBOSS data directory");

    dir  = ajStrNew();
    
    i = 0;

    while(Jprefix[i].Directory)
    {
        ajFmtPrintS(&dir,"%S%s",datadir,Jprefix[i].Directory);

        if(!ajFilenameExistsDir(dir))
        {
            p = ajStrGetPtr(dir);
#ifndef WIN32
            mkdir(p,0644);
#else
            _mkdir(p);
#endif
        }
        
        if(!ajFilenameExistsDir(dir))
            ajFatal("jaspextract: No such directory %S",
                    dir);

        ++i;
    }
    
    ajStrDel(&dir);
    
    return;
}
示例#29
0
static void dastestSaveRawFeatures(AjPFilebuff buff, const AjPStr ffname)
{
    AjPFile ffile = NULL;
    AjPStr line   = ajStrNew();
    AjPStr ffnamee = ajStrNew();

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

    while(!ajFilebuffIsEmpty(buff))
    {
	ajBuffreadLine(buff,&line);

	ajDebug("ajDasQueryParse: line: %S", line);
	ajWriteline(ffile, line);
	ajStrDel(&line);
    }

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

    return;
}
示例#30
0
static void silent_fmt_hits(AjPList hits, AjPFeattable feat,
			    AjBool silent, AjBool rev)
{
    PSilent res;
    AjPFeature sf = NULL;
    AjPStr tmpFeatStr = NULL;

    ajListSort(hits,silent_basecompare);

    while(ajListPop(hits,(void **)&res))
    {
	if (rev)
	    sf = ajFeatNewIIRev(feat,
				res->match, res->match+ajStrGetLen(res->site)-1);
	else
	    sf = ajFeatNewII(feat,
			     res->match, res->match+ajStrGetLen(res->site)-1);

	if (silent)
	{
	    ajFmtPrintS(&tmpFeatStr, "*silent Yes");
	    ajFeatTagAdd (sf, NULL, tmpFeatStr);
	}
	ajFmtPrintS(&tmpFeatStr, "*enzyme %S", res->code);
	ajFeatTagAdd (sf, NULL, tmpFeatStr);
	ajFmtPrintS(&tmpFeatStr, "*rspattern %S", res->site);
	ajFeatTagAdd (sf, NULL, tmpFeatStr);
	ajFmtPrintS(&tmpFeatStr, "*baseposn %d", res->base);
	ajFeatTagAdd (sf, NULL, tmpFeatStr);
	ajFmtPrintS(&tmpFeatStr, "*aa %S.%S", res->seqaa, res->reaa);
	ajFeatTagAdd (sf, NULL, tmpFeatStr);
	ajFmtPrintS(&tmpFeatStr, "*mutation %c->%c", res->obase,res->nbase);
	ajFeatTagAdd (sf, NULL, tmpFeatStr);
	
       ajStrDel(&res->code);
       ajStrDel(&res->site);
       ajStrDel(&res->seqaa);
       ajStrDel(&res->reaa);
       AJFREE(res);
    }

    ajStrDel(&tmpFeatStr);
    return;
}