Example #1
0
void ensProjectionsegmentDel(EnsPProjectionsegment *Pps)
{
    EnsPProjectionsegment pthis = NULL;
    
    if(!Pps)
        return;
    
    if(!*Pps)
        return;

    pthis = *Pps;
    
    pthis->Use--;
    
    if(pthis->Use)
    {
	*Pps = NULL;
	
	return;
    }
    
    ensSliceDel(&pthis->TrgSlice);
    
    AJFREE(pthis);

    *Pps = NULL;
    
    return;
}
Example #2
0
AjBool ensKaryotypebandadaptorFetchAllByChromosomeBand(
    EnsPKaryotypebandadaptor adaptor,
    const AjPStr name,
    const AjPStr band,
    AjPList kblist)
{
    char *txtband = NULL;
    
    AjBool value = AJFALSE;
    
    AjPStr constraint = NULL;
    
    EnsPDatabaseadaptor dba = NULL;
    
    EnsPSlice slice     = NULL;
    EnsPSliceadaptor sa = NULL;
    
    if(!adaptor)
	return ajFalse;
    
    if(!name)
	return ajFalse;
    
    if(!band)
	return ajFalse;
    
    if(!kblist)
	return ajFalse;
    
    dba = ensFeatureadaptorGetDatabaseadaptor(adaptor->Adaptor);
    
    sa = ensRegistryGetSliceadaptor(dba);
    
    ensSliceadaptorFetchByRegion(sa,
				 (const AjPStr) NULL,
				 (const AjPStr) NULL,
				 name,
				 0,
				 0,
				 0,
				 &slice);
    
    ensDatabaseadaptorEscapeC(dba, &txtband, band);
    
    constraint = ajFmtStr("karyotype.band LIKE '%s%%'", txtband);
    
    ajCharDel(&txtband);
    
    value = ensFeatureadaptorFetchAllBySliceConstraint(adaptor->Adaptor,
						       slice,
						       constraint,
						       (const AjPStr) NULL,
						       kblist);
    
    ajStrDel(&constraint);
    
    ensSliceDel(&slice);
    
    return value;
}
Example #3
0
AjBool ensKaryotypebandadaptorFetchAllByChromosomeName(
    EnsPKaryotypebandadaptor adaptor,
    const AjPStr name,
    AjPList kblist)
{
    AjBool value = AJFALSE;
    
    EnsPDatabaseadaptor dba = NULL;
    
    EnsPSlice slice     = NULL;
    EnsPSliceadaptor sa = NULL;
    
    if(!adaptor)
	return ajFalse;
    
    if(!name)
	return ajFalse;
    
    if(!kblist)
	return ajFalse;
    
    dba = ensFeatureadaptorGetDatabaseadaptor(adaptor->Adaptor);
    
    sa = ensRegistryGetSliceadaptor(dba);
    
    ensSliceadaptorFetchByRegion(sa,
				 (const AjPStr) NULL,
				 (const AjPStr) NULL,
				 name,
				 0,
				 0,
				 0,
				 &slice);
    
    value = ensFeatureadaptorFetchAllBySlice(adaptor->Adaptor,
					     slice,
					     (const AjPStr) NULL,
					     kblist);
    
    ensSliceDel(&slice);
    
    return value;
}
Example #4
0
static AjBool karyotypeBandadaptorFetchAllBySQL(EnsPDatabaseadaptor dba,
                                                const AjPStr statement,
                                                EnsPAssemblymapper am,
                                                EnsPSlice slice,
                                                AjPList kblist)
{
    ajuint identifier = 0;
    
    ajuint srid    = 0;
    ajuint srstart = 0;
    ajuint srend   = 0;
    
    AjPStr name  = NULL;
    AjPStr stain = NULL;
    
    AjPSqlstatement sqls = NULL;
    AjISqlrow sqli       = NULL;
    AjPSqlrow sqlr       = NULL;
    
    EnsPCoordsystemadaptor csa = NULL;
    
    EnsPFeature feature = NULL;
    
    EnsPKaryotypeband kb         = NULL;
    EnsPKaryotypebandadaptor kba = NULL;
    
    EnsPSlice srslice   = NULL;
    EnsPSliceadaptor sa = NULL;
    
    if(!dba)
	return ajFalse;
    
    if(!statement)
	return ajFalse;
    
    (void) am;
    
    (void) slice;
    
    if(!kblist)
	return ajFalse;
    
    csa = ensRegistryGetCoordsystemadaptor(dba);

    /*
    ** AJB: The variable kba, set below, is not used elsewhere
    ** in the function. Needs fixing appropriately.
    */
    
    kba = ensRegistryGetKaryotypebandadaptor(dba);
    
    sa = ensRegistryGetSliceadaptor(dba);
    
    sqls = ensDatabaseadaptorSqlstatementNew(dba, statement);
    
    sqli = ajSqlrowiterNew(sqls);
    
    while(!ajSqlrowiterDone(sqli))
    {
	identifier = 0;
	srid       = 0;
	srstart    = 0;
	srend      = 0;
	name       = ajStrNew();
	stain      = ajStrNew();
	
	sqlr = ajSqlrowiterGet(sqli);
	
	ajSqlcolumnToUint(sqlr, &identifier);
	ajSqlcolumnToUint(sqlr, &srid);
	ajSqlcolumnToUint(sqlr, &srstart);
	ajSqlcolumnToUint(sqlr, &srend);
        ajSqlcolumnToStr(sqlr, &name);
        ajSqlcolumnToStr(sqlr, &stain);
	
	/* Need to get the internal Ensembl Sequence Region identifier. */
	
	srid = ensCoordsystemadaptorGetInternalSeqregionIdentifier(csa, srid);
	
	/*
	** FIXME: karyotype.seq_region_start and karyotype.seq_region_end are
	** defined as signed in the tables.sql file.
	** All other features use unsigned start and end coordinates.
	*/
	
	ensSliceadaptorFetchBySeqregionIdentifier(sa, srid, 0, 0, 0, &srslice);
	
	feature = ensFeatureNewS((EnsPAnalysis) NULL,
				 srslice,
				 srstart,
				 srend,
				 1);
	
	kb = ensKaryotypebandNew(identifier, feature, name, stain);
	
	ajListPushAppend(kblist, (void *) kb);
	
	ensFeatureDel(&feature);
	
	ensSliceDel(&srslice);
	
	ajStrDel(&name);
	ajStrDel(&stain);
    }
    
    ajSqlrowiterDel(&sqli);
    
    ajSqlstatementDel(&sqls);
    
    return ajTrue;
}