Ejemplo n.º 1
0
/* --- .Call ENTRY POINT --- */
SEXP find_palindromes(SEXP x, SEXP min_armlength, SEXP max_looplength,
		      SEXP max_mismatch, SEXP L2R_lkup)
{
	Chars_holder x_holder;
	int x_len, min_arm_len, max_loop_len1, max_nmis, lkup_len, n;
	const int *lkup;

	x_holder = hold_XRaw(x);
	x_len = x_holder.length;
	min_arm_len = INTEGER(min_armlength)[0];
	max_loop_len1 = INTEGER(max_looplength)[0] + 1;
	max_nmis = INTEGER(max_mismatch)[0];
	if (L2R_lkup == R_NilValue) {
		lkup = NULL;
		lkup_len = 0;
	} else {
		lkup = INTEGER(L2R_lkup);
		lkup_len = LENGTH(L2R_lkup);
	}
	_init_match_reporting("MATCHES_AS_RANGES", 1);
	for (n = 0; n < x_len; n++) {
		/* Find palindromes centered on n. */
		get_find_palindromes_at(x_holder.ptr, x_len, n - 1, n + 1,
					max_loop_len1, min_arm_len, max_nmis,
					lkup, lkup_len);
		/* Find palindromes centered on n + 0.5. */
		get_find_palindromes_at(x_holder.ptr, x_len, n, n + 1,
					max_loop_len1, min_arm_len, max_nmis,
					lkup, lkup_len);
	}
	return _reported_matches_asSEXP();
}
Ejemplo n.º 2
0
/* --- .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();
}
Ejemplo n.º 3
0
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();
}