SEXP debug_match_pattern_indels() { #ifdef DEBUG_BIOSTRINGS const char *p = "ABCDE", *s = "BCDExAxBCDDxDABCxExxABDCExExAABCDEE"; debug = !debug; Rprintf("Debug mode turned %s in file %s\n", debug ? "on" : "off", __FILE__); if (debug == 1) { _init_match_reporting("MATCHES_AS_NULL", 1); test_match_pattern_indels(p, s, 0, "30:34"); test_match_pattern_indels(p, s, 1, "1:4, 14:18, 30:34"); test_match_pattern_indels(p, s, 2, "1:4, 8:10, 14:18, 21:23, 30:34"); } #else Rprintf("Debug mode not available in file %s\n", __FILE__); #endif return R_NilValue; }
/* --- .Call ENTRY POINT --- */ SEXP XString_match_pattern(SEXP pattern, SEXP subject, SEXP max_mismatch, SEXP min_mismatch, SEXP with_indels, SEXP fixed, SEXP algorithm, SEXP count_only) { Chars_holder P, S; const char *algo; int is_count_only; P = hold_XRaw(pattern); S = hold_XRaw(subject); algo = CHAR(STRING_ELT(algorithm, 0)); is_count_only = LOGICAL(count_only)[0]; _init_match_reporting(is_count_only ? "MATCHES_AS_COUNTS" : "MATCHES_AS_RANGES", 1); _match_pattern_XString(&P, &S, max_mismatch, min_mismatch, with_indels, fixed, algo); return _reported_matches_asSEXP(); }
SEXP match_BOC2_exact(SEXP p_xp, SEXP p_offset, SEXP p_length, SEXP s_xp, SEXP s_offset, SEXP s_length, SEXP code1, SEXP code2, SEXP code3, SEXP code4, SEXP buf_xp, SEXP stats, SEXP count_only) { int pat_offset, pat_length, subj_offset, subj_length, c1, c2, c3, c4, is_count_only; const Rbyte *pat, *subj; SEXP buf; pat_offset = INTEGER(p_offset)[0]; pat_length = INTEGER(p_length)[0]; pat = RAW(R_ExternalPtrTag(p_xp)) + pat_offset; subj_offset = INTEGER(s_offset)[0]; subj_length = INTEGER(s_length)[0]; subj = RAW(R_ExternalPtrTag(s_xp)) + subj_offset; c1 = INTEGER(code1)[0]; c2 = INTEGER(code2)[0]; c3 = INTEGER(code3)[0]; c4 = INTEGER(code4)[0]; buf = R_ExternalPtrTag(buf_xp); is_count_only = LOGICAL(count_only)[0]; _init_match_reporting(is_count_only ? "MATCHES_AS_COUNTS" : "MATCHES_AS_RANGES", 1); BOC2_exact_search( (char *) pat, pat_length, (char *) subj, subj_length, (char) c1, (char) c2, (char) c3, (char) c4, INTEGER(buf), REAL(VECTOR_ELT(stats, 0)), INTEGER(VECTOR_ELT(stats, 1)), INTEGER(VECTOR_ELT(stats, 2)), INTEGER(VECTOR_ELT(stats, 3)), INTEGER(VECTOR_ELT(stats, 4))); return _reported_matches_asSEXP(); }
static SEXP vwhich_XStringSet_XStringSet(SEXP pattern, SEXP subject, SEXP max_mismatch, SEXP min_mismatch, SEXP with_indels, SEXP fixed, SEXP algorithm) { XStringSet_holder P, S; int P_length, S_length, i, j; Chars_holder P_elt, S_elt; const char *algo; IntAEAE *ans_buf; P = _hold_XStringSet(pattern); P_length = _get_length_from_XStringSet_holder(&P); S = _hold_XStringSet(subject); S_length = _get_length_from_XStringSet_holder(&S); algo = CHAR(STRING_ELT(algorithm, 0)); ans_buf = new_IntAEAE(S_length, S_length); for (j = 0; j < S_length; j++) IntAE_set_nelt(ans_buf->elts[j], 0); _init_match_reporting("MATCHES_AS_COUNTS", 1); for (i = 0; i < P_length; i++) { P_elt = _get_elt_from_XStringSet_holder(&P, i); for (j = 0; j < S_length; j++) { S_elt = _get_elt_from_XStringSet_holder(&S, j); _match_pattern_XString(&P_elt, &S_elt, max_mismatch, min_mismatch, with_indels, fixed, algo); if (_get_match_count() != 0) IntAE_insert_at(ans_buf->elts[j], IntAE_get_nelt(ans_buf->elts[j]), i + 1); _drop_reported_matches(); } } return new_LIST_from_IntAEAE(ans_buf, 0); }
/* --- .Call ENTRY POINT --- * Arguments are the same as for XString_match_pattern() except for: * subject: XStringSet object. */ SEXP XStringSet_vmatch_pattern(SEXP pattern, SEXP subject, SEXP max_mismatch, SEXP min_mismatch, SEXP with_indels, SEXP fixed, SEXP algorithm, SEXP ms_mode) { Chars_holder P, S_elt; XStringSet_holder S; int S_length, j; const char *algo; P = hold_XRaw(pattern); S = _hold_XStringSet(subject); S_length = _get_XStringSet_length(subject); algo = CHAR(STRING_ELT(algorithm, 0)); _init_match_reporting(CHAR(STRING_ELT(ms_mode, 0)), S_length); for (j = 0; j < S_length; j++) { S_elt = _get_elt_from_XStringSet_holder(&S, j); _set_active_PSpair(j); _match_pattern_XString(&P, &S_elt, max_mismatch, min_mismatch, with_indels, fixed, algo); } return _MatchBuf_as_SEXP(_get_internal_match_buf(), R_NilValue); }