示例#1
0
void gt_ma_clean(void)
{
  gt_assert(ma);
  gt_mutex_lock(bookkeeping_lock);
  ma->bookkeeping = false;
  gt_hashmap_delete(ma->allocated_pointer);
  gt_mutex_unlock(bookkeeping_lock);
  gt_mutex_delete(bookkeeping_lock);
  free(ma);
  ma = NULL;
}
示例#2
0
void gt_alphabet_delete(GtAlphabet *alphabet)
{
  if (!alphabet) return;
  gt_mutex_lock(alphabet->refmutex);
  if (alphabet->reference_count) {
    alphabet->reference_count--;
    gt_mutex_unlock(alphabet->refmutex);
    return;
  }
  gt_mutex_unlock(alphabet->refmutex);
  gt_free(alphabet->mapdomain);
  gt_free(alphabet->characters);
  if (alphabet->alphadef != NULL)
    gt_str_delete(alphabet->alphadef);
  gt_mutex_delete(alphabet->refmutex);
  gt_free(alphabet);
}
示例#3
0
void gt_spacepeak_clean()
{
  if (!peaklogger) return;
  gt_mutex_delete(peaklogger->mutex);
  free(peaklogger);
}
/* to be called from implementing class! */
int gt_feature_index_unit_test(GtFeatureIndex *fi, GtError *err)
{
  int had_err = 0, i, rval;
  GtFeatureIndexTestShared sh;
  GtStrArray *seqids;
  GtStr *seqid;
  GtRange check_range;
  GtRegionNode *rn;
  bool has_seqid;
  gt_error_check(err);

  sh.mutex = gt_mutex_new();
  sh.nodes = gt_array_new(sizeof (GtFeatureNode*));
  sh.error_count = 0;
  sh.next_node_idx = 0;
  sh.fi = fi;
  sh.err = gt_error_new();

  /* create region */
  seqid = gt_str_new_cstr(GT_FI_TEST_SEQID);
  rn = (GtRegionNode*) gt_region_node_new(seqid, GT_FI_TEST_START,
                                          GT_FI_TEST_END);

  /* test seqid is not supposed to exist */
  gt_ensure(gt_feature_index_has_seqid(sh.fi, &has_seqid,
                                                 GT_FI_TEST_SEQID, err) == 0);
  gt_ensure(!has_seqid);

  /* add a sequence region directly and check if it has been added */
  rval = gt_feature_index_add_region_node(sh.fi, rn, err);
  gt_ensure(rval == 0);
  gt_genome_node_delete((GtGenomeNode*) rn);
  gt_ensure(gt_feature_index_has_seqid(sh.fi, &has_seqid,
                                                GT_FI_TEST_SEQID, err) == 0);
  gt_ensure(has_seqid);

  gt_feature_index_get_range_for_seqid(sh.fi, &check_range, GT_FI_TEST_SEQID,
                                       err);
  gt_ensure(check_range.start == GT_FI_TEST_START
                    && check_range.end == GT_FI_TEST_END);

  /* set up nodes to store */
  for (i=0;i<GT_FI_TEST_FEATURES_PER_THREAD*gt_jobs;i++) {
    GtUword start, end;
    GtFeatureNode *fn;
    start = random() % (GT_FI_TEST_END - GT_FI_TEST_FEATURE_WIDTH);
    end = start + random() % (GT_FI_TEST_FEATURE_WIDTH);
    fn = gt_feature_node_cast(gt_feature_node_new(seqid, "gene", start, end,
                                                  GT_STRAND_FORWARD));
    gt_array_add(sh.nodes, fn);
  }
  /* test parallel addition */
  gt_multithread(gt_feature_index_unit_test_add, &sh, err);
  seqids = gt_feature_index_get_seqids(fi, err);
  gt_ensure(seqids);
  gt_ensure(gt_feature_index_has_seqid(fi, &has_seqid,GT_FI_TEST_SEQID,
                                                err) == 0);
  gt_ensure(has_seqid);
  gt_ensure(gt_str_array_size(seqids) == 1);

  /* test parallel query */
  if (!had_err)
    gt_multithread(gt_feature_index_unit_test_query, &sh, err);
  gt_ensure(sh.error_count == 0);

  gt_mutex_delete(sh.mutex);
  gt_error_delete(sh.err);
  gt_str_array_delete(seqids);
  gt_array_delete(sh.nodes);
  gt_str_delete(seqid);
  return had_err;
}
示例#5
0
void gt_symbol_clean(void)
{
  gt_cstr_table_delete(symbols);
  gt_mutex_delete(symbol_mutex);
}
示例#6
0
文件: yarandom.c 项目: 9beckert/TIR
void gt_ya_rand_clean(void)
{
  if (!mutex) return;
  gt_mutex_delete(mutex);
  mutex = NULL;
}