Beispiel #1
0
EnsPProjectionsegment ensProjectionsegmentNew(ajuint srcstart, ajuint srcend,
                                              EnsPSlice trgslice)
{
    EnsPProjectionsegment ps = NULL;
    
    /*
     ajDebug("ensProjectionsegmentNew\n"
	     "  srcstart %u\n"
	     "  srcend %u\n"
	     "  trgslice %p\n",
	     srcstart,
	     srcend,
	     trgslice);
     
     ensSliceTrace(trgslice, 1);
     */
    
    if(!trgslice)
        return NULL;
    
    AJNEW0(ps);
    
    ps->SrcStart = srcstart;
    
    ps->SrcEnd = srcend;
    
    ps->TrgSlice = ensSliceNewRef(trgslice);
    
    ps->Use = 1;
    
    return ps;
}
Beispiel #2
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;
}
Beispiel #3
0
static PJspmat jaspscan_infonew(void)
{
    PJspmat thys = NULL;
    
    AJNEW0(thys);

    thys->id       = ajStrNew();
    thys->num      = ajStrNew();
    thys->name     = ajStrNew();
    thys->klass    = ajStrNew();
    thys->species  = ajStrNew();
    thys->sgroup   = ajStrNew();
    thys->protseq  = ajStrNew();
    thys->exp      = ajStrNew();
    thys->pmid     = ajStrNew();
    thys->models   = ajStrNew();
    thys->mcs      = ajStrNew();
    thys->jaspar   = ajStrNew();
    thys->transfac = ajStrNew();
    thys->content  = ajStrNew();
    thys->desc     = ajStrNew();
    thys->comment  = ajStrNew();
    thys->erttss   = ajStrNew();
    thys->srttss   = ajStrNew();
    thys->consens  = ajStrNew();
    
    return thys;
}
Beispiel #4
0
EnsPKaryotypeband ensKaryotypebandNew(ajuint identifier,
                                      EnsPFeature feature,
                                      AjPStr name,
                                      AjPStr stain)
{
    EnsPKaryotypeband kb = NULL;
    
    if(!feature)
	return NULL;
    
    AJNEW0(kb);
    
    kb->Use = 1;
    
    kb->Identifier = identifier;
    
    kb->Feature = ensFeatureNewRef(feature);
    
    if(name)
	kb->Name = ajStrNewRef(name);
    
    if(stain)
	kb->Stain = ajStrNewRef(stain);
    
    return kb;
}
Beispiel #5
0
AjPRegexp ajRegCompC(const char* rexp)
{
    AjPRegexp ret;
    int options = 0;
    int errpos  = 0;
    const char *errptr            = NULL;
    const unsigned char *tableptr = NULL;

    AJNEW0(ret);
    AJCNEW0(ret->ovector, AJREG_OVECSIZE);
    ret->ovecsize = AJREG_OVECSIZE/3;
    ret->pcre = pcre_compile(rexp, options, &errptr, &errpos, tableptr);

    if(!ret->pcre)
    {
	ajErr("Failed to compile regular expression '%s' at position %d: %s",
	      rexp, errpos, errptr);
	AJFREE(ret);
	return NULL;
    }

    regAlloc += sizeof(ret);
    regCount ++;
    regTotal ++;
    /*ajDebug("ajRegCompC %x size %d regexp '%s'\n",
      ret, (int) sizeof(ret), rexp);*/

    return ret;
}
Beispiel #6
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;
}
Beispiel #7
0
AjPResource ajResourceNewResource(const AjPResource res)
{
    AjPResource ret;

    AJNEW0(ret);

    ret->Id       = ajStrNewS(res->Id);
    ret->Acc      = ajStrNewS(res->Acc);
    ret->Name     = ajStrNewS(res->Name);
    ret->Desc     = ajStrNewS(res->Desc);
    ret->Url      = ajStrNewS(res->Url);

    ret->Cat     = ajListstrNewList(res->Cat);
    ret->Idalt   = ajListstrNewList(res->Idalt);
    ret->Taxon   = ajListNew();
    ret->Edamdat = ajListNew();
    ret->Edamfmt = ajListNew();
    ret->Edamid  = ajListNew();
    ret->Edamtpc = ajListNew();
    ajRestermlistClone(res->Taxon,   ret->Taxon);
    ajRestermlistClone(res->Edamdat, ret->Edamdat);
    ajRestermlistClone(res->Edamfmt, ret->Edamfmt);
    ajRestermlistClone(res->Edamid,  ret->Edamid);
    ajRestermlistClone(res->Edamtpc, ret->Edamtpc);
    ret->Xref    = ajListNew();
    ajReslinklistClone(res->Xref,    ret->Xref);
    ret->Query   = ajListNew();
    ajResquerylistClone(res->Query,  ret->Query);
    ret->Example = ajListstrNewList(res->Example);

    return ret;
}
Beispiel #8
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;
}
Beispiel #9
0
EnsPKaryotypebandadaptor ensKaryotypebandadaptorNew(EnsPDatabaseadaptor dba)
{
    EnsPKaryotypebandadaptor kba = NULL;
    
    if(!dba)
	return NULL;
    
    AJNEW0(kba);
    
    kba->Adaptor =
	ensFeatureadaptorNew(dba,
			     karyotypeBandadaptorTables,
			     karyotypeBandadaptorColumns,
			     karyotypeBandadaptorLeftJoin,
			     karyotypeBandadaptorDefaultCondition,
			     karyotypeBandadaptorFinalCondition,
			     karyotypeBandadaptorFetchAllBySQL,
			     (void* (*)(const void* key)) NULL, /* Fread */
			     karyotypeBandadaptorCacheReference,
			     (AjBool (*)(const void* value)) NULL, /* Fwrite */
			     karyotypeBandadaptorCacheDelete,
			     karyotypeBandadaptorCacheSize,
			     karyotypeBandadaptorGetFeature,
			     "Karyotype Band");
    
    return kba;
}
Beispiel #10
0
EnsPAssemblyexception ensAssemblyexceptionNewObj(
    const EnsPAssemblyexception object)
{
    EnsPAssemblyexception ae = NULL;

    if(!object)
        return NULL;

    AJNEW0(ae);

    ae->Use = 1;

    ae->Identifier          = object->Identifier;
    ae->Adaptor             = object->Adaptor;
    ae->SeqregionIdentifier = object->SeqregionIdentifier;
    ae->SeqregionStart      = object->SeqregionStart;
    ae->SeqregionEnd        = object->SeqregionEnd;
    ae->ExcRegionIdentifier = object->ExcRegionIdentifier;
    ae->ExcRegionStart      = object->ExcRegionStart;
    ae->ExcRegionEnd        = object->ExcRegionEnd;
    ae->Orientation         = object->Orientation;
    ae->Type                = object->Type;

    return ae;
}
Beispiel #11
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;
}
Beispiel #12
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;
}
Beispiel #13
0
EnsPKaryotypeband ensKaryotypebandNewObj(const EnsPKaryotypeband object)
{
    EnsPKaryotypeband kb = NULL;
    
    if(!object)
	return NULL;
    
    AJNEW0(kb);
    
    kb->Use = 1;
    
    kb->Identifier = object->Identifier;
    
    kb->Adaptor = object->Adaptor;
    
    kb->Feature = ensFeatureNewRef(object->Feature);
    
    if(object->Name)
        kb->Name = ajStrNewRef(object->Name);
    
    if(object->Stain)
        kb->Stain = ajStrNewRef(object->Stain);
    
    return kb;
}
Beispiel #14
0
EnsPGvsynonym ensGvsynonymNewIni(EnsPGvsynonymadaptor gvsa,
                                 ajuint identifier,
                                 EnsPGvsource gvsource,
                                 AjPStr name,
                                 AjPStr moleculetype,
                                 ajuint gvvidentifier,
                                 ajuint subidentifier)
{
    EnsPGvsynonym gvs = NULL;

    AJNEW0(gvs);

    gvs->Use        = 1U;
    gvs->Identifier = identifier;
    gvs->Adaptor    = gvsa;
    gvs->Gvsource   = ensGvsourceNewRef(gvsource);

    if (name)
        gvs->Name = ajStrNewRef(name);

    if (moleculetype)
        gvs->Moleculetype = ajStrNewRef(moleculetype);

    gvs->Gvvariationidentifier = gvvidentifier;
    gvs->Subidentifier         = subidentifier;

    return gvs;
}
Beispiel #15
0
EnsPGvsynonym ensGvsynonymNewCpy(const EnsPGvsynonym gvs)
{
    EnsPGvsynonym pthis = NULL;

    if (!gvs)
        return NULL;

    AJNEW0(pthis);

    pthis->Use        = 1U;
    pthis->Identifier = gvs->Identifier;
    pthis->Adaptor    = gvs->Adaptor;
    pthis->Gvsource   = ensGvsourceNewRef(gvs->Gvsource);

    if (gvs->Name)
        pthis->Name = ajStrNewRef(gvs->Name);

    if (gvs->Moleculetype)
        pthis->Moleculetype = ajStrNewRef(gvs->Moleculetype);

    pthis->Gvvariationidentifier = gvs->Gvvariationidentifier;
    pthis->Subidentifier         = gvs->Subidentifier;

    return pthis;
}
Beispiel #16
0
void ajCallRegisterOld(const char *name, CallFunc func)
{
    void *rec;
    char* keyname = NULL;
    ajuint *i;
 
    if(!oldcallTable)
    {
	oldcallTable = ajTableNewFunctionLen(50, callCmpStr,callStrHash);
	oldcallCount = ajTableNewFunctionLen(50, callCmpStr,callStrHash);
    }
    
    rec = ajTableFetch(oldcallTable, name);	/* does it exist already */

    if(!rec)
    {
	keyname = ajCharNewC(name);
	ajTablePut(oldcallTable, keyname, (void *) func);
	keyname = ajCharNewC(name);
        AJNEW0(i);
	ajTablePut(oldcallCount, keyname, i);
    }

    return;
}
Beispiel #17
0
AjPResquery ajResqueryNew(void)
{
    AjPResquery ret;

    AJNEW0(ret);

    return ret;
}
Beispiel #18
0
AjPXml ajXmlNew(void)
{
    AjPXml ret;

    AJNEW0(ret);

    return ret;
}
Beispiel #19
0
AjPResterm ajRestermNew(void)
{
    AjPResterm ret;

    AJNEW0(ret);

    return ret;
}
Beispiel #20
0
AjPRefseq ajRefseqNew(void)
{
    AjPRefseq ret;

    AJNEW0(ret);

    return ret;
}
Beispiel #21
0
AjPTime ajTimeNew(void)
{
    AjPTime thys = NULL;

    AJNEW0(thys);

    return thys ;
}
Beispiel #22
0
AjPReslink ajReslinkNew(void)
{
    AjPReslink ret;

    AJNEW0(ret);

    return ret;
}
Beispiel #23
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;
}
Beispiel #24
0
static PJsphits jaspscan_hitsnew(void)
{
    PJsphits thys = NULL;
    
    AJNEW0(thys);
    thys->matname = ajStrNew();

    return thys;
}
Beispiel #25
0
/* @funcstatic sigscanlig_LighitNew *******************************************
**
** Constructor for Lighit object. 
** 
** @param [r] ligid [AjPStr] Ligand ID. 
** @param [r] ns    [ajint]  List of signnature objects.
** @param [r] np    [ajint]  Number of hit to generate.
** @param [r] score [float]  True if sequence is to be printed. 
**
** @return [AjBool] True on success
** @@
******************************************************************************/
SigPLighit sigscanlig_LighitNew(void)
{
    SigPLighit ret = NULL;
    
    AJNEW0(ret);
    
    ret->ligid = ajStrNew();
    
    return ret;
}
Beispiel #26
0
/* @funcstatic ajEdamNew ******************************************************
**
** edam constructor
** The array is NOT allocated 
**
** @return [PEdam] New object
** @@
******************************************************************************/
PEdam     ajEdamNew(void)
{
  PEdam ret;

  AJNEW0(ret);
  
  ret->dat = NULL;
  ret->n = 0;

  return ret;
}
Beispiel #27
0
PKtypedat  ajKtypedatNew(void)
{
  PKtypedat ret;

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

  return ret;
}
Beispiel #28
0
/* @funcstatic ajKtypeNew *****************************************************
**
** ktype constructor
**
** @return [PKtype] New object
** @@
******************************************************************************/
PKtype     ajKtypeNew(void)
{
  PKtype ret;

  AJNEW0(ret);
  
  ret->dat = NULL;
  ret->n = 0;

  return ret;
}
Beispiel #29
0
AjPPatComp ajPatCompNew (void)
{
    AjPPatComp pthis;

    AJNEW0(pthis);

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

    return pthis;
}
Beispiel #30
0
static void filebuffLineAdd(AjPFilebuff buff, const AjPStr line)
{
    /* ajDebug("fileBuffLineAdd '%S'\n", line);*/
    if(buff->Freelines)
    {
	if(!buff->Lines)
	{
	    /* Need to set first line in list */
	    buff->Lines = buff->Freelines;
	}
	else
	    buff->Last->Next = buff->Freelines;

	buff->Last = buff->Freelines;
	buff->Freelines = buff->Freelines->Next;

	if(!buff->Freelines)
	{
	    /* Free list now empty */
	    buff->Freelast = NULL;
	}
    }
    else
    {
	/* No Free list, make a new string */
	if(!buff->Lines)
	    buff->Lines = AJNEW0(buff->Last);
	else
	    buff->Last = AJNEW0(buff->Last->Next);
    }
    
    ajStrAssignS(&buff->Last->Line, line);
    buff->Prev = buff->Curr;
    buff->Curr = buff->Last;
    buff->Last->Next = NULL;
    buff->Last->Fpos = buff->Fpos;
    buff->Pos++;
    buff->Size++;
        
    return;
}