static void showcomparisonfailure(const char *filename,
                                  int line,
                                  const char *where,
                                  const GtEncseq *encseq,
                                  GtReadmode readmode,
                                  const GtSuffixsortspace *suffixsortspace,
                                  GtUword subbucketleft,
                                  GtUword depth,
                                  GtUword idx1,
                                  GtUword idx2,
                                  int cmp,
                                  GtUword maxlcp)
{
  GtUword pos1, pos2;

  pos1 = gt_suffixsortspace_get(suffixsortspace,subbucketleft,idx1);
  pos2 = gt_suffixsortspace_get(suffixsortspace,subbucketleft,idx2);
  fprintf(stderr,"ERROR: file \"%s\", line %d: ",filename,line);
  fprintf(stderr,"%s("GT_WU" vs "GT_WU""
                 " "GT_WU"=\"",
                       where,
                       idx1,
                       idx2,
                       pos1);
  gt_encseq_showatstartposwithdepth(stderr,encseq,readmode,pos1,depth);
  fprintf(stderr,"\",\"");
  gt_encseq_showatstartposwithdepth(stderr,encseq,readmode,pos2,depth);
  fprintf(stderr,"\"="GT_WU")=%d with maxlcp "GT_WU",depth="GT_WU"\n",pos2,cmp,
          maxlcp,depth);
}
Exemple #2
0
void gt_Outlcpinfo_check_lcpvalues(const GtEncseq *encseq,
                                   GtReadmode readmode,
                                   const GtSuffixsortspace *sortedsample,
                                   GtUword effectivesamplesize,
                                   const GtOutlcpinfo *outlcpinfosample,
                                   bool checkequality)
{
  GT_UNUSED int cmp;
  GtUword idx, reallcp, startpos1, startpos2, currentlcp,
                totalcmpmissing = 0;

  if (effectivesamplesize == 0)
  {
    return;
  }
  startpos1 = gt_suffixsortspace_getdirect(sortedsample,0);
  for (idx=1UL; idx<effectivesamplesize; idx++)
  {
    startpos2 = gt_suffixsortspace_getdirect(sortedsample,idx);
    cmp = gt_encseq_check_comparetwosuffixes(encseq,
                                             readmode,
                                             &reallcp,
                                             false,
                                             false,
                                             0,
                                             startpos1,
                                             startpos2,
                                             NULL,
                                             NULL);
    gt_assert(cmp <= 0);
    gt_assert(GT_ISIBITSET(outlcpinfosample->lcpsubtab.tableoflcpvalues
                                                      .isset,idx));
    currentlcp = (GtUword) outlcpinfosample->lcpsubtab.tableoflcpvalues.
                                 bucketoflcpvalues[idx];
    if ((checkequality && currentlcp != reallcp) ||
        (!checkequality && currentlcp > reallcp))
    {
      fprintf(stderr,"idx="GT_WU",suffixpair="GT_WU","GT_WU": "
                     "currentlcp = "GT_WU" %s "GT_WU" = reallcp\n",
                      idx,startpos1,startpos2,currentlcp,
                      checkequality ? "!=" : ">",reallcp);
      gt_encseq_showatstartposwithdepth(stderr,encseq,readmode,startpos1,50UL);
      fprintf(stderr,"\n");
      gt_encseq_showatstartposwithdepth(stderr,encseq,readmode,startpos2,50UL);
      fprintf(stderr,"\n");
      exit(GT_EXIT_PROGRAMMING_ERROR);
    } else
    {
      totalcmpmissing += (reallcp - currentlcp);
    }
    startpos1 = startpos2;
  }
  /*printf("totalcmpmissing = "GT_WU"(avg=%.2f)\n",
         totalcmpmissing,(double) totalcmpmissing/effectivesamplesize);*/
}
Exemple #3
0
static int processleafedge_shulen(bool firstsucc,
                                  unsigned long fatherdepth,
                                  GtBUinfo_shulen *father,
                                  unsigned long leafnumber,
                                  GtBUstate_shulen *state,
                                  GT_UNUSED GtError *err)
{
  unsigned long gnum;

#ifdef SHUDEBUG
  printf("processleafedge %lu firstsucc=%s, "
         " depth(father)=%lu, path=",
         leafnumber,
         firstsucc ? "true" : "false",
         fatherdepth);
  if (fatherdepth > 0)
  {
    gt_encseq_showatstartposwithdepth(stdout,
                                      state->encseq,
                                      GT_READMODE_FORWARD,
                                      leafnumber,
                                      fatherdepth);
  }
  printf("\n");
#endif
  if (state->file_to_genome_map != NULL)
  {
    gnum = state->file_to_genome_map[gt_encseq_filenum(state->encseq,
                                                       leafnumber)];
  } else
  {
    gnum = gt_encseq_filenum(state->encseq,leafnumber);
  }
  if (firstsucc)
  {
    gt_assert(father != NULL);
    if (father->gnumdist == NULL)
    {
      father->gnumdist
        = gt_malloc(sizeof (*father->gnumdist) * state->numofdbfiles);
    }
    resetgnumdist_shulen(father,state->numofdbfiles);
#ifdef SHUDEBUG
    shownode(__LINE__,state,"father",father);
#endif
  } else
  {
#ifdef SHUDEBUG
    shownode(__LINE__,state,"father",father);
#endif
    shu_compute_leaf_edge_contrib(state,father->gnumdist,gnum,fatherdepth);
  }
  father->gnumdist[gnum]++;
#ifdef SHUDEBUG
  printf("gnumdist[id=%lu,filenum=%lu]=%lu\n",father->id,gnum,
                                              father->gnumdist[gnum]);
  state->lastleafnumber = leafnumber;
#endif
  return 0;
}
void gt_showentiresuftab(const GtEncseq *encseq,
                         GtReadmode readmode,
                         const GtSuffixsortspace *suffixsortspace,
                         GtUword subbucketleft,
                         GtUword depth)
{
  GtUword idx, pos, totallength = gt_encseq_total_length(encseq);

  for (idx = 0; idx <= totallength; idx++)
  {
    pos = gt_suffixsortspace_get(suffixsortspace,subbucketleft,idx);
    printf("suftab["GT_WU"]="GT_WU" ",idx,pos);
    gt_encseq_showatstartposwithdepth(stdout,encseq,readmode,pos,depth);
    printf("\n");
  }
}
Exemple #5
0
static int processbranchingedge_shulen(bool firstsucc,
                                       unsigned long fatherdepth,
                                       GtBUinfo_shulen *father,
                                       GT_UNUSED unsigned long sondepth,
                                       GT_UNUSED unsigned long sonwidth,
                                       GtBUinfo_shulen *son,
                                       GtBUstate_shulen *state,
                                       GT_UNUSED GtError *err)
{
  unsigned long idx;

#ifdef SHUDEBUG
  printf("%s firstsucc=%s, depth(father)=%lu,path=",__func__,
         firstsucc ? "true" : "false",fatherdepth);
  if (fatherdepth > 0)
  {
    gt_encseq_showatstartposwithdepth(stdout,
                                      state->encseq,
                                      GT_READMODE_FORWARD,
                                      state->lastleafnumber,
                                      fatherdepth);
  }
  printf("\n");
#endif
  if (firstsucc)
  {
    gt_assert(father != NULL);
    if (father->gnumdist == NULL)
    {
      father->gnumdist
        = gt_malloc(sizeof (*father->gnumdist) * state->numofdbfiles);
      resetgnumdist_shulen(father,state->numofdbfiles);
    }
#ifdef SHUDEBUG
    shownode(__LINE__,state,"father",father);
#endif
  } else
  {
#ifdef SHUDEBUG
    gt_assert(father != NULL);
    shownode(__LINE__,state,"father",father);
    gt_assert(son != NULL);
    shownode(__LINE__,state,"son",son);
#endif
    cartproduct_shulen(state, fatherdepth, father->gnumdist, son->gnumdist);
    cartproduct_shulen(state, fatherdepth, son->gnumdist, father->gnumdist);
  }
  if (son != NULL)
  {
    for (idx = 0; idx < state->numofdbfiles; idx++)
    {
      father->gnumdist[idx] += son->gnumdist[idx];
      son->gnumdist[idx] = 0;
#ifdef SHUDEBUG
      printf("gnumdist[id=%lu,filenum=%lu]=%lu\n",father->id,idx,
                                                  father->gnumdist[idx]);
      printf("gnumdist[id=%lu,filenum=%lu]=0\n",son->id,idx);
#endif
    }
  }
  return 0;
}