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; }
static int feature_index_lua_get_features_for_seqid(lua_State *L) { GtFeatureIndex **feature_index; const char *seqid; GtArray *features; feature_index = check_feature_index(L, 1); seqid = luaL_checkstring(L, 2); features = gt_feature_index_get_features_for_seqid(*feature_index, seqid); push_features_as_table(L, features); gt_array_delete(features); 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_features_for_range(lua_State *L) { GtFeatureIndex **feature_index; const char *seqid; GtRange *range; GtArray *features; int had_err; feature_index = check_feature_index(L, 1); seqid = luaL_checkstring(L, 2); luaL_argcheck(L, gt_feature_index_has_seqid(*feature_index, seqid), 2, "feature_index does not contain seqid"); range = check_range(L, 3); features = gt_array_new(sizeof (GtGenomeNode*)); had_err = gt_feature_index_get_features_for_range(*feature_index, features, seqid, range, NULL); gt_assert(!had_err); /* it was checked before that the feature_index contains the given sequence id*/ push_features_as_table(L, features); gt_array_delete(features); return 1; }