Beispiel #1
0
void checksuflinks(Suffixarray *s, Uint i, Uint j){
  Uint k, childlcp, suflcp, *space = NULL;
  PairUint* child, childsuf;
  Container *children;
  // ignore singletons as initial input
  if (i == j){
    return;
  }
  children = getChildintervals(space, s, i, j, 0);
  for (k = 0; k < bl_containerSize(children); k++){
    child = (PairUint *) bl_containerGet(children, k);
    // exclude singletons
    if (child->a == child->b){
      return;
    }
    // check suflink of child
    childlcp = getlcpval(s, child->a, child->b);
    childsuf = getSuflink(s, child->a, child->b);
    suflcp = getlcpval(s, childsuf.a, childsuf.b);
    if (childlcp != suflcp + 1){
      DBG("suf[%u, %u, %u]=[%u, %u, %u]\n", child->a, child->b, childlcp,
	  childsuf.a, childsuf.b, suflcp);
    }
    // recursively check all children of child
    checksuflinks(s, child->a, child->b);
  }
  bl_containerDestruct(children, NULL);
  free(children);
}
Beispiel #2
0
void FragmentList::freeFragList(Container* frags) {
    for (uint32_t i = 0; i < bl_containerSize(frags); i++){
        slmatch_t *sl = (slmatch_t *) bl_containerGet(frags, i);
        if (sl->chain != nullptr){
            std::cerr << "still at least one chain not freed before end: " << i << "\n";
            exit(-1);
            bl_slchainDestruct(sl->chain);
            free(sl->chain);
        }
    }
    bl_containerDestruct(frags, bl_slmatchDestruct);
    free(frags);
}
Beispiel #3
0
void suffix_mng_free(suffix_mng_t *p) {
  if (p) {
    if (p->suffix_lists) {
      for (int i = 0; i < p->num_chroms; i++) {
	if (p->suffix_lists[i]) {
	  linked_list_free(p->suffix_lists[i], (void *)seed_free);
	}
      }
      free(p->suffix_lists);
    }
    if (p->subject){
      for (int i = 0; i < bl_containerSize(p->subject); i++) {
	free(*(char **) bl_containerGet(p->subject, i));
      }
      bl_containerDestruct(p->subject, NULL);
      free(p->subject);
    }
    free(p);
  }
}
Beispiel #4
0
void
kmismatch(void *space,
    Suffixarray *s,
    fasta_t *reads,
    Uint k,
    Uint* counter,
    Uint rep_type,
    unsigned char silent,
    FILE *dev)
{
  Uint i, curlen;
  char *buffer, *curseq;
  branch_t *V; 
  Gmap map;
  Uint noofmatches=0;
  gread_t read;
  Container C;
  pthread_mutex_t *mtx=NULL;
  
  if (counter == NULL) {
    initProgressBarVT();
  } else { 
    mtx = &mutex2;
  }

  initGmap(&map, s->seq, 1);
  
  for (i=0; i < reads->noofseqs; i++) {

    noofmatches = 0;
    initRead(&read, reads->seqs[i]);
    setReads(&map, &read, 1);
    
    if (!silent) {
      if (mtx == NULL) {
        progressBarVT("reads matched.", reads->noofseqs, i, 25);
      } else {
        (*counter)++;
      }
    }

    curseq = reads->seqs[i]->sequence;
    curlen = reads->seqs[i]->length;

    V=kmis(space, s, curseq, curlen, k, &noofmatches);

    if(noofmatches) {
      bl_containerInit(&C, 100, sizeof(gmatch_t));
      branch2match(s, &C, V, noofmatches);
      setMatches(&read, (gmatch_t*)C.contspace, 
		 bl_containerSize(&C), PLUSSTRAND);
      
      reportMatch(dev, &map, rep_type, 0, mtx, curlen, curlen);
      bl_containerDestruct(&C, NULL);
      FREEMEMORY(space, V);
    }

    initRead(&read, reads->seqs[i]);
    setReads(&map, &read, 1);
    
    buffer = charDNAcomplement(space, curseq, curlen);
    V=kmis(space, s, buffer, curlen, k, &noofmatches);

    if(noofmatches) {
      bl_containerInit(&C, 100, sizeof(gmatch_t));
      branch2match(s, &C, V, noofmatches);
      setMatches(&read, (gmatch_t*)C.contspace, 
		 bl_containerSize(&C), MINUSSTRAND);
      reportMatch(dev, &map, rep_type, 0, mtx, curlen, curlen);
      bl_containerDestruct(&C, NULL);
      FREEMEMORY(space, V);
    }
    FREEMEMORY(space, buffer);
  }

  return;
}