void gt_feature_info_delete(GtFeatureInfo *fi) { if (!fi) return; gt_hashmap_delete(fi->id_to_genome_node); gt_hashmap_delete(fi->id_to_pseudo_parent); gt_free(fi); }
static void gff3_visitor_free(GtNodeVisitor *nv) { GtGFF3Visitor *gff3_visitor = gff3_visitor_cast(nv); gt_assert(gff3_visitor); gt_string_distri_delete(gff3_visitor->id_counter); gt_hashmap_delete(gff3_visitor->feature_node_to_id_array); gt_hashmap_delete(gff3_visitor->feature_node_to_unique_id_str); gt_cstr_table_delete(gff3_visitor->used_ids); }
void gt_gtf_parser_delete(GtGTFParser *parser) { if (!parser) return; gt_region_node_builder_delete(parser->region_node_builder); gt_hashmap_delete(parser->gene_id_hash); gt_hashmap_delete(parser->seqid_to_str_mapping); gt_hashmap_delete(parser->source_to_str_mapping); gt_hashmap_delete(parser->transcript_id_to_name_mapping); gt_hashmap_delete(parser->gene_id_to_name_mapping); gt_free(parser); }
void gt_type_graph_delete(GtTypeGraph *type_graph) { unsigned long i; if (!type_graph) return; gt_bool_matrix_delete(type_graph->part_of_in_edges); gt_bool_matrix_delete(type_graph->part_of_out_edges); for (i = 0; i < gt_array_size(type_graph->nodes); i++) gt_type_node_delete(*(GtTypeNode**) gt_array_get(type_graph->nodes, i)); gt_array_delete(type_graph->nodes); gt_hashmap_delete(type_graph->nodemap); gt_hashmap_delete(type_graph->name2id); gt_free(type_graph); }
void gt_layout_delete(GtLayout *layout) { if (!layout) return; gt_rwlock_wrlock(layout->lock); if (layout->twc && layout->own_twc) gt_text_width_calculator_delete(layout->twc); gt_hashmap_delete(layout->tracks); gt_array_delete(layout->custom_tracks); if (layout->blocks) gt_hashmap_delete(layout->blocks); gt_rwlock_unlock(layout->lock); gt_rwlock_delete(layout->lock); gt_free(layout); }
void gt_xrf_abbr_entry_delete(GtXRFAbbrEntry *abbr_entry) { if (!abbr_entry) return; gt_str_delete(abbr_entry->filename); gt_hashmap_delete(abbr_entry->content); gt_free(abbr_entry); }
static void add_ids_visitor_free(GtNodeVisitor *nv) { GtAddIDsVisitor *add_ids_visitor = add_ids_visitor_cast(nv); gt_hashmap_delete(add_ids_visitor->undefined_sequence_regions); gt_cstr_table_delete(add_ids_visitor->defined_seqids); gt_queue_delete(add_ids_visitor->node_buffer); }
void gth_region_factory_save(GthRegionFactory *rf, GtArray *nodes, GthInput *input) { GtHashmap *sequence_regions; GtUword i, j; GtStr *sequenceid; GT_UNUSED int had_err; gt_assert(rf && nodes && input); gt_assert(!rf->factory_was_used); rf->seqid_store = seqid_store_new(input); sequence_regions = gt_hashmap_new(GT_HASH_STRING, NULL, NULL); sequenceid = gt_str_new(); for (i = 0; i < gth_input_num_of_gen_files(input); i++) { gth_input_load_genomic_file(input, i, false); for (j = 0; j < gth_input_num_of_gen_seqs(input, i); j++) { gt_str_reset(sequenceid); gth_input_save_gen_identifier(input, sequenceid, i, j); make_sequence_region(sequence_regions, sequenceid, rf, input, i, j); } } gt_str_delete(sequenceid); had_err = gt_hashmap_foreach_in_key_order(sequence_regions, save_sequence_region, nodes, NULL); gt_assert(!had_err); /* should not happen */ gt_hashmap_delete(sequence_regions); rf->factory_was_used = true; }
void gt_diagram_delete(GtDiagram *diagram) { if (!diagram) return; gt_rwlock_wrlock(diagram->lock); gt_array_delete(diagram->features); if (diagram->blocks) gt_hashmap_delete(diagram->blocks); gt_hashmap_delete(diagram->nodeinfo); gt_hashmap_delete(diagram->collapsingtypes); gt_hashmap_delete(diagram->groupedtypes); gt_hashmap_delete(diagram->caption_display_status); gt_array_delete(diagram->custom_tracks); gt_rwlock_unlock(diagram->lock); gt_rwlock_delete(diagram->lock); gt_free(diagram); }
void gt_seqid2seqnum_mapping_delete(GtSeqid2SeqnumMapping *mapping) { if (!mapping) return; gt_hashmap_delete(mapping->map); gt_free(mapping->filename); gt_free(mapping); }
static void gt_hmmer_parse_status_delete(GtHMMERParseStatus *s) { if (!s) return; gt_str_delete(s->cur_model); gt_hashmap_delete(s->models); gt_free(s); }
static void filter_stream_free(GtNodeStream *ns) { AgnFilterStream *stream = filter_stream_cast(ns); gt_node_stream_delete(stream->in_stream); gt_queue_delete(stream->cache); gt_hashmap_delete(stream->typestokeep); }
void gt_line_breaker_captions_delete(GtLineBreaker *lb) { GtLineBreakerCaptions *lbcap; if (!lb) return; lbcap = gt_line_breaker_captions_cast(lb); gt_hashmap_delete(lbcap->linepositions); }
void gt_line_breaker_bases_delete(GtLineBreaker *lb) { GtLineBreakerBases *lbb; if (!lb) return; lbb = gt_line_breaker_bases_cast(lb); gt_hashmap_delete(lbb->itrees); }
void gt_diagram_reset_track_selector_func(GtDiagram *diagram) { gt_assert(diagram); gt_rwlock_wrlock(diagram->lock); diagram->select_func = default_track_selector; gt_hashmap_delete(diagram->blocks); diagram->blocks = NULL; gt_rwlock_unlock(diagram->lock); }
static void targetbest_filter_stream_free(GtNodeStream *gs) { GtTargetbestFilterStream *tfs = targetbest_filter_stream_cast(gs); for (; tfs->next != NULL; tfs->next = gt_dlistelem_next(tfs->next)) gt_genome_node_delete(gt_dlistelem_get_data(tfs->next)); gt_dlist_delete(tfs->trees); gt_hashmap_delete(tfs->target_to_elem); gt_node_stream_delete(tfs->in_stream); }
void gt_type_node_delete(GtTypeNode *type_node) { if (!type_node) return; gt_hashmap_delete(type_node->cache); gt_array_delete(type_node->is_a_out_edges); gt_array_delete(type_node->part_of_list); gt_array_delete(type_node->is_a_list); gt_free(type_node); }
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); }
void gtr_register_components(GtR *gtr) { gt_assert(gtr); /* add tools */ gt_toolbox_delete(gtr->tools); gtr->tools = gtt_tools(); /* add unit tests */ gt_hashmap_delete(gtr->unit_tests); gtr->unit_tests = gtt_unit_tests(); }
static void snp_annotator_visitor_free(GtNodeVisitor *nv) { GtSNPAnnotatorVisitor *sav; if (!nv) return; sav = snp_annotator_visitor_cast(nv); gt_genome_node_delete((GtGenomeNode*) sav->gene); if (sav->own_tt) gt_trans_table_delete(sav->tt); gt_region_mapping_delete(sav->rmap); gt_hashmap_delete(sav->rnaseqs); }
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; }
void gt_xrf_checker_delete(GtXRFChecker *xrc) { if (!xrc) return; if (xrc->reference_count) { xrc->reference_count--; return; } gt_xrf_abbr_parse_tree_delete(xrc->xpt); gt_hashmap_delete(xrc->abbrvs); gt_splitter_delete(xrc->splitter); gt_free(xrc); }
static void gt_ltr_cluster_stream_free(GtNodeStream *ns) { unsigned long i; GtLTRClusterStream *lcs = gt_ltr_cluster_stream_cast(ns); gt_node_visitor_delete((GtNodeVisitor*) lcs->lcv); gt_hashmap_delete(lcs->feat_to_encseq); gt_str_array_delete(lcs->feat_to_encseq_keys); for (i = 0; i < gt_array_size(lcs->nodes); i++) gt_genome_node_delete(*(GtGenomeNode**) gt_array_get(lcs->nodes, i)); gt_array_delete(lcs->nodes); gt_node_stream_delete(lcs->in_stream); }
void gt_ltrfileout_stream_free(GtNodeStream *ns) { GtLTRdigestFileOutStream *ls = gt_ltrdigest_file_out_stream_cast(ns); if (ls->tabout_file != NULL) gt_file_delete(ls->tabout_file); if (ls->pbsout_file != NULL) gt_file_delete(ls->pbsout_file); if (ls->pptout_file != NULL) gt_file_delete(ls->pptout_file); if (ls->ltr5out_file != NULL) gt_file_delete(ls->ltr5out_file); if (ls->ltr3out_file != NULL) gt_file_delete(ls->ltr3out_file); if (ls->elemout_file != NULL) gt_file_delete(ls->elemout_file); gt_hashmap_delete(ls->pdomout_files); gt_hashmap_delete(ls->pdomali_files); gt_hashmap_delete(ls->pdomaa_files); gt_node_visitor_delete((GtNodeVisitor*) ls->lv); gt_node_stream_delete(ls->in_stream); }
int main(int argc, char **argv) { if(argc != 2) { fputs("usage: vang schema.file\n", stderr); return 1; } gt_lib_init(); char *schemafile = argv[1]; FILE *schema = fopen(schemafile, "r"); if(schema == NULL) { fprintf(stderr, "error: unable to open schema file '%s'\n", schemafile); return 1; } GtArray *entry_datatypes = gt_array_new( sizeof(char *) ); GtHashmap *entries = gt_hashmap_new( GT_HASH_STRING, NULL, (GtFree)vang_schema_entry_delete ); VangSchemaEntry *entry; while( (entry = vang_schema_entry_next(schema)) != NULL ) { char *datatype = (char *)vang_schema_entry_get_datatype(entry); VangSchemaEntry *testentry = gt_hashmap_get(entries, datatype); if(testentry != NULL) { fprintf( stderr, "warning: already have an entry for data type '%s'; " "replacing\n", datatype ); vang_schema_entry_delete(testentry); } gt_hashmap_add(entries, datatype, entry); gt_array_add(entry_datatypes, datatype); } unsigned long i; for(i = 0; i < gt_array_size(entry_datatypes); i++) { const char *type = *(const char **)gt_array_get(entry_datatypes, i); VangSchemaEntry *entry = gt_hashmap_get(entries, type); vang_schema_entry_to_string(entry, stdout); puts(""); } gt_array_delete(entry_datatypes); gt_hashmap_delete(entries); gt_lib_clean(); return 0; }
void gt_diagram_set_track_selector_func(GtDiagram *diagram, GtTrackSelectorFunc bsfunc, void *ptr) { gt_assert(diagram); gt_rwlock_wrlock(diagram->lock); /* register selector function and attached pointer */ diagram->select_func = bsfunc; diagram->ptr = ptr; /* this could change track assignment -> discard current blocks and requeue */ gt_hashmap_delete(diagram->blocks); diagram->blocks = NULL; gt_rwlock_unlock(diagram->lock); }
void gt_bed_parser_delete(GtBEDParser *bed_parser) { if (!bed_parser) return; gt_free(bed_parser->block_type); gt_free(bed_parser->thick_feature_type); gt_free(bed_parser->feature_type); gt_str_delete(bed_parser->another_word); gt_str_delete(bed_parser->word); gt_hashmap_delete(bed_parser->seqid_to_str_mapping); while (gt_queue_size(bed_parser->feature_nodes)) gt_genome_node_delete(gt_queue_get(bed_parser->feature_nodes)); gt_queue_delete(bed_parser->feature_nodes); gt_region_node_builder_delete(bed_parser->region_node_builder); gt_free(bed_parser); }
static int check_cds_phases_if_necessary(GtFeatureNode *fn, GtCDSCheckVisitor *v, bool second_pass, GtError *err) { GtFeatureNodeIterator *fni; GtFeatureNode *node; GtArray *cds_features = NULL; GtHashmap *multi_features = NULL; int had_err = 0; gt_error_check(err); gt_assert(fn); fni = gt_feature_node_iterator_new_direct(fn); while ((node = gt_feature_node_iterator_next(fni))) { if (gt_feature_node_has_type(node, gt_ft_CDS)) { if (gt_feature_node_is_multi(node)) { GtArray *features; if (!multi_features) multi_features = gt_hashmap_new(GT_HASH_DIRECT, NULL, (GtFree) gt_array_delete); if ((features = gt_hashmap_get(multi_features, gt_feature_node_get_multi_representative(node)))) { gt_array_add(features, node); } else { GtFeatureNode *representative; features = gt_array_new(sizeof (GtFeatureNode*)); representative = gt_feature_node_get_multi_representative(node); gt_array_add(features, representative); gt_hashmap_add(multi_features, representative, features); } } else { if (!cds_features) cds_features = gt_array_new(sizeof (GtFeatureNode*)); gt_array_add(cds_features, node); } } } if (cds_features) had_err = check_cds_phases(cds_features, v, false, second_pass, err); if (!had_err && multi_features) had_err = gt_hashmap_foreach(multi_features, check_cds_phases_hm, v, err); gt_array_delete(cds_features); gt_hashmap_delete(multi_features); gt_feature_node_iterator_delete(fni); return had_err; }
void gtr_delete(GtR *gtr) { if (!gtr) return; gt_fa_fclose(gtr->logfp); gt_str_delete(gtr->testspacepeak); gt_str_delete(gtr->debugfp); gt_str_delete(gtr->test_only); gt_str_delete(gtr->manoutdir); gt_toolbox_delete(gtr->tools); gt_hashmap_delete(gtr->unit_tests); if (gtr->L) lua_close(gtr->L); #ifndef WITHOUT_CAIRO gt_style_delete_without_state(gtr->style); #endif gt_free(gtr); }
void gt_md5_tab_delete(GtMD5Tab *md5_tab) { GtUword i; if (!md5_tab) return; if (md5_tab->reference_count) { md5_tab->reference_count--; return; } gt_fa_xmunmap(md5_tab->fingerprints); gt_fa_unlock(md5_tab->fingerprints_file); gt_fa_xfclose(md5_tab->fingerprints_file); gt_hashmap_delete(md5_tab->md5map); if (md5_tab->owns_md5s) { for (i = 0; i < md5_tab->num_of_md5s; i++) gt_free(md5_tab->md5_fingerprints[i]); gt_free(md5_tab->md5_fingerprints); } gt_free(md5_tab); }