Module: BioDSL::Ambiguity

Included in:
Assemble, BackTrack, Dynamic, Hamming, Levenshtein
Defined in:
lib/BioDSL/seq/ambiguity.rb

Overview

Namespace for Ambiguity.

Instance Method Summary collapse

Instance Method Details

#add_ambiguity_macro(inline_builder) ⇒ Object

Add C functions to Inline::C object.

Parameters:

  • inline_builder (Inline::C)

    Inline C object.



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/BioDSL/seq/ambiguity.rb', line 35

def add_ambiguity_macro(inline_builder)
  # Macro for matching nucleotides including ambiguity codes.
  inline_builder.prefix %(
    #define MATCH(A,B) ((bitmap[(int) A] & bitmap[(int) B]) != 0)
  )

  # Bitmap for matching nucleotides including ambiguity codes.
  # For each value bits are set from the left: bit pos 1 for A,
  # bit pos 2 for T, bit pos 3 for C, and bit pos 4 for G.
  inline_builder.prefix %(
    char bitmap[256] = {
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
        0, 1,14, 4,11, 0, 0, 8, 7, 0, 0,10, 0, 5,15, 0,
        0, 0, 9,12, 2, 2,13, 3, 0, 6, 0, 0, 0, 0, 0, 0,
        0, 1,14, 4,11, 0, 0, 8, 7, 0, 0,10, 0, 5,15, 0,
        0, 0, 9,12, 2, 2,13, 3, 0, 6, 0, 0, 0, 0, 0, 0,
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
    };
  )
end