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) {
    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;

Share :

Related Posts

ALIGN_DOWN_POW2

ALIGN_DOWN_POW2 Description Aligns the given value down to the nearest power-of-two multiple.

Read More

BitVecDotProduct

BitVecDotProduct Description Calculate dot product of two bitvectors. Dot product is the count of positions where both bits are 1.

Read More

BitVecHammingDistance

BitVecHammingDistance Description Calculate Hamming distance between two bitvectors. Hamming distance is the number of positions where bits differ.

Read More