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

BitVecInsert

BitVecInsert Description Insert a bit at given index in bitvector. Shifts all bits at and after the index to the right.

Read More

BitVecEntropy

BitVecEntropy Description Calculate information entropy of a bitvector. Entropy measures the randomness/information content of the bit pattern.

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