static int feature_index_lua_add_feature_node(lua_State *L)
{
  GtFeatureIndex **fi;
  GtGenomeNode **gn;
  GtFeatureNode *fn;
  GtStr *seqid;
  GtError *err;
  bool has_seqid;
  gt_assert(L);
  fi = check_feature_index(L, 1);
  gn = check_genome_node(L, 2);
  fn = gt_feature_node_cast(*gn);
  luaL_argcheck(L, fn, 2, "not a feature node");
  seqid = gt_genome_node_get_seqid(*gn);
  luaL_argcheck(L, seqid, 2, "feature does not have a sequence id");
  err = gt_error_new();
  if (gt_feature_index_has_seqid(*fi, &has_seqid, gt_str_get(seqid), err))
    return gt_lua_error(L, err);
  gt_error_delete(err);
  luaL_argcheck(L, has_seqid, 2,
                "feature index does not contain corresponding sequence region");
  err = gt_error_new();
  if (gt_feature_index_add_feature_node(*fi, fn, err))
    return gt_lua_error(L, err);
  gt_error_delete(err);
  return 0;
}
static int feature_index_lua_get_features_for_range(lua_State *L)
{
  GtFeatureIndex **feature_index;
  const char *seqid;
  GtRange *range;
  GtError *err;
  bool has_seqid;
  GtArray *features;
  GT_UNUSED int had_err;

  feature_index = check_feature_index(L, 1);
  seqid = luaL_checkstring(L, 2);
  err = gt_error_new();
  if (gt_feature_index_has_seqid(*feature_index, &has_seqid, seqid, err))
    return gt_lua_error(L, err);
  gt_error_delete(err);
  luaL_argcheck(L, has_seqid, 2,
                "feature_index does not contain seqid");
  range = check_range(L, 3);
  features = gt_array_new(sizeof (GtGenomeNode*));
  err = gt_error_new();
  had_err = gt_feature_index_get_features_for_range(*feature_index, features,
                                                    seqid, range, err);
  if (had_err)
    return gt_lua_error(L, err);
  gt_error_delete(err);
  push_features_as_table(L, features);
  gt_array_delete(features);
  return 1;
}
Example #3
0
GtStrArray* agn_seq_union(GtFeatureIndex *refrfeats, GtFeatureIndex *predfeats,
                          AgnLogger *logger)
{
  // Fetch seqids from reference and prediction annotations
  GtError *e = gt_error_new();
  GtStrArray *refrseqids = gt_feature_index_get_seqids(refrfeats, e);
  if(gt_error_is_set(e))
  {
    agn_logger_log_error(logger, "error fetching seqids for reference: %s",
                         gt_error_get(e));
    gt_error_unset(e);
  }
  GtStrArray *predseqids = gt_feature_index_get_seqids(predfeats, e);
  if(gt_error_is_set(e))
  {
    agn_logger_log_error(logger, "error fetching seqids for prediction: %s",
                         gt_error_get(e));
    gt_error_unset(e);
  }
  gt_error_delete(e);
  if(agn_logger_has_error(logger))
  {
    gt_str_array_delete(refrseqids);
    gt_str_array_delete(predseqids);
    return NULL;
  }
  GtStrArray *seqids = agn_gt_str_array_union(refrseqids, predseqids);

  gt_str_array_delete(refrseqids);
  gt_str_array_delete(predseqids);
  return seqids;
}
Example #4
0
static void infer_cds_visitor_test_data(GtQueue *queue)
{
  GtError *error = gt_error_new();
  const char *file = "data/gff3/grape-codons.gff3";
  GtNodeStream *gff3in = gt_gff3_in_stream_new_unsorted(1, &file);
  gt_gff3_in_stream_check_id_attributes((GtGFF3InStream *)gff3in);
  gt_gff3_in_stream_enable_tidy_mode((GtGFF3InStream *)gff3in);
  GtLogger *logger = gt_logger_new(true, "", stderr);
  GtNodeStream *icv_stream = agn_infer_cds_stream_new(gff3in, NULL, logger);
  GtArray *feats = gt_array_new( sizeof(GtFeatureNode *) );
  GtNodeStream *arraystream = gt_array_out_stream_new(icv_stream, feats, error);
  int pullresult = gt_node_stream_pull(arraystream, error);
  if(pullresult == -1)
  {
    fprintf(stderr, "[AgnInferCDSVisitor::infer_cds_visitor_test_data] error "
            "processing features: %s\n", gt_error_get(error));
  }
  gt_node_stream_delete(gff3in);
  gt_node_stream_delete(icv_stream);
  gt_node_stream_delete(arraystream);
  gt_logger_delete(logger);
  gt_array_sort(feats, (GtCompare)agn_genome_node_compare);
  gt_array_reverse(feats);
  while(gt_array_size(feats) > 0)
  {
    GtFeatureNode *fn = *(GtFeatureNode **)gt_array_pop(feats);
    gt_queue_add(queue, fn);
  }
  gt_array_delete(feats);
  gt_error_delete(error);
}
Example #5
0
GtFeatureIndex *agn_import_canonical(int numfiles, const char **filenames,
                                     AgnLogger *logger)
{
  GtNodeStream *gff3 = gt_gff3_in_stream_new_unsorted(numfiles, filenames);
  gt_gff3_in_stream_check_id_attributes((GtGFF3InStream *)gff3);
  gt_gff3_in_stream_enable_tidy_mode((GtGFF3InStream *)gff3);

  GtFeatureIndex *features = gt_feature_index_memory_new();
  GtNodeStream *cgstream = agn_canon_gene_stream_new(gff3, logger);
  GtNodeStream *featstream = gt_feature_out_stream_new(cgstream, features);

  GtError *error = gt_error_new();
  int result = gt_node_stream_pull(featstream, error);
  if(result == -1)
  {
    agn_logger_log_error(logger, "error processing node stream: %s",
                         gt_error_get(error));
  }
  gt_error_delete(error);

  if(agn_logger_has_error(logger))
  {
    gt_feature_index_delete(features);
    features = NULL;
  }
  gt_node_stream_delete(gff3);
  gt_node_stream_delete(cgstream);
  gt_node_stream_delete(featstream);
  return features;
}
Example #6
0
GtFeatureIndex *agn_import_simple(int numfiles, const char **filenames,
                                  char *type, AgnLogger *logger)
{
  GtFeatureIndex *features = gt_feature_index_memory_new();

  GtNodeStream *gff3 = gt_gff3_in_stream_new_unsorted(numfiles, filenames);
  gt_gff3_in_stream_check_id_attributes((GtGFF3InStream *)gff3);
  gt_gff3_in_stream_enable_tidy_mode((GtGFF3InStream *)gff3);

  GtHashmap *typestokeep = gt_hashmap_new(GT_HASH_STRING, NULL, NULL);
  gt_hashmap_add(typestokeep, type, type);
  GtNodeStream *filterstream = agn_filter_stream_new(gff3, typestokeep);

  GtNodeStream *featstream = gt_feature_out_stream_new(filterstream, features);

  GtError *error = gt_error_new();
  int result = gt_node_stream_pull(featstream, error);
  if(result == -1)
  {
    agn_logger_log_error(logger, "error processing node stream: %s",
                         gt_error_get(error));
  }
  gt_error_delete(error);

  if(agn_logger_has_error(logger))
  {
    gt_feature_index_delete(features);
    features = NULL;
  }
  gt_node_stream_delete(gff3);
  gt_node_stream_delete(filterstream);
  gt_node_stream_delete(featstream);
  return features;
}
Example #7
0
static int feature_node_lua_extract_sequence(lua_State *L)
{
  GtGenomeNode **gn;
  GtFeatureNode *fn;
  const char *type;
  bool join;
  GtRegionMapping **region_mapping;
  GtStr *sequence;
  GtError *err;
  gn = check_genome_node(L, 1);
  /* make sure we get a feature node */
  fn = gt_feature_node_try_cast(*gn);
  luaL_argcheck(L, fn, 1, "not a feature node");
  type = luaL_checkstring(L, 2);
  join = lua_toboolean(L, 3);
  region_mapping = check_region_mapping(L, 4);
  err = gt_error_new();
  sequence = gt_str_new();
  if (gt_extract_feature_sequence(sequence, *gn, type, join, NULL, NULL,
                                  *region_mapping, err)) {
    gt_str_delete(sequence);
    return gt_lua_error(L, err);
  }
  if (gt_str_length(sequence))
    lua_pushstring(L, gt_str_get(sequence));
  else
    lua_pushnil(L);
  gt_str_delete(sequence);
  gt_error_delete(err);
  return 1;
}
GtUword gt_cntlist_xload(const char *filename, GtBitsequence **cntlist,
    GtUword expected_nofreads)
{
  int retval;
  GtUword found_nofreads;
  GtError *err;

  if (!gt_file_exists(filename))
  {
    fprintf(stderr, "FATAL: error by loading contained reads list: "
        "file %s does not exist\n", filename);
    exit(EXIT_FAILURE);
  }

  err = gt_error_new();
  retval = gt_cntlist_parse(filename, true, cntlist, &found_nofreads, err);
  if (retval != 0)
  {
    fprintf(stderr, "FATAL: error by parsing contained reads list: %s\n",
        gt_error_get(err));
    exit(EXIT_FAILURE);
  }
  gt_error_delete(err);

  if (found_nofreads != expected_nofreads)
  {
    fprintf(stderr, "FATAL: error by parsing contained reads list: "
        "file specifies a wrong number of reads\nexpected "GT_WU", found "
        GT_WU"\n", expected_nofreads, found_nofreads);
    exit(EXIT_FAILURE);
  }

  return gt_cntlist_count(*cntlist, found_nofreads);
}
Example #9
0
static void gt_hpol_processor_output_segment(GtAlignedSegment *as,
    bool may_be_gapped, GtFile *outfp, const char *desc)
{
  unsigned long slen;
  if (may_be_gapped)
    gt_aligned_segment_ungap_seq_and_qual(as);
  slen = (unsigned long)strlen(gt_aligned_segment_seq(as));
  gt_assert(slen == (unsigned long)strlen(gt_aligned_segment_qual(as)));
  if (gt_aligned_segment_is_reverse(as))
  {
    GtError *err = gt_error_new();
    char *q = gt_aligned_segment_qual(as), tmp;
    unsigned long i;
    for (i = 0; i < (slen + 1UL) >> 1; i++)
    {
      tmp = q[i];
      q[i] = q[slen - i - 1UL];
      q[slen - i - 1UL] = tmp;
    }
    gt_assert((unsigned long)strlen(gt_aligned_segment_qual(as)) == slen);
    if (gt_reverse_complement(gt_aligned_segment_seq(as), slen, err) != 0)
    {
      fprintf(stderr, "error: %s", gt_error_get(err));
      exit(EXIT_FAILURE);
    }
    gt_error_delete(err);
  }
  gt_fastq_show_entry((desc != NULL) ? desc :
      gt_aligned_segment_description(as), gt_aligned_segment_seq(as),
      gt_aligned_segment_qual(as), slen, 0, false, outfp);
}
Example #10
0
static int canvas_cairo_file_lua_new_generic(lua_State *L, GtGraphicsOutType t)
{
  GtCanvas **canvas;
  GtImageInfo **ii;
  unsigned int width,
               height;
  GtError *err;
  GtStyle *style;
  width = luaL_checkint(L, 1);
  height = luaL_checkint(L, 2);
  /* create canvas */
  style = gt_lua_get_style_from_registry(L);
  canvas = lua_newuserdata(L, sizeof (GtCanvas*));
  gt_assert(canvas);
  /* if a imageinfo object is passed, it must be correct type */
  if (lua_isnil(L, 3)) {
    err = gt_error_new();
    *canvas = gt_canvas_cairo_file_new(style, t, width, height, NULL, err);
  } else {
    ii = check_imageinfo(L, 3);
    err = gt_error_new();
    *canvas = gt_canvas_cairo_file_new(style, t, width, height, *ii, err);
  }
  if (gt_error_is_set(err))
    return gt_lua_error(L, err);
  gt_error_delete(err);
  luaL_getmetatable(L, CANVAS_METATABLE);
  lua_setmetatable(L, -2);
  return 1;
}
Example #11
0
File: init.c Project: 9beckert/TIR
static void proc_env_options(void)
{
  int argc;
  char *env_options, **argv;
  GtSplitter *splitter;
  GtError *err;
  /* construct argument vector from $GT_ENV_OPTIONS */
  env_options = getenv("GT_ENV_OPTIONS");
  if (!env_options)
    return;
  env_options = gt_cstr_dup(env_options); /* make writeable copy */
  splitter = gt_splitter_new();
  gt_splitter_split(splitter, env_options, strlen(env_options), ' ');
  argc = gt_splitter_size(splitter);
  argv = gt_cstr_array_preprend((const char**) gt_splitter_get_tokens(splitter),
                             "env");
  argc++;
  /* parse options contained in $GT_ENV_OPTIONS */
  err = gt_error_new();
  switch (parse_env_options(argc, (const char**) argv, err)) {
    case GT_OPTION_PARSER_OK: break;
    case GT_OPTION_PARSER_ERROR:
      fprintf(stderr, "error parsing $GT_ENV_OPTIONS: %s\n", gt_error_get(err));
      gt_error_unset(err);
      break;
    case GT_OPTION_PARSER_REQUESTS_EXIT: break;
  }
  gt_error_delete(err);
  gt_free(env_options);
  gt_splitter_delete(splitter);
  gt_cstr_array_delete(argv);
}
Example #12
0
static void gv_test_calc_integrity(AgnUnitTest *test)
{
  const char *filename = "data/gff3/gaeval-stream-unit-test-2.gff3";
  GtNodeStream *align_in = gt_gff3_in_stream_new_unsorted(1, &filename);
  AgnGaevalParams params = { 0.6, 0.3, 0.05, 0.05, 400, 200, 100 };
  GtNodeVisitor *nv = agn_gaeval_visitor_new(align_in, params);
  AgnGaevalVisitor *gv = gaeval_visitor_cast(nv);
  gt_node_stream_delete(align_in);

  GtNodeStream *gff3in = gt_gff3_in_stream_new_unsorted(1, &filename);
  GtHashmap *typestokeep = gt_hashmap_new(GT_HASH_STRING, NULL, NULL);
  gt_hashmap_add(typestokeep, "mRNA", "mRNA");
  GtNodeStream *filtstream = agn_filter_stream_new(gff3in, typestokeep);
  GtLogger *logger = gt_logger_new(true, "", stderr);
  GtNodeStream *ics = agn_infer_cds_stream_new(filtstream, NULL, logger);
  GtNodeStream *ies = agn_infer_exons_stream_new(ics, NULL, logger);

  GtError *error = gt_error_new();
  GtArray *feats = gt_array_new( sizeof(GtFeatureNode *) );
  GtNodeStream *featstream = gt_array_out_stream_new(ies, feats, error);
  int result = gt_node_stream_pull(featstream, error);
  if(result == -1)
  {
    fprintf(stderr, "[AgnGaevalVisitor::gv_test_calc_integrity] error "
            "processing GFF3: %s\n", gt_error_get(error));
    return;
  }
  gt_node_stream_delete(gff3in);
  gt_node_stream_delete(filtstream);
  gt_node_stream_delete(featstream);
  gt_node_stream_delete(ics);
  gt_node_stream_delete(ies);
  gt_logger_delete(logger);
  gt_hashmap_delete(typestokeep);

  agn_assert(gt_array_size(feats) == 2);
  GtFeatureNode *g1 = *(GtFeatureNode **)gt_array_get(feats, 0);
  GtFeatureNode *g2 = *(GtFeatureNode **)gt_array_get(feats, 1);

  double cov1 = gaeval_visitor_calculate_coverage(gv,  g1, error);
  double cov2 = gaeval_visitor_calculate_coverage(gv,  g2, error);
  double int1 = gaeval_visitor_calculate_integrity(gv, g1, cov1, NULL, error);
  double int2 = gaeval_visitor_calculate_integrity(gv, g2, cov2, NULL, error);

  bool test1 = fabs(cov1 - 1.000) < 0.001 &&
               fabs(cov2 - 0.997) < 0.001 &&
               fabs(int1 - 0.850) < 0.001 &&
               fabs(int2 - 0.863) < 0.001;
  agn_unit_test_result(test, "calculate integrity", test1);

  gt_error_delete(error);
  gt_array_delete(feats);
  gt_genome_node_delete((GtGenomeNode *)g1);
  gt_genome_node_delete((GtGenomeNode *)g2);
  gt_node_visitor_delete(nv);
}
Example #13
0
int gt_lua_error(lua_State *L, GtError *err)
{
  gt_assert(L && err);
  gt_assert(gt_error_is_set(err));
  luaL_where(L, 1);
  lua_pushstring(L, gt_error_get(err));
  gt_error_delete(err);
  lua_concat(L, 2);
  return lua_error(L);
}
Example #14
0
static int encseq_lua_mirror(lua_State *L)
{
  GtEncseq **encseq;
  GtError *err = gt_error_new();
  encseq = check_encseq(L, 1);
  gt_assert(*encseq);
  luaL_argcheck(L, !gt_encseq_is_mirrored(*encseq), 1, "is already mirrored");
  if (gt_encseq_mirror(*encseq, err) != 0)
    gt_lua_error(L, err);
  gt_error_delete(err);
  return 0;
}
static int feature_index_lua_get_range_for_seqid(lua_State *L)
{
  GtFeatureIndex **feature_index;
  const char *seqid;
  GtError *err;
  GtRange range;
  bool has_seqid;
  feature_index = check_feature_index(L, 1);
  seqid = luaL_checkstring(L, 2);
  err = gt_error_new();
  if (gt_feature_index_has_seqid(*feature_index, &has_seqid, seqid, err))
    return gt_lua_error(L, err);
  gt_error_delete(err);
  luaL_argcheck(L, has_seqid, 2,
                "feature_index does not contain seqid");
  err = gt_error_new();
  if (gt_feature_index_get_range_for_seqid(*feature_index, &range, seqid, err))
    return gt_lua_error(L, err);
  gt_error_delete(err);
  return gt_lua_range_push(L, range);
}
Example #16
0
static int genome_node_lua_accept(lua_State *L)
{
  GtGenomeNode **gn;
  GtNodeVisitor **gv;
  GtError *err;
  gn = check_genome_node(L, 1);
  gv = check_genome_visitor(L, 2);
  err = gt_error_new();
  if (gt_genome_node_accept(*gn, *gv, err))
    return gt_lua_error(L, err);
  gt_error_delete(err);
  return 0;
}
int main(int argc, char *argv[])
{
  GtError *err;
  GtWord readlong;
  bool haserr = false, withsequence = false;
  char *indexname = NULL, *mumlength_string = NULL;

  if (argc == 3)
  {
    withsequence = false;
    indexname = argv[1];
    mumlength_string = argv[2];
  } else
  {
    if (argc == 4)
    {
      if (strcmp(argv[1],"-s") != 0)
      {
        usage(argv[0]);
        return EXIT_FAILURE;
      }
      withsequence = true;
      indexname = argv[2];
      mumlength_string = argv[3];
    } else
    {
      usage(argv[0]);
      return EXIT_FAILURE;
    }
  }
  if (sscanf(mumlength_string,GT_WD,&readlong) != 1 || readlong < 0)
  {
    usage(argv[0]);
    return EXIT_FAILURE;
  }
  gt_lib_init();
  err = gt_error_new();
  if (gt_stree_mum(indexname, (GtUword) readlong, withsequence, err) != 0)
  {
    fprintf(stderr,"%s: failure when enumerating branch locs for "
                   " index %s: %s\n",
                   argv[0],indexname,gt_error_get(err));
    haserr = true;
  }
  gt_error_delete(err);
  if (gt_lib_clean() != 0)
  {
    return GT_EXIT_PROGRAMMING_ERROR;
  }
  return haserr ? EXIT_FAILURE : EXIT_SUCCESS;
}
Example #18
0
static int feature_index_lua_add_gff3file(lua_State *L)
{
  GtFeatureIndex **fi;
  const char *filename;
  GtError *err;
  gt_assert(L);
  fi = check_feature_index(L, 1);
  filename = luaL_checkstring(L, 2);
  err = gt_error_new();
  if (gt_feature_index_add_gff3file(*fi, filename, err))
    return gt_lua_error(L, err);
  gt_error_delete(err);
  return 0;
}
Example #19
0
static int encseq_encoder_lua_use_representation(lua_State *L)
{
  GtEncseqEncoder **encoder;
  const char *repr;
  GtError *err;
  encoder = check_encseq_encoder(L, 1);
  repr = luaL_checkstring(L, 2);
  gt_assert(*encoder);
  err = gt_error_new();
  if (gt_encseq_encoder_use_representation(*encoder, repr, err) != 0)
    gt_lua_error(L, err);
  gt_error_delete(err);
  return 0;
}
Example #20
0
static int encseq_encoder_lua_use_symbolmap_file(lua_State *L)
{
  GtEncseqEncoder **encoder;
  const char *smapfile;
  GtError *err;
  encoder = check_encseq_encoder(L, 1);
  smapfile = luaL_checkstring(L, 2);
  gt_assert(*encoder);
  err = gt_error_new();
  if (gt_encseq_encoder_use_symbolmap_file(*encoder, smapfile, err) != 0)
    gt_lua_error(L, err);
  gt_error_delete(err);
  return 0;
}
static int gt_node_stream_lua_next_tree(lua_State *L)
{
  GtNodeStream **gs = check_genome_stream(L, 1);
  GtGenomeNode *gn;
  GtError *err = gt_error_new();
  if (gt_node_stream_next(*gs, &gn, err))
    return gt_lua_error(L, err); /* handle error */
  else if (gn)
    gt_lua_genome_node_push(L, gn);
  else
    lua_pushnil(L);
  gt_error_delete(err);
  return 1;
}
Example #22
0
static int layout_lua_get_height(lua_State *L)
{
    GtLayout **layout;
    GtError *err;
    int had_err = 0;
    unsigned long height;
    layout = check_layout(L, 1);
    err = gt_error_new();
    had_err = gt_layout_get_height(*layout, &height, err);
    lua_pushnumber(L, height);
    if (had_err < 0)
        return gt_lua_error(L, err);
    gt_error_delete(err);
    return 1;
}
Example #23
0
static int layout_lua_sketch(lua_State *L)
{
    GtLayout **layout;
    GtCanvas **canvas;
    GtError *err;
    int had_err = 0;
    layout = check_layout(L, 1);
    canvas = check_canvas(L, 2);
    err = gt_error_new();
    had_err = gt_layout_sketch(*layout, *canvas, err);
    if (had_err < 0)
        return gt_lua_error(L, err);
    gt_error_delete(err);
    return 0;
}
Example #24
0
static int encseq_builder_lua_build(lua_State *L)
{
  GtEncseqBuilder **builder;
  GtEncseq *encseq;
  GtError *err;
  builder = check_encseq_builder(L, 1);
  err = gt_error_new();
  encseq = gt_encseq_builder_build(*builder, err);
  if (encseq == NULL) {
    gt_lua_error(L, err);
  } else
    gt_lua_encseq_push(L, encseq);
  gt_error_delete(err);
  return 1;
}
static int feature_index_lua_get_seqids(lua_State *L)
{
  GtFeatureIndex **feature_index;
  GtStrArray *seqids;
  GtError *err;
  feature_index = check_feature_index(L, 1);
  err = gt_error_new();
  seqids = gt_feature_index_get_seqids(*feature_index, err);
  if (!seqids)
    return gt_lua_error(L, err);
  gt_error_delete(err);
  /* push table containing sequence ids onto the stack */
  gt_lua_push_strarray_as_table(L, seqids);
  gt_str_array_delete(seqids);
  return 1;
}
static int feature_index_lua_add_region_node(lua_State *L)
{
  GtFeatureIndex **fi;
  GtGenomeNode **gn;
  GtRegionNode *rn;
  GtError *err;
  gt_assert(L);
  fi = check_feature_index(L, 1);
  gn = check_genome_node(L, 2);
  rn = gt_region_node_try_cast(*gn);
  luaL_argcheck(L, rn, 2, "not a region node");
  err = gt_error_new();
  if (gt_feature_index_add_region_node(*fi, rn, err))
    return gt_lua_error(L, err);
  gt_error_delete(err);
  return 0;
}
static int feature_index_lua_has_seqid(lua_State *L)
{
  GtFeatureIndex **feature_index;
  bool has_seqid;
  const char *seqid;
  GtError *err;
  int had_err = 0;
  feature_index = check_feature_index(L, 1);
  seqid = luaL_checkstring(L, 2);
  err = gt_error_new();
  had_err = gt_feature_index_has_seqid(*feature_index, &has_seqid, seqid, err);
  if (had_err)
    return gt_lua_error(L, err);
  gt_error_delete(err);
  lua_pushboolean(L, has_seqid);
  return 1;
}
Example #28
0
static int encseq_loader_lua_load(lua_State *L)
{
  GtEncseqLoader **loader;
  const char *indexname;
  GtError *err = gt_error_new();
  GtEncseq *encseq;
  loader = check_encseq_loader(L, 1);
  indexname = luaL_checkstring(L, 2);
  gt_assert(*loader);
  encseq = gt_encseq_loader_load(*loader, indexname, err);
  if (encseq == NULL)
    gt_lua_error(L, err);
  else {
    gt_lua_encseq_push(L, encseq);
  }
  gt_error_delete(err);
  return 1;
}
static int feature_index_lua_get_features_for_seqid(lua_State *L)
{
  GtFeatureIndex **feature_index;
  const char *seqid;
  GtArray *features;
  GtError *err;
  feature_index = check_feature_index(L, 1);
  seqid = luaL_checkstring(L, 2);
  err = gt_error_new();
  features = gt_feature_index_get_features_for_seqid(*feature_index, seqid,
                                                     err);
  if (!features)
    return gt_lua_error(L, err);
  gt_error_delete(err);
  push_features_as_table(L, features);
  gt_array_delete(features);
  return 1;
}
static int feature_index_lua_get_first_seqid(lua_State *L)
{
  GtFeatureIndex **feature_index;
  char *seqid;
  GtError *err;
  feature_index = check_feature_index(L, 1);
  err = gt_error_new();
  seqid = gt_feature_index_get_first_seqid(*feature_index, err);
  if (gt_error_is_set(err))
    return gt_lua_error(L, err);
  gt_error_delete(err);
  if (seqid) {
    lua_pushstring(L, seqid);
    gt_free(seqid);
  } else
    lua_pushnil(L);
  return 1;
}