Skip to content
BitVecAlignmentScore

BitVecAlignmentScore

BitVecAlignmentScore

Description

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

Parameters

Name Direction Description
bv1 in First bitvector
bv2 in Second bitvector
match in Score for matching bits
mismatch in Score for mismatching bits

Usage example (from documentation)

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

Returns

Total alignment score

Usage example (Cross-references)

Usage examples (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) {
        WriteFmt("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) {
        WriteFmt("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) {
        WriteFmt("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) {
        WriteFmt("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;
Last updated on