Ejemplo n.º 1
0
static AjPTable btwisted_getdinucdata(AjPFile inf)
{
    AjPStr valstr   = NULL;
    AjPStr key      = NULL;
    AjPStr line     = NULL;
    AjPStrTok token = NULL;
    AjPTable table  = NULL;

    valstr = ajStrNew();
    line = ajStrNew();

    table = ajTablestrNewCase(20);

    while(ajReadlineTrim(inf,&line))
    {
	if(*ajStrGetPtr(line)=='#')
	    continue;
	token = ajStrTokenNewC(line," \n\t\r");
	key   = ajStrNew();
	ajStrTokenNextParseC(&token," \n\t\r",&key);
	valstr = ajStrNew();
	ajStrTokenNextParseC(&token," \n\t\r",&valstr);
	ajTablePut(table,(void *)key,(void *) valstr);
	ajStrTokenDel(&token);
    }


    ajStrDel(&line);

    return table;
}
Ejemplo n.º 2
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;
}
Ejemplo n.º 3
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;
}
Ejemplo n.º 4
0
static void remap_RemoveMinMax(AjPList restrictlist,
	AjPTable hittable, ajint mincuts, ajint maxcuts)
{

    AjIList miter;		/* iterator for matches list */
    EmbPMatMatch m = NULL;	/* restriction enzyme match structure */
    PValue value;
    AjPStr key  = NULL;
    AjPStr keyv = NULL;


    key = ajStrNew();

    /* if no hits then ignore much of this routine */
    if(ajListGetLength(restrictlist))
    {
        /* count the enzymes */
	miter = ajListIterNewread(restrictlist);
	while((m = ajListIterGet(miter)) != NULL)
	{
	    ajStrAssignS(&key, m->cod);

	    /* increment the count of key */
	    value = (PValue) ajTableFetchmodS(hittable, key);
	    if(value == NULL)
	    {
		AJNEW0(value);
		value->count = 1;
		value->iso = ajStrNew();
		ajStrAssignS(&(value->iso), m->iso);
		keyv = ajStrNew();
		ajStrAssignS(&keyv,key);
		ajTablePut(hittable, (void *)keyv, (void *)value);
	    }
	    else
		value->count++;
	}
	ajListIterDel(&miter);


	/* now remove enzymes from restrictlist if <mincuts | >maxcuts */
	miter = ajListIterNew(restrictlist);
	while((m = ajListIterGet(miter)) != NULL)
	{
	    value = (PValue) ajTableFetchmodS(hittable, (m->cod));
            if(value->count < mincuts || value->count > maxcuts)
	    {
            	ajListIterRemove(miter);
                embMatMatchDel(&m);
            }
	}
	ajListIterDel(&miter);
    }

    ajStrDel(&key);

    return;
}
Ejemplo n.º 5
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;
}
Ejemplo n.º 6
0
static ajint cutgextract_readcodons(AjPFile inf, AjBool allrecords,
				    ajint *count)
{
    static int cutidx[] =
    {
	42,43,46,41,45,44,26,30,31,29,27,28,48,51,47,50,
	52,49,55,56,53,54,36,38,35,37, 4, 6, 3, 5,17,18,
	16,15,57,59,60,58,24,25,34,33,39,40,20,19,11,12,
	10, 9,63,62, 8, 7,14,13,21,23,22,32,61, 1, 0, 2
    };
    AjPStr line  = NULL;
    AjPStr value = NULL;
    ajint thiscount[64];

    AjPStrTok token = NULL;
    ajint i;
    ajint n = 0;
    ajint nstops = 0;


    if(!line)
    {
	line  = ajStrNew();
	value = ajStrNew();
    }

    if(!ajReadlineTrim(inf,&line))
	ajFatal("Premature end of file");


    token = ajStrTokenNewC(line," \n\t\r");
    for(i=0;i<CODONS;++i)
    {
	ajStrTokenNextParseC(&token," \n\t\r",&value);
	ajStrToInt(value,&n);
	thiscount[cutidx[i]] = n;
	if(i>60)
	    nstops += n;
    }

    ajStrDel(&line);
    ajStrDel(&value);
    ajStrTokenDel(&token);

    if(!allrecords)
	if(nstops > 1)
	    return -1;

    for(i=0;i<CODONS;++i)
    {
	count[i] += thiscount[i];
    }	

    return nstops;
}
Ejemplo n.º 7
0
PKtypedat  ajKtypedatNew(void)
{
  PKtypedat ret;

  AJNEW0(ret);
  ret->acdtype = ajStrNew();
  ret->edam    = ajStrNew();
  ret->ktype   = ajStrNew();

  return ret;
}
Ejemplo n.º 8
0
AjPPatComp ajPatCompNew (void)
{
    AjPPatComp pthis;

    AJNEW0(pthis);

    pthis->pattern=ajStrNew();
    pthis->regex=ajStrNew();

    return pthis;
}
Ejemplo n.º 9
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;
}
Ejemplo n.º 10
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;
}
Ejemplo n.º 11
0
int main(int argc, char **argv)
{
    AjPSeqall  seqall;
    AjPSeq     a;
    AjPSeqout  outf;
    AjPStr     substr;
    AjPStr     back;
    AjPStr     gctable;
    AjPCod     codon = NULL;
 
    ajint      gctablenum;

    ajint beg;
    ajint end;

    embInit("backtranambig", argc, argv);

    seqall    = ajAcdGetSeqall("sequence");
    outf      = ajAcdGetSeqoutall("outfile");
    gctable   = ajAcdGetListSingle("table");
    ajStrToInt(gctable, &gctablenum);

    codon = ajCodNewCodenum(gctablenum);
    while(ajSeqallNext(seqall, &a))
    {
        substr = ajStrNew();
        beg    = ajSeqGetBegin(a);
        end    = ajSeqGetEnd(a);
        ajStrAssignSubC(&substr,ajSeqGetSeqC(a),beg-1,end-1);

        back = ajStrNew();
        ajCodBacktranslateAmbig(&back,substr,codon);

        ajSeqAssignSeqS (a, back);
        ajSeqSetNuc(a);

        ajSeqoutWriteSeq(outf,a);
    }

    ajSeqoutClose(outf);

    ajStrDel(&back);
    ajStrDel(&substr);
    ajSeqoutDel(&outf);
    ajCodDel(&codon);
    ajStrDel(&gctable);
    ajSeqallDel(&seqall);
    ajSeqDel(&a);

    embExit();

    return 0;
}
Ejemplo n.º 12
0
/* @funcstatic ajEdamdatNew ***************************************************
**
** edamdat constructor
** The array is NOT allocated 
**
** @return [PEdamdat] New object
** @@
******************************************************************************/
PEdamdat  ajEdamdatNew(void)
{
  PEdamdat ret;

  AJNEW0(ret);
  ret->acdtype  = ajStrNew();
  ret->edam     = ajStrNew();
  ret->acdattr  = NULL;
  ret->n        = 0;

  return ret;
}
Ejemplo n.º 13
0
AjPResource ajResourceNew(void)
{
    AjPResource ret;

    AJNEW0(ret);

    ret->Id       = ajStrNew();
    ret->Idalt    = ajListstrNew();
    ret->Acc      = ajStrNew();
    ret->Name     = ajStrNew();
    ret->Desc     = ajStrNew();
    ret->Url      = ajStrNew();
    ret->Urllink  = ajStrNew();
    ret->Urlrest  = ajStrNew();
    ret->Urlsoap  = ajStrNew();
    ret->Cat      = ajListstrNew();
    ret->Taxon    = ajListNew();
    ret->Edamdat  = ajListNew();
    ret->Edamfmt  = ajListNew();
    ret->Edamid   = ajListNew();
    ret->Edamtpc  = ajListNew();
    ret->Xref     = ajListNew();
    ret->Query    = ajListNew();
    ret->Example  = ajListstrNew();

    return ret;
}
Ejemplo n.º 14
0
static void makeprotseq_parse_pepstats(AjPList* list,AjPFile data)
{
    AjPStr line = ajStrNew();
    AjPStr ch;
    AjPStr chcopy = NULL;
    const AjPStr tok;
    double value = 0.0;
    ajint count = 0;
    ajint i = 0;

    ajDebug("Parsing pepstats file.\n");

    /* skip the lines before residues */
    while(ajReadline(data,&line))
    {
        if(ajStrFindC(line,"Residue") == 0)
            break;
    }

    /* parse residue part */
    while(ajReadlineTrim(data,&line))
    {
        if(ajStrParseCountC(line," \t") == 0)
            break;

        ch = ajStrNew();
        tok = ajStrParseWhite(line);
        ajStrAppendS(&ch,tok);
        ajStrFmtLower(&ch);

        for(count = 1; count < 5; count++)
            tok = ajStrParseWhite(NULL);

        ajStrToDouble(tok,&value);
        count = (ajint) (value * 100) +
                ((value - (int) value ) >= 0.5 ? 1 : 0);

        for(i=0; i<count; i++)
        {
            chcopy = ajStrNewS(ch);
            ajListstrPush(*list,chcopy);
        }

        ajStrDel(&ch);
    }

    ajStrDel(&line);

    return;
}
Ejemplo n.º 15
0
AjPMatrixf ajMatrixfNewAsym(const AjPPStr codes, ajint n, 
			    const AjPPStr rcodes, ajint rn, 
			    const AjPStr filename)
{
    ajint i = 0;
    AjPMatrixf ret = 0;
    ajint nsize;
    ajint rnsize;
 
    if((!n) || (!codes) || (!filename))
	return NULL;

    nsize = n + 1;
    rnsize = rn + 1;

    AJNEW0(ret);

    ajStrAssignS(&ret->Name, filename);

    AJCNEW0(ret->Codes, n);

    for(i=0; i<n; i++)
	ret->Codes[i] = ajStrNew();

    for(i=0; i<n; i++)
	ajStrAssignS(&ret->Codes[i], codes[i]);

    ret->Size = nsize;


    AJCNEW0(ret->CodesRow, rn);

    for(i=0; i<rn; i++)
	ret->CodesRow[i] = ajStrNew();

    for(i=0; i<rn; i++)
	ajStrAssignS(&ret->CodesRow[i], rcodes[i]);

    ret->SizeRow = rnsize;


    AJCNEW0(ret->Matrixf, rnsize);

    for(i=0; i<rnsize; i++)
	AJCNEW0(ret->Matrixf[i], nsize);

    ret->Cvt = ajSeqcvtNewStrAsym(codes, n, rcodes, rn);

    return ret;
}
Ejemplo n.º 16
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;
}
Ejemplo n.º 17
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;
}
Ejemplo n.º 18
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;
}
Ejemplo n.º 19
0
AjBool ensKaryotypebandTrace(const EnsPKaryotypeband kb, ajuint level)
{
    AjPStr indent = NULL;
    
    if(!kb)
	return ajFalse;
    
    indent = ajStrNew();
    
    ajStrAppendCountK(&indent, ' ', level * 2);
    
    ajDebug("%SensKaryotypebandTrace %p\n"
	    "%S  Adaptor %p\n"
	    "%S  Identifier %u\n"
	    "%S  Feature %p\n"
	    "%S  Name '%S'\n"
	    "%S  Stain '%S'\n",
	    indent, kb,
	    indent, kb->Adaptor,
	    indent, kb->Identifier,
	    indent, kb->Feature,
	    indent, kb->Name,
	    indent, kb->Stain);
    
    ensFeatureTrace(kb->Feature, 1);
    
    ajStrDel(&indent);
    
    return ajTrue;
}
Ejemplo n.º 20
0
static void matPushHitInt(const AjPStr n, const EmbPMatPrints m,
			  AjPList *l, ajint pos,
			  ajint score, ajint elem, ajint hpe, ajint hpm)
{
    EmbPMatMatch mat;

    AJNEW0 (mat);
    mat->seqname = ajStrNewC(ajStrGetPtr(n));
    mat->cod     = ajStrNewC(ajStrGetPtr((m)->cod));
    mat->acc     = ajStrNewC(ajStrGetPtr((m)->acc));
    mat->tit     = ajStrNewC(ajStrGetPtr((m)->tit));
    mat->pat     = ajStrNew();
    mat->n       = (m)->n;
    mat->len     = (m)->len[elem];
    mat->thresh  = (m)->thresh[elem];
    mat->max     = (m)->max[elem];
    mat->element = elem;
    mat->start   = pos;
    mat->score   = score;
    mat->hpe     = hpe;
    mat->hpm     = hpm;
    mat->all	 = ajFalse;
    mat->ordered = ajFalse;

    ajListPush(*l,(void *)mat);

    return;
}
Ejemplo n.º 21
0
static void splitter_ProcessChunk (AjPSeqout seqout, const AjPSeq seq,
                                   ajuint start, ajuint end, const AjPStr name,
                                   AjBool feature)
{
    AjPStr str;

    AjPFeattable new_feattable = NULL;
    AjPSeq subseq;

    ajDebug("splitter_ProcessChunk %d..%d '%S' %B\n",
            start, end, name, feature);

    str    = ajStrNew();
    subseq = ajSeqNew();
  
  
    new_feattable = ajFeattableNew(name);
    subseq->Fttable = new_feattable;
    ajFeattableSetNuc(new_feattable);

    ajStrAssignSubC(&str,ajSeqGetSeqC(seq),start,end);
    ajSeqAssignSeqS(subseq,str);

    if(feature)
        splitter_AddSubSeqFeat(subseq->Fttable,start,end,seq);

    ajSeqAssignNameS(subseq, name);
    splitter_write(seqout,subseq,seq);

    ajStrDel(&str);
    ajSeqDel(&subseq);

    return;
}
Ejemplo n.º 22
0
static void remap_RenamePreferred(const AjPList list, const AjPTable table, 
				   AjPList newlist) 
{
    AjIList iter = NULL;
    AjPStr key   = NULL;
    const AjPStr value = NULL;
    AjPStr name  = NULL;

    iter = ajListIterNewread(list);
               
    while((key = (AjPStr)ajListIterGet(iter)))
    {
        /* 
        ** If a key-value entry found, write the new value to the new list
        ** else write the old key name to the new list
        */
        value = ajTableFetchS(table, key);
        name = ajStrNew();
        if(value)
	{
	    ajDebug("Rename: %S renamed to %S\n", key, value);
            ajStrAssignS(&name, value);
	}
	else
	{
	    ajDebug("Rename: %S not found\n", key);
	    ajStrAssignS(&name, key);
	}
        ajListstrPushAppend(newlist, name);
    }
                      
    ajListIterDel(&iter);

    return; 
}
Ejemplo n.º 23
0
AjBool ensProjectionsegmentTrace(const EnsPProjectionsegment ps, ajuint level)
{
    AjPStr indent = NULL;
    
    if(!ps)
	return ajFalse;
    
    indent = ajStrNew();
    
    ajStrAppendCountK(&indent, ' ', level * 2);
    
    ajDebug("%SensProjectionsegmentTrace %p\n"
	    "%S  SrcStart %d\n"
	    "%S  SrcEnd %d\n"
	    "%S  TrgSlice %p\n"
	    "%S  Use %u\n",
	    indent, ps,
	    indent, ps->SrcStart,
	    indent, ps->SrcEnd,
	    indent, ps->TrgSlice,
	    indent, ps->Use);
    
    ensSliceTrace(ps->TrgSlice, level + 1);
    
    ajStrDel(&indent);
    
    return ajTrue;
}
Ejemplo n.º 24
0
AjBool ensGvdatabaseadaptorTrace(const EnsPGvdatabaseadaptor gvdba,
                                 ajuint level)
{
    AjPStr indent = NULL;

    if (!gvdba)
        return ajFalse;

    indent = ajStrNew();

    ajStrAppendCountK(&indent, ' ', level * 2);

    ajDebug("%SensGvdatabaseadaptorTrace %p\n"
            "%S  Databaseadaptor %p\n"
            "%S  Failedvariations '%B'\n",
            indent, gvdba,
            indent, gvdba->Adaptor,
            indent, gvdba->Failedvariations);

    ensDatabaseadaptorTrace(gvdba->Adaptor, level + 1);

    ajStrDel(&indent);

    return ajTrue;
}
Ejemplo n.º 25
0
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;
}
Ejemplo n.º 26
0
static void restover_read_equiv(AjPFile equfile, AjPTable table)
{
    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);
	ajTablePut(table,(void *)key, (void *)value);
    }

    ajStrDel(&line);

    return;
}
Ejemplo n.º 27
0
AjPMatrix ajMatrixNew(const AjPPStr codes, ajint n, const AjPStr filename)
{
    ajint     i   = 0;
    AjPMatrix ret = NULL;
    ajint nsize;

    if((!n) || (!codes) || (!filename))
	return NULL;

    nsize = n + 1;

    AJNEW0(ret);

    ajStrAssignS(&ret->Name, filename);

    AJCNEW0(ret->Codes, n);

    for(i=0; i<n; i++)
	ret->Codes[i] = ajStrNew();
    
    for(i=0; i<n; i++)
	ajStrAssignS(&ret->Codes[i], codes[i]);

    ret->Size = nsize;

    AJCNEW0(ret->Matrix, nsize);

    for(i=0; i<nsize; i++)
	AJCNEW0(ret->Matrix[i], nsize);

    ret->Cvt = ajSeqcvtNewStr(codes, n);

    return ret;
}
Ejemplo n.º 28
0
static void tranalign_AddGaps(AjPSeq newseq,
			      const AjPSeq nseq, const AjPSeq pseq,
			      ajlong npos)
{

    AjPStr newstr = NULL;
    ajuint ppos = 0;

    newstr = ajStrNew();

    for(; ppos<ajSeqGetLen(pseq); ppos++)
    	if(ajSeqGetSeqC(pseq)[ppos] == '-')
    	    ajStrAppendC(&newstr, "---");
	else
	{
    	    ajStrAppendSubS(&newstr, ajSeqGetSeqS(nseq), npos, npos+2);
    	    npos+=3;
    	}

    ajDebug("aligned seq=%S\n", newstr);
    ajSeqAssignSeqS(newseq, newstr);

    ajStrDel(&newstr);

    return;
}
Ejemplo n.º 29
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;;
}
Ejemplo n.º 30
0
AjBool ensIntronTrace(const EnsPIntron intron, ajuint level)
{
    AjPStr indent = NULL;
    
    if(!intron)
	return ajFalse;
    
    indent = ajStrNew();
    
    ajStrAppendCountK(&indent, ' ', level * 2);
    
    ajDebug("%SensIntronTrace %p\n"
	    "%S  Feature %p\n"
	    "%S  PreviousExon %p\n"
	    "%S  NextExon %p\n"
	    "%S  Use %u\n",
	    indent, intron,
	    indent, intron->Feature,
	    indent, intron->PreviousExon,
	    indent, intron->NextExon,
	    indent, intron->Use);
    
    ensFeatureTrace(intron->Feature, level + 1);
    
    ensExonTrace(intron->PreviousExon, level + 1);
    
    ensExonTrace(intron->NextExon, level + 1);
    
    ajStrDel(&indent);
    
    return ajTrue;
}