<commit_before>#include "./../lib/replaceAnnotation.h"

void load_annotation_from_Node(Node*  node, int lvl_node, int size_kmer, int longest_annot, info_per_level*  info_per_lvl,
                               Pvoid_t* PJArray, annotation_array_elem* annot_sorted, annotation_inform* ann_inf){

    ASSERT_NULL_PTR(node,"load_annotation_from_Node()")
    ASSERT_NULL_PTR(info_per_lvl,"load_annotation_from_Node()")

    int i = -1;

    if ((CC*)node->CC_array != NULL){
        do {
            i++;
            load_annotation_from_CC(&(((CC*)node->CC_array)[i]), lvl_node, size_kmer, longest_annot, info_per_lvl,
                                    PJArray, annot_sorted, ann_inf);
        }
        while (IS_EVEN(((CC*)node->CC_array)[i].type));
    }

    if (node->UC_array.suffixes != NULL){
        load_annotation_from_UC(&(node->UC_array), info_per_lvl[lvl_node].size_kmer_in_bytes,
                                node->UC_array.nb_children >> 1, longest_annot, PJArray, annot_sorted, ann_inf);
    }
}

void load_annotation_from_CC(CC*  cc, int lvl_cc, int size_kmer, int longest_annot, info_per_level*  info_per_lvl,
                             Pvoid_t* PJArray, annotation_array_elem* annot_sorted, annotation_inform* ann_inf){

    ASSERT_NULL_PTR(cc,"load_annotation_from_CC()")

    UC* uc;

    int i;

    int nb_skp = CEIL(cc->nb_elem, info_per_lvl[lvl_cc].nb_ucs_skp);

    if (size_kmer != NB_CHAR_SUF_PREF){

        for (i = 0; i < nb_skp; i++){

            uc = &(((UC*)cc->children)[i]);
            load_annotation_from_UC(uc, info_per_lvl[lvl_cc].size_kmer_in_bytes_minus_1, uc->nb_children,
                                    longest_annot, PJArray, annot_sorted, ann_inf);
        }
    }
    else{
        for (i = 0; i < nb_skp; i++){

            uc = &(((UC*)cc->children)[i]);

            if (i != nb_skp-1){
                load_annotation_from_UC(uc, 0, info_per_lvl[lvl_cc].nb_ucs_skp, longest_annot,
                                        PJArray, annot_sorted, ann_inf);
            }
            else{
                load_annotation_from_UC(uc, 0, cc->nb_elem - i * info_per_lvl[lvl_cc].nb_ucs_skp, longest_annot,
                                        PJArray, annot_sorted, ann_inf);
            }
        }
    }

    for (i = 0; i < cc->nb_Node_children; i++){
        load_annotation_from_Node(&(cc->children_Node_container[i]), lvl_cc-1, size_kmer-NB_CHAR_SUF_PREF,
                                  longest_annot, info_per_lvl, PJArray, annot_sorted, ann_inf);
    }

    return;
}

void load_annotation_from_UC(UC* uc, int size_substring, int nb_children, int longest_annot,
                             Pvoid_t* PJArray, annotation_array_elem* annot_sorted, annotation_inform* ann_inf){

    ASSERT_NULL_PTR(uc, "load_annotation_from_UC()")

    if (uc->suffixes != NULL){

        PWord_t PValue;

        uint64_t size_decomp;

        int i = 0, j = 0;
        int bits_per_byte_checksum = SIZE_BITS_UINT_8T - 1;
        int size_line = size_substring + uc->size_annot;

        int shift_mode_3;
        int size_checksum;
        int size_tmp;

        uint32_t position;

        uint8_t* annot_tmp;
        uint8_t* annot_start;
        uint8_t** extended_annots = get_extend_annots(uc, size_substring, nb_children, 0, nb_children-1);

        UC_SIZE_ANNOT_T *min_sizes = min_size_per_sub(uc->suffixes, nb_children, size_substring, uc->size_annot);

        uint8_t* annot = calloc(longest_annot + CEIL(longest_annot, SIZE_BITS_UINT_8T) + 4, sizeof(uint8_t));
        ASSERT_NULL_PTR(annot, "load_annotation_from_UC()")

        for (i=0; i<nb_children; i++){

            if ((extended_annots != NULL) && (extended_annots[i] != NULL) && (extended_annots[i][0] != 0)){
                memcpy(&(annot[3]), &(uc->suffixes[i * size_line + size_substring]), uc->size_annot * sizeof(uint8_t));
                annot[uc->size_annot + 3] = extended_annots[i][0];
                min_sizes[i] = uc->size_annot + 1;
            }
            else memcpy(&(annot[3]), &(uc->suffixes[i * size_line + size_substring]), min_sizes[i] * sizeof(uint8_t));

            if ((annot[3] & 0x3) == 3){
<commit_msg>Correction bug affecting colors compression<commit_after>#include "./../lib/replaceAnnotation.h"

void load_annotation_from_Node(Node*  node, int lvl_node, int size_kmer, int longest_annot, info_per_level*  info_per_lvl,
                               Pvoid_t* PJArray, annotation_array_elem* annot_sorted, annotation_inform* ann_inf){

    ASSERT_NULL_PTR(node,"load_annotation_from_Node()")
    ASSERT_NULL_PTR(info_per_lvl,"load_annotation_from_Node()")

    int i = -1;

    if ((CC*)node->CC_array != NULL){
        do {
            i++;
            load_annotation_from_CC(&(((CC*)node->CC_array)[i]), lvl_node, size_kmer, longest_annot, info_per_lvl,
                                    PJArray, annot_sorted, ann_inf);
        }
        while (IS_EVEN(((CC*)node->CC_array)[i].type));
    }

    if (node->UC_array.suffixes != NULL){
        load_annotation_from_UC(&(node->UC_array), info_per_lvl[lvl_node].size_kmer_in_bytes,
                                node->UC_array.nb_children >> 1, longest_annot, PJArray, annot_sorted, ann_inf);
    }
}

void load_annotation_from_CC(CC*  cc, int lvl_cc, int size_kmer, int longest_annot, info_per_level*  info_per_lvl,
                             Pvoid_t* PJArray, annotation_array_elem* annot_sorted, annotation_inform* ann_inf){

    ASSERT_NULL_PTR(cc,"load_annotation_from_CC()")

    UC* uc;

    int i;

    int nb_skp = CEIL(cc->nb_elem, info_per_lvl[lvl_cc].nb_ucs_skp);

    if (size_kmer != NB_CHAR_SUF_PREF){

        for (i = 0; i < nb_skp; i++){

            uc = &(((UC*)cc->children)[i]);
            load_annotation_from_UC(uc, info_per_lvl[lvl_cc].size_kmer_in_bytes_minus_1, uc->nb_children,
                                    longest_annot, PJArray, annot_sorted, ann_inf);
        }
    }
    else{
        for (i = 0; i < nb_skp; i++){

            uc = &(((UC*)cc->children)[i]);

            if (i != nb_skp-1){
                load_annotation_from_UC(uc, 0, info_per_lvl[lvl_cc].nb_ucs_skp, longest_annot,
                                        PJArray, annot_sorted, ann_inf);
            }
            else{
                load_annotation_from_UC(uc, 0, cc->nb_elem - i * info_per_lvl[lvl_cc].nb_ucs_skp, longest_annot,
                                        PJArray, annot_sorted, ann_inf);
            }
        }
    }

    for (i = 0; i < cc->nb_Node_children; i++){
        load_annotation_from_Node(&(cc->children_Node_container[i]), lvl_cc-1, size_kmer-NB_CHAR_SUF_PREF,
                                  longest_annot, info_per_lvl, PJArray, annot_sorted, ann_inf);
    }

    return;
}

void load_annotation_from_UC(UC* uc, int size_substring, int nb_children, int longest_annot,
                             Pvoid_t* PJArray, annotation_array_elem* annot_sorted, annotation_inform* ann_inf){

    ASSERT_NULL_PTR(uc, "load_annotation_from_UC()")

    if (uc->suffixes != NULL){

        PWord_t PValue;

        uint64_t size_decomp;

        int i = 0, j = 0;
        int bits_per_byte_checksum = SIZE_BITS_UINT_8T - 1;
        int size_line = size_substring + uc->size_annot;

        int shift_mode_3;
        int size_checksum;
        int size_tmp;

        uint32_t position;

        uint8_t* annot_tmp;
        uint8_t* annot_start;
        uint8_t** extended_annots = get_extend_annots(uc, size_substring, nb_children, 0, nb_children-1);

        UC_SIZE_ANNOT_T *min_sizes = min_size_per_sub(uc->suffixes, nb_children, size_substring, uc->size_annot);

        uint8_t* annot = calloc(longest_annot + CEIL(longest_annot, SIZE_BITS_UINT_8T-1) + 4, sizeof(uint8_t));
        ASSERT_NULL_PTR(annot, "load_annotation_from_UC()")

        for (i=0; i<nb_children; i++){

            if ((extended_annots != NULL) && (extended_annots[i] != NULL) && (extended_annots[i][0] != 0)){
                memcpy(&(annot[3]), &(uc->suffixes[i * size_line + size_substring]), uc->size_annot * sizeof(uint8_t));
                annot[uc->size_annot + 3] = extended_annots[i][0];
                min_sizes[i] = uc->size_annot + 1;
            }
            else memcpy(&(annot[3]), &(uc->suffixes[i * size_line + size_substring]), min_sizes[i] * sizeof(uint8_t));

            if ((annot[3] & 0x3) == 3){

{'fraction_non_alphanumeric': 0.12179640718562874, 'fraction_numerical': 0.010179640718562874, 'mean_word_length': 2.4565397350993377, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 51, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1038461', 'n_tokens_mistral': 3098, 'n_tokens_neox': 2907, 'n_words': 490}