Ejemplo n.º 1
0
int gt_feature_index_add_gff3file(GtFeatureIndex *feature_index,
                                  const char *gff3file, GtError *err)
{
  GtNodeStream *gff3_in_stream;
  GtGenomeNode *gn;
  GtArray *tmp;
  int had_err = 0;
  GtUword i;
  gt_error_check(err);
  gt_assert(feature_index && gff3file);
  tmp = gt_array_new(sizeof (GtGenomeNode*));
  gff3_in_stream = gt_gff3_in_stream_new_unsorted(1, &gff3file);
  while (!(had_err = gt_node_stream_next(gff3_in_stream, &gn, err)) && gn)
    gt_array_add(tmp, gn);
  if (!had_err) {
    GtNodeVisitor *feature_visitor = gt_feature_visitor_new(feature_index);
    for (i=0;i<gt_array_size(tmp);i++) {
      gn = *(GtGenomeNode**) gt_array_get(tmp, i);
      /* no need to lock, add_*_node() is synchronized */
      had_err = gt_genome_node_accept(gn, feature_visitor, NULL);
      gt_assert(!had_err); /* cannot happen */
    }
    gt_node_visitor_delete(feature_visitor);
  }
  gt_node_stream_delete(gff3_in_stream);
  for (i=0;i<gt_array_size(tmp);i++)
    gt_genome_node_delete(*(GtGenomeNode**) gt_array_get(tmp, i));
  gt_array_delete(tmp);
  return had_err;
}
Ejemplo n.º 2
0
GtNodeStream* gt_feature_stream_new(GtNodeStream *in_stream, GtFeatureIndex *fi)
{
  GtNodeStream *gs;
  GtFeatureStream *feature_stream;
  gs = gt_node_stream_create(gt_feature_stream_class(), false);
  feature_stream = feature_stream_cast(gs);
  feature_stream->in_stream = gt_node_stream_ref(in_stream);
  feature_stream->feature_visitor = gt_feature_visitor_new(fi);
  return gs;
}
Ejemplo n.º 3
0
static int feature_visitor_lua_new(lua_State *L)
{
  GtNodeVisitor **feature_visitor;
  GtFeatureIndex **feature_index;
  feature_visitor = lua_newuserdata(L, sizeof (GtNodeVisitor*));
  gt_assert(feature_visitor);
  feature_index = check_feature_index(L, 1);
  *feature_visitor = gt_feature_visitor_new(*feature_index);
  luaL_getmetatable(L, GENOME_VISITOR_METATABLE);
  lua_setmetatable(L, -2);
  return 1;
}