예제 #1
0
static GtCondenseq *condenseq_new_empty(const GtAlphabet *alph)
{
  GtCondenseq *condenseq = gt_malloc(sizeof (*condenseq));
  condenseq->alphabet = gt_alphabet_ref((GtAlphabet *) alph);

  condenseq->buffsize =
    condenseq->ldb_allocated =
    condenseq->ldb_nelems =
    condenseq->orig_length =
    condenseq->orig_num_seq =
    condenseq->ubuffsize =
    condenseq->udb_allocated =
    condenseq->udb_nelems = 0;

  condenseq->id_len = GT_UNDEF_UWORD;

  condenseq->buffer = NULL;
  condenseq->filename = NULL;
  condenseq->links = NULL;
  condenseq->orig_ids = NULL;
  condenseq->sdstab = NULL;
  condenseq->ssptab = NULL;
  condenseq->ubuffer = NULL;
  condenseq->unique_es = NULL;
  condenseq->uniques = NULL;

  return condenseq;
}
예제 #2
0
파일: score_matrix.c 프로젝트: 9beckert/TIR
GtScoreMatrix* gt_score_matrix_new(GtAlphabet *alphabet)
{
  GtScoreMatrix *sm;
  gt_assert(alphabet);
  sm = gt_malloc(sizeof (GtScoreMatrix));
  sm->alphabet = gt_alphabet_ref(alphabet);
  sm->dimension = gt_alphabet_size(alphabet);
  gt_array2dim_calloc(sm->scores, sm->dimension, sm->dimension);
  return sm;
}
예제 #3
0
static int encseq_lua_alphabet(lua_State *L)
{
  GtEncseq **encseq;
  GtAlphabet *alpha;
  encseq = check_encseq(L, 1);
  gt_assert(*encseq);
  alpha = gt_alphabet_ref(gt_encseq_alphabet(*encseq));
  gt_lua_alphabet_push(L, alpha);
  return 1;
}
예제 #4
0
파일: seq.c 프로젝트: 9beckert/TIR
GtSeq* gt_seq_new(const char *seq, unsigned long seqlen, GtAlphabet *seqalpha)
{
  GtSeq *s;
  gt_assert(seq && seqalpha);
  s = gt_calloc(1, sizeof (GtSeq));
  s->seq = (char*) seq;
  s->seqlen = seqlen;
  s->seqalpha = gt_alphabet_ref(seqalpha);
  return s;
}
예제 #5
0
GtSamfileIterator* gt_samfile_iterator_new(const char *samfilename,
                                           const char *mode,
                                           void *aux,
                                           GtAlphabet *alphabet)
{
  GtSamfileIterator *s_iter;
  s_iter = gt_malloc(sizeof (GtSamfileIterator));
  s_iter->samfile = samopen(samfilename, mode, aux);
  s_iter->current_alignment = NULL;
  s_iter->alphabet = gt_alphabet_ref(alphabet);
  return s_iter;
}
예제 #6
0
GtSamAlignment *gt_sam_alignment_new(GtAlphabet *alphabet)
{
  GtSamAlignment *sam_alignment;
  gt_assert(alphabet != NULL);

  sam_alignment = gt_malloc(sizeof (GtSamAlignment));
  sam_alignment->s_alignment = bam_init1();
  sam_alignment->alphabet = gt_alphabet_ref(alphabet);
  sam_alignment->seq_buffer = NULL;
  sam_alignment->qual_buffer = NULL;
  sam_alignment->s_bufsize = 0;
  sam_alignment->q_bufsize = 0;
  sam_alignment->rightmost = GT_UNDEF_ULONG;
  return sam_alignment;
}
예제 #7
0
GtWtree* gt_wtree_encseq_new(GtEncseq *encseq)
{
  /* sample rate for compressd bitseq */
  const unsigned int samplerate = 32U;
  GtWtree *wtree;
  GtWtreeEncseq *wtree_encseq;
  wtree = gt_wtree_create(gt_wtree_encseq_class());
  wtree_encseq = gt_wtree_encseq_cast(wtree);
  wtree_encseq->encseq = gt_encseq_ref(encseq);
  wtree_encseq->alpha = gt_alphabet_ref(gt_encseq_alphabet(encseq));
  /* encoded chars + WC given by gt_alphabet_size,
     we have to encode UNDEFCHAR and SEPARATOR too */
  wtree_encseq->alpha_size = gt_alphabet_size(wtree_encseq->alpha) + 2;
  wtree->members->num_of_symbols = (GtUword) wtree_encseq->alpha_size;
  /* levels in tree: \lceil log_2(\sigma)\rceil */
  wtree_encseq->levels =
    gt_determinebitspervalue((GtUword) wtree_encseq->alpha_size);
  wtree_encseq->root_fo = gt_wtree_encseq_fill_offset_new();
  wtree_encseq->current_fo = wtree_encseq->root_fo;
  wtree->members->length =
    gt_encseq_total_length(encseq);
  /* each level has number of symbols bits */
  wtree_encseq->num_of_bits =
    wtree_encseq->levels *
    wtree->members->length;
  wtree_encseq->bits_size =
    wtree_encseq->num_of_bits / (sizeof (GtBitsequence) * CHAR_BIT);
  if (wtree_encseq->num_of_bits % (sizeof (GtBitsequence) * CHAR_BIT) != 0)
    wtree_encseq->bits_size++;
  wtree_encseq->bits =
    gt_calloc((size_t) wtree_encseq->bits_size, sizeof (GtBitsequence));
  wtree_encseq->node_start = 0;
  gt_wtree_encseq_fill_bits(wtree_encseq);
  wtree_encseq->c_bits =
    gt_compressed_bitsequence_new(wtree_encseq->bits,
                                  samplerate,
                                  wtree_encseq->num_of_bits);
  gt_free(wtree_encseq->bits);
  wtree_encseq->bits = NULL;
  return wtree;
}
예제 #8
0
GtAlphabet *gt_condenseq_alphabet(const GtCondenseq *condenseq)
{
  return gt_alphabet_ref(condenseq->alphabet);
}
예제 #9
0
int gt_mapfmindex (Fmindex *fmindex,const char *indexname,
                GtLogger *logger,GtError *err)
{
  FILE *fpin = NULL;
  bool haserr = false, storeindexpos = true;
  GtSpecialcharinfo specialcharinfo;

  gt_error_check(err);
  fmindex->mappedptr = NULL;
  fmindex->bwtformatching = NULL;
  fmindex->alphabet = NULL;
  fpin = gt_fa_fopen_with_suffix(indexname,FMASCIIFILESUFFIX,"rb",err);
  if (fpin == NULL)
  {
    haserr = true;
  }
  if (!haserr)
  {
    if (scanfmafileviafileptr(fmindex,
                              &specialcharinfo,
                              &storeindexpos,
                              indexname,
                              fpin,
                              logger,
                              err) != 0)
    {
      haserr = true;
    }
  }
  gt_fa_xfclose(fpin);
  if (!haserr)
  {
    fmindex->bwtformatching = mapbwtencoding(indexname,logger,err);
    if (fmindex->bwtformatching == NULL)
    {
      haserr = true;
    }
  }
  if (!haserr)
  {
    fmindex->specpos.nextfreeGtPairBwtidx
      = (unsigned long) gt_determinenumberofspecialstostore(&specialcharinfo);
    fmindex->specpos.spaceGtPairBwtidx = NULL;
    fmindex->specpos.allocatedGtPairBwtidx = 0;
    fmindex->alphabet = gt_alphabet_ref(
                                  gt_encseq_alphabet(fmindex->bwtformatching));
    if (fmindex->alphabet == NULL)
    {
      haserr = true;
    }
  }
  if (!haserr)
  {
    GtStr *tmpfilename;

    gt_computefmkeyvalues (fmindex,
                           &specialcharinfo,
                           fmindex->bwtlength,
                           fmindex->log2bsize,
                           fmindex->log2markdist,
                           gt_alphabet_num_of_chars(fmindex->alphabet),
                           fmindex->suffixlength,
                           storeindexpos);
    tmpfilename = gt_str_new_cstr(indexname);
    gt_str_append_cstr(tmpfilename,FMDATAFILESUFFIX);
    if (gt_fillfmmapspecstartptr(fmindex,storeindexpos,tmpfilename,err) != 0)
    {
      haserr = true;
    }
    gt_str_delete(tmpfilename);
  }
  if (haserr)
  {
    gt_freefmindex(fmindex);
  }
  return haserr ? -1 : 0;
}