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; }
void ajPatlistSeqRemoveCurrent (AjPPatlistSeq thys) { if (!thys->Iter) return; ajListIterRemove(thys->Iter); ajListIterGetBack(thys->Iter); return; }
static AjBool cacheNodeRemove(EnsPCache cache, const CachePNode node) { AjIList iter = NULL; CachePNode lnode = NULL; if(!cache) return ajFalse; if(!node) return ajFalse; /* Remove the node from the AJAX List. */ iter = ajListIterNew(cache->List); while(!ajListIterDone(iter)) { lnode = (CachePNode) ajListIterGet(iter); if(lnode == node) { ajListIterRemove(iter); break; } } ajListIterDel(&iter); /* Remove the node from the AJAX Table. */ ajTableRemove(cache->Table, node->Key); /* Update the cache statistics. */ cache->Bytes -= node->Bytes; cache->Count--; cache->Removed++; return ajTrue; }
static void extractfeat_FeatureFilter(AjPFeattable featab, const AjPStr source, const AjPStr type, ajint sense, AjBool testscore, float minscore, float maxscore, const AjPStr tag, const AjPStr value) { AjIList iter = NULL; AjPFeature gf = NULL; /* ** 'tagsmatch' is set true if a parent of a join() ** has matching tag/values. ** Remember the value of a the pattern match to the tags ** of the parent of a join() because the children of the join() ** don't contain the tags information in their gf's */ AjBool tagsmatch = ajFalse; /* foreach feature in the feature table */ if(featab) { iter = ajListIterNew(featab->Features); while(!ajListIterDone(iter)) { gf = (AjPFeature)ajListIterGet(iter); if(!extractfeat_MatchFeature(gf, source, type, sense, testscore, minscore, maxscore, tag, value, &tagsmatch)) { /* no match, so delete feature from feature table */ ajFeatDel(&gf); ajListIterRemove(iter); } } ajListIterDel(&iter); } return; }
void* ensCacheFetch(EnsPCache cache, void *key) { void *value = NULL; AjIList iter = NULL; CachePNode lnode = NULL; CachePNode tnode = NULL; if(!cache) return NULL; if(!key) return NULL; tnode = (CachePNode) ajTableFetch(cache->Table, key); if(tnode) { cache->Hit++; /* Move the node to the end of the list. */ iter = ajListIterNew(cache->List); while(!ajListIterDone(iter)) { lnode = (CachePNode) ajListIterGet(iter); if(lnode == tnode) { ajListIterRemove(iter); ajListPushAppend(cache->List, (void *) lnode); break; } } ajListIterDel(&iter); /* ** Reference the object when returned by the cache so that external ** code has to delete it irrespectively whether it was read from the ** cache or instantiated by the cache->Read function. */ if(cache->Reference && tnode->Value) value = (*cache->Reference)(tnode->Value); } else { cache->Miss++; if(cache->Read) { value = (*cache->Read)(key); if(value) { tnode = cacheNodeNew(cache, key, value); if(!cacheNodeInsert(cache, tnode)) cacheNodeDel(cache, &tnode); } } } return value; }