BitVecAlignmentScore

Table of Contents

BitVecAlignmentScore

Description

Calculate alignment score between two bitvectors. Used in bioinformatics-style sequence alignment with match/mismatch scoring.

Parameters

NameDirectionDescription
bv1inFirst bitvector
bv2inSecond bitvector
matchinScore for matching bits
mismatchinScore for mismatching bits

Usage example (from documentation)

  int score = BitVecAlignmentScore(&seq1, &seq2, 2, -1);

Usage example (Cross-references)

    }
    
    int BitVecAlignmentScore(BitVec *bv1, BitVec *bv2, int match, int mismatch) {
    ValidateBitVec(bv1);
    ValidateBitVec(bv2);
    // Test BitVecAlignmentScore basic functionality
    bool test_bitvec_alignment_score_basic(void) {
    printf("Testing BitVecAlignmentScore basic functionality\n");
    
    BitVec bv1    = BitVecInit();
    BitVecPush(&bv2, true);
    
    int score = BitVecAlignmentScore(&bv1, &bv2, 2, -1);
    result    = result && (score == 6); // 3 matches * 2
    BitVecPush(&bv2, false);
    
    score  = BitVecAlignmentScore(&bv1, &bv2, 2, -1);
    result = result && (score == -3); // 3 mismatches * -1
    // Test BitVecAlignmentScore edge cases
    bool test_bitvec_alignment_score_edge_cases(void) {
    printf("Testing BitVecAlignmentScore edge cases\n");
    
    BitVec bv1    = BitVecInit();
    
    // Test empty bitvectors
    int score = BitVecAlignmentScore(&bv1, &bv2, 1, -1);
    result    = result && (score == 0);
    BitVecPush(&bv2, false);
    
    score  = BitVecAlignmentScore(&bv1, &bv2, 1, -1);
    result = result && (score == 2); // 2 matches
    double correlation = BitVecCorrelation(&bv1, &bv2);
    double entropy1    = BitVecEntropy(&bv1);
    int    align_score = BitVecAlignmentScore(&bv1, &bv2, 1, -1);
    u64    best_align  = BitVecBestAlignment(&bv1, &bv2);
    
    bool test_bitvec_alignment_score_null_bv1(void) {
    printf("Testing BitVecAlignmentScore(NULL, bv2, 1, -1) - should fatal\n");
    BitVec bv2 = BitVecInit();
    BitVecPush(&bv2, true);
    BitVec bv2 = BitVecInit();
    BitVecPush(&bv2, true);
    BitVecAlignmentScore(NULL, &bv2, 1, -1);
    BitVecDeinit(&bv2);
    return true;
    
    bool test_bitvec_alignment_score_null_bv2(void) {
    printf("Testing BitVecAlignmentScore(bv1, NULL, 1, -1) - should fatal\n");
    BitVec bv1 = BitVecInit();
    BitVecPush(&bv1, true);
    BitVec bv1 = BitVecInit();
    BitVecPush(&bv1, true);
    BitVecAlignmentScore(&bv1, NULL, 1, -1);
    BitVecDeinit(&bv1);
    return true;

Share :

Related Posts

BitVecJaccardSimilarity

BitVecJaccardSimilarity Description Calculate Jaccard similarity between two bitvectors. Jaccard similarity = |intersection| / |union|

Read More

BitVecRemove

BitVecRemove Description Remove a bit at given index from bitvector. Shifts all bits after the index to the left.

Read More

BitVecEditDistance

BitVecEditDistance Description Calculate edit distance between two bitvectors. Edit distance is minimum number of single-bit operations to transform one into the other.

Read More