static bool filter_targetstrand(GtFeatureNode *fn, GtStrand targetstrand) { const char *target; gt_assert(fn); if (targetstrand != GT_NUM_OF_STRAND_TYPES && (target = gt_feature_node_get_attribute(fn, GT_GFF_TARGET))) { unsigned long num_of_targets; GtStrand parsed_strand; GT_UNUSED int had_err; had_err = gt_gff3_parser_parse_target_attributes(target, &num_of_targets, NULL, NULL, &parsed_strand, "", 0, NULL); gt_assert(!had_err); if (num_of_targets == 1 && parsed_strand != GT_NUM_OF_STRAND_TYPES && parsed_strand != targetstrand) { return true; } } return false; }
static void filter_targetbest(GtFeatureNode *current_feature, GtDlist *trees, GtHashmap *target_to_elem) { unsigned long num_of_targets; GtDlistelem *previous_elem; GtStr *first_target_id; const char *target; int had_err; gt_assert(current_feature && trees); target = gt_feature_node_get_attribute(current_feature, TARGET_STRING); gt_assert(target); first_target_id = gt_str_new(); had_err = gt_gff3_parser_parse_target_attributes(target, &num_of_targets, first_target_id, NULL, NULL, "", 0, NULL); gt_assert(!had_err); if (num_of_targets == 1) { GtStr *key = gt_str_new(); build_key(key, current_feature, first_target_id); if (!(previous_elem = gt_hashmap_get(target_to_elem, gt_str_get(key)))) { /* element with this target_id not included yet -> include it */ include_feature(trees, target_to_elem, current_feature, key); } else { GtFeatureNode *previous_feature = gt_dlistelem_get_data(previous_elem); /* element with this target_id included already -> compare them */ if (gt_feature_node_get_score(current_feature) > gt_feature_node_get_score(previous_feature)) { /* current feature is better -> replace previous feature */ replace_previous_elem(previous_elem, current_feature, trees, target_to_elem, key); } else /* current feature is not better -> remove it */ gt_genome_node_delete((GtGenomeNode*) current_feature); } gt_str_delete(key); } else gt_dlist_add(trees, current_feature); gt_str_delete(first_target_id); }