示例#1
0
static void emira_dolistsingles(AjPStr *cl, AjPTable table)
{
    ajuint i;
    AjPStr squal = NULL;
    AjPStr prefix = NULL;
    AjPStr key    = NULL;
    AjPStr value  = NULL;
    
    prefix = ajStrNew();
    key    = ajStrNew();
    
    i = 0;

    while(miralistsingles[i].qname)
    {
	squal = ajAcdGetListSingle(miralistsingles[i].qname);
	ajStrAssignC(&key,miralistsingles[i].qname);
	ajStrAssignC(&prefix,"");

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

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

    return;
}
示例#2
0
static const AjPStr eprimer3_tableget(const char *key1, ajint number,
                                      const char *key2,
                                      const AjPTable table)
{
    AjPStr fullkey = NULL;
    AjPStr keynum  = NULL;
    const AjPStr value   = NULL;

    ajStrAssignC(&fullkey, key1);

    if(number > 0)
    {
        ajStrAppendC(&fullkey, "_");
        ajStrFromInt(&keynum, number);
        ajStrAppendS(&fullkey, keynum);
    }

    if(strcmp(key2, ""))
        ajStrAppendC(&fullkey, "_");

    ajStrAppendC(&fullkey, key2);
    ajDebug("Constructed key=%S\n", fullkey);
    value = ajTableFetchS(table, fullkey);


    ajStrDel(&fullkey);
    ajStrDel(&keynum);

    return value;
}
示例#3
0
文件: embprop.c 项目: WenchaoLin/JAMg
AjBool embPropGetProperties(const EmbPPropAmino prop, AjPStr* Pstr)
{
    ajStrAssignC(Pstr, "");

    if(prop->tiny)
        ajStrAppendC(Pstr, "tiny,");

    if(prop->sm_all)
        ajStrAppendC(Pstr, "small,");

    if(prop->aliphatic)
        ajStrAppendC(Pstr, "aliphatic,");

    if(prop->aromatic)
        ajStrAppendC(Pstr, "aromatic,");

    if(prop->polar)
        ajStrAppendC(Pstr, "polar,");

    if(prop->nonpolar)
        ajStrAppendC(Pstr, "nonpolar,");

    ajStrTrimEndC(Pstr, ",");

    if(!ajStrGetLen(*Pstr))
        return ajFalse;

    return ajTrue;
}
示例#4
0
static ajint prophet_getType(AjPFile inf, AjPStr *tname)
{
    AjPStr line = NULL;
    const char *p = NULL;
    ajint ret = 0;

    line = ajStrNew();

    while(ajReadlineTrim(inf,&line))
    {
	p = ajStrGetPtr(line);
	if(!*p || *p=='#' || *p=='!' || *p=='\n')
	    continue;
	break;
    }

    if(!strncmp(p,"Gribskov",8))
	ret = 1;

    if(!strncmp(p,"Henikoff",8))
	ret = 2;

    ajStrAssignC(tname,p);

    ajStrDel(&line);

    return ret;
}
示例#5
0
static const AjPStr assemSAMGetReadgroupHeaderlines(const AjPAssem assem)
{
    AjPStr* rgids = NULL;
    const AjPAssemReadgroup rg = NULL;
    ajint i =0;

    ajTableToarrayKeys(assem->Readgroups, (void***)&rgids);

    ajStrAssignC(&assemoutSamLinetxt, "");

    while (rgids[i])  /* read groups */
    {
	rg = ajTableFetchS(assem->Readgroups, rgids[i++]);
	ajFmtPrintAppS(&assemoutSamLinetxt, "@RG\tID:%S", rg->ID);

	if(rg->CN)
	    ajFmtPrintAppS(&assemoutSamLinetxt, "\tCN:%S", rg->CN);

	if(rg->Desc)
	    ajFmtPrintAppS(&assemoutSamLinetxt, "\tDS:%S", rg->Desc);

	if(rg->Date)
	    ajFmtPrintAppS(&assemoutSamLinetxt, "\tDT:%S", rg->Date);

	if(rg->FlowOrder)
	    ajFmtPrintAppS(&assemoutSamLinetxt, "\tFO:%S", rg->FlowOrder);

	if(rg->KeySeq)
	    ajFmtPrintAppS(&assemoutSamLinetxt, "\tKS:%S", rg->KeySeq);

	if(rg->Library)
	    ajFmtPrintAppS(&assemoutSamLinetxt, "\tLB:%S", rg->Library);

	if(rg->Programs)
	    ajFmtPrintAppS(&assemoutSamLinetxt, "\tPG:%S", rg->Programs);

	if(rg->Isize)
	    ajFmtPrintAppS(&assemoutSamLinetxt, "\tPI:%d", rg->Isize);

	if(rg->Platform)
	    ajFmtPrintAppS(&assemoutSamLinetxt, "\tPL:%s",
	                   ajAssemreadgroupGetPlatformname(rg));

	if(rg->Unit)
	    ajFmtPrintAppS(&assemoutSamLinetxt, "\tPU:%S", rg->Unit);

	if(rg->Sample)
	    ajFmtPrintAppS(&assemoutSamLinetxt, "\tSM:%S", rg->Sample);

	ajStrAppendC(&assemoutSamLinetxt, "\n");

    }

    AJFREE(rgids);

    return assemoutSamLinetxt;
}
示例#6
0
static void emira_dobools(AjPStr *cl, AjPTable table)
{
    ajuint i;
    AjBool bqual = ajFalse;
    AjBool def   = ajFalse;
    AjPStr prefix = NULL;
    AjPStr key    = NULL;
    AjPStr value  = NULL;
    
    prefix = ajStrNew();
    key    = ajStrNew();
    
    i = 0;

    while(mirabools[i].qname)
    {
	bqual = ajAcdGetBoolean(mirabools[i].qname);
	ajStrAssignC(&key,mirabools[i].qname);
	ajStrAssignC(&prefix,"");

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

	def = ajCharMatchC(mirabools[i].def,"N") ? ajFalse : ajTrue;
	if(bqual != def)
	{
	    ajFmtPrintAppS(cl," -%S%s=",prefix,mirabools[i].mname);
	    if(bqual)
		ajFmtPrintAppS(cl,"yes");
	    else
		ajFmtPrintAppS(cl,"no");
	}
	
	++i;
    }

    ajStrDel(&key);
    ajStrDel(&prefix);
    
    return;
}
示例#7
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;
}
示例#8
0
文件: ajhist.c 项目: WenchaoLin/JAMg
void ajHistSetmultiYlabelC(AjPHist thys, ajuint indexnum, const char *txt)
{
    if(indexnum >= thys->numofdatapoints)
    {
	ajErr("Histograms can only be allocated from 0 to %d. NOT %u",
	      thys->numofdatapoints-1,indexnum);
	return;
    }

    ajStrAssignC(&thys->hists[indexnum]->yaxis,txt);

    return;
}
示例#9
0
AjBool ensGvdatabaseadaptorFailedvariationsconstraint(
    EnsPGvdatabaseadaptor gvdba,
    const AjPStr tablename,
    AjPStr *Pconstraint)
{
    char *txttablename = NULL;

    if (!gvdba)
        return ajFalse;

    if (!Pconstraint)
        return ajFalse;

    if (!*Pconstraint)
        *Pconstraint = ajStrNew();

    if (gvdba->Failedvariations)
    {
        if ((tablename != NULL) && (ajStrGetLen(tablename)))
        {
            ensDatabaseadaptorEscapeC(
                ensGvdatabaseadaptorGetDatabaseadaptor(gvdba),
                &txttablename,
                tablename);

            ajStrAssignC(Pconstraint, txttablename);

            ajCharDel(&txttablename);
        }
        else
            ajStrAssignC(Pconstraint, "failed_variation");

        ajStrAppendC(Pconstraint, ".variation_id IS NULL");
    }
    else
        ajStrAssignC(Pconstraint, "1");

    return ajTrue;
}
示例#10
0
文件: ajreg.c 项目: ICO2S/emboss
AjBool ajRegPost(const AjPRegexp rp, AjPStr* post)
{
    if(rp->ovector[1])
    {
	ajStrAssignC(post, &rp->orig[rp->ovector[1]]);

	return ajTrue;
    }

    ajStrDelStatic(post);

    return ajFalse;
}
示例#11
0
static void emira_dointegers(AjPStr *cl, AjPTable table)
{
    ajuint i;
    ajint  iqual;
    int  dval = 0;
    AjPStr prefix = NULL;
    AjPStr key    = NULL;
    AjPStr value  = NULL;
    
    prefix = ajStrNew();
    key    = ajStrNew();
    
    i = 0;

    while(miraintegers[i].qname)
    {
	iqual = ajAcdGetInt(miraintegers[i].qname);
	ajStrAssignC(&key,miraintegers[i].qname);
	ajStrAssignC(&prefix,"");

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

	if(sscanf(miraintegers[i].def,"%d",&dval) != 1)
	    ajFatal("Dval conversion error in emira_dointegers()");

	if(iqual != dval)
	    ajFmtPrintAppS(cl," -%S%s=%d",prefix,miraintegers[i].mname,iqual);

	++i;
    }

    ajStrDel(&key);
    ajStrDel(&prefix);
    
    return;
}
示例#12
0
/* @funcstatic ssematch_convertbases ******************************************
**
** Convert AjPStr of stride-assigned secondary structures to AjPSeq of 
** secondary structures in 3-state assignment.
**
** @param [r]  qs  [AjPstr]  String
** 
** @return [w] q3s [AjPSeq] Sequence
**
** @@
******************************************************************************/
static AjPSeq ssematch_convertbases(AjPStr qs)
{
    AjIStr     iter = NULL;
    char       base;    
    AjPSeq     tmp_seq   = NULL;   
    AjPStr     tmp_str   = NULL;   
    AjPStr name_str = NULL;

    /* Iterate through letters of string*/
    /* StrIterGetK:returns Current text string within iterator, char* */
    /* helices H, G, I -> G & I are changed to H 
       extended conformation -> E stays as E
       bridge B/b, turn T, coil C -> all changed to L */



    iter    = ajStrIterNew(qs);
    tmp_str = ajStrNew();

    do
    {
	base = ajStrIterGetK(iter);
	    
	if((base == 'G') || (base == 'I'))
	    base = 'H';
	else if((base == 'B') || (base == 'b') || (base == 'T')	
		|| (base == 'C'))
	    base = 'L';

	ajStrAppendK(&tmp_str, base);
    }
    while(ajStrIterNext(iter));
    

    ajStrAssignC(&name_str, "convertbases");
    tmp_seq = ajSeqNewNameS(tmp_str, name_str);


    /* Tidy up */
    ajStrIterDel(&iter);
    ajStrDel(&tmp_str);
    ajStrDel(&name_str);

    return tmp_seq;
}
示例#13
0
static AjBool extractfeat_MatchPatternDescribe(const AjPFeature feat, 
					       const AjPStr describe,
					       AjPStr *strout)
{
    AjIList titer;                      /* iterator for feat */
    AjPStr tagnam = NULL;        /* tag structure */
    AjPStr tagval = NULL;        /* tag structure */
    AjBool val = ajFalse;               /* returned value */


    /* iterate through the tags and test for match to patterns */
    titer = ajFeatTagIter(feat);

    while(ajFeatTagval(titer, &tagnam, &tagval))
    {
        if(embMiscMatchPatternDelimC(tagnam, describe, ",;|"))
	{
            /* There's a match, so write to strout in a pretty format */
            if(!val)
            	ajStrAssignC(strout, "(");
            else
            	ajStrAppendC(strout, ", ");
            val = ajTrue;
            ajStrAppendS(strout, tagnam);

            if(ajStrGetLen(tagval))
	    {
            	ajStrAppendC(strout, "=\"");
            	ajStrAppendS(strout, tagval);
            	ajStrAppendC(strout, "\"");
            }
        }	
    }
    ajListIterDel(&titer);

    if(val)
        ajStrAppendC(strout, ") ");


    ajStrDel(&tagnam);
    ajStrDel(&tagval);

    return val;
}
示例#14
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;
}
示例#15
0
文件: gfile.c 项目: ktnyt/GEMBASSY
AjBool gtaiFileOutURLS(AjPStr url, AjPFile* outf, AjBool tai){
  if(tai)
    {
      CURL *curl;
      CURLcode curl_res;

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

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

      curl_global_init(CURL_GLOBAL_ALL);

      curl = curl_easy_init();

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

      curl_res = curl_easy_perform(curl);

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

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

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

  return gFileOutURLS(url, outf);
}
示例#16
0
void ajAssemoutprintWiki(AjPFile outf)
{
    ajint i = 0;
    ajint j = 0;
    AjPStr namestr = NULL;

    ajFmtPrintF(outf, "{| class=\"wikitable sortable\" border=\"2\"\n");
    ajFmtPrintF(outf, "|-\n");
    ajFmtPrintF(outf, "!Format!!"
                "class=\"unsortable\"|Description\n");

    for(i=0; assemoutFormatDef[i].Name; i++)
    {
        ajFmtPrintF(outf, "|-\n");
        ajStrAssignC(&namestr, assemoutFormatDef[i].Name);

        for(j=i+1; assemoutFormatDef[j].Name; j++)
        {
            if(assemoutFormatDef[j].Write == assemoutFormatDef[i].Write)
            {
                ajFmtPrintAppS(&namestr, "<br>%s",
                               assemoutFormatDef[j].Name);
                ajWarn("Assembly output format '%s' same as '%s' "
                       "but not alias",
                       assemoutFormatDef[j].Name,
                       assemoutFormatDef[i].Name);
            }
        }
        ajFmtPrintF(outf, "|%S||%s\n",
                    namestr,
                    assemoutFormatDef[i].Desc);
    }

    ajFmtPrintF(outf, "|}\n");

    ajStrDel(&namestr);

    return;
}
示例#17
0
/* @funcstatic seqwords_keysearch  ********************************************
**
** Search swissprot with terms structure and writes a hitlist structure
**
** @param [r] inf   [AjPFile]     File pointer to swissprot database
** @param [r] terms [AjPTerms]    Terms object pointer
** @param [w] hits  [EmbPHitlist*] Hitlist object pointer
**
** @return [AjBool] True on success
** @@
******************************************************************************/
static AjBool seqwords_keysearch(AjPFile inf, 
				 AjPTerms terms,
				 EmbPHitlist *hits)
{
    AjPStr   line           =NULL;	/* Line of text. */
    AjPStr   id             =NULL;	/* Line of text. */
    AjPStr   temp           =NULL;
    ajint    s              =0;         /* Temp. start of hit value. */
    ajint    e              =0;         /* Temp. end of hit value. */
    AjPInt   start          =NULL;      /* Array of start of hit(s). */
    AjPInt   end            =NULL;      /* Array of end of hit(s). */
    ajint    nhits          =0;         /* Number of hits. */
    ajint    x              =0;         
    AjBool   foundkw        =ajFalse;
    AjBool   foundft        =ajFalse;


    /* Check for valid args. */
    if(!inf)
	return ajFalse;
    

    

    /* Allocate strings and arrays. */
    line       = ajStrNew();
    id         = ajStrNew();
    start      = ajIntNew();
    end        = ajIntNew();



    /* Start of main loop. */
    while((ajReadlineTrim(inf,&line)))
    {
	/* Parse the AC line. */
	if(ajStrPrefixC(line,"AC"))
	{
	    /* Copy accesion number and remove the ';' from the end. */
	    ajFmtScanS(line, "%*s %S", &id);
	    ajStrExchangeCC(&id, ";", "\0");
	    
	    
	    /* Reset flags & no. hits. */
	    foundkw=ajFalse;
	    foundft=ajFalse;
	    nhits=0;
	}
	
	
	/* Search the description and keyword lines with search terms. */
	else if((ajStrPrefixC(line,"DE") || (ajStrPrefixC(line,"KW"))))
	{
	    /* 
	     ** Search terms have a leading and trailing space to prevent 
	     ** them being found as substrings within other words.  To 
	     ** catch cases where a DE or KW line begins with a search 
	     ** term, we must add a leading and trailing space to line.
	     ** We must first remove punctation from the line to be parsed.
	     */
	    ajStrExchangeSetCC(&line, ".,;:", "    ");
	    ajStrAppendK(&line, ' ');
	    ajStrInsertC(&line, 0, " ");


	    for (x = 0; x < terms->N; x++)
		/* Search term is found. */
		if((ajStrFindCaseS(line, terms->Keywords[x])!=-1))
		{	
		    foundkw=ajTrue;
		    break;
		}
	}

	
	/* Search the feature table line with search terms. */
	else if((ajStrPrefixC(line,"FT   DOMAIN")))
	{
	    /*	
	     ** Search terms have a leading and trailing space to prevent 
	     ** them being found as substrings within other words.  To 
	     ** catch cases where a FT line ends with a search 
	     ** term, we must add a  trailing space to line 
	     ** We must first remove punctation from the line to be parsed.
	     */
	    ajStrExchangeSetCC(&line, ".,;:", "    ");
	    ajStrAppendK(&line, ' ');
	    

	    for (x = 0; x < terms->N; x++)
		if((ajStrFindCaseS(line, terms->Keywords[x])!=-1))
		{
		    /* Search term is found. */
		    foundft = ajTrue;
		    nhits++;
		    
		    /* Assign start and end of hit. */
		    ajFmtScanS(line, "%*s %*s %d %d", &s, &e);


		    ajIntPut(&start, nhits-1, s);
		    ajIntPut(&end, nhits-1, e);
		    break;
		}
	}
	

	/* Parse the sequence. */
	else if((ajStrPrefixC(line,"SQ") && ((foundkw == ajTrue) ||
					     (foundft == ajTrue))))
	{
	    /* Allocate memory for temp. sequence. */
	    temp       = ajStrNew();


	    /* Read the sequence into hitlist structure. */
	    while((ajReadlineTrim(inf,&line)) && !ajStrPrefixC(line,"//"))
		/* Read sequence line into temp. */
		ajStrAppendC(&temp,ajStrGetPtr(line)+3);
 

	    /* Clean up temp. sequence. */
	    ajStrRemoveWhite(&temp);


	    /*Priority is given to domain (rather than full length) sequence.*/
	    if(foundft)
	    {
		for(x=0;x<nhits;x++)
		{
		    /* Increment counter of hits for subsequent hits*/
		    (*hits)->N++;

		    
		    /* Reallocate memory for array of hits in hitlist
                       structure. */
		    AJCRESIZE((*hits)->hits, (*hits)->N);
		    (*hits)->hits[(*hits)->N-1]=embHitNew();
		    ajStrAssignC(&(*hits)->hits[(*hits)->N-1]->Model,
				 "KEYWORD");
		    

		    /* Assign start and end of hit. */
		    (*hits)->hits[(*hits)->N-1]->Start = ajIntGet(start, x);
		    (*hits)->hits[(*hits)->N-1]->End = ajIntGet(end, x);
				

		    /* Extract sequence within specified range */
		    ajStrAssignSubS(&(*hits)->hits[(*hits)->N - 1]->Seq, temp, 
				(*hits)->hits[(*hits)->N - 1]->Start - 1, 
				(*hits)->hits[(*hits)->N - 1]->End - 1);
		    

		    /* Put id into structure */
		    ajStrAssignRef(&(*hits)->hits[(*hits)->N - 1]->Acc, id);
		}
	    }
	    else
	    {
		/* Increment counter of hits */
		(*hits)->N++;

		    
		/* Reallocate memory for array of hits in hitlist structure */
		AJCRESIZE((*hits)->hits, (*hits)->N);
		(*hits)->hits[(*hits)->N-1]=embHitNew();
		ajStrAssignC(&(*hits)->hits[(*hits)->N-1]->Model, "KEYWORD");

		/* Extract whole sequence */
		ajStrAssignRef(&(*hits)->hits[(*hits)->N - 1]->Seq, temp); 
		(*hits)->hits[(*hits)->N - 1]->Start = 1; 
		(*hits)->hits[(*hits)->N - 1]->End =
		    ajStrGetLen((*hits)->hits[(*hits)->N - 1]->Seq); 


		/* Put id into structure */
		ajStrAssignRef(&(*hits)->hits[(*hits)->N - 1]->Acc, id);
	    }

	    /* Free temp. sequence */
	    ajStrDel(&temp);
	}
    }


    /* Clean up */
    ajStrDel(&line);
    ajStrDel(&id);
    ajIntDel(&start);
    ajIntDel(&end);

    return ajTrue;
}
示例#18
0
/* @funcstatic seqwords_TermsRead *********************************************
 **
 ** Read the next Terms object from a file in embl-like format. The search 
 ** terms are modified with a leading and trailing space.
 **
 ** @param [r] inf  [AjPFile]   Input file stream
 ** @param [w] thys [AjPTerms*] Terms object
 **
 ** @return [AjBool] True on succcess
 ** @@
 *****************************************************************************/
static AjBool seqwords_TermsRead(AjPFile inf, 
				 AjPTerms *thys)
{    
    AjPStr   line           =NULL;	/* Line of text. */
    AjPStr   temp           =NULL;
    AjPList  list_terms     =NULL;	/* List of keywords for a scop node*/
    AjBool   ok             =ajFalse;
    AjPStr   type           = NULL;


    /* Memory management */
    (*thys)=seqwords_TermsNew();
    list_terms = ajListstrNew();
    line       = ajStrNew();
    type       = ajStrNew();
    
    /* Read first line. */
    ok = ajReadlineTrim(inf,&line);


    while(ok && !ajStrPrefixC(line,"//"))
    {
	if(ajStrPrefixC(line,"XX"))
	{
	    ok = ajReadlineTrim(inf,&line);
	    continue;
	}	
	else if(ajStrPrefixC(line,"TY"))
	{
	    ajFmtScanS(line, "%*s %S", &type);
	    
	    if(ajStrMatchC(type, "SCOP"))
		(*thys)->Type = ajSCOP;
	    else if(ajStrMatchC(type, "CATH"))
		(*thys)->Type = ajCATH;
	}
	else if(ajStrPrefixC(line,"CL"))
	{
	    ajStrAssignC(&(*thys)->Class,ajStrGetPtr(line)+3);
	    ajStrRemoveWhiteExcess(&(*thys)->Class);
	}
	else if(ajStrPrefixC(line,"AR"))
	{
	    ajStrAssignC(&(*thys)->Architecture,ajStrGetPtr(line)+3);
	    ajStrRemoveWhiteExcess(&(*thys)->Architecture);
	}
	else if(ajStrPrefixC(line,"TP"))
	{
	    ajStrAssignC(&(*thys)->Topology,ajStrGetPtr(line)+3);
	    ajStrRemoveWhiteExcess(&(*thys)->Topology);
	}
	else if(ajStrPrefixC(line,"FO"))
	{
	    ajStrAssignC(&(*thys)->Fold,ajStrGetPtr(line)+3);
	    while(ajReadlineTrim(inf,&line))
	    {
		if(ajStrPrefixC(line,"XX"))
		    break;
		ajStrAppendC(&(*thys)->Fold,ajStrGetPtr(line)+3);
	    }
	    ajStrRemoveWhiteExcess(&(*thys)->Fold);
	}
	else if(ajStrPrefixC(line,"SF"))
	{
	    ajStrAssignC(&(*thys)->Superfamily,ajStrGetPtr(line)+3);
	    while(ajReadlineTrim(inf,&line))
	    {
		if(ajStrPrefixC(line,"XX"))
		    break;
		ajStrAppendC(&(*thys)->Superfamily,ajStrGetPtr(line)+3);
	    }
	    ajStrRemoveWhiteExcess(&(*thys)->Superfamily);
	}
	else if(ajStrPrefixC(line,"FA"))
	{
	    ajStrAssignC(&(*thys)->Family,ajStrGetPtr(line)+3);
	    while(ajReadlineTrim(inf,&line))
	    {
		if(ajStrPrefixC(line,"XX"))
		    break;
		ajStrAppendC(&(*thys)->Family,ajStrGetPtr(line)+3);
	    }
	    ajStrRemoveWhiteExcess(&(*thys)->Family);
	}
	else if(ajStrPrefixC(line,"TE")) 
	{
	    /* Copy and clean up term. */
	    temp    = ajStrNew();
	    ajStrAssignC(&temp,ajStrGetPtr(line)+3);
	    ajStrRemoveWhiteExcess(&temp);

	    
	    /* Append a leading and trailing space to search term*/
	    ajStrAppendK(&temp, ' ');
	    ajStrInsertC(&temp, 0, " ");

	    
	    /* Add the current term to the list. */
	    ajListstrPush(list_terms,temp);		    
	}

	ok = ajReadlineTrim(inf,&line);
    }
    if(!ok)
    {
	/* Clean up. */
	ajListstrFree(&list_terms);
	ajStrDel(&line);
	
    
	/* Return. */
	return ajFalse;
    }
        
    
    /* Convert the AjPList of terms to array of AjPSeq's. */
    if(!((*thys)->N=ajListstrToarray((AjPList)list_terms,&(*thys)->Keywords)))
	ajWarn("Zero sized list of terms passed into seqwords_TermsRead");


    /* Clean up.  Free the list (not the nodes!). */
    ajListstrFree(&list_terms);
    ajStrDel(&line);
    ajStrDel(&type);
    
    return ajTrue;
} 
示例#19
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;
}
示例#20
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;
}
示例#21
0
int main(int argc, char **argv)
{

    AjPSeqall seqall;
    AjPSeqout seqout;
    AjPSeq seq;
    ajint size;
    ajint overlap;
    ajint len;
    ajint pos;
    AjBool addover;
    AjBool feature;
    AjPStr outseq_name = ajStrNew();

    ajint start;
    ajint end;

    embInit("splitter", argc, argv);

    seqout  = ajAcdGetSeqoutall("outseq");
    seqall  = ajAcdGetSeqall("sequence");
    size    = ajAcdGetInt("size");
    overlap = ajAcdGetInt("overlap");
    addover = ajAcdGetBoolean("addoverlap");
    feature = ajAcdGetBoolean("feature");

    while(ajSeqallNext(seqall, &seq))
    {
	ajSeqTrim(seq);

	len = ajSeqGetLen(seq);
	pos = 0;

        ajStrAssignC(&outseq_name, "");

        if (!addover)
        {
            while(pos+size <= len-1)
            {
                start = pos;
                end = pos+size-1;
                splitter_MakeSubSeqName (&outseq_name, seq, start, end);
                splitter_ProcessChunk (seqout, seq, start, end,
                                       outseq_name, feature);
                pos += size-overlap;
            }
        }
        else
        {
            while(pos+size+overlap < len-1)
            {
                start = pos;
                end = pos+size+overlap-1;
                splitter_MakeSubSeqName (&outseq_name, seq, start, end);
                splitter_ProcessChunk (seqout, seq, start, end,
                                       outseq_name, feature);
                pos += size;
            }
        }

        splitter_MakeSubSeqName(&outseq_name, seq, pos, len-1);
        splitter_ProcessChunk (seqout, seq, pos, len-1,
                               outseq_name, feature);
    }

    ajSeqoutClose(seqout);
    ajSeqallDel(&seqall);
    ajSeqoutDel(&seqout);
    ajSeqDel(&seq);
    ajStrDel(&outseq_name);

    embExit();

    return 0;
}
示例#22
0
文件: ajresource.c 项目: ICO2S/emboss
AjBool ajResourceGetDbdata(const AjPResource resource, AjPQuery qry,
                           AjBool findformat(const AjPStr format,
                                             ajint *iformat))
{
    AjIList iter;
    AjPResquery resqry = NULL;
    ajint format;
    AjBool ret = ajFalse;

    if(!resource)
        return ajFalse;

    qry->InDrcat = ajTrue;

    ajStrAssignC(&qry->DbType, ajNamQueryGetDatatypeC(qry));

    ajDebug("ajResourceGetDbdata dbtype %S %d\n", qry->DbType, qry->DataType);

    if(qry->DataType == AJDATATYPE_URL)
    {
        ajStrAssignC(&qry->Method, "urlonly");
        qry->QueryType = AJQUERY_ENTRY;
        qry->HasAcc = ajFalse;

        iter = ajListIterNewread(resource->Query);
        while(!ajListIterDone(iter)) 
        {
            resqry = ajListIterGet(iter);

            ajDebug("ajResourceGetDbdata test fmt: '%S' edam: '%S'\n",
                    resqry->Format, resqry->FormatTerm);

            if(ajStrMatchC(resqry->FormatTerm, "2331"))
            {
                ajDebug("     OK fmt: '%S' edam: '%S' url '%S'\n",
                        resqry->Format, resqry->FormatTerm, resqry->Url);
                ajStrAssignS(&qry->Formatstr, resqry->FormatTerm);
                ajStrAssignS(&qry->DbUrl, resqry->Url);
                ret = ajTrue;
            }
        }
        ajListIterDel(&iter);
    }
    else 
    {
        ajStrAssignC(&qry->Method, "url");
        qry->QueryType = AJQUERY_ENTRY;
        qry->HasAcc = ajFalse;

        iter = ajListIterNewread(resource->Query);
        while(!ajListIterDone(iter)) 
        {
            resqry = ajListIterGet(iter);

            ajDebug("ajResourceGetDbdata test fmt: '%S' edam: '%S'\n",
                    resqry->Format, resqry->FormatTerm);

            if(findformat(resqry->Format, &format))
            {
                ajDebug("     OK fmt: '%S' url '%S'\n",
                        resqry->Format, resqry->Url);
                ajStrAssignS(&qry->Formatstr, resqry->Format);
                ajStrAssignS(&qry->DbUrl, resqry->Url);
                ret = ajTrue;
            }
            if(ajStrGetLen(resqry->FormatTerm) &&
               findformat(resqry->FormatTerm, &format))
            {
                ajDebug("     OK edam: '%S' url '%S'\n",
                        resqry->FormatTerm, resqry->Url);
                ajStrAssignS(&qry->Formatstr, resqry->FormatTerm);
                ajStrAssignS(&qry->DbUrl, resqry->Url);
                ret = ajTrue;
            }
        }
        ajListIterDel(&iter);
    }

    return ret;
}
示例#23
0
ajint ajUserGet(AjPStr* pthis, const char* fmt, ...)
{
    AjPStr thys;
    const char *cp;
    char *buff;
    va_list args;
    ajint ipos;
    ajint isize;
    ajint ilen;
    ajint jlen;
    ajint fileBuffSize = ajFileValueBuffsize();

    va_start(args, fmt);
    ajFmtVError(fmt, args);
    va_end(args);

    if(ajFileValueRedirectStdin())
    {
	ajUser("(Standard input in use: using default)");
	ajStrAssignC(pthis, "");

	return ajStrGetLen(*pthis);
    }

    ajStrSetRes(pthis, fileBuffSize);
    buff  = ajStrGetuniquePtr(pthis);
    thys = *pthis;
    isize = ajStrGetRes(thys);
    ilen  = 0;
    ipos  = 0;
    

    /*ajDebug("ajUserGet buffer len: %d res: %d ptr: %x\n",
	     ajStrGetLen(thys), ajStrGetRes(thys), thys->Ptr);*/

    while(buff)
    {

#ifndef __ppc__
	cp = fgets(&buff[ipos], isize, stdin);
#else
	cp = ajSysFuncFgets(&buff[ipos], isize, stdin);
#endif

        if(!cp && !ipos)
	{
	    if(feof(stdin))
	    {
		ajErr("Unable to get reply from user - end of standard input");
		ajExitBad();
	    }
	    else
		ajFatal("Error reading from user: '******'\n",
			strerror(errno));
	}

	jlen = strlen(&buff[ipos]);
	ilen += jlen;

	/*
	 ** We need to read again if:
	 ** We have read the entire buffer
	 ** and we don't have a newline at the end
	 ** (must be careful about that - we may just have read enough)
	 */
	ajStrSetValidLen(pthis, ilen);
	thys = *pthis;

	if((jlen == (isize-1)) &&
	   (ajStrGetCharLast(thys) != '\n'))
	{
	    ajStrSetRes(pthis, ajStrGetRes(thys)+fileBuffSize);
	    thys = *pthis;
	    /*ajDebug("more to do: jlen: %d ipos: %d isize: %d ilen: %d "
		    "Size: %d\n",
		    jlen, ipos, isize, ilen, ajStrGetRes(thys));*/
	    ipos += jlen;
	    buff = ajStrGetuniquePtr(pthis);
	    isize = ajStrGetRes(thys) - ipos;
	    /* ajDebug("expand to: ipos: %d isize: %d Size: %d\n",
		    ipos, isize, ajStrGetRes(thys)); */

	}
	else
	    buff = NULL;
    }
    
    ajStrSetValidLen(pthis, ilen);

    if(ajStrGetCharLast(*pthis) == '\n')
	ajStrCutEnd(pthis, 1);

    /* PC files have \r\n Macintosh files have just \r : this fixes both */

    if(ajStrGetCharLast(*pthis) == '\r')
    {
	/*ajDebug("Remove carriage-return characters from PC-style files\n");*/
	ajStrCutEnd(pthis, 1);
    }

    ajStrTrimWhite(pthis);

    return ajStrGetLen(*pthis);
}
示例#24
0
文件: ajhist.c 项目: WenchaoLin/JAMg
void ajHistSetYlabelC(AjPHist thys, const char* txt)
{
    ajStrAssignC(&thys->yaxisleft,txt);

    return;
}
示例#25
0
文件: ajhist.c 项目: WenchaoLin/JAMg
void ajHistSetXlabelC(AjPHist thys, const char* txt)
{
    ajStrAssignC(&thys->xaxis,txt);

    return;
}
示例#26
0
文件: ajhist.c 项目: WenchaoLin/JAMg
void ajHistSetTitleC(AjPHist thys, const char* txt)
{
    ajStrAssignC(&thys->title,txt);

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

    AjPFile inf	 = NULL;
    AjPFile inf2 = NULL;
    AjPFeattable tab = NULL;
    AjPReport report = NULL;

    AjPSeq sequence = NULL;

    AjPStr redatanew = NULL;
    AjPStr str	     = NULL;
    AjPStr regexp    = NULL;
    AjPStr temp	     = NULL;
    AjPStr text      = NULL;
    AjPStr docdata   = NULL;
    AjPStr data      = NULL;
    AjPStr accession = NULL;
    AjPStr name      = NULL;
    EmbPPatMatch match = NULL;
    AjPStr savereg = NULL;
    AjPStr fthit   = NULL;

    AjBool full;
    AjBool prune;

    ajint i;
    ajint number;
    ajint start;
    ajint end;
    ajint length;
    ajint zstart;
    ajint zend;
    const char *p;
    ajint seqlength;
    AjPStr tmpstr  = NULL;
    AjPStr tailstr = NULL;
    AjPFeature gf;

    embInit("patmatmotifs", argc, argv);

    ajStrAssignC(&fthit, "SO:0001067");

    savereg   = ajStrNew();
    str       = ajStrNew();
    regexp    = ajStrNew();
    temp      = ajStrNew();
    data      = ajStrNew();
    accession = ajStrNew();
    text      = ajStrNew();
    name      = ajStrNew();

    sequence = ajAcdGetSeq("sequence");
    report   = ajAcdGetReport("outfile");
    full     = ajAcdGetBoolean("full");
    prune    = ajAcdGetBoolean("prune");

    ajSeqFmtUpper(sequence);		/* prosite regexs are all upper case */
    tab = ajFeattableNewSeq(sequence);
    ajStrAssignC(&tailstr, "");

    seqlength = ajStrGetLen(str);
    str       = ajSeqGetSeqCopyS(sequence);

    redatanew = ajStrNewC("PROSITE/prosite.lines");
    docdata   = ajStrNewC("PROSITE/");

    inf = ajDatafileNewInNameS(redatanew);
    if(!inf)
	ajFatal("Either EMBOSS_DATA undefined or PROSEXTRACT needs running");

    ajFmtPrintAppS(&tmpstr, "Full: %B\n", full);
    ajFmtPrintAppS(&tmpstr, "Prune: %B\n", prune);
    ajFmtPrintAppS(&tmpstr, "Data_file: %F\n", inf);
    ajReportSetHeaderS(report, tmpstr);

    while(ajReadlineTrim(inf, &regexp))
    {
	p=ajStrGetPtr(regexp);
	if(*p && *p!=' ' && *p!='^')
	{
	    p=ajSysFuncStrtok(p," ");
	    ajStrAssignC(&name,p);
	    if(prune)
		if(ajStrMatchCaseC(name,"myristyl") ||
		   ajStrMatchCaseC(name,"asn_glycosylation") ||
		   ajStrMatchCaseC(name,"camp_phospho_site") ||
		   ajStrMatchCaseC(name,"pkc_phospho_site") ||
		   ajStrMatchCaseC(name,"ck2_phospho_site") ||
		   ajStrMatchCaseC(name,"tyr_phospho_site"))
		{
		    for(i=0;i<4;++i)
			ajReadlineTrim(inf, &regexp);
		    continue;
		}
	    p=ajSysFuncStrtok(NULL," ");
	    ajStrAssignC(&accession,p);
	}

	if(ajStrPrefixC(regexp, "^"))
	{
	    p = ajStrGetPtr(regexp);

	    ajStrAssignC(&temp,p+1);
	    ajStrAssignC(&savereg,p+1);

	    match = embPatMatchFind(temp, str, ajFalse, ajFalse);
	    number = embPatMatchGetNumber(match);

	    for(i=0; i<number; i++)
	    {
		seqlength = ajStrGetLen(str);

		start = 1+embPatMatchGetStart(match, i);

		end = 1+embPatMatchGetEnd(match, i);

		length = embPatMatchGetLen(match, i);

		gf = ajFeatNew(tab, NULL, fthit, start, end,
			       (float) length, ' ', 0);

		ajFmtPrintS(&tmpstr, "*motif %S", name);
		ajFeatTagAddSS(gf, NULL, tmpstr);

		if(start-5<0)
		    zstart = 0;
		else
		    zstart = start-5;

		if(end+5> seqlength)
		    zend = end;
		else
		    zend = end+5;


		ajStrAssignSubS(&temp, str, zstart, zend);
	    }


	    if(full && number)
	    {
		ajStrAssignC(&redatanew,ajStrGetPtr(docdata));
		ajStrAppendC(&redatanew,ajStrGetPtr(accession));
		inf2 = ajDatafileNewInNameS(redatanew);
		if(!inf2)
		    continue;

		/*
		** Insert Prosite documentation from files made by
		** prosextract.c
		*/
		ajFmtPrintAppS(&tailstr, "Motif: %S\n", name);
		ajFmtPrintAppS(&tailstr, "Count: %d\n\n", number);
		while(ajReadlineTrim(inf2, &text))
		    ajFmtPrintAppS(&tailstr, "%S\n", text);

		ajFmtPrintAppS(&tailstr, "\n***************\n\n");
		ajFileClose(&inf2);

	    }
	    embPatMatchDel(&match);
	}
    }

    ajReportSetTailS(report,tailstr);
    ajReportWrite(report, tab, sequence);

    ajReportDel(&report);
    ajFeattableDel(&tab);

    ajStrDel(&temp);
    ajStrDel(&regexp);
    ajStrDel(&savereg);
    ajStrDel(&str);
    ajStrDel(&data);
    ajStrDel(&docdata);
    ajStrDel(&text);
    ajStrDel(&redatanew);
    ajStrDel(&accession);
    ajSeqDel(&sequence);
    ajStrDel(&tailstr);
    ajStrDel(&fthit);
    ajStrDel(&name);
    ajStrDel(&tmpstr);

    ajFeattableDel(&tab);
    ajFileClose(&inf);

    embExit();

    return 0;
}
示例#28
0
static void remap_RestrictPreferred(const AjPList l, const AjPTable t)
{
    AjIList iter   = NULL;
    EmbPMatMatch m = NULL;
    const AjPStr value   = NULL;
    AjPStr newiso  = NULL;
    AjBool found;		/* name found in isoschizomer list */
        	    
    /* for parsing value->iso string */
    AjPStrTok tok = NULL;
    char tokens[] = " ,";
    AjPStr code = NULL;

    iter = ajListIterNewread(l);
    
    while((m = (EmbPMatMatch)ajListIterGet(iter)))
    {
	found = ajFalse;
	
    	/* get prototype name */
    	value = ajTableFetchS(t, m->cod);
    	if(value) 
    	{
    	    ajStrAssignC(&newiso, "");

	    /* parse isoschizomer names from m->iso */
	    ajStrTokenDel(&tok);
            tok = ajStrTokenNewC(m->iso,  tokens);
            while(ajStrTokenNextParseC(&tok, tokens, &code))
            {
	        if(ajStrGetLen(newiso) > 0)
	            ajStrAppendC(&newiso, ",");

		/* found the prototype name? */
	        if(!ajStrCmpCaseS(code, value)) 
	        {
	            ajStrAppendS(&newiso, m->cod);
	            found = ajTrue;
	        }
		else
	            ajStrAppendS(&newiso, code);
            }
            ajStrTokenDel(&tok);

	    /* if the name was not replaced, then add it in now */
	    if(!found)
	    {
	        if(ajStrGetLen(newiso) > 0)
	            ajStrAppendC(&newiso, ",");

	        ajStrAppendS(&newiso, m->cod);	
	    }
	    
	    ajDebug("RE: %S -> %S iso=%S newiso=%S\n", m->cod, value,
		    m->iso, newiso);

	    /* replace the old iso string with the new one */
	    ajStrAssignS(&m->iso, newiso);

	    /* rename the enzyme to the prototype name */
    	    ajStrAssignS(&m->cod, value);
    	}
    }
    
    ajListIterDel(&iter);     
    ajStrDel(&newiso);
    ajStrDel(&code);
    ajStrTokenDel(&tok);

    return; 
}
示例#29
0
int main(int argc, char **argv)
{
    AjPSeqall seqall;
    AjPSeq seq   = NULL;
    AjPReport report = NULL;

    AjPStr jaspdir = NULL;
    AjPStr menu    = NULL;
    AjPStr substr  = NULL;
    AjPStr mats    = NULL;
    AjPStr excl    = NULL;

    float thresh = 0.;
    
    ajuint recurs  = 0;
    
    AjPStr dir    = NULL;
    AjPStr mfname = NULL;
    
    AjPList flist = NULL;
    AjPList hits  = NULL;

    AjPStr head   = NULL;
    
    
    ajint begin;
    ajint end;
    ajuint mno;
    
    char cp;
    ajuint i;
    AjPTable mattab = NULL;
    AjPFeattable TabRpt = NULL;
    AjBool both = ajFalse;
    

    embInit("jaspscan", argc, argv);

    seqall     = ajAcdGetSeqall("sequence");
    menu       = ajAcdGetListSingle("menu");
    mats       = ajAcdGetString("matrices");
    excl       = ajAcdGetString("exclude");
    thresh     = ajAcdGetFloat("threshold");
    report     = ajAcdGetReport("outfile");
    both       = ajAcdGetBoolean("both");
    
    jaspdir = ajStrNew();
    substr  = ajStrNew();
    
    flist = ajListNew();
    hits  = ajListNew();
    dir   = ajStrNew();
    head  = ajStrNew();
    
    cp = ajStrGetCharFirst(menu);

    if(cp=='C')
	ajStrAssignC(&jaspdir,J_COR);
    else if(cp=='F')
	ajStrAssignC(&jaspdir,J_FAM);
    else if(cp=='P')
	ajStrAssignC(&jaspdir,J_PHY);
    else if(cp=='N')
	ajStrAssignC(&jaspdir,J_CNE);
    else if(cp=='O')
	ajStrAssignC(&jaspdir,J_POL);
    else if(cp=='S')
	ajStrAssignC(&jaspdir,J_SPL);
    else
	ajFatal("Invalid JASPAR database selection");


    ajStrAssignS(&dir, ajDatafileValuePath());
    if(!ajStrGetLen(dir))
	ajFatal("EMBOSS DATA directory couldn't be determined");


    jaspscan_ParseInput(dir, jaspdir, mats, excl, &recurs, flist);
    mno = ajListGetLength(flist);


    if(cp == 'C')
	mattab = jaspscan_ReadCoreList(jaspdir);
    if(cp == 'F')
	mattab = jaspscan_ReadFamList(jaspdir);
    if(cp == 'P')
	mattab = jaspscan_ReadCoreList(jaspdir);
    if(cp == 'N')
	mattab = jaspscan_ReadCoreList(jaspdir);
    if(cp == 'O')
	mattab = jaspscan_ReadCoreList(jaspdir);
    if(cp == 'S')
	mattab = jaspscan_ReadCoreList(jaspdir);

    ajFmtPrintS(&head,"Database scanned: %S  Threshold: %.3f",jaspdir,thresh);
    ajReportSetHeaderS(report,head);
    
    while(ajSeqallNext(seqall, &seq))
    {
	begin  = ajSeqallGetseqBegin(seqall);
	end    = ajSeqallGetseqEnd(seqall);

	ajStrAssignSubC(&substr,ajSeqGetSeqC(seq),begin-1,end-1);
	ajStrFmtUpper(&substr);

	TabRpt = ajFeattableNewSeq(seq);


	for(i=0; i < mno; ++i)
	{
	    ajListPop(flist,(void **)&mfname);

	    jaspscan_scan(substr,begin,mfname, cp, thresh, both, hits);

            ajListPushAppend(flist, (void **)mfname);
	}

	jaspscan_ReportHits(TabRpt,mattab,hits);

	ajReportWrite(report, TabRpt, seq);
	ajFeattableDel(&TabRpt);
    }


    while(ajListPop(flist,(void **)&mfname))
        ajStrDel(&mfname);

    
    ajStrDel(&dir);
    ajStrDel(&menu);
    ajStrDel(&excl);
    ajStrDel(&substr);
    ajStrDel(&mats);
    ajStrDel(&head);
    ajStrDel(&jaspdir);

    ajSeqDel(&seq);

    ajTableMapDel(mattab,jaspscan_ClearTable,NULL);
    ajTableFree(&mattab);

    ajListFree(&flist);
    ajListFree(&hits);
    
    ajSeqallDel(&seqall);
    ajReportDel(&report);
    
    embExit();

    return 0;
}
示例#30
0
文件: tfscan.c 项目: WenchaoLin/JAMg
int main(int argc, char **argv)
{
    AjPSeqall seqall;
    AjPSeq seq   = NULL;
    AjPReport outf = NULL;
    AjPFile inf  = NULL;

    ajint begin;
    ajint end;

    AjPList l = NULL;

    AjPStr strand = NULL;
    AjPStr substr = NULL;
    AjPStr line   = NULL;
    AjPStr name   = NULL;
    AjPStr acc    = NULL;
    AjPStr bf     = NULL;
    AjPStr menu;
    AjPStr pattern  = NULL;
    AjPStr opattern = NULL;
    AjPStr pname    = NULL;
    AjPStr key      = NULL;
    AjPStr value    = NULL;
    AjPTable atable = NULL;
    AjPTable btable = NULL;
    
    ajint mismatch;
    ajint minlength;
    
    ajint sum;
    ajint v;

    char cp;
    const char *p;


    embInit("tfscan", argc, argv);

    seqall     = ajAcdGetSeqall("sequence");
    outf       = ajAcdGetReport("outfile");
    mismatch   = ajAcdGetInt("mismatch");
    minlength  = ajAcdGetInt("minlength");
    menu       = ajAcdGetListSingle("menu");

    pname = ajStrNew();
    cp=ajStrGetCharFirst(menu);

    if(cp=='F')
	ajStrAssignC(&pname,"tffungi");
    else if(cp=='I')
	ajStrAssignC(&pname,"tfinsect");
    else if(cp=='O')
	ajStrAssignC(&pname,"tfother");
    else if(cp=='P')
	ajStrAssignC(&pname,"tfplant");
    else if(cp=='V')
	ajStrAssignC(&pname,"tfvertebrate");
    else if(cp=='C')
	inf = ajAcdGetDatafile("custom");

    if(cp!='C')
    {
	inf = ajDatafileNewInNameS(pname);
	if(!inf)
	    ajFatal("Either EMBOSS_DATA undefined or TFEXTRACT needs running");
    }

    name     = ajStrNew();
    acc      = ajStrNew();
    bf       = ajStrNewC("");
    substr   = ajStrNew();
    line     = ajStrNew();
    pattern  = ajStrNewC("AA");
    opattern = ajStrNew();

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

	ajStrAssignSubC(&substr,ajStrGetPtr(strand),begin-1,end-1);
	ajStrFmtUpper(&substr);

	l=ajListNew();
	atable = ajTablestrNew(1000);
	btable = ajTablestrNew(1000);
	
	sum=0;
	while(ajReadlineTrim(inf,&line))
	{
	    p = ajStrGetPtr(line);

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

	    ajFmtScanS(line,"%S%S%S",&pname,&pattern,&acc);
	    p += ajStrGetLen(pname);
	    while(*p && *p==' ')
		++p;
	    p += ajStrGetLen(pattern);
	    while(*p && *p==' ')
		++p;
	    p += ajStrGetLen(acc);
	    while(*p && *p==' ')
		++p;

	    ajStrAssignS(&opattern,pattern);
	    ajStrAssignC(&bf,p); /* rest of line */
	    
	    v = embPatVariablePattern(pattern,substr,pname,l,0,
				      mismatch,begin);
	    if(v)
	    {
		key = ajStrNewS(pname);
		value = ajStrNewS(acc);
		ajTablePut(atable,(void *)key,(void *)value);
		key = ajStrNewS(pname);
		value = ajStrNewS(bf);
		ajTablePut(btable,(void *)key,(void *)value);
	    }
	    sum += v;
	}

	if(sum)
	    tfscan_print_hits(&l,sum,outf,atable,seq,minlength,
			      btable);

	ajFileSeek(inf,0L,0);
	ajListFree(&l);
	ajTablestrFree(&atable);
	ajTablestrFree(&btable);
	ajStrDel(&strand);
    }

    ajStrDel(&line);
    ajStrDel(&name);
    ajStrDel(&acc);
    ajStrDel(&pname);
    ajStrDel(&opattern);
    ajStrDel(&bf);
    ajStrDel(&pattern);
    ajStrDel(&substr);
    ajSeqDel(&seq);
    ajFileClose(&inf);
    ajReportClose(outf);
    ajReportDel(&outf);

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

    embExit();

    return 0;
}